src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
@@ -291,8 +291,15 @@ ProductionOrderBom orderBom, List<ProductionBomStructure> structureList, Long rootProductModelId) { // éæ°æ¥è¯¢BOMç»æï¼æåèç¹ä¼å æåº List<ProductionBomStructure> routingStructureList = this.list( Wrappers.<ProductionBomStructure>lambdaQuery() .eq(ProductionBomStructure::getProductionOrderBomId, orderBom.getId()) .orderByDesc(ProductionBomStructure::getParentId) .orderByAsc(ProductionBomStructure::getId)); ProductionOrderRouting orderRouting = getOrCreateOrderRoutingSnapshot(productionOrderId, productionOrder, orderBom, rootProductModelId); List<ProductionOrderRoutingOperation> desiredOperationList = buildDesiredRoutingOperationList(structureList, rootProductModelId); List<ProductionOrderRoutingOperation> desiredOperationList = buildDesiredRoutingOperationList(routingStructureList, rootProductModelId); List<ProductionOrderRoutingOperation> existingOperationList = productionOrderRoutingOperationMapper.selectList( Wrappers.<ProductionOrderRoutingOperation>lambdaQuery() .eq(ProductionOrderRoutingOperation::getOrderRoutingId, orderRouting.getId()) @@ -310,7 +317,7 @@ if (matchedOperation == null) { matchedOperation = insertRoutingOperationSnapshot(orderRouting.getId(), productionOrderId, desiredOperation); } else { updateRoutingOperationSnapshotIfNecessary(desiredOperation, orderRouting.getId(), productionOrderId, matchedOperation); updateRoutingOperationSnapshotIfNecessary(matchedOperation, orderRouting.getId(), productionOrderId, desiredOperation); } finalOperationList.add(matchedOperation); } @@ -381,14 +388,14 @@ Map<Long, ProductionBomStructure> structureById = structureList.stream() .filter(item -> item != null && item.getId() != null) .collect(Collectors.toMap(ProductionBomStructure::getId, item -> item, (left, right) -> left)); // æå»ºç¶-åæ å°å ³ç³» Map<Long, List<ProductionBomStructure>> treeMap = buildParentChildMap(structureList); // 使ç¨ååºéåæå»ºæä½å表ï¼å ååç¶ï¼ç¡®ä¿å·¥èºè·¯çº¿é¡ºåºæ£ç¡®ï¼ Map<String, ProductionBomStructure> uniqueOperationMap = new LinkedHashMap<>(); for (ProductionBomStructure bomStructure : structureList) { if (bomStructure == null || bomStructure.getTechnologyOperationId() == null) { continue; } Long outputProductModelId = resolveOutputProductModelId(resolveOperationOutputNode(bomStructure, structureById), rootProductModelId); uniqueOperationMap.putIfAbsent(buildBomOperationDedupKey(bomStructure, outputProductModelId), bomStructure); } buildOperationListPostOrder(null, treeMap, uniqueOperationMap, structureById, rootProductModelId); List<ProductionOrderRoutingOperation> desiredOperationList = new ArrayList<>(); int dragSort = 1; for (ProductionBomStructure bomStructure : uniqueOperationMap.values()) { @@ -405,6 +412,52 @@ desiredOperationList.add(routingOperation); } return desiredOperationList; } private Map<Long, List<ProductionBomStructure>> buildParentChildMap(List<ProductionBomStructure> structureList) { Map<Long, List<ProductionBomStructure>> treeMap = new LinkedHashMap<>(); Map<Long, Integer> childCountMap = new HashMap<>(); // 第ä¸éï¼ç»è®¡æ¯ä¸ªèç¹çåèç¹æ°éï¼åæ¶æå»ºåå§æ å° for (ProductionBomStructure structure : structureList) { if (structure == null) continue; Long parentId = structure.getParentId(); childCountMap.merge(parentId, 1, Integer::sum); // ç»è®¡æ¯ä¸ªç¶èç¹æå¤å°ä¸ªåèç¹ treeMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(structure); } // 第äºéï¼å¯¹æ¯ä¸ªç¶èç¹ä¸çåèç¹æåèç¹æ°éååºæåºï¼æåèç¹çä¼å ï¼ for (Map.Entry<Long, List<ProductionBomStructure>> entry : treeMap.entrySet()) { List<ProductionBomStructure> children = entry.getValue(); children.sort((a, b) -> { int countA = childCountMap.getOrDefault(a.getId(), 0); int countB = childCountMap.getOrDefault(b.getId(), 0); return Integer.compare(countB, countA); // åèç¹å¤çæåé¢ }); } return treeMap; } private void buildOperationListPostOrder(Long parentId, Map<Long, List<ProductionBomStructure>> treeMap, Map<String, ProductionBomStructure> uniqueOperationMap, Map<Long, ProductionBomStructure> structureById, Long rootProductModelId) { List<ProductionBomStructure> children = treeMap.get(parentId); if (children == null || children.isEmpty()) { return; } for (ProductionBomStructure child : children) { // å éå½å¤çåèç¹ buildOperationListPostOrder(child.getId(), treeMap, uniqueOperationMap, structureById, rootProductModelId); // åå¤çå½åèç¹ if (child.getTechnologyOperationId() != null) { Long outputProductModelId = resolveOutputProductModelId(resolveOperationOutputNode(child, structureById), rootProductModelId); uniqueOperationMap.putIfAbsent(buildBomOperationDedupKey(child, outputProductModelId), child); } } } private Map<String, Deque<ProductionOrderRoutingOperation>> buildExistingRoutingOperationBucketMap(List<ProductionOrderRoutingOperation> existingOperationList) { @@ -482,6 +535,12 @@ if (!Objects.equals(currentOperation.getIsProduction(), desiredOperation.getIsProduction())) { update.setIsProduction(desiredOperation.getIsProduction()); currentOperation.setIsProduction(desiredOperation.getIsProduction()); changed = true; } // æ´æ° dragSort åæ®µï¼ç¡®ä¿å·¥èºè·¯çº¿é¡ºåºæ£ç¡® if (!Objects.equals(currentOperation.getDragSort(), desiredOperation.getDragSort())) { update.setDragSort(desiredOperation.getDragSort()); currentOperation.setDragSort(desiredOperation.getDragSort()); changed = true; } if (!Objects.equals(currentOperation.getType(), desiredOperation.getType())) { @@ -744,8 +803,8 @@ return; } for (ProductionBomStructureDto node : source) { flattenTree(node.getChildren(), result); // å é彿·»å åèç¹ result.add(node); flattenTree(node.getChildren(), result); } } src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
@@ -126,6 +126,7 @@ String text = inspectParams.stream().map(QualityInspectParam::getParameterItem).collect(Collectors.joining(",")); qualityUnqualified.setDefectivePhenomena(text + "è¿äºææ ä¸åå¨ä¸åæ ¼");//ä¸åæ ¼ç°è±¡ qualityUnqualified.setInspectId(qualityInspect.getId()); qualityUnqualified.setId(null); qualityUnqualifiedMapper.insert(qualityUnqualified); } src/main/java/com/ruoyi/sales/dto/SalesLedgerImportDto.java
@@ -43,6 +43,10 @@ @Excel(name = "ç¾è®¢æ¥æ", width = 30, dateFormat = "yyyy-MM-dd") private Date executionDate; @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "äº¤ä»æ¥æ", width = 30, dateFormat = "yyyy-MM-dd") private Date deliveryDate; @Schema(description = "仿¬¾æ¹å¼") @Excel(name = "仿¬¾æ¹å¼") private String paymentMethod; src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java
@@ -73,6 +73,9 @@ @Excel(name = "æ¯å¦è´¨æ£", readConverterExp = "0=å¦,1=æ¯") private Boolean isChecked; /** * æ¯å¦ç产 */ @Excel(name = "æ¯å¦ç产", readConverterExp = "0=å¦,1=æ¯") private Integer isProduction; } src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -285,6 +285,9 @@ * å é¤ç产计å */ public void deleteProductionData(List<Long> productIds) { if (CollectionUtils.isEmpty(productIds)) { return; } List<ProductionPlan> productionPlans = productionPlanMapper.selectList( new LambdaQueryWrapper<ProductionPlan>() .in(ProductionPlan::getSalesLedgerProductId, productIds.stream().map(Long::intValue).collect(Collectors.toList()))); src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1,6 +1,7 @@ package com.ruoyi.sales.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; @@ -27,8 +28,9 @@ import com.ruoyi.framework.security.LoginUser; import com.ruoyi.framework.web.domain.R; import com.ruoyi.other.mapper.TempFileMapper; import com.ruoyi.other.pojo.TempFile; import com.ruoyi.production.mapper.*; import com.ruoyi.production.mapper.ProductionProductInputMapper; import com.ruoyi.production.mapper.ProductionProductMainMapper; import com.ruoyi.production.mapper.ProductionProductOutputMapper; import com.ruoyi.production.service.ProductionProductMainService; import com.ruoyi.project.system.domain.SysDept; import com.ruoyi.project.system.domain.SysUser; @@ -44,7 +46,6 @@ import com.ruoyi.sales.vo.SalesLedgerVo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FilenameUtils; import org.jetbrains.annotations.Nullable; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -55,15 +56,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.RoundingMode; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.YearMonth; @@ -347,9 +343,17 @@ if (CollectionUtils.isEmpty(salesLedgerImportDtoList)) return R.fail("éå®å°è´¦æ°æ®ä¸ºç©ºï¼"); List<SalesLedgerImportDto> salesLedgerProductImportDtoList = stringListMap.get("éå®äº§åæ°æ®"); if (CollectionUtils.isEmpty(salesLedgerProductImportDtoList)) return R.fail("éå®äº§åæ°æ®ä¸ºç©ºï¼"); // å®¢æ·æ°æ® List<Customer> customers = customerMapper.selectList(new LambdaQueryWrapper<Customer>().in(Customer::getCustomerName, salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getCustomerName).collect(Collectors.toList()))); // å®¢æ·æ°æ® - åè listPage æ¥è¯¢ç§æµ·å®¢æ·ï¼type = 0ï¼ // type = 0ï¼ç§æµ·å®¢æ·ï¼æè type = 1ï¼å ¬æµ·å®¢æ·ï¼ä¸å·²è¢«åé ï¼å¹¶ä¸æ¯èªå·±é¢ç¨ãèªå·±å建æè å ±äº«ç»èªå·±çå®¢æ· Long loginUserId = loginUser.getUser().getUserId(); List<Customer> customers = customerMapper.selectList(new QueryWrapper<Customer>() .in("customer_name", salesLedgerImportDtoList.stream() .map(SalesLedgerImportDto::getCustomerName).collect(Collectors.toList())) .and(wrapper -> wrapper.eq("type", 0) .or(wrapper2 -> wrapper2.eq("type", 1).eq("is_assigned", 1))) .and(wrapper -> wrapper.eq("usage_user", loginUserId) .or(wrapper2 -> wrapper2.eq("create_user", loginUserId) .or(wrapper3 -> wrapper3.exists("select 1 from customer_user cu where cu.customer_id = customer.id and cu.user_id = " + loginUserId))))); // // è§æ ¼åå·æ°æ® // List<ProductModel> productModels = productModelMapper.selectList(new LambdaQueryWrapper<ProductModel>().in(ProductModel::getModel, // salesLedgerProductImportDtoList.stream().map(SalesLedgerImportDto::getSpecificationModel).collect(Collectors.toList()))); @@ -370,17 +374,16 @@ SalesLedger salesLedger = new SalesLedger(); BeanUtils.copyProperties(salesLedgerImportDto, salesLedger); salesLedger.setExecutionDate(DateUtils.toLocalDate(salesLedgerImportDto.getExecutionDate())); salesLedger.setDeliveryDate(DateUtils.toLocalDate(salesLedgerImportDto.getDeliveryDate())); // éè¿å®¢æ·åç§°æ¥è¯¢å®¢æ·IDï¼å®¢æ·ååå· salesLedger.setCustomerId(customers.stream() Optional<Customer> customerOptional = customers.stream() .filter(customer -> customer.getCustomerName().equals(salesLedger.getCustomerName())) .findFirst() .map(Customer::getId) .orElse(null)); salesLedger.setCustomerContractNo(customers.stream() .filter(customer -> customer.getCustomerName().equals(salesLedger.getCustomerName())) .findFirst() .map(Customer::getTaxpayerIdentificationNumber) .orElse(null)); .findFirst(); if (customerOptional.isEmpty()) { throw new RuntimeException("客æ·:" + salesLedger.getCustomerName() + "ä¸åå¨ï¼æè éç§æµ·ç¨æ·"); } salesLedger.setCustomerId(customerOptional.get().getId()); salesLedger.setCustomerContractNo(customerOptional.get().getTaxpayerIdentificationNumber()); Long aLong = sysUsers.stream() .filter(sysUser -> sysUser.getNickName().equals(salesLedger.getEntryPerson())) .findFirst() @@ -410,13 +413,16 @@ salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 2, RoundingMode.HALF_UP)); salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity()); salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxExclusiveTotalPrice()); list.stream() .filter(map -> map.get("productName").equals(salesLedgerProduct.getProductCategory()) && map.get("model").equals(salesLedgerProduct.getSpecificationModel())) .findFirst() .ifPresent(map -> { salesLedgerProduct.setProductModelId(Long.parseLong(map.get("modelId").toString())); salesLedgerProduct.setProductId(Long.parseLong(map.get("id").toString())); }); // æ ¡éªäº§åè§æ ¼æ¯å¦åå¨ Optional<Map<String, Object>> productModelOptional = list.stream() .filter(map -> Objects.equals(map.get("productName"), salesLedgerProduct.getProductCategory()) && Objects.equals(map.get("model"), salesLedgerProduct.getSpecificationModel())) .findFirst(); if (productModelOptional.isEmpty()) { throw new RuntimeException("产å大类:" + salesLedgerProduct.getProductCategory() + ",è§æ ¼åå·:" + salesLedgerProduct.getSpecificationModel() + "ä¸åå¨ï¼"); } Map<String, Object> productModelMap = productModelOptional.get(); salesLedgerProduct.setProductModelId(Long.parseLong(productModelMap.get("modelId").toString())); salesLedgerProduct.setProductId(Long.parseLong(productModelMap.get("id").toString())); // salesLedgerProduct.setProductId(productList.stream() // .filter(product -> product.getProductName().equals(salesLedgerProduct.getProductCategory())) // .findFirst() @@ -431,6 +437,7 @@ salesLedgerProduct.setRegisterDate(LocalDateTime.now()); salesLedgerProduct.setApproveStatus(0); salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice()); salesLedgerProduct.setIsProduction(salesLedgerProductImportDto.getIsProduction() == 1); salesLedgerProductMapper.insert(salesLedgerProduct); // æ·»å çäº§æ°æ® salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); @@ -440,6 +447,7 @@ return R.ok(null, "å¯¼å ¥æå"); } catch (Exception e) { e.printStackTrace(); return R.fail("å¯¼å ¥å¤±è´¥ï¼" + e.getMessage()); } return R.ok(null, "å¯¼å ¥å¤±è´¥"); } src/main/java/com/ruoyi/staff/service/impl/StaffOnJobServiceImpl.java
@@ -1,12 +1,13 @@ package com.ruoyi.staff.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.dto.WordDateDto; import com.ruoyi.project.system.domain.SysDept; @@ -46,7 +47,7 @@ @RequiredArgsConstructor @Service public class StaffOnJobServiceImpl extends ServiceImpl<StaffOnJobMapper, StaffOnJob> implements IStaffOnJobService { public class StaffOnJobServiceImpl extends ServiceImpl<StaffOnJobMapper, StaffOnJob> implements IStaffOnJobService { private final StaffOnJobMapper staffOnJobMapper; private final SysDeptMapper sysDeptMapper; @@ -64,22 +65,22 @@ private final StaffEmergencyContactMapper staffEmergencyContactMapper; private final StaffEmergencyContactServiceImpl staffEmergencyContactServiceImpl; //å¨èåå·¥å°è´¦å页æ¥è¯¢ // å¨èåå·¥å°è´¦å页æ¥è¯¢ @Override public IPage<StaffOnJobDto> staffOnJobListPage(Page page, StaffOnJob staffOnJob) { return staffOnJobMapper.staffOnJobListPage(page,staffOnJob); return staffOnJobMapper.staffOnJobListPage(page, staffOnJob); } //æ°å¢å ¥è // æ°å¢å ¥è @Override @Transactional(rollbackFor = Exception.class) public int add(StaffOnJobDto staffOnJobPrams) { String[] ignoreProperties = {"id"};//æé¤id屿§ String[] ignoreProperties = { "id" };// æé¤id屿§ // 夿ç¼å·æ¯å¦åå¨ List<StaffOnJob> staffOnJobs = staffOnJobMapper.selectList(Wrappers.<StaffOnJob>lambdaQuery().eq(StaffOnJob::getStaffNo, staffOnJobPrams.getStaffNo())); if (staffOnJobs != null && !staffOnJobs.isEmpty()){ throw new BaseException("ç¼å·ä¸º"+staffOnJobPrams.getStaffNo()+"çå工已ç»åå¨,æ æ³æ°å¢!!!"); List<StaffOnJob> staffOnJobs = staffOnJobMapper.selectList( Wrappers.<StaffOnJob>lambdaQuery().eq(StaffOnJob::getStaffNo, staffOnJobPrams.getStaffNo())); if (staffOnJobs != null && !staffOnJobs.isEmpty()) { throw new BaseException("ç¼å·ä¸º" + staffOnJobPrams.getStaffNo() + "çå工已ç»åå¨,æ æ³æ°å¢!!!"); } // åå»ºå ¥èæ°æ® @@ -88,23 +89,23 @@ staffOnJobMapper.insert(staffOnJobPrams); // æ¥è¯¢ç¨æ·æ¯å¦å·²ç»æ°å¢ SysUser sysUser = sysUserService.selectUserById(staffOnJobPrams.getId()); if(sysUser == null){ if (sysUser == null) { SysUser sysUser1 = new SysUser(); sysUser1.setUserName(staffOnJobPrams.getStaffNo()); sysUser1.setNickName(staffOnJobPrams.getStaffName()); String s = SecurityUtils.encryptPassword("123456"); sysUser1.setPassword(s); if(staffOnJobPrams.getSysPostId() != null){ Long[] posts = new Long[]{staffOnJobPrams.getSysPostId().longValue()}; if (staffOnJobPrams.getSysPostId() != null) { Long[] posts = new Long[] { staffOnJobPrams.getSysPostId().longValue() }; sysUser1.setPostIds(posts); } sysUser1.setRoleIds(new Long[]{staffOnJobPrams.getRoleId()}); sysUser1.setDeptIds(new Long[]{staffOnJobPrams.getSysDeptId()}); sysUser1.setRoleIds(new Long[] { staffOnJobPrams.getRoleId() }); sysUser1.setDeptIds(new Long[] { staffOnJobPrams.getSysDeptId() }); sysUser1.setStatus("0"); sysUserService.insertUser(sysUser1); } // ç»å®åè¡¨æ°æ® bingingStaffOnJobExtra(staffOnJobPrams.getId(),staffOnJobPrams); bingingStaffOnJobExtra(staffOnJobPrams.getId(), staffOnJobPrams); // å建ååè®°å½ StaffContract staffContract = new StaffContract(); staffContract.setStaffOnJobId(staffOnJobPrams.getId()); @@ -114,32 +115,32 @@ return staffContractMapper.insert(staffContract); } //æ´æ°å ¥èä¿¡æ¯ // æ´æ°å ¥èä¿¡æ¯ @Override @Transactional(rollbackFor = Exception.class) public int update(Long id, StaffOnJobDto staffOnJobParams) { // å¤æå¯¹è±¡æ¯å¦åå¨ StaffOnJob job = staffOnJobMapper.selectById(id); if (job == null){ throw new BaseException("ç¼å·ä¸º"+staffOnJobParams.getStaffNo()+"çåå·¥ä¸åå¨,æ æ³æ´æ°!!!"); if (job == null) { throw new BaseException("ç¼å·ä¸º" + staffOnJobParams.getStaffNo() + "çåå·¥ä¸åå¨,æ æ³æ´æ°!!!"); } String[] ignoreProperties = {"id"};//æé¤æ´æ°å±æ§ String[] ignoreProperties = { "id" };// æé¤æ´æ°å±æ§ // è·åææ°ååæ°æ®ï¼å¹¶ä¸æ´æ° StaffContract contract = staffContractMapper.selectOne(Wrappers.<StaffContract>lambdaQuery() .eq(StaffContract::getStaffOnJobId, id) .last("limit 1") .orderByDesc(StaffContract::getId)); if (contract != null){ BeanUtils.copyProperties(staffOnJobParams,contract,ignoreProperties); if (contract != null) { BeanUtils.copyProperties(staffOnJobParams, contract, ignoreProperties); staffContractMapper.updateById(contract); } // å 餿æåè¡¨æ°æ® delStaffOnJobExtra(Arrays.asList(id)); // ç»å®åè¡¨æ°æ® bingingStaffOnJobExtra(id,staffOnJobParams); bingingStaffOnJobExtra(id, staffOnJobParams); // æ´æ°åå·¥æ°æ® staffOnJobParams.setContractExpireTime(staffOnJobParams.getContractEndTime()); return staffOnJobMapper.updateById(staffOnJobParams); @@ -147,26 +148,27 @@ /** * ç»å®åå·¥åè¡¨æ°æ® * * @param staffOnJobPrams * @param id */ public void bingingStaffOnJobExtra(Long id,StaffOnJob staffOnJobPrams) { public void bingingStaffOnJobExtra(Long id, StaffOnJob staffOnJobPrams) { // æ°å¢æè²ç»å if(CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffEducationList())){ if (CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffEducationList())) { staffOnJobPrams.getStaffEducationList().stream() .filter(Objects::nonNull) // è¿æ»¤null对象ï¼é¿å 空æé .forEach(staff -> staff.setStaffOnJobId(id)); // èµå¼ staffEducationService.saveBatch(staffOnJobPrams.getStaffEducationList()); } // æ°å¢å·¥ä½ç»å if(CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffWorkExperienceList())){ if (CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffWorkExperienceList())) { staffOnJobPrams.getStaffWorkExperienceList().stream() .filter(Objects::nonNull) // è¿æ»¤null对象ï¼é¿å 空æé .forEach(staff -> staff.setStaffOnJobId(id)); // èµå¼ staffWorkExperienceServiceImpl.saveBatch(staffOnJobPrams.getStaffWorkExperienceList()); } // æ°å¢ç´§æ¥è系人 if(CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffEmergencyContactList())){ if (CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffEmergencyContactList())) { staffOnJobPrams.getStaffEmergencyContactList().stream() .filter(Objects::nonNull) // è¿æ»¤null对象ï¼é¿å 空æé .forEach(staff -> staff.setStaffOnJobId(id)); // èµå¼ @@ -174,27 +176,30 @@ } } /** * éè¿åå·¥idå 餿è²ç»åï¼å·¥ä½ç»åï¼ç´§æ¥è系人 * * @param ids * @return */ public void delStaffOnJobExtra(List<Long> ids) { // å 餿è²ç»å staffEducationService.remove(Wrappers.<StaffEducation>lambdaQuery().in(StaffEducation::getStaffOnJobId,ids)); staffEducationService.remove(Wrappers.<StaffEducation>lambdaQuery().in(StaffEducation::getStaffOnJobId, ids)); // å é¤å·¥ä½ç»å staffWorkExperienceServiceImpl.remove(Wrappers.<StaffWorkExperience>lambdaQuery().in(StaffWorkExperience::getStaffOnJobId,ids)); staffWorkExperienceServiceImpl .remove(Wrappers.<StaffWorkExperience>lambdaQuery().in(StaffWorkExperience::getStaffOnJobId, ids)); // å é¤ç´§æ¥è系人 staffEmergencyContactServiceImpl.remove(Wrappers.<StaffEmergencyContact>lambdaQuery().in(StaffEmergencyContact::getStaffOnJobId,ids)); staffEmergencyContactServiceImpl .remove(Wrappers.<StaffEmergencyContact>lambdaQuery().in(StaffEmergencyContact::getStaffOnJobId, ids)); } //å é¤å ¥è // å é¤å ¥è @Override @Transactional(rollbackFor = Exception.class) public int delStaffOnJobs(List<Integer> ids) { List<StaffOnJob> staffOnJobs = staffOnJobMapper.selectList(Wrappers.<StaffOnJob>lambdaQuery().in(StaffOnJob::getId, ids)); if(CollectionUtils.isEmpty(staffOnJobs)){ List<StaffOnJob> staffOnJobs = staffOnJobMapper .selectList(Wrappers.<StaffOnJob>lambdaQuery().in(StaffOnJob::getId, ids)); if (CollectionUtils.isEmpty(staffOnJobs)) { throw new BaseException("该åå·¥ä¸åå¨,æ æ³å é¤!!!"); } // å é¤å ¥èæ°æ® @@ -202,11 +207,13 @@ // å é¤ç¦»èæ°æ® staffLeaveMapper.delete(Wrappers.<StaffLeave>lambdaQuery().in(StaffLeave::getStaffOnJobId, ids)); // å 餿å¡è®°å½ personalAttendanceRecordsMapper.delete(Wrappers.<PersonalAttendanceRecords>lambdaQuery().in(PersonalAttendanceRecords::getStaffOnJobId, ids)); personalAttendanceRecordsMapper.delete( Wrappers.<PersonalAttendanceRecords>lambdaQuery().in(PersonalAttendanceRecords::getStaffOnJobId, ids)); // å é¤ç¨æ·æ°æ® List<SysUser> sysUsers = sysUserMapper.selectList(Wrappers.<SysUser>lambdaQuery() .in(SysUser::getUserName, staffOnJobs.stream().map(StaffOnJob::getStaffNo).collect(Collectors.toList()))); if(CollectionUtils.isNotEmpty(sysUsers)){ .in(SysUser::getUserName, staffOnJobs.stream().map(StaffOnJob::getStaffNo).collect(Collectors.toList()))); if (CollectionUtils.isNotEmpty(sysUsers)) { Long[] longs = sysUsers.stream().map(SysUser::getUserId).toArray(Long[]::new); sysUserService.deleteUserByIds(longs); } @@ -214,7 +221,8 @@ delStaffOnJobExtra(ids.stream().map(Integer::longValue).collect(Collectors.toList())); // å é¤ååæ°æ® return staffContractMapper.delete(Wrappers.<StaffContract>lambdaQuery().in(StaffContract::getStaffOnJobId, ids)); return staffContractMapper .delete(Wrappers.<StaffContract>lambdaQuery().in(StaffContract::getStaffOnJobId, ids)); } // ç»ç¾åå @@ -223,7 +231,7 @@ public int renewContract(Long id, StaffContract staffContract) { // å¤æå¯¹è±¡æ¯å¦åå¨ StaffOnJob job = staffOnJobMapper.selectById(id); if (job == null){ if (job == null) { throw new BaseException("该åå·¥ä¸åå¨,æ æ³æ´æ°!!!"); } @@ -241,10 +249,10 @@ return 0; } //å¨èå工详æ // å¨èå工详æ @Override public StaffOnJobDto staffOnJobDetail(Long id) { StaffOnJob staffOnJob = staffOnJobMapper.selectById(id); StaffOnJob staffOnJob = staffOnJobMapper.selectById(id); if (staffOnJob == null) { throw new IllegalArgumentException("该åå·¥ä¸åå¨"); } @@ -264,7 +272,7 @@ .eq(StaffContract::getStaffOnJobId, staffOnJob.getId()) .last("limit 1") .orderByDesc(StaffContract::getId)); if (contract != null){ if (contract != null) { staffOnJobDto.setContractTerm(contract.getContractTerm()); staffOnJobDto.setContractStartTime(contract.getContractStartTime()); staffOnJobDto.setContractEndTime(contract.getContractEndTime()); @@ -272,14 +280,16 @@ // è·ååè¡¨æ°æ® staffOnJobDto.setStaffEducationList(staffEducationMapper.selectList(Wrappers.<StaffEducation>lambdaQuery() .eq(StaffEducation::getStaffOnJobId, staffOnJob.getId()))); staffOnJobDto.setStaffWorkExperienceList(staffWorkExperienceMapper.selectList(Wrappers.<StaffWorkExperience>lambdaQuery() .eq(StaffWorkExperience::getStaffOnJobId, staffOnJob.getId()))); staffOnJobDto.setStaffEmergencyContactList(staffEmergencyContactMapper.selectList(Wrappers.<StaffEmergencyContact>lambdaQuery() .eq(StaffEmergencyContact::getStaffOnJobId, staffOnJob.getId()))); staffOnJobDto.setStaffWorkExperienceList( staffWorkExperienceMapper.selectList(Wrappers.<StaffWorkExperience>lambdaQuery() .eq(StaffWorkExperience::getStaffOnJobId, staffOnJob.getId()))); staffOnJobDto.setStaffEmergencyContactList( staffEmergencyContactMapper.selectList(Wrappers.<StaffEmergencyContact>lambdaQuery() .eq(StaffEmergencyContact::getStaffOnJobId, staffOnJob.getId()))); return staffOnJobDto; } //å¨èåå·¥å¯¼åº // å¨èåå·¥å¯¼åº @Override public void staffOnJobExport(HttpServletResponse response, StaffOnJob staffOnJob) { List<StaffOnJobDto> staffOnJobs = staffOnJobMapper.staffOnJobList(staffOnJob); @@ -298,39 +308,62 @@ try { ExcelUtil<StaffOnJobExcelDto> util = new ExcelUtil<>(StaffOnJobExcelDto.class); List<StaffOnJobExcelDto> staffOnJobs = util.importExcel(file.getInputStream()); if (CollectionUtils.isEmpty(staffOnJobs)){ if (CollectionUtils.isEmpty(staffOnJobs)) { return false; } // è·åææé¨é¨æ°æ® List<SysDept> sysDepts = sysDeptMapper.selectList(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getDelFlag, 0)); List<SysDept> sysDepts = sysDeptMapper .selectList(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getDelFlag, 0)); // è·åææè§è²æ°æ® List<SysRole> sysRoles = sysRoleMapper.selectRoleAll(); staffOnJobs.forEach(staffOnJob -> { // å¤çååæéæ°æ®æ ¼å¼ if (staffOnJob.getContractTerm() != null && !staffOnJob.getContractTerm().trim().isEmpty()) { String term = staffOnJob.getContractTerm().trim(); try { Integer.parseInt(term); } catch (NumberFormatException e) { throw new ServiceException("åå·¥[" + staffOnJob.getStaffName() + "]çååæé[" + staffOnJob.getContractTerm() + "]æ ¼å¼ä¸æ£ç¡®ï¼å¿ 须为纯æ°å(å¦: 1, 2, 3)"); } } StaffOnJobDto staffOnJobDto = new StaffOnJobDto(); BeanUtils.copyProperties(staffOnJob, staffOnJobDto); // éè¿åç§°è·åé¨é¨id staffOnJobDto.setSysDeptId(// ... existing code ... sysDepts.stream() .filter(dept -> dept.getDeptName() != null && dept.getDeptName().equals(staffOnJob.getSysDeptName())) .findFirst() .map(SysDept::getDeptId) .orElse(null) ); Long deptId = sysDepts.stream() .filter(dept -> dept.getDeptName() != null && dept.getDeptName().equals(staffOnJob.getSysDeptName())) .findFirst() .map(SysDept::getDeptId) .orElse(null); if (deptId == null) { throw new ServiceException( "åå·¥[" + staffOnJob.getStaffName() + "]çé¨é¨[" + staffOnJob.getSysDeptName() + "]ä¸åå¨ï¼è¯·æ£æ¥æ°æ®"); } staffOnJobDto.setSysDeptId(deptId); // éè¿åç§°è·åè§è²id staffOnJobDto.setRoleId(sysRoles.stream() .filter(role -> role.getRoleName() != null && role.getRoleName().equals(staffOnJob.getRoleName())) Long roleId = sysRoles.stream() .filter(role -> role.getRoleName() != null && role.getRoleName().equals(staffOnJob.getRoleName())) .findFirst() .map(SysRole::getRoleId) .orElse( null)); add(staffOnJobDto); .orElse(null); if (roleId == null) { throw new ServiceException( "åå·¥[" + staffOnJob.getStaffName() + "]çè§è²[" + staffOnJob.getRoleName() + "]ä¸åå¨ï¼è¯·æ£æ¥æ°æ®"); } staffOnJobDto.setRoleId(roleId); SpringUtils.getAopProxy(this).add(staffOnJobDto); }); return true; } catch (ServiceException | BaseException e) { throw e; } catch (Exception e) { e.printStackTrace(); return false; log.error("åå·¥å°è´¦å¯¼å ¥å¤±è´¥ : " + e.getMessage()); throw new ServiceException("å¯¼å ¥å¤±è´¥: " + e.getMessage()); } } @Override public String exportCopy(HttpServletResponse response, StaffOnJob staffOnJob) throws Exception { @@ -339,7 +372,7 @@ // è®¾ç½®æ¨¡æ¿æä»¶æå¨ç®å½ï¼ç»å¯¹è·¯å¾ï¼ä¾å¦ï¼/templates/ï¼ cfg.setClassForTemplateLoading(StaffOnJobServiceImpl.class, "/static"); cfg.setDefaultEncoding("UTF-8"); //2.å®ä¹éè¦å¡«å çåé // 2.å®ä¹éè¦å¡«å çåé // â æé å工信æ¯ï¼å®é 项ç®ä¸å¯ä»æ°æ®åº/Excel读åï¼ WordDateDto staff = new WordDateDto(); BeanUtils.copyProperties(staffOnJob, staff); @@ -349,7 +382,7 @@ Instant instant = staff.getContractExpireTime().toInstant(); // ä¹å¯ä»¥æå®å ·ä½æ¶åºï¼ä¾å¦Asia/Shanghaiï¼ LocalDate localDate = instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDate(); // ååç»ææ¶é´ LocalDate localDate = instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDate(); // ååç»ææ¶é´ LocalDate localDate1 = localDate.minusYears(Integer.parseInt(staff.getContractTerm()));// ååå¼å§æ¶é´ // ç¾è®¢æ¥æè½¬æ¢lcoaldate @@ -362,7 +395,7 @@ staff.setQyear(localDate2.getYear() + ""); staff.setQmoth(localDate2.getMonthValue() + ""); staff.setQday(localDate2.getDayOfMonth() + ""); if(staff.getDateSelect().equals("A")){ if (staff.getDateSelect().equals("A")) { staff.setSyear(localDate1.getYear() + ""); staff.setSmoth(localDate1.getMonthValue() + ""); staff.setSday(localDate1.getDayOfMonth() + ""); @@ -376,7 +409,7 @@ staff.setSeyear(localDate4.getYear() + ""); staff.setSemoth(localDate4.getMonthValue() + ""); staff.setSeday(localDate4.getDayOfMonth() + ""); }else if (staff.getDateSelect().equals("B")){ } else if (staff.getDateSelect().equals("B")) { staff.setBsyear(localDate1.getYear() + ""); staff.setBsmoth(localDate1.getMonthValue() + ""); @@ -388,29 +421,27 @@ staff.setBseyear(localDate4.getYear() + ""); staff.setBsemoth(localDate4.getMonthValue() + ""); staff.setBseday(localDate4.getDayOfMonth() + ""); }else if (staff.getDateSelect().equals("C")){ } else if (staff.getDateSelect().equals("C")) { staff.setCsyear(localDate1.getYear() + ""); staff.setCsmoth(localDate1.getMonthValue() + ""); staff.setCsday(localDate1.getDayOfMonth() + ""); } Map<String,Object> data = new HashMap<>(); data.put("item",staff); //3.å è½½XML æ¨¡æ¿ Map<String, Object> data = new HashMap<>(); data.put("item", staff); // 3.å è½½XML æ¨¡æ¿ Template template = cfg.getTemplate("å³å¨åå书.xml"); //4.çæå¡«å åç XML å 容 // 4.çæå¡«å åç XML å 容 StringWriter out = new StringWriter(); template.process(data, out); String filledXml = out.toString(); //5.å°XMLå 容åå ¥äº¤ä»¶å¹¶æ¹ä¸º.docx æ ¼å¼ // 5.å°XMLå 容åå ¥äº¤ä»¶å¹¶æ¹ä¸º.docx æ ¼å¼ File outputFile = new File(url); try(FileOutputStream fos = new FileOutputStream(outputFile); OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) { try (FileOutputStream fos = new FileOutputStream(outputFile); OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) { osw.write(filledXml); } return url; } } src/main/java/com/ruoyi/stock/dto/StockInRecordDto.java
@@ -18,6 +18,11 @@ */ private String model; /** * æ¹æ¬¡å· */ private String batchNo; /** * 产ååä½ */ private String unit; src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
@@ -79,4 +79,7 @@ @Schema(description = "产åid") private Long productId; @Schema(description = "æ¹æ¬¡å·") private String batchNo; } src/main/java/com/ruoyi/stock/dto/StockOutRecordDto.java
@@ -21,6 +21,10 @@ */ private String model; /** * æ¹æ¬¡å· */ private String batchNo; /** * 产ååä½ */ private String unit; src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -31,6 +31,12 @@ <if test="params.productName != null and params.productName != ''"> and p.product_name like concat('%',#{params.productName},'%') </if> <if test="params.model != null and params.model != ''"> and pm.model like concat('%',#{params.model},'%') </if> <if test="params.batchNo != null and params.batchNo != ''"> and sir.batch_no like concat('%',#{params.batchNo},'%') </if> <if test="params.type != null and params.type != ''"> and sir.type = #{params.type} </if> src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -209,6 +209,12 @@ <if test="ew.topParentProductId != null and ew.topParentProductId > 0"> and combined.product_id in (select id from product_tree) </if> <if test="ew.model != null and ew.model !=''"> and combined.model like concat('%',#{ew.model},'%') </if> <if test="ew.batchNo != null and ew.batchNo !=''"> and combined.batch_no like concat('%',#{ew.batchNo},'%') </if> </where> group by product_model_id, src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -46,6 +46,12 @@ <if test="params.productName != null and params.productName != ''"> and p.product_name like concat('%',#{params.productName},'%') </if> <if test="params.model != null and params.model != ''"> and pm.model like concat('%',#{params.model},'%') </if> <if test="params.batchNo != null and params.batchNo != ''"> and sor.batch_no like concat('%',#{params.batchNo},'%') </if> <if test="params.type != null and params.type != ''"> and sor.type = #{params.type} </if> src/main/resources/static/ÏúÊŲ̂Õ˵¼ÈëÄ£°å.xlsxBinary files differ