From fbde0b947b4641081b558302ea77d88c902c4cd1 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 30 四月 2025 10:03:24 +0800
Subject: [PATCH] 可靠性计划优化检验项
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 137 ++++++++-------------------------------------
1 files changed, 24 insertions(+), 113 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
index ae86eed..513ba8c 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -10,14 +10,12 @@
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
-import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
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.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.mapper.StandardProductListMapper;
@@ -28,6 +26,7 @@
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.numgen.NumberGenerator;
import com.ruoyi.common.utils.*;
+import com.ruoyi.common.utils.api.IfsApiUtils;
import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.inspect.dto.*;
import com.ruoyi.inspect.mapper.*;
@@ -37,17 +36,15 @@
import com.ruoyi.inspect.service.InsProductService;
import com.ruoyi.inspect.service.InsSampleService;
import com.ruoyi.inspect.vo.InsOrderPrintingVo;
-import com.ruoyi.inspect.vo.SampleDefectsFatherVo;
-import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours;
import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary;
import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService;
-import com.ruoyi.system.mapper.CustomMapper;
import com.ruoyi.system.mapper.UserMapper;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -94,7 +91,6 @@
//鑾峰彇妫�楠屼笅鍗曟暟鎹�
@Override
public IPage<SampleOrderDto> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto) {
- //todo: 鍙湅鎴戝垽鏂叏閮�,涓汉,缁勭粐鐨勬潈闄�
String laboratory = null;
// 鍒ゆ柇鏄惁鏄叏閮�
String isOrderAll = null;
@@ -102,7 +98,12 @@
isOrderAll = "1";
sampleOrderDto.setState(null);
}
- return insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll);
+ SampleOrderDto otherParam = new SampleOrderDto();
+ otherParam.setLaboratory(laboratory);
+ otherParam.setIsOrderAll(isOrderAll);
+ otherParam.setCheckUserId(SecurityUtils.getUserId());
+ IPage<SampleOrderDto> sampleOrderDtoIPage = insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), otherParam);
+ return sampleOrderDtoIPage;
}
@@ -125,7 +126,6 @@
.in(InsProduct::getInsSampleId, ids)
.eq(InsProduct::getState, 1)
.select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory));
-
// 鎵归噺娣诲姞妫�楠屼换鍔$姸鎬佽〃
List<InsOrderState> insOrderStateList = insProducts.stream().map(insProduct -> {
InsOrderState insOrderState = new InsOrderState();
@@ -189,10 +189,18 @@
auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
auxiliaryOutputWorkingHours.setPrice(insProduct.getPrice());//鍗曚环
auxiliaryOutputWorkingHours.setSampleId(insProduct.getInsSampleId());//鏍峰搧id
- auxiliaryOutputWorkingHours.setInsProductId(insProduct.getId());//妫�楠岄」id
+ auxiliaryOutputWorkingHours.setInsProductId(Math.toIntExact(insProduct.getId()));//妫�楠岄」id
return auxiliaryOutputWorkingHours;
}).collect(Collectors.toList());
+
+ // 鍒濇鍒嗛厤妫�楠屼汉锛屽悇涓楠岄」榛樿璁㈠崟鐨勬楠屼汉
+ List<Integer> insProductIds = insProductList.stream().map(insproduct -> {
+ return Math.toIntExact(insproduct.getId());
+ }).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(insProductIds)){
+ insProductMapper.batchUpdateInsProductCheckUserId(insProductIds, userId);
+ }
auxiliaryOutputWorkingHoursTemporaryService.saveBatch(outputWorkingHours);
return 1;
@@ -298,7 +306,7 @@
ip2.addAll(insProducts);
}
for (InsProduct product : ip2) {
- product.setStandardMethodListId(a.getInsulating().getStandardMethodListId());
+ product.setStandardMethodListId(a.getInsulating().getStandardMethodListIds().toString());
}
addInsProductMethod(a.getId(), ip2);
}
@@ -316,7 +324,7 @@
ip2.addAll(insProducts);
}
for (InsProduct product : ip2) {
- product.setStandardMethodListId(a.getAuxiliaryWireCore().getStandardMethodListId());
+ product.setStandardMethodListId(a.getAuxiliaryWireCore().getStandardMethodListId().toString());
}
addInsProductMethod(a.getId(), ip2);
}
@@ -442,6 +450,9 @@
if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) {
throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪");
}
+ if (StringUtils.isBlank(product.getSonLaboratory())) {
+ throw new ErrorException("鏈夋楠岄」鐨勭殑瀛愬疄楠屽涓虹粦瀹�, 璇峰厛缁戝畾瀛愬疄楠屽");
+ }
insProductMapper.insert(product);
}
}
@@ -493,7 +504,7 @@
}
// 鐢熸垚缂栧彿
String no = numberGenerator.generateNumberWithPrefix(3,
- "JCZX/ZB-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
+ "JCZX/SP-" + code + LimsDateUtil.resetDate(LocalDateTime.now()),
InsOrder::getEntrustCode);
// 鍒ゆ柇鏄惁鏄搴︽楠�, 鏄搴︽楠屽彇娑堝師鏉愭枡瀛e害妫�楠屼笅鍗�
if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) {
@@ -557,112 +568,12 @@
return productDto2IPage;
}
- @Override
- public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) {
- String dates = costStatisticsDto.getDates();
- String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
- costStatisticsDto.setDates(null);
-
- //todo:浠呯湅鑷繁
-
- IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> {
- Set<String> uniqueTags = new HashSet<>();
- if (dto.getInspectionItem().contains(",")) {
- for (String s : dto.getInspectionItem().split(",")) {
- uniqueTags.add(s.split("@")[0]);
- }
- } else {
- uniqueTags.add(dto.getInspectionItem().split("@")[0]);
- }
- dto.setInspectionItem(uniqueTags.toString());
- return dto;
- }).collect(Collectors.toList());
- dtoIPage.setRecords(collect);
- return dtoIPage;
- }
-
- @Override
- public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) {
- Map<String, Object> map = new HashMap<>();
- String dates = costStatisticsDto.getDates();
- String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
- costStatisticsDto.setDates(null);
- List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- double totalPrice = costStatisticsDtos.stream()
- .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞�
- .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum())
- .sum();
- map.put("total", totalPrice);
- return map;
- }
-
- @Override
- public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) {
- List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber);
- Map<String, Object> map = new HashMap<>();
- map.put("records", sampleDefectsFatherVos);
- Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber);
- map.put("total", aLong);
- return map;
- }
@Override
public int updateStatus(Integer id) {
return insOrderMapper.updateStatus(id);
}
-
- @Override
- public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException {
- //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹�
- String dates = costStatisticsDto.getDates();
- String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(",");
- costStatisticsDto.setDates(null);
- List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- costStatisticsDtos = costStatisticsDtos.stream().map(dto -> {
- Set<String> uniqueTags = new HashSet<>();
- if (dto.getInspectionItem().contains(",")) {
- for (String s : dto.getInspectionItem().split(",")) {
- uniqueTags.add(s.split("@")[0]);
- }
- } else {
- uniqueTags.add(dto.getInspectionItem().split("@")[0]);
- }
- dto.setInspectionItem(uniqueTags.toString());
- return dto;
- }).collect(Collectors.toList());
-
- response.setContentType("application/vnd.ms-excel");
- response.setCharacterEncoding("UTF-8");
- // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴
- String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8");
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
- Map<String, List<CostStatisticsDto>> groupByCompany =
- costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany()))
- .collect(Collectors.groupingBy(CostStatisticsDto::getCompany));
- try {
- // 鏂板缓ExcelWriter
- // 鏂板缓ExcelWriter
- ExcelWriter excelWriter =
- EasyExcel.write(response.getOutputStream())
- .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
- .build();
- for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) {
- String sheetName = companyDataEntry.getKey();
- List<CostStatisticsDto> dataList = companyDataEntry.getValue();
- WriteSheet mainSheet = EasyExcel.writerSheet(sheetName)
- .head(CostStatisticsDto.class)
- .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
- .build();
- excelWriter.write(dataList, mainSheet);
- }
- // 鍏抽棴娴�
- excelWriter.finish();
- } catch (IOException e) {
- throw new RuntimeException("瀵煎嚭澶辫触");
- }
- }
/**
* 鑾峰彇ifs搴撳瓨淇℃伅
--
Gitblit v1.9.3