| | |
| | | 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.InsOrderDeviceRecordDto; |
| | | import com.ruoyi.inspect.dto.InsPlaceOrderDto; |
| | | import com.ruoyi.inspect.mapper.InsProductResultMapper; |
| | | import com.ruoyi.inspect.mapper.InsSampleMapper; |
| | | import com.ruoyi.inspect.pojo.*; |
| | | 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.*; |
| | | import com.ruoyi.process.pojo.InspectionOrder; |
| | | import com.ruoyi.process.pojo.InspectionOrderBindLog; |
| | | import com.ruoyi.process.pojo.InspectionOrderDetail; |
| | | 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; |
| | |
| | | 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.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class InspectionOrderServiceImpl extends ServiceImpl<InspectionOrderMapper, InspectionOrder> implements InspectionOrderService { |
| | | @Resource |
| | | private InspectionOrderBindLogMapper inspectionOrderBindLogMapper; |
| | | @Resource |
| | | private InspectionOrderDetailService inspectionOrderDetailService; |
| | | @Resource |
| | |
| | | @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 |
| | |
| | | |
| | | /** |
| | | * 检验委托单新增 |
| | | * |
| | | * @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())) { |
| | |
| | | } |
| | | inspectionOrderDetailService.saveBatch(inspectionOrder.getOrderDetailList()); |
| | | } |
| | | /*新增7.8报告结果*/ |
| | | ProcessReport processReport = new ProcessReport(); |
| | | processReport.setInspectionOrderId(inspectionOrder.getInsOrderId()); |
| | | processReport.setInsReportCode(inspectionOrder.getEntrustCode());//报告编号=委托编号 |
| | | //页数 |
| | | try { |
| | | com.aspose.words.Document doc = new com.aspose.words.Document(path); |
| | | processReport.setPages(doc.getPageCount()+""); |
| | | } catch (Exception e) { |
| | | } |
| | | processReport.setNumber("1");//发送份数默认1 |
| | | processReport.setSend(inspectionOrder.getCommissionUnit());//发往何处=委托单位 |
| | | processReport.setMethod(inspectionOrder.getSend()==1?"自取":"其他");//发送方式 |
| | | processReport.setSendTime(insReport.getRatifyTime().toLocalDate());//发送日期 |
| | | processReport.setSendUser(64);//发送人固定 |
| | | processReport.setSignatory(inspectionOrder.getCommissionUser());//签收人=委托人 |
| | | processReportService.save(processReport); |
| | | /*新增7.1委托单对应的设备使用记录*/ |
| | | addDeviceRecord(inspectionOrder,insReport.getWriteUserId()); |
| | | /*新增7.4样品接收*/ |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getInsOrderId, inspectionOrder.getInsOrderId())); |
| | | if (insSamples.size()>0){ |
| | | List<ProcessSample> processSamples = new ArrayList<>(); |
| | | for (InsSample insSample : insSamples) { |
| | | ProcessSample processSample = new ProcessSample(); |
| | | processSample.setReceiveDate(inspectionOrder.getSampleData());//收样日期=领样日期 |
| | | processSample.setSampleCode(insSample.getSampleCode());//样品编号 |
| | | processSample.setSampleName(insSample.getSample());//样品名称 |
| | | processSample.setNum(1);//样品数量=1 |
| | | processSample.setSampleSupplier(inspectionOrder.getCommissionUnit());//来样单位 |
| | | LocalDate plusMonths = inspectionOrder.getSampleData() == null ? null : inspectionOrder.getSampleData().plusMonths(1); |
| | | processSample.setLeaveDate(plusMonths);//留样日期=收样日期往后延一个月 |
| | | processSample.setSampleState(inspectionOrder.getSampleStatus());//样品状态 |
| | | processSample.setDealTime(plusMonths);//退样日期=留样日期 |
| | | processSample.setInspectionOrderId(inspectionOrder.getInspectionOrderId());//委托单id |
| | | processSamples.add(processSample); |
| | | } |
| | | processSampleService.saveBatch(processSamples); |
| | | } |
| | | return true; |
| | | return inspectionOrder; |
| | | } |
| | | |
| | | private synchronized void addDeviceRecord(InspectionOrder inspectionOrder,Integer userId) { |
| | | private synchronized void addDeviceRecord(InspectionOrder inspectionOrder, Integer userId) { |
| | | // 查询设备使用记录查询该订单的使用记录 |
| | | Set<String> recordCodeset = processOrderDeviceMapper.selectDeviceNumber(inspectionOrder.getInspectionOrderId()); |
| | | // 获取订单设备编号 |
| | |
| | | |
| | | /** |
| | | * 检验委托单修改 |
| | | * |
| | | * @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); |
| | | |
| | | // 删除之前的详情 |
| | |
| | | .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()); |
| | | |
| | | //修改7.9报告结果 |
| | | ProcessReport processReport = processReportService.getOne(Wrappers.<ProcessReport>lambdaQuery().eq(ProcessReport::getInspectionOrderId, InspectionOrder.getInspectionOrderId())); |
| | | processReport.setInsReportCode(InspectionOrder.getEntrustCode());//报告编号=委托编号 |
| | | processReportService.updateById(processReport); |
| | | |
| | | 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); |
| | | //删除7.8报告 |
| | | processReportService.remove(Wrappers.<ProcessReport>lambdaQuery() |
| | | .eq(ProcessReport::getInspectionOrderId, inspectionOrderId)); |
| | | //删除对应的设备使用记录 |
| | | processOrderDeviceService.remove(Wrappers.<ProcessOrderDevice>lambdaQuery() |
| | | .eq(ProcessOrderDevice::getInspectionOrderId, inspectionOrderId)); |
| | | //删除对应的7.4的样品申请 |
| | | List<ProcessSample> processSamples = processSampleMapper.selectList(Wrappers.<ProcessSample>lambdaQuery() |
| | | .eq(ProcessSample::getInspectionOrderId, inspectionOrderId)); |
| | | if (processSamples.size()>0){ |
| | | List<Integer> list = processSamples.stream().map(ProcessSample::getId).collect(Collectors.toList()); |
| | | processDealService.remove(Wrappers.<ProcessDeal>lambdaQuery() |
| | | .in(ProcessDeal::getProcessSampleId,list)); |
| | | } |
| | | //删除对应7.4的样品接收 |
| | | processSampleService.remove(Wrappers.<ProcessSample>lambdaQuery() |
| | | .eq(ProcessSample::getInspectionOrderId,inspectionOrderId)); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 检验委托单查看详情 |
| | | * |
| | | * @param inspectionOrderId |
| | | * @return |
| | | */ |
| | |
| | | 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("正式报告文件不存在,无法同步到检验委托单"); |
| | | } |
| | | 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("正式报告文件不存在,无法同步到检验委托单"); |
| | | } |
| | | 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 |
| | |
| | | baseMapper.update(null, Wrappers.<InspectionOrder>lambdaUpdate() |
| | | .eq(InspectionOrder::getInspectionOrderId, inspectionOrderId) |
| | | .set(InspectionOrder::getFileUrl, "/word/" + pathName)); |
| | | |
| | | |
| | | |
| | | } catch (Exception e) { |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |
| | |
| | | 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; |
| | | } |
| | | } |