From 55db6f66c093c07df100cb0e609091030c2a4925 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 24 九月 2026 09:19:20 +0800
Subject: [PATCH] feat(process): 完善检验委托单功能实现绑定和关联管理 - 实现检验委托单与成品下单的绑定功能,包括新增绑定、解除绑定和变更绑定关系 - 添加检验委托单关联状态查询和未绑定委托单筛选功能 - 实现检验委托单绑定日志记录和报告同步功能
---
cnas-process/src/main/java/com/ruoyi/process/service/impl/InspectionOrderServiceImpl.java | 390 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 319 insertions(+), 71 deletions(-)
diff --git a/cnas-process/src/main/java/com/ruoyi/process/service/impl/InspectionOrderServiceImpl.java b/cnas-process/src/main/java/com/ruoyi/process/service/impl/InspectionOrderServiceImpl.java
index 526aa38..dba5579 100644
--- a/cnas-process/src/main/java/com/ruoyi/process/service/impl/InspectionOrderServiceImpl.java
+++ b/cnas-process/src/main/java/com/ruoyi/process/service/impl/InspectionOrderServiceImpl.java
@@ -1,5 +1,8 @@
package com.ruoyi.process.service.impl;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -7,20 +10,34 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
+import com.ruoyi.common.numgen.NumberGenerator;
+import com.ruoyi.common.core.domain.entity.Custom;
+import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.utils.QueryWrappers;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.exception.ErrorException;
+import com.ruoyi.inspect.dto.InsPlaceOrderDto;
+import com.ruoyi.inspect.mapper.InsProductResultMapper;
+import com.ruoyi.inspect.mapper.InsSampleMapper;
import com.ruoyi.inspect.pojo.InsOrder;
+import com.ruoyi.inspect.pojo.InsProductResult;
import com.ruoyi.inspect.pojo.InsReport;
import com.ruoyi.inspect.service.InsOrderService;
import com.ruoyi.inspect.service.InsReportService;
import com.ruoyi.inspect.util.HackLoopTableRenderPolicy;
import com.ruoyi.process.dto.InspectionOrderDto;
import com.ruoyi.process.dto.InspectionOrderExportDto;
+import com.ruoyi.process.mapper.InspectionOrderBindLogMapper;
import com.ruoyi.process.mapper.InspectionOrderMapper;
+import com.ruoyi.process.mapper.ProcessOrderDeviceMapper;
+import com.ruoyi.process.mapper.ProcessSampleMapper;
import com.ruoyi.process.pojo.InspectionOrder;
+import com.ruoyi.process.pojo.InspectionOrderBindLog;
import com.ruoyi.process.pojo.InspectionOrderDetail;
-import com.ruoyi.process.service.InspectionOrderDetailService;
-import com.ruoyi.process.service.InspectionOrderService;
+import com.ruoyi.process.pojo.ProcessOrderDevice;
+import com.ruoyi.process.service.*;
+import com.ruoyi.system.mapper.UserMapper;
+import com.ruoyi.system.mapper.CustomMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -40,7 +57,10 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
/**
* <p>
@@ -54,17 +74,42 @@
@Transactional(rollbackFor = Exception.class)
public class InspectionOrderServiceImpl extends ServiceImpl<InspectionOrderMapper, InspectionOrder> implements InspectionOrderService {
@Resource
+ private InspectionOrderBindLogMapper inspectionOrderBindLogMapper;
+ @Resource
private InspectionOrderDetailService inspectionOrderDetailService;
@Resource
private InsOrderService insOrderService;
@Resource
+ private InsSampleMapper insSampleMapper;
+ @Resource
private InsReportService insReportService;
@Value("${wordUrl}")
private String wordUrl;
+ @Resource
+ private ProcessReportService processReportService;
+ @Resource
+ private ProcessOrderDeviceMapper processOrderDeviceMapper;
+ @Resource
+ private InsProductResultMapper insProductResultMapper;
+ @Resource
+ private ProcessOrderDeviceService processOrderDeviceService;
+ @Resource
+ private UserMapper userMapper;
+ @Resource
+ private CustomMapper customMapper;
+ @Resource
+ private ProcessSampleService processSampleService;
+ @Resource
+ private ProcessSampleMapper processSampleMapper;
+ @Resource
+ private ProcessDealService processDealService;
+ @Resource
+ private NumberGenerator<InspectionOrder> numberGenerator;
/**
* 妫�楠屽鎵樺崟鍒嗛〉鏌ヨ
+ *
* @param page
* @param InspectionOrder
* @return
@@ -76,39 +121,23 @@
/**
* 妫�楠屽鎵樺崟鏂板
+ *
* @param inspectionOrder
* @return
*/
@Override
- public boolean addInspectionOrder(InspectionOrderDto inspectionOrder) {
- if (inspectionOrder.getInsOrderId() == null) {
- throw new ErrorException("缂哄皯璁㈠崟id");
+ public InspectionOrderDto addInspectionOrder(InspectionOrderDto inspectionOrder) {
+ if (inspectionOrder.getInsOrderId() != null) {
+ throw new ErrorException("鏂板妫�楠屽鎵樺崟涓嶅厑璁哥洿鎺ョ粦瀹氭垚鍝佷笅鍗曪紝璇峰湪鎴愬搧涓嬪崟椤甸潰閫夋嫨濮旀墭鍗�");
}
+ normalizeCommissionParty(inspectionOrder);
- // 澶嶅埗鎶ュ憡
- // 鏌ヨ璁㈠崟鎶ュ憡
- InsReport insReport = insReportService.getOne(Wrappers.<InsReport>lambdaQuery()
- .eq(InsReport::getInsOrderId, inspectionOrder.getInsOrderId()));
-
- String path = wordUrl + insReport.getUrl().replaceFirst("/word", "");
-
- String fileName =LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + "濮旀墭鍗曟姤鍛�.docx";
-
- // 婧愭枃浠惰矾寰�
- Path sourcePath = Paths.get(path);
- // 鐩爣鏂囦欢璺緞
- Path targetPath = Paths.get(wordUrl + "/" + fileName);
-
- try {
- // 澶嶅埗鏂囦欢锛屽鏋滅洰鏍囨枃浠跺凡瀛樺湪锛屽垯瑕嗙洊
- Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
- // 娣诲姞鏂囦欢鍦板潃
- inspectionOrder.setFileUrl("/word/" + fileName);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
+ inspectionOrder.setInspectionOrderCode(numberGenerator.generateNumberWithPrefix(4,
+ "WTD" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")),
+ InspectionOrder::getInspectionOrderCode));
+ // 濮旀墭缂栧彿鐢辨垚鍝佷笅鍗曟祦绋嬬敓鎴愶紝濮旀墭鍗曟柊澧為樁娈典笉寰楁墜宸ュ~鍐欍��
+ inspectionOrder.setEntrustCode(null);
+ inspectionOrder.setFileUrl(null);
baseMapper.insert(inspectionOrder);
// 鏂板璇︽儏
if (CollectionUtils.isNotEmpty(inspectionOrder.getOrderDetailList())) {
@@ -117,17 +146,70 @@
}
inspectionOrderDetailService.saveBatch(inspectionOrder.getOrderDetailList());
}
+ return inspectionOrder;
+ }
- return true;
+ private synchronized void addDeviceRecord(InspectionOrder inspectionOrder, Integer userId) {
+ // 鏌ヨ璁惧浣跨敤璁板綍鏌ヨ璇ヨ鍗曠殑浣跨敤璁板綍
+ Set<String> recordCodeset = processOrderDeviceMapper.selectDeviceNumber(inspectionOrder.getInspectionOrderId());
+ // 鑾峰彇璁㈠崟璁惧缂栧彿
+ List<InsProductResult> resultList = insProductResultMapper.selectResultByOrderId(inspectionOrder.getInsOrderId());
+ Set<String> deviceCodeSet = new HashSet<>();
+ for (InsProductResult result : resultList) {
+ // 娣诲姞璁惧缂栧彿
+ List<JSONObject> jsonObjects = JSON.parseArray(result.getEquipValue(), JSONObject.class);
+ for (JSONObject jsonObject : jsonObjects) {
+ if (!"".equals(jsonObject.get("v") + "")) {
+ List<String> v = StrUtil.split(jsonObject.get("v") + "", "锛�");
+ deviceCodeSet.addAll(v);
+ }
+ }
+ }
+ // 1.鍒ゆ柇鏄惁鏈夋病鏈夋坊鍔犵殑浣跨敤璁板綍
+ Set<String> orderDeviceNumbers = getDeviceDifference(deviceCodeSet, recordCodeset);
+ // 娣诲姞浣跨敤璁板綍, 鏍规嵁缂栧彿鏌ヨ璁惧id
+ if (CollectionUtils.isNotEmpty(orderDeviceNumbers)) {
+ List<Integer> orderDeviceIds = processOrderDeviceMapper.selectDeviceIdsByNumbers(orderDeviceNumbers);
+ List<ProcessOrderDevice> collect = orderDeviceIds.stream().map(deviceId -> {
+ ProcessOrderDevice processOrderDevice = new ProcessOrderDevice();
+ processOrderDevice.setInspectionOrderId(inspectionOrder.getInspectionOrderId());
+ processOrderDevice.setDeviceId(deviceId);
+ processOrderDevice.setSampleCode(inspectionOrder.getEntrustCode());
+ processOrderDevice.setUseBefore(1);
+ processOrderDevice.setUseAfter(1);
+ processOrderDevice.setUsePerson(userMapper.selectById(userId).getName());//浣跨敤浜�
+ processOrderDevice.setUsePersonId(userId);//浣跨敤浜篿d
+ return processOrderDevice;
+ }).collect(Collectors.toList());
+ processOrderDeviceService.saveBatch(collect);
+ }
+ }
+
+ private static Set<String> getDeviceDifference(Set<String> number1, Set<String> number2) {
+ return number1.stream().filter(s1 -> number2.stream().noneMatch(s2 -> s1.equals(s2)))
+ .collect(Collectors.toSet());
}
/**
* 妫�楠屽鎵樺崟淇敼
+ *
* @param InspectionOrder
* @return
*/
@Override
public boolean updateInspectionOrder(InspectionOrderDto InspectionOrder) {
+ InspectionOrder oldInspectionOrder = baseMapper.selectById(InspectionOrder.getInspectionOrderId());
+ if (oldInspectionOrder == null) {
+ throw new ErrorException("妫�楠屽鎵樺崟涓嶅瓨鍦�");
+ }
+ normalizeCommissionParty(InspectionOrder);
+ // 缂栧彿銆佸叧鑱斿叧绯汇�佹寮忓鎵樼紪鍙峰拰鎶ュ憡鍦板潃鍙兘鐢变笓鐢ㄦ祦绋嬬淮鎶ゃ��
+ InspectionOrder.setInspectionOrderCode(null);
+ InspectionOrder.setInsOrderId(null);
+ InspectionOrder.setEntrustCode(null);
+ InspectionOrder.setFileUrl(null);
+ InspectionOrder.setSampleTakerUserId(null);
+ InspectionOrder.setSampleTakerUser(null);
baseMapper.updateById(InspectionOrder);
// 鍒犻櫎涔嬪墠鐨勮鎯�
@@ -135,21 +217,32 @@
.eq(InspectionOrderDetail::getInspectionOrderId, InspectionOrder.getInspectionOrderId()));
// 鏂板璇︽儏
- for (InspectionOrderDetail InspectionOrderDetail : InspectionOrder.getOrderDetailList()) {
- InspectionOrderDetail.setInspectionOrderId(InspectionOrder.getInspectionOrderId());
+ if (CollectionUtils.isNotEmpty(InspectionOrder.getOrderDetailList())) {
+ for (InspectionOrderDetail InspectionOrderDetail : InspectionOrder.getOrderDetailList()) {
+ InspectionOrderDetail.setInspectionOrderId(InspectionOrder.getInspectionOrderId());
+ }
+ inspectionOrderDetailService.saveBatch(InspectionOrder.getOrderDetailList());
}
- inspectionOrderDetailService.saveBatch(InspectionOrder.getOrderDetailList());
return true;
}
/**
* 妫�楠屽鎵樺崟鍒犻櫎
+ *
* @param inspectionOrderId
* @return
*/
@Override
public boolean delInspectionOrder(Integer inspectionOrderId) {
+ InspectionOrder inspectionOrder = baseMapper.selectById(inspectionOrderId);
+ if (inspectionOrder == null) {
+ throw new ErrorException("妫�楠屽鎵樺崟涓嶅瓨鍦�");
+ }
+ if (inspectionOrder.getInsOrderId() != null) {
+ throw new ErrorException("宸茬粦瀹氭垚鍝佷笅鍗曠殑妫�楠屽鎵樺崟涓嶅厑璁稿垹闄�");
+ }
+
inspectionOrderDetailService.remove(Wrappers.<InspectionOrderDetail>lambdaQuery()
.eq(InspectionOrderDetail::getInspectionOrderId, inspectionOrderId));
baseMapper.deleteById(inspectionOrderId);
@@ -158,6 +251,7 @@
/**
* 妫�楠屽鎵樺崟鏌ョ湅璇︽儏
+ *
* @param inspectionOrderId
* @return
*/
@@ -173,43 +267,197 @@
return inspectionOrderDto;
}
- /**
- * 鏍规嵁鎴愬搧璁㈠崟id鏌ヨ濮旀墭鍗曡鎯�
- * @param insOrderId
- * @return
- */
@Override
- public InspectionOrderDto getInspectionOrderByInsOderId(Integer insOrderId) {
- InsOrder order = insOrderService.getById(insOrderId);
- InspectionOrderDto inspectionOrderDto = new InspectionOrderDto();
- inspectionOrderDto.setInsOrderId(order.getId());//鎴愬搧璁㈠崟id
- inspectionOrderDto.setEntrustCode(order.getEntrustCode());//濮旀墭缂栧彿
- inspectionOrderDto.setSampleName(order.getSample());//璇曟牱鍚嶇О
- inspectionOrderDto.setProduction(order.getProduction());//鐢熶骇鍗曚綅
- inspectionOrderDto.setCommissionUnit(order.getCompany());//濮旀墭鍗曚綅
- inspectionOrderDto.setCommissionUser(order.getPrepareUser());//濮旀墭浜�
- inspectionOrderDto.setSampleStatus("瀹屽ソ");//鏍峰搧鐘舵��
- inspectionOrderDto.setIsLeave(order.getIsLeave());//鏄惁鐣欐牱
- inspectionOrderDto.setProcessing(order.getProcessing());//鏍峰搧澶勭悊鏂瑰紡
- inspectionOrderDto.setAppointed(order.getAppointed());//绾﹀畾鏃堕棿
- inspectionOrderDto.setSend(order.getSend());//鎶ュ憡鍙戦�佹柟寮�
- inspectionOrderDto.setCommissionPhone(order.getPhone());//鎶ュ憡鍙戦�佹柟寮�
-
- return inspectionOrderDto;
+ public IPage<InspectionOrder> pageUnboundInspectionOrder(Page page, InspectionOrder inspectionOrder) {
+ return baseMapper.pageUnboundInspectionOrder(page, QueryWrappers.queryWrappers(inspectionOrder));
}
-
- /**
- * 濮旀墭鍗曟煡璇㈡垚鍝佽鍗�
- * @return
- */
@Override
- public IPage<InsOrder> getInsOrderOnInspection(Page page, InsOrder insOrder) {
- return baseMapper.getInsOrderOnInspection(page, QueryWrappers.queryWrappers(insOrder));
+ public InspectionOrderDto getInspectionOrderForPlaceOrder(Integer inspectionOrderId) {
+ InspectionOrder inspectionOrder = baseMapper.selectById(inspectionOrderId);
+ if (inspectionOrder == null) {
+ throw new ErrorException("妫�楠屽鎵樺崟涓嶅瓨鍦�");
+ }
+ if (inspectionOrder.getInsOrderId() != null) {
+ throw new ErrorException("璇ユ楠屽鎵樺崟宸茬粦瀹氭垚鍝佷笅鍗曪紝涓嶈兘閲嶅閫夋嫨");
+ }
+ return getInspectionOrderOne(inspectionOrderId);
+ }
+
+ @Override
+ public Integer addInsOrderWithInspectionOrder(InsPlaceOrderDto insPlaceOrderDto) {
+ if (insPlaceOrderDto == null || insPlaceOrderDto.getInspectionOrderId() == null) {
+ throw new ErrorException("璇烽�夋嫨妫�楠屽鎵樺崟");
+ }
+ if (insPlaceOrderDto.getInsOrder() == null) {
+ throw new ErrorException("缂哄皯鎴愬搧涓嬪崟淇℃伅");
+ }
+ InspectionOrder inspectionOrder = baseMapper.selectById(insPlaceOrderDto.getInspectionOrderId());
+ if (inspectionOrder == null) {
+ throw new ErrorException("妫�楠屽鎵樺崟涓嶅瓨鍦�");
+ }
+ if (inspectionOrder.getInsOrderId() != null) {
+ throw new ErrorException("璇ユ楠屽鎵樺崟宸茬粦瀹氭垚鍝佷笅鍗曪紝涓嶈兘閲嶅鎻愪氦");
+ }
+ if (inspectionOrder.getCommissionUnitId() == null) {
+ throw new ErrorException("璇峰厛瀹屽杽濮旀墭鍗曚綅");
+ }
+ if (inspectionOrder.getCommissionUserId() == null) {
+ throw new ErrorException("璇峰厛瀹屽杽濮旀墭浜�");
+ }
+
+ fillInsOrderFromInspectionOrder(inspectionOrder, insPlaceOrderDto.getInsOrder());
+ Integer insOrderId = insOrderService.addInsOrder(insPlaceOrderDto.getSampleList(), insPlaceOrderDto.getInsOrder());
+ Long sampleTakerUserId = SecurityUtils.getUserId();
+ User sampleTaker = sampleTakerUserId == null ? null : userMapper.selectById(sampleTakerUserId);
+ int updated = baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate()
+ .eq(InspectionOrder::getInspectionOrderId, inspectionOrder.getInspectionOrderId())
+ .isNull(InspectionOrder::getInsOrderId)
+ .set(InspectionOrder::getInsOrderId, insOrderId)
+ .set(InspectionOrder::getSampleTakerUserId, sampleTakerUserId == null ? null : sampleTakerUserId.intValue())
+ .set(InspectionOrder::getSampleTakerUser, sampleTaker == null ? null : sampleTaker.getName()));
+ if (updated != 1) {
+ throw new ErrorException("妫�楠屽鎵樺崟宸茶鍏朵粬涓嬪崟缁戝畾锛岃鍒锋柊鍚庨噸璇�");
+ }
+ return insOrderId;
+ }
+
+ private void fillInsOrderFromInspectionOrder(InspectionOrder inspectionOrder, InsOrder insOrder) {
+ insOrder.setEntrustCode(null);
+ insOrder.setSample(inspectionOrder.getSampleName());
+ insOrder.setCompany(inspectionOrder.getCommissionUnit());
+ insOrder.setCompanyId(inspectionOrder.getCommissionUnitId());
+ insOrder.setProduction(inspectionOrder.getProduction());
+ insOrder.setPrepareUser(inspectionOrder.getCommissionUser());
+ insOrder.setPhone(inspectionOrder.getCommissionPhone());
+ insOrder.setSampleStatus(inspectionOrder.getSampleStatus());
+ insOrder.setIsLeave(inspectionOrder.getIsLeave());
+ insOrder.setProcessing(inspectionOrder.getProcessing());
+ insOrder.setAppointed(inspectionOrder.getAppointed());
+ insOrder.setSend(inspectionOrder.getSend());
+ }
+
+ /** 浠呬俊浠诲鎴峰拰浜哄憳涓绘暟鎹紝鍚嶇О涓庣數璇濆潎浠ヤ富鏁版嵁蹇収涓哄噯銆� */
+ private void normalizeCommissionParty(InspectionOrder inspectionOrder) {
+ if (inspectionOrder.getCommissionUnitId() == null) {
+ throw new ErrorException("璇烽�夋嫨濮旀墭鍗曚綅");
+ }
+ Custom custom = customMapper.selectById(inspectionOrder.getCommissionUnitId());
+ if (custom == null) {
+ throw new ErrorException("濮旀墭鍗曚綅涓嶅瓨鍦ㄦ垨宸插仠鐢�");
+ }
+ inspectionOrder.setCommissionUnit(custom.getCompany());
+
+ if (inspectionOrder.getCommissionUserId() == null) {
+ throw new ErrorException("璇烽�夋嫨濮旀墭浜�");
+ }
+ User commissionUser = userMapper.selectById(inspectionOrder.getCommissionUserId());
+ if (commissionUser == null) {
+ throw new ErrorException("濮旀墭浜轰笉瀛樺湪鎴栧凡鍋滅敤");
+ }
+ inspectionOrder.setCommissionUser(commissionUser.getName());
+ inspectionOrder.setCommissionPhone(commissionUser.getPhone());
+ }
+
+ @Override
+ public void syncEntrustCode(Integer insOrderId) {
+ if (insOrderId == null) {
+ return;
+ }
+ InsOrder insOrder = insOrderService.getById(insOrderId);
+ if (insOrder == null || StrUtil.isBlank(insOrder.getEntrustCode())) {
+ return;
+ }
+ baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate()
+ .eq(InspectionOrder::getInsOrderId, insOrderId)
+ .set(InspectionOrder::getEntrustCode, insOrder.getEntrustCode()));
+ }
+
+ @Override
+ public void syncReportFile(Integer insReportId) {
+ if (insReportId == null) {
+ return;
+ }
+ InsReport insReport = insReportService.getById(insReportId);
+ if (insReport == null || !Integer.valueOf(1).equals(insReport.getIsRatify())) {
+ return;
+ }
+ InspectionOrder inspectionOrder = baseMapper.selectOne(Wrappers.<InspectionOrder>lambdaQuery()
+ .eq(InspectionOrder::getInsOrderId, insReport.getInsOrderId())
+ .last("limit 1"));
+ if (inspectionOrder == null) {
+ return;
+ }
+
+ String sourceUrl = StrUtil.isBlank(insReport.getUrlS()) ? insReport.getUrl() : insReport.getUrlS();
+ if (StrUtil.isBlank(sourceUrl)) {
+ throw new ErrorException("姝e紡鎶ュ憡鏂囦欢涓嶅瓨鍦紝鏃犳硶鍚屾鍒版楠屽鎵樺崟");
+ }
+ String sourceFileName = sourceUrl.substring(sourceUrl.lastIndexOf('/') + 1);
+ String extension = sourceFileName.lastIndexOf('.') >= 0
+ ? sourceFileName.substring(sourceFileName.lastIndexOf('.')) : ".docx";
+ String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss"))
+ + "_" + inspectionOrder.getInspectionOrderCode() + "_濮旀墭鍗曟姤鍛�" + extension;
+ Path sourcePath = Paths.get(wordUrl + sourceUrl.replaceFirst("/word", ""));
+ Path targetPath = Paths.get(wordUrl, fileName);
+ try {
+ if (!Files.exists(sourcePath)) {
+ throw new ErrorException("姝e紡鎶ュ憡鏂囦欢涓嶅瓨鍦紝鏃犳硶鍚屾鍒版楠屽鎵樺崟");
+ }
+ Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
+ baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate()
+ .eq(InspectionOrder::getInspectionOrderId, inspectionOrder.getInspectionOrderId())
+ .set(InspectionOrder::getFileUrl, "/word/" + fileName));
+ } catch (ErrorException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ErrorException("鎶ュ憡鍚屾澶辫触");
+ }
+ }
+
+ @Override
+ public boolean changeBinding(Integer insOrderId, Integer inspectionOrderId, String reason) {
+ if (insOrderId == null || inspectionOrderId == null || StrUtil.isBlank(reason)) {
+ throw new ErrorException("缂哄皯鍙樻洿鍏宠仈鎵�闇�鍙傛暟");
+ }
+ InsOrder insOrder = insOrderService.getById(insOrderId);
+ if (insOrder == null) {
+ throw new ErrorException("鎴愬搧涓嬪崟涓嶅瓨鍦�");
+ }
+ if (!(Integer.valueOf(0).equals(insOrder.getState()) || Integer.valueOf(2).equals(insOrder.getState()))
+ || StrUtil.isNotBlank(insOrder.getEntrustCode())) {
+ throw new ErrorException("褰撳墠涓嬪崟宸茶繘鍏ユ楠屾祦绋嬫垨宸茬敓鎴愬鎵樼紪鍙凤紝涓嶅厑璁稿彉鏇村叧鑱�");
+ }
+ InspectionOrder target = baseMapper.selectById(inspectionOrderId);
+ if (target == null || target.getInsOrderId() != null) {
+ throw new ErrorException("鐩爣妫�楠屽鎵樺崟涓嶅瓨鍦ㄦ垨宸茶缁戝畾");
+ }
+ InspectionOrder oldInspectionOrder = baseMapper.selectOne(Wrappers.<InspectionOrder>lambdaQuery()
+ .eq(InspectionOrder::getInsOrderId, insOrderId));
+ baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate()
+ .eq(InspectionOrder::getInsOrderId, insOrderId)
+ .set(InspectionOrder::getInsOrderId, null));
+ int updated = baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate()
+ .eq(InspectionOrder::getInspectionOrderId, inspectionOrderId)
+ .isNull(InspectionOrder::getInsOrderId)
+ .set(InspectionOrder::getInsOrderId, insOrderId));
+ if (updated != 1) {
+ throw new ErrorException("鐩爣妫�楠屽鎵樺崟宸茶鍏朵粬涓嬪崟缁戝畾锛岃鍒锋柊鍚庨噸璇�");
+ }
+ InspectionOrderBindLog bindLog = new InspectionOrderBindLog();
+ bindLog.setInsOrderId(insOrderId);
+ bindLog.setOldInspectionOrderId(oldInspectionOrder == null ? null : oldInspectionOrder.getInspectionOrderId());
+ bindLog.setNewInspectionOrderId(inspectionOrderId);
+ bindLog.setChangeReason(reason.trim());
+ bindLog.setCreateUser(SecurityUtils.getUserId().intValue());
+ bindLog.setCreateTime(LocalDateTime.now());
+ inspectionOrderBindLogMapper.insert(bindLog);
+ return true;
}
/**
* 濮旀墭鍗曟垚鍝佹姤鍛婁笂浼�
+ *
* @param file
* @param inspectionOrderId
* @return
@@ -231,7 +479,6 @@
baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate()
.eq(InspectionOrder::getInspectionOrderId, inspectionOrderId)
.set(InspectionOrder::getFileUrl, "/word/" + pathName));
-
} catch (Exception e) {
@@ -273,6 +520,7 @@
template.write(os);
os.flush();
os.close();
+ inputStream.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("瀵煎嚭澶辫触");
@@ -297,14 +545,14 @@
inspectionOrderExportDto.setAppointedString(inspectionOrder.getAppointed().format(formatter));
}
- inspectionOrderExportDto.setIsLeave1(inspectionOrder.getIsLeave() != null && inspectionOrder.getIsLeave() == 1? "鈽�" : "鈻�");
- inspectionOrderExportDto.setIsLeave2(inspectionOrder.getIsLeave() != null && inspectionOrder.getIsLeave() == 0? "鈽�" : "鈻�");
- inspectionOrderExportDto.setSend0(inspectionOrder.getSend() != null && inspectionOrder.getSend() == 1? "鈽�" : "鈻�");
- inspectionOrderExportDto.setSend1(inspectionOrder.getSend() != null && inspectionOrder.getSend() == 0? "鈽�" : "鈻�");
- inspectionOrderExportDto.setProcessing0(inspectionOrder.getProcessing() != null && inspectionOrder.getProcessing() == 0? "鈽�" : "鈻�");
- inspectionOrderExportDto.setProcessing1(inspectionOrder.getProcessing() != null && inspectionOrder.getProcessing() == 1? "鈽�" : "鈻�");
- inspectionOrderExportDto.setCriterionRule0(inspectionOrder.getCriterionRule() != null && inspectionOrder.getCriterionRule() == 0? "鈽�" : "鈻�");
- inspectionOrderExportDto.setCriterionRule1(inspectionOrder.getCriterionRule() != null && inspectionOrder.getCriterionRule() == 1? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setIsLeave1(inspectionOrder.getIsLeave() != null && inspectionOrder.getIsLeave() == 1 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setIsLeave2(inspectionOrder.getIsLeave() != null && inspectionOrder.getIsLeave() == 0 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setSend0(inspectionOrder.getSend() != null && inspectionOrder.getSend() == 1 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setSend1(inspectionOrder.getSend() != null && inspectionOrder.getSend() == 0 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setProcessing0(inspectionOrder.getProcessing() != null && inspectionOrder.getProcessing() == 0 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setProcessing1(inspectionOrder.getProcessing() != null && inspectionOrder.getProcessing() == 1 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setCriterionRule0(inspectionOrder.getCriterionRule() != null && inspectionOrder.getCriterionRule() == 0 ? "鈽�" : "鈻�");
+ inspectionOrderExportDto.setCriterionRule1(inspectionOrder.getCriterionRule() != null && inspectionOrder.getCriterionRule() == 1 ? "鈽�" : "鈻�");
return inspectionOrderExportDto;
}
}
--
Gitblit v1.9.3