From 99755eea33cf009c36507df468c244f3be5b34c9 Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期五, 28 二月 2025 17:27:31 +0800 Subject: [PATCH] Merge branch 'dev' of http://114.132.189.42:9002/r/lims-ruoyi-after into dev_cr --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 276 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 152 insertions(+), 124 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java index 5b7231d..69d71dc 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java @@ -2,8 +2,6 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateTime; -import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; @@ -44,7 +42,6 @@ import com.ruoyi.inspect.util.HackLoopTableRenderPolicy; import com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo; import com.ruoyi.inspect.vo.InsOrderPlanVO; -import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper; import com.ruoyi.performance.mapper.PerformanceShiftMapper; import com.ruoyi.performance.mapper.ShiftTimeMapper; import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours; @@ -57,7 +54,6 @@ import com.ruoyi.system.service.InformationNotificationService; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xwpf.usermodel.*; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; import org.springframework.mock.web.MockMultipartFile; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -71,13 +67,10 @@ import java.math.RoundingMode; import java.nio.file.Files; import java.nio.file.Paths; -import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -160,7 +153,8 @@ private InsOrderDeviceRecordService insOrderDeviceRecordService; @Resource private ISysDictTypeService iSysDictTypeService; - + @Resource + private InsOrderRatesService insOrderRatesService; @Override public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) { @@ -749,7 +743,7 @@ @Transactional(rollbackFor = Exception.class) public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) { InsOrder order = insOrderMapper.selectById(orderId); - // 鍒ゆ柇鏄惁鏈夐噸澶嶇紪鍙�, 鏈夐噸澶嶇紪鍙峰仛鎻愰啋 + // 1. 鍒ゆ柇鏄惁鏈夐噸澶嶇紪鍙�, 鏈夐噸澶嶇紪鍙峰仛鎻愰啋 Long codeCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() .ne(InsOrder::getState, -1) .ne(InsOrder::getIfsInventoryId, order.getIfsInventoryId()) @@ -758,7 +752,7 @@ throw new ErrorException("褰撳墠缂栧彿鏈夐噸澶�, 璇峰厛鍘讳慨鏀归噸澶嶇紪鍙�"); } - // 鍒ゆ柇璇ヨ鍗曟槸鍚︽槸绗竴娆$敓浜� + // 2. 鍒ゆ柇璇ヨ鍗曟槸鍚︽槸绗竴娆$敓浜�(鍚庣画鎶ュ憡鐢熸垚鍙彇绗竴娆℃彁浜ゆ椂闂�) if (!(order.getIsFirstSubmit() != null && order.getIsFirstSubmit().equals(1))) { insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() .eq(InsOrder::getId, orderId) @@ -766,11 +760,12 @@ .set(InsOrder::getFirstSubmitDate, LocalDateTime.now())); } + // 3. 鍒ゆ柇鏄惁鏈夋湭妫�椤� List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() .eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); - List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); + List<Integer> InsSampleIds = insSamples.stream().map(InsSample::getId).collect(Collectors.toList()); List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() - .in(InsProduct::getInsSampleId, ids) + .in(InsProduct::getInsSampleId, InsSampleIds) .eq(InsProduct::getSonLaboratory, laboratory) .eq(InsProduct::getState, 1) .and(wrapper -> wrapper @@ -778,10 +773,8 @@ .or() .eq(InsProduct::getInsResult, 2) ) - .isNull(InsProduct::getInsFiberId) - .isNull(InsProduct::getInsFibersId) .ne(InsProduct::getIsBinding, 1)); - insProducts.addAll(insProductMapper.selectFiberInsProduct(ids, laboratory)); + insProducts.addAll(insProductMapper.selectFiberInsProduct(InsSampleIds, laboratory)); if (insProducts.size() > 0) { String str = ""; int count = 0; @@ -794,21 +787,21 @@ throw new ErrorException("<strong>瀛樺湪寰呮楠岀殑椤圭洰锛�</strong><br/>" + str); } } + + // 4.淇敼妫�娴嬬粨鏋� insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, orderId) .eq(InsOrderState::getLaboratory, laboratory) .set(InsOrderState::getInsTime, LocalDateTime.now()) .set(InsOrderState::getInsState, 3) .set(InsOrderState::getVerifyUser, verifyUser)); - // 鍙戦�佹秷鎭� + + // 5.鍙戦�佹秷鎭�氱煡缁欏鏍镐汉 // 鏌ヨ褰撳墠浜轰俊鎭� Integer userId = SecurityUtils.getUserId().intValue(); String userName = insProductMapper.selectUserById(userId).get("name"); - // 鏌ヨ鍙戦�佷汉淇℃伅 String sendUserAccount = insProductMapper.selectUserById(verifyUser).get("account"); - - InformationNotification info = new InformationNotification(); info.setCreateUser(userName); info.setMessageType("2"); @@ -820,15 +813,16 @@ info.setJumpPath("b1-inspect-orderPlan-review"); informationNotificationService.addInformationNotification(info); - //澶嶆牳浜�--妫�楠屽崟鐩稿叧璐熻矗浜� + // 6.澶嶆牳浜�--鏂板妫�楠屽崟鐩稿叧璐熻矗浜� InsSampleUser insSampleUser = new InsSampleUser(); insSampleUser.setUserId(verifyUser); insSampleUser.setInsSampleId(orderId); insSampleUser.setState(1); insSampleUser.setSonLaboratory(laboratory); insSampleUserMapper.insert(insSampleUser); - /*鏍¢獙涓�涓媟esult琛�*/ - CompletableFuture.supplyAsync(() -> { + + // 7.鏍¢獙涓�涓媟esult琛�(閬垮厤鍑虹幇澶氫釜妫�楠岄」缁撴灉) + threadPoolTaskExecutor.execute(() -> { List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList()); for (Integer ip : ips) { List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() @@ -839,26 +833,116 @@ } } } - return null; }); - // 鎻愪氦鐢熸垚鎶ュ憡 + // 8.鎻愪氦鐢熸垚鎶ュ憡 this.generateReport(orderId); - // 娣诲姞涓存椂pdf鐢熸垚鍦板潃 + // 9.娣诲姞涓存椂pdf鐢熸垚鍦板潃 InsReport report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() .eq(InsReport::getInsOrderId, orderId)); String tempUrlPdf = this.wordToPdfTemp(report.getUrl().replace("/word", wordUrl)); report.setTempUrlPdf("/word/" + tempUrlPdf); insReportMapper.updateById(report); - // 鏌ヨ璁㈠崟 + // 10.鍘熷璁板綍妯℃澘澶嶅埗(娣诲姞澶囦唤, 閬垮厤淇敼鍘熷妯℃澘褰卞搷鍒板凡缁忓畬鎴愮殑鍗曞瓙) + this.templateCopy(orderId, InsSampleIds); + + // 11.鎴愬搧鎶芥牱娣诲姞鍚堟牸鐘舵�� + // 鍒ゆ柇鏄惁鏈夋娊鏍蜂俊鎭� + if (order.getQuarterItemId() != null) { + // 鍒ゆ柇鏄惁鏈変笉鍚堟牸 + this.addProductSpotCheck(insSamples, order); + } + + // 12.娣诲姞宸ユ椂 + // 鍒犻櫎鍘熸湰璁㈠崟宸ユ椂 + auxiliaryOutputWorkingHoursService.remove(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() + .eq(AuxiliaryOutputWorkingHours::getOrderId, orderId)); + // 鏌ヨ宸ユ椂鏆傚瓨 + List<AuxiliaryOutputWorkingHoursTemporary> hoursTemporaries = auxiliaryOutputWorkingHoursTemporaryService.list(Wrappers.<AuxiliaryOutputWorkingHoursTemporary>lambdaQuery() + .eq(AuxiliaryOutputWorkingHoursTemporary::getOrderId, orderId)); + List<AuxiliaryOutputWorkingHours> outputWorkingHours = hoursTemporaries.stream().map(hoursTemporary -> { + AuxiliaryOutputWorkingHours workingHours = new AuxiliaryOutputWorkingHours(); + BeanUtil.copyProperties(hoursTemporary, workingHours); + workingHours.setId(null); + return workingHours; + }).collect(Collectors.toList()); + auxiliaryOutputWorkingHoursService.saveBatch(outputWorkingHours); + + // 13.娣诲姞璁㈠崟璐圭敤缁熻淇℃伅 + List<InsProduct> productList = insProductMapper.selectProductByOrderId(orderId); + // 鍒犻櫎鍘熸湰璐圭敤淇℃伅 + insOrderRatesService.remove(Wrappers.<InsOrderRates>lambdaQuery() + .eq(InsOrderRates::getInsOrderId, orderId)); + List<InsOrderRates> orderRatesList = productList.stream().map(insProduct -> { + InsOrderRates insOrderRates = new InsOrderRates(); + insOrderRates.setInsOrderId(orderId); + insOrderRates.setInsSampleId(insProduct.getInsSampleId()); + insOrderRates.setInsProductId(insProduct.getId()); + insOrderRates.setSampleCode(insProduct.getSampleCode()); + insOrderRates.setEntrustCode(order.getEntrustCode()); + insOrderRates.setInspectionItemClass(insProduct.getInspectionItemClass()); + insOrderRates.setInspectionItem(insProduct.getInspectionItem()); + insOrderRates.setInspectionItemSubclass(insProduct.getInspectionItemSubclass()); + insOrderRates.setCableTag(insProduct.getCableTag()); + insOrderRates.setRates(insProduct.getRates()); + insOrderRates.setManHourGroup(insProduct.getManHourGroup()); + return insOrderRates; + }).collect(Collectors.toList()); + insOrderRatesService.saveBatch(orderRatesList); + + + // 14.鍙戦�佷紒涓氬井淇¢�氱煡 + // 鏌ヨ鍘熸潗鏂� + IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); + // 鏌ヨ鏍峰搧淇℃伅 InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() .eq(InsSample::getInsOrderId, orderId) .last("limit 1")); - // 鏌ヨ鍘熸潗鏂� - IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId()); + threadPoolTaskExecutor.execute(() -> { + String message = ""; + message += "妫�楠屼换鍔″鏍搁�氱煡"; + message += "\n鎻愪氦浜�: " + userName; + message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); + message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); + message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); + if (ifsInventoryQuantity != null) { + message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); + } + //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 + try { + WxCpUtils.inform(sendUserAccount, message, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + // 15.ifs绉诲簱(鍘熸潗鏂欓渶瑕佽繘琛岀Щ搴撴搷浣�) --> 鏈�鍚庢墽琛�,鍥犱负澶辫触鏃犳硶鍥炴粴 + if (ifsInventoryQuantity != null) { + // 鐧昏妫�楠岀粨鏋� + // 鍒ゆ柇鏄惁鏈変笉鍚堟牸, 鏈変笉鍚堟牸涓嶈兘绉诲簱 + // todo: ifs绉诲簱 + insReportService.isRawMaterial(order); + } else { + // 淇敼鎴愬搧鐘舵�� + // 鍒ゆ柇鏄惁鏈変笉鍚堟牸 + Long unqualifiedCount = insReportService.getUnqualifiedCount(order); + if (unqualifiedCount.equals(0L)) { + insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getId, order.getId()) + .set(InsOrder::getInsResult, 1)); + } else { + insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() + .eq(InsOrder::getId, order.getId()) + .set(InsOrder::getInsResult, 0)); + } + } + + return 1; + } + + private void templateCopy(Integer orderId, List<Integer> ids) { // 鍒犻櫎鍘熸湰妯℃澘 insOrderStandardTemplateService.remove(Wrappers.<InsOrderStandardTemplate>lambdaQuery() .eq(InsOrderStandardTemplate::getInsOrderId, orderId)); @@ -883,99 +967,6 @@ } } } - - // 娣诲姞宸ユ椂 - // 鍒犻櫎鍘熸湰璁㈠崟宸ユ椂 - auxiliaryOutputWorkingHoursService.remove(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() - .eq(AuxiliaryOutputWorkingHours::getOrderId, orderId)); - // 鏌ヨ宸ユ椂鏆傚瓨 - List<AuxiliaryOutputWorkingHoursTemporary> hoursTemporaries = auxiliaryOutputWorkingHoursTemporaryService.list(Wrappers.<AuxiliaryOutputWorkingHoursTemporary>lambdaQuery() - .eq(AuxiliaryOutputWorkingHoursTemporary::getOrderId, orderId)); - List<AuxiliaryOutputWorkingHours> outputWorkingHours = hoursTemporaries.stream().map(hoursTemporary -> { - AuxiliaryOutputWorkingHours workingHours = new AuxiliaryOutputWorkingHours(); - BeanUtil.copyProperties(hoursTemporary, workingHours); - workingHours.setId(null); - return workingHours; - }).collect(Collectors.toList()); - auxiliaryOutputWorkingHoursService.saveBatch(outputWorkingHours); - - // 鎴愬搧鎶芥牱娣诲姞鍚堟牸鐘舵�� - // 鍒ゆ柇鏄惁鏈夋娊鏍蜂俊鎭� - if (order.getQuarterItemId() != null) { - // 鍒ゆ柇鏄惁鏈変笉鍚堟牸 - Long unqualifiedCount = 0L; - if (CollectionUtils.isNotEmpty(insSamples)) { - unqualifiedCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() - .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) - .eq(InsProduct::getInsResult, 0)); - - // 鍒ゆ柇濡傛灉鏈変笉鍚堟牸鐨勬楠岄」, 鍒ゆ柇鏈夋病鏈夋楠岄」澶嶆祴, 澶嶆牳鍚堟牸涔熺畻鍚堟牸閫氳繃 - if (!unqualifiedCount.equals(0L)) { - List<InsProduct> productList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() - .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) - .eq(InsProduct::getInsResult, 0)); - - boolean flag = true; - for (InsProduct insProduct : productList) { - Long unqualifiedProductCount = insUnqualifiedRetestProductMapper.selectCount(Wrappers.<InsUnqualifiedRetestProduct>lambdaQuery() - .eq(InsUnqualifiedRetestProduct::getInsProductId, insProduct.getId()) - .ne(InsUnqualifiedRetestProduct::getInsResult, 0)); - if (unqualifiedProductCount != 2) { - flag = false; - } - } - if (flag) { - unqualifiedCount = 0L; - } - } - } - spotCheckQuarterItemMapper.update(null, Wrappers.<SpotCheckQuarterItem>lambdaUpdate() - .eq(SpotCheckQuarterItem::getQuarterItemId, order.getQuarterItemId()) - .set(SpotCheckQuarterItem::getResult, unqualifiedCount.equals(0L) ? "鍚堟牸" : "涓嶅悎鏍�")); - - } - - // 鍙戦�佷紒涓氬井淇¢�氱煡 - threadPoolTaskExecutor.execute(() -> { - String message = ""; - message += "妫�楠屼换鍔″鏍搁�氱煡"; - message += "\n鎻愪氦浜�: " + userName; - message += "\n濮旀墭缂栧彿: " + order.getEntrustCode(); - message += "\n鏍峰搧鍚嶇О: " + insSample.getModel(); - message += "\n瑙勬牸鍨嬪彿: " + order.getPartDetail(); - if (ifsInventoryQuantity != null) { - message += "\n鎵规鍙�: " + ifsInventoryQuantity.getUpdateBatchNo(); - } - //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡 鎻愪氦澶嶆牳 - try { - WxCpUtils.inform(sendUserAccount, message, null); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - - // ifs绉诲簱 - if (ifsInventoryQuantity != null) { - // 鐧昏妫�楠岀粨鏋� - // 鍒ゆ柇鏄惁鏈変笉鍚堟牸, 鏈変笉鍚堟牸涓嶈兘绉诲簱 - // todo: ifs绉诲簱 - insReportService.isRawMaterial(order); - } else { - // 淇敼鎴愬搧鐘舵�� - // 鍒ゆ柇鏄惁鏈変笉鍚堟牸 - Long unqualifiedCount = insReportService.getUnqualifiedCount(order); - if (unqualifiedCount.equals(0L)) { - insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() - .eq(InsOrder::getId, order.getId()) - .set(InsOrder::getInsResult, 1)); - } else { - insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate() - .eq(InsOrder::getId, order.getId()) - .set(InsOrder::getInsResult, 0)); - } - } - - return 1; } @@ -4040,7 +4031,7 @@ } /** - * 淇濆瓨鍏冩闃块噷杩涜揣楠岃瘉鍘熷璁板綍 + * *****淇濆瓨鍏冩闃块噷杩涜揣楠岃瘉鍘熷璁板綍***** * @param insOrderId 璁㈠崟Id * @param examineUserId 澶嶆牳浜篒d * @param writeUserId 妫�楠屽憳Id @@ -4190,7 +4181,7 @@ /** - * 鏍煎紡鍖栬繘鍘傞獙璇佸唴瀹� + * ***鏍煎紡鍖栬繘鍘傞獙璇佸唴瀹�**** * @param basicType * @return */ @@ -4219,7 +4210,7 @@ } /** - * word杞崲pdf + * ***word杞崲pdf*** * @param path * @return */ @@ -4266,4 +4257,41 @@ return null; } + /** + * *****淇敼鎴愬搧鎶芥牱鐘舵��****** + * @param insSamples + * @param order + */ + private void addProductSpotCheck(List<InsSample> insSamples, InsOrder order) { + Long unqualifiedCount = 0L; + if (CollectionUtils.isNotEmpty(insSamples)) { + unqualifiedCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() + .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) + .eq(InsProduct::getInsResult, 0)); + + // 鍒ゆ柇濡傛灉鏈変笉鍚堟牸鐨勬楠岄」, 鍒ゆ柇鏈夋病鏈夋楠岄」澶嶆祴, 澶嶆牳鍚堟牸涔熺畻鍚堟牸閫氳繃 + if (!unqualifiedCount.equals(0L)) { + List<InsProduct> productList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() + .in(InsProduct::getInsSampleId, insSamples.stream().map(InsSample::getId).collect(Collectors.toList())) + .eq(InsProduct::getInsResult, 0)); + + boolean flag = true; + for (InsProduct insProduct : productList) { + Long unqualifiedProductCount = insUnqualifiedRetestProductMapper.selectCount(Wrappers.<InsUnqualifiedRetestProduct>lambdaQuery() + .eq(InsUnqualifiedRetestProduct::getInsProductId, insProduct.getId()) + .ne(InsUnqualifiedRetestProduct::getInsResult, 0)); + if (unqualifiedProductCount != 2) { + flag = false; + } + } + if (flag) { + unqualifiedCount = 0L; + } + } + } + spotCheckQuarterItemMapper.update(null, Wrappers.<SpotCheckQuarterItem>lambdaUpdate() + .eq(SpotCheckQuarterItem::getQuarterItemId, order.getQuarterItemId()) + .set(SpotCheckQuarterItem::getResult, unqualifiedCount.equals(0L) ? "鍚堟牸" : "涓嶅悎鏍�")); + } + } -- Gitblit v1.9.3