basic-server/src/main/java/com/ruoyi/basic/controller/StandardProductListUpdateRecordController.java
@@ -32,8 +32,8 @@ @ApiOperation(value = "æ åæ ä¸ä¿®æ¹è®°å½å页æ¥è¯¢") @GetMapping("/standardProductListRecordPage") public Result standardProductListRecordPage(Page page, StandardProductListUpdateRecord standardProductListUpdateRecord) { return Result.success(standardProductListUpdateRecordService.standardProductListRecordPage(page,standardProductListUpdateRecord)); public Result standardProductListRecordPage(Page page, StandardProductListUpdateRecordDto standardProductListUpdateRecordDto) { return Result.success(standardProductListUpdateRecordService.standardProductListRecordPage(page,standardProductListUpdateRecordDto)); } @ApiOperation(value = "æ åæ ä¸æ£éªé¡¹ä¿®æ¹è®°å½æ¥è¯¢") basic-server/src/main/java/com/ruoyi/basic/controller/StandardTreeController.java
@@ -222,7 +222,7 @@ @ApiOperation(value = "å é¤åå®¶è¦æ±å¼ç»å®") @DeleteMapping("/deleteProductSupplierAsk") public Result deleteProductSupplierAsk(Integer supplierAskId) { standardProductListSupplierAskService.removeById(supplierAskId); standardProductListSupplierAskService.deleteProductSupplierAsk(supplierAskId); return Result.success(); } basic-server/src/main/java/com/ruoyi/basic/dto/StandardProductListUpdateRecordDto.java
@@ -15,7 +15,6 @@ * æ åæ ä¸çæ£éªé¡¹ç®ä¿®æ¹è®°å½ * */ @TableName(value ="standard_product_list_update_record") @Data public class StandardProductListUpdateRecordDto extends StandardProductListUpdateRecord { @@ -23,9 +22,9 @@ * åå»ºç¨æ·åç§° */ private String createUserName; /** * ä¿®æ¹ç¨æ·åç§° */ private String updateUserName; } basic-server/src/main/java/com/ruoyi/basic/mapper/StandardProductListSupplierAskBackupRelMapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,24 @@ package com.ruoyi.basic.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.basic.pojo.StandardProductListSupplierAskBackupRel; import org.apache.ibatis.annotations.Param; import java.util.List; public interface StandardProductListSupplierAskBackupRelMapper extends BaseMapper<StandardProductListSupplierAskBackupRel> { /** * æ ¹æ®æ åæ ä¸æ£éªé¡¹idå é¤å ³èåå®¶å¤ä»½æ°æ® * @param productIds * @return */ int batchDeleteByProductIds(@Param("productIds") List<Long> productIds); /** * æ¹éæå ¥å ³èåå®¶å¤ä»½æ°æ® * @param list * @return */ int batchInsertSupplierAskBackUpRel(@Param("list") List<StandardProductListSupplierAskBackupRel> list); } basic-server/src/main/java/com/ruoyi/basic/mapper/StandardProductListSupplierAskMapper.java
@@ -3,6 +3,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.basic.pojo.StandardProductListSupplierAsk; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * æ£éªé¡¹ç®åå®¶å¯åº¦ç»å®è¡¨ @@ -13,6 +16,7 @@ @Mapper public interface StandardProductListSupplierAskMapper extends BaseMapper<StandardProductListSupplierAsk> { int batchInsertSupplierAsk(@Param("list") List<StandardProductListSupplierAsk> list); } basic-server/src/main/java/com/ruoyi/basic/mapper/StandardProductListUpdateRecordMapper.java
@@ -20,10 +20,10 @@ * æ åæ ä¸æ£éªé¡¹ä¿®æ¹è®°å½å页æ¥è¯¢ * * @param page * @param ew * @param record * @return */ IPage<StandardProductListUpdateRecordDto> standardProductListRecordPage(Page page, @Param("ew") QueryWrapper<StandardProductListUpdateRecord> ew); IPage<StandardProductListUpdateRecordDto> standardProductListRecordPage(Page page, @Param("record") StandardProductListUpdateRecordDto record); } basic-server/src/main/java/com/ruoyi/basic/pojo/StandardProductList.java
@@ -221,5 +221,6 @@ private String conductorType; @ApiModelProperty("å®¡æ ¸ç¶æ 0 æªæäº¤ 1 å®¡æ ¸ä¸ 2 å®¡æ ¸éè¿ 3 å®¡æ ¸æªéè¿") @TableField(updateStrategy = FieldStrategy.IGNORED) private String checkStatus; } basic-server/src/main/java/com/ruoyi/basic/pojo/StandardProductListSupplierAskBackupRel.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,58 @@ package com.ruoyi.basic.pojo; import com.baomidou.mybatisplus.annotation.*; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; /** * æ£éªé¡¹ç®åå®¶å¯åº¦ç»å®è¡¨ * * @author zhuo * @since 2024-09-23 */ @TableName(value ="standard_product_list_supplier_ask_backup_rel") @Data public class StandardProductListSupplierAskBackupRel { @TableId(type = IdType.AUTO) private Integer supplierAskId; @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("æ£éªé¡¹ç®id") private Long productListId; @ApiModelProperty("åå®¶åç§°") private String supplierName; @ApiModelProperty("è¦æ±å¼") private String ask; @ApiModelProperty("è¦æ±æè¿°") private String tell; @ApiModelProperty(value = "å建人id") @TableField(fill = FieldFill.INSERT) private Integer createUser; @ApiModelProperty(value = "ä¿®æ¹äººid") @TableField(fill = FieldFill.INSERT_UPDATE) private Integer updateUser; @ApiModelProperty(value = "å建æ¶é´") @TableField(fill = FieldFill.INSERT) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; @ApiModelProperty(value = "æ´æ°æ¶é´") @TableField(fill = FieldFill.INSERT_UPDATE) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; } basic-server/src/main/java/com/ruoyi/basic/service/StandardProductListSupplierAskService.java
@@ -19,5 +19,9 @@ Integer updateProductSupplierAsk(StandardProductListSupplierAsk supplierAsk); void deleteProductSupplierAsk(Integer supplierAskId); void backupSupplierAsk(StandardProductListSupplierAsk supplierAsk); } basic-server/src/main/java/com/ruoyi/basic/service/StandardProductListUpdateRecordService.java
@@ -25,10 +25,10 @@ /** * æ åæ ä¸æ£éªé¡¹ä¿®æ¹è®°å½å页æ¥è¯¢ * @param page * @param record * @param standardProductListUpdateRecordDto * @return */ IPage<StandardProductListUpdateRecordDto> standardProductListRecordPage(Page page, StandardProductListUpdateRecord record); IPage<StandardProductListUpdateRecordDto> standardProductListRecordPage(Page page, StandardProductListUpdateRecordDto standardProductListUpdateRecordDto); /** * æ åæ ä¸æ£éªé¡¹ä¿®æ¹è®°å½æ¥è¯¢ basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java
@@ -12,6 +12,7 @@ import com.ruoyi.basic.mapper.*; import com.ruoyi.basic.pojo.*; import com.ruoyi.basic.service.StandardMethodListService; import com.ruoyi.basic.service.StandardProductListSupplierAskService; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.QueryWrappers; import com.ruoyi.common.utils.SecurityUtils; @@ -68,6 +69,12 @@ @Autowired private StandardProductListUpdateRecordRelMapper standardProductListUpdateRecordRelMapper; @Autowired private StandardProductListSupplierAskService standardProductListSupplierAskService; @Autowired private StandardProductListSupplierAskBackupRelMapper standardProductListSupplierAskBackupRelMapper; @Override public int upStandardProductList(StandardProductList list) { @@ -87,6 +94,10 @@ BeanUtils.copyProperties(standardProductList, productListBackupRel); standardProductListBackupRelMapper.insert(productListBackupRel); } // å ³èåå®¶å¤ä»½ StandardProductListSupplierAsk standardProductListSupplierAsk = new StandardProductListSupplierAsk(); standardProductListSupplierAsk.setProductListId(list.getId()); standardProductListSupplierAskService.backupSupplierAsk(standardProductListSupplierAsk); // ä¿®æ¹ç¶æ list.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); return standardProductListMapper.updateById(list); @@ -505,6 +516,10 @@ BeanUtils.copyProperties(standardProductList, productListBackupRel); standardProductListBackupRelMapper.insert(productListBackupRel); } // å ³èåå®¶å¤ä»½ StandardProductListSupplierAsk standardProductListSupplierAsk = new StandardProductListSupplierAsk(); standardProductListSupplierAsk.setProductListId(list.getId()); standardProductListSupplierAskService.backupSupplierAsk(standardProductListSupplierAsk); // ä¿®æ¹ç¶æ list.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); standardProductListMapper.updateSection(list); @@ -713,25 +728,41 @@ } // å®¡æ ¸éè¿ if(StandardProductListChcekTypeEnums.PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ // å é¤å¤ä»½æ°æ® standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); // ä¿®æ¹ç¶æ standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.PASS_CHECK.getCode()); } // å®¡æ ¸æªéè¿ if(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ // æ¥è¯¢ææçå¤ä»½æ°æ® // æ¥è¯¢æææ åæ ä¸çæ£éªé¡¹ç®å¤ä»½æ°æ® List<StandardProductListBackupRel> standardProductListBackupRelList = standardProductListBackupRelMapper.selectBatchIds(standardProductListIds); // åæ»æ°æ® // åæ»æ åæ ä¸çæ£éªé¡¹ç®æ°æ® for (StandardProductListBackupRel standardProductListBackupRel : standardProductListBackupRelList) { StandardProductList standardProductList = new StandardProductList(); BeanUtils.copyProperties(standardProductListBackupRel, standardProductList); standardProductList.setCheckStatus(""); standardProductListMapper.updateById(standardProductList); } // å é¤å¤ä»½æ°æ® standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); // åæ»æ£éªé¡¹ç®åå®¶å¯åº¦ç»å®è¡¨æ°æ® QueryWrapper<StandardProductListSupplierAskBackupRel> supplierAskBackupRelQueryWrapper = new QueryWrapper<>(); supplierAskBackupRelQueryWrapper.in("product_list_id",standardProductListIds); List<StandardProductListSupplierAskBackupRel> standardProductListSupplierAskBackupRelList = standardProductListSupplierAskBackupRelMapper.selectList(supplierAskBackupRelQueryWrapper); if(!CollectionUtils.isEmpty(standardProductListSupplierAskBackupRelList)){ QueryWrapper<StandardProductListSupplierAsk> deleteWrapper = new QueryWrapper<>(); deleteWrapper.in("product_list_id",standardProductListIds); standardProductListSupplierAskMapper.delete(deleteWrapper); ArrayList<StandardProductListSupplierAsk> supplierAskRollBackList = new ArrayList<>(); for (StandardProductListSupplierAskBackupRel standardProductListSupplierAskBackupRel : standardProductListSupplierAskBackupRelList) { StandardProductListSupplierAsk standardProductListSupplierAsk = new StandardProductListSupplierAsk(); BeanUtils.copyProperties(standardProductListSupplierAskBackupRel, standardProductListSupplierAsk); supplierAskRollBackList.add(standardProductListSupplierAsk); } standardProductListSupplierAskMapper.batchInsertSupplierAsk(supplierAskRollBackList); } } // å 餿 åæ ä¸çæ£éªé¡¹ç®å¤ä»½æ°æ® standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); // å é¤ç»å®åå®¶å¤ä»½æ°æ® standardProductListSupplierAskBackupRelMapper.batchDeleteByProductIds(standardProductListIds); standardProductListUpdateRecordMapper.updateById(standardProductListUpdateRecord); } basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListSupplierAskServiceImpl.java
@@ -1,13 +1,24 @@ package com.ruoyi.basic.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.basic.enums.StandardProductListChcekTypeEnums; import com.ruoyi.basic.mapper.StandardProductListMapper; import com.ruoyi.basic.mapper.StandardProductListSupplierAskBackupRelMapper; import com.ruoyi.basic.pojo.StandardProductList; import com.ruoyi.basic.pojo.StandardProductListSupplierAskBackupRel; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.basic.mapper.StandardProductListSupplierAskMapper; import com.ruoyi.basic.pojo.StandardProductListSupplierAsk; import com.ruoyi.basic.service.StandardProductListSupplierAskService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; /** @@ -18,6 +29,12 @@ */ @Service public class StandardProductListSupplierAskServiceImpl extends ServiceImpl<StandardProductListSupplierAskMapper, StandardProductListSupplierAsk> implements StandardProductListSupplierAskService { @Autowired private StandardProductListSupplierAskBackupRelMapper standardProductListSupplierAskBackupRelMapper; @Autowired private StandardProductListMapper standardProductListMapper; /** * æ¥è¯¢åå®¶è¦æ±å¼ç»å® @@ -39,10 +56,18 @@ * @return */ @Override @Transactional(rollbackFor = Exception.class) public Integer addProductSupplierAsk(StandardProductListSupplierAsk supplierAsk) { if (supplierAsk.getProductListId() == null) { throw new BaseException("缺å°äº§å对象id"); } // æ°å¢åå¤ä»½ backupSupplierAsk(supplierAsk); // ä¿®æ¹ç¶æä¸ºå¾ æäº¤ StandardProductList standardProductList = new StandardProductList(); standardProductList.setId(supplierAsk.getProductListId()); standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); standardProductListMapper.updateById(standardProductList); // æ¥è¯¢æ¹åå®¶æ¯å¦ç»å®è¿ Long count = baseMapper.selectCount(Wrappers.<StandardProductListSupplierAsk>lambdaQuery() .eq(StandardProductListSupplierAsk::getProductListId, supplierAsk.getProductListId()) @@ -51,9 +76,6 @@ throw new BaseException("该产åå·²ç»å®è¿è¯¥åå®¶"); } baseMapper.insert(supplierAsk); // return supplierAsk.getSupplierAskId(); } @@ -63,10 +85,18 @@ * @return */ @Override @Transactional(rollbackFor = Exception.class) public Integer updateProductSupplierAsk(StandardProductListSupplierAsk supplierAsk) { if (supplierAsk.getProductListId() == null) { throw new BaseException("ç¼ºå°æ£éªé¡¹id"); } // ä¿®æ¹åå¤ä»½ backupSupplierAsk(supplierAsk); // ä¿®æ¹ç¶æä¸ºå¾ æäº¤ StandardProductList standardProductList = new StandardProductList(); standardProductList.setId(supplierAsk.getProductListId()); standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); standardProductListMapper.updateById(standardProductList); // æ¥è¯¢æ¹åå®¶æ¯å¦ç»å®è¿ Long count = baseMapper.selectCount(Wrappers.<StandardProductListSupplierAsk>lambdaQuery() .ne(StandardProductListSupplierAsk::getSupplierAskId, supplierAsk.getSupplierAskId()) @@ -78,5 +108,47 @@ baseMapper.updateById(supplierAsk); return supplierAsk.getSupplierAskId(); } @Override @Transactional(rollbackFor = Exception.class) public void deleteProductSupplierAsk(Integer supplierAskId) { StandardProductListSupplierAsk supplierAsk = baseMapper.selectById(supplierAskId); // å é¤åå¤ä»½ backupSupplierAsk(supplierAsk); // ä¿®æ¹ç¶æä¸ºå¾ æäº¤ StandardProductList standardProductList = new StandardProductList(); standardProductList.setId(supplierAsk.getProductListId()); standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); standardProductListMapper.updateById(standardProductList); baseMapper.deleteById(supplierAskId); } /** * æ£éªé¡¹ç®åå®¶å¯åº¦ç»å®å¤ä»½è¡¨è¡¨å¤ä»½ * * @param supplierAsk */ @Override public void backupSupplierAsk(StandardProductListSupplierAsk supplierAsk) { // æ¥è¯¢å¤ä»½æ°æ®æ¯å¦åå¨ï¼å¦ææä¸åå¤ä»½ QueryWrapper<StandardProductListSupplierAskBackupRel> backupQueryWrapper = new QueryWrapper<>(); backupQueryWrapper.eq("product_list_id", supplierAsk.getProductListId()); List<StandardProductListSupplierAskBackupRel> standardProductListSupplierAskBackupRels = standardProductListSupplierAskBackupRelMapper.selectList(backupQueryWrapper); // æ¥è¯¢åæ°æ®è¿è¡å¤ä»½ if(CollectionUtils.isEmpty(standardProductListSupplierAskBackupRels)){ QueryWrapper<StandardProductListSupplierAsk> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("product_list_id", supplierAsk.getProductListId()); List<StandardProductListSupplierAsk> standardProductListSupplierAskList = baseMapper.selectList(queryWrapper); List<StandardProductListSupplierAskBackupRel> supplierAskBackupRelInsertList = new ArrayList<>(); for (StandardProductListSupplierAsk standardProductListSupplierAsk : standardProductListSupplierAskList) { StandardProductListSupplierAskBackupRel standardProductListSupplierAskBackupRel = new StandardProductListSupplierAskBackupRel(); BeanUtils.copyProperties(standardProductListSupplierAsk, standardProductListSupplierAskBackupRel); supplierAskBackupRelInsertList.add(standardProductListSupplierAskBackupRel); } if(!CollectionUtils.isEmpty(supplierAskBackupRelInsertList)){ standardProductListSupplierAskBackupRelMapper.batchInsertSupplierAskBackUpRel(supplierAskBackupRelInsertList); } } } } basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListUpdateRecordServiceImpl.java
@@ -65,8 +65,8 @@ * @return */ @Override public IPage<StandardProductListUpdateRecordDto> standardProductListRecordPage(Page page, StandardProductListUpdateRecord record) { return standardProductListUpdateRecordMapper.standardProductListRecordPage(page,QueryWrappers.queryWrappers(record)); public IPage<StandardProductListUpdateRecordDto> standardProductListRecordPage(Page page, StandardProductListUpdateRecordDto record) { return standardProductListUpdateRecordMapper.standardProductListRecordPage(page,record); } /** basic-server/src/main/resources/mapper/StandardProductListSupplierAskBackupRelMapper.xml
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,39 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.ruoyi.basic.mapper.StandardProductListSupplierAskBackupRelMapper"> <delete id="batchDeleteByProductIds"> delete from standard_product_list_supplier_ask_backup_rel where product_list_id in <foreach collection="productIds" open="(" close=")" separator="," item="item"> #{item} </foreach> </delete> <insert id="batchInsertSupplierAskBackUpRel"> INSERT INTO standard_product_list_supplier_ask_backup_rel ( supplier_ask_id, product_list_id, supplier_name, ask, tell, create_user, update_user, create_time, update_time )values <foreach collection="list" item="item" separator=","> ( #{item.supplierAskId}, #{item.productListId}, #{item.supplierName}, #{item.ask}, #{item.tell}, #{item.createUser}, #{item.updateUser}, #{item.createTime}, #{item.updateTime} ) </foreach> </insert> </mapper> basic-server/src/main/resources/mapper/StandardProductListSupplierAskMapper.xml
@@ -2,4 +2,30 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.ruoyi.basic.mapper.StandardProductListSupplierAskMapper"> <insert id="batchInsertSupplierAsk"> INSERT INTO standard_product_list_supplier_ask ( supplier_ask_id, product_list_id, supplier_name, ask, tell, create_user, update_user, create_time, update_time )values <foreach collection="list" item="item" separator=","> ( #{item.supplierAskId}, #{item.productListId}, #{item.supplierName}, #{item.ask}, #{item.tell}, #{item.createUser}, #{item.updateUser}, #{item.createTime}, #{item.updateTime} ) </foreach> </insert> </mapper> basic-server/src/main/resources/mapper/StandardProductListUpdateRecordMapper.xml
@@ -5,12 +5,16 @@ <mapper namespace="com.ruoyi.basic.mapper.StandardProductListUpdateRecordMapper"> <select id="standardProductListRecordPage" resultType="com.ruoyi.basic.dto.StandardProductListUpdateRecordDto"> SELECT *, ( SELECT NAME FROM `user` WHERE id = create_user ) AS createUserName, ( SELECT NAME FROM `user` WHERE id = update_user ) AS updateUserName T2.name AS create_user_name, T3.name AS update_user_name FROM standard_product_list_update_record <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> ${ew.customSqlSegment} </if> standard_product_list_update_record T1 LEFT JOIN user T2 ON T1.create_user = T2.id LEFT JOIN user T3 ON T1.update_user = T3.id <where> <if test="record.createUserName != null and record.createUserName != ''"> T2.name like concat('%',#{record.createUserName},'%') </if> </where> </select> </mapper> cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
@@ -511,19 +511,26 @@ @Override @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) public void importExcel(List<Device> batch) { if (CollectionUtils.isEmpty(batch)) { if (CollUtil.isEmpty(batch)) { return; } // 1. æ¹éæ¥è¯¢å ³èæ°æ®ï¼ç¨æ·ãå®éªå®¤ï¼ // æåè·å设å¤åç§°ãåå·å管çç¼å·éå Set<String> deviceNames = batch.stream().map(Device::getDeviceName).collect(Collectors.toSet()); Set<String> specificationModels = batch.stream().map(Device::getSpecificationModel).collect(Collectors.toSet()); Set<String> managementNumbers = batch.stream().map(Device::getManagementNumber).collect(Collectors.toSet()); // æ¹éæ¥è¯¢å ³èæ°æ®ï¼ç¨æ·ãå®éªå®¤ï¼ Map<String, Integer> userMap = queryUserMap(batch); Map<String, Integer> labMap = queryLabMap(batch); // 2. å åå¤çï¼è½¬æ¢å ³èåæ®µå¹¶å»é processBatch(batch, userMap, labMap); // å åå¤çï¼è½¬æ¢å ³èåæ®µå¹¶å»éï¼åæ¶æåæå ¥åæ´æ°å表 List<Device> toInsert = new ArrayList<>(); List<Device> toUpdate = new ArrayList<>(); processBatch(batch, userMap, labMap, deviceNames, specificationModels, managementNumbers, toInsert, toUpdate); // 3. æ¹éæä½æ°æ®åº batchOperate(batch); // æ¹éæä½æ°æ®åº batchOperate(toInsert, toUpdate); } private Map<String, Integer> queryUserMap(List<Device> batch) { @@ -552,31 +559,35 @@ ).stream().collect(Collectors.toMap(Laboratory::getLaboratoryName, Laboratory::getId)); } private void processBatch(List<Device> batch, Map<String, Integer> userMap, Map<String, Integer> labMap) { private void processBatch(List<Device> batch, Map<String, Integer> userMap, Map<String, Integer> labMap, Set<String> deviceNames, Set<String> specificationModels, Set<String> managementNumbers, List<Device> toInsert, List<Device> toUpdate) { // é¢è®¡ç®å¯ä¸é®ï¼è®¾å¤åç§°+åå·+管çç¼å·ï¼ Map<String, Device> existDevices = deviceMapper.selectList( new LambdaQueryWrapper<Device>() .in(Device::getDeviceName, batch.stream().map(Device::getDeviceName).collect(Collectors.toSet())) .in(Device::getSpecificationModel, batch.stream().map(Device::getSpecificationModel).collect(Collectors.toSet())) .in(Device::getManagementNumber, batch.stream().map(Device::getManagementNumber).collect(Collectors.toSet())) .in(Device::getDeviceName, deviceNames) .in(Device::getSpecificationModel, specificationModels) .in(Device::getManagementNumber, managementNumbers) ).stream().collect(Collectors.toMap( d -> d.getDeviceName() + "|" + d.getSpecificationModel() + "|" + d.getManagementNumber(), Function.identity() )); List<Device> toInsert = new ArrayList<>(); List<Device> toUpdate = new ArrayList<>(); for (Device device : batch) { // 转æ¢å ³èåæ®µ device.setEquipmentManager(userMap.get(device.getEquipmentManagerName())); device.setSubordinateDepartmentsId(labMap.get(device.getSubordinateDepartments())); //设å¤ç¶æ if (ObjectUtils.isNotEmpty(device.getDeviceStatusName())){ //æ¥åå ¸å¯¹åºçå¼ String status = sysDictDataMapper.selectDictValue("device_status", device.getDeviceStatusName()); device.setDeviceStatus(Integer.parseInt(status)); // 设å¤ç¶æ if (ObjectUtils.isNotEmpty(device.getDeviceStatusName())) { try { // æ¥åå ¸å¯¹åºçå¼ String status = sysDictDataMapper.selectDictValue("device_status", device.getDeviceStatusName()); device.setDeviceStatus(Integer.parseInt(status)); } catch (Exception e) { // å¤çå¼å¸¸ï¼ä¾å¦è®°å½æ¥å¿ e.printStackTrace(); } } // çæå¯ä¸é® @@ -589,27 +600,12 @@ toInsert.add(device); } } batch.clear(); batch.addAll(toInsert); batch.addAll(toUpdate); } private void batchOperate(List<Device> batch) { // æåæå ¥åæ´æ°å表 List<Device> toInsert = new ArrayList<>(); List<Device> toUpdate = new ArrayList<>(); for (Device device : batch) { if (device.getId() == null) { toInsert.add(device); } else { toUpdate.add(device); } } private void batchOperate(List<Device> toInsert, List<Device> toUpdate) { // æ¹éæå ¥ if (CollUtil.isNotEmpty(toInsert)) { baseMapper.insertBatchSomeColumn(toInsert); deviceMapper.insertBatchSomeColumn(toInsert); } // æ¹éæ´æ°