From d2264d73349d8f0cea3d6bde472548dde227c168 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期一, 07 四月 2025 09:15:38 +0800
Subject: [PATCH] 查询货架条件加上状态
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 245 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 202 insertions(+), 43 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
index bac2940..cecfcbe 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -24,6 +24,7 @@
import com.yuanchu.mom.service.*;
import com.yuanchu.mom.utils.*;
import com.yuanchu.mom.vo.*;
+import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -35,6 +36,7 @@
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
+import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.nio.file.Files;
@@ -48,6 +50,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+
+import org.apache.poi.hwpf.HWPFDocument;
/**
* 妫�楠屼换鍔�-涓氬姟瀹炵幇灞�
@@ -357,6 +361,14 @@
} else if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("鐢佃矾璇曢獙") && split[split.length - 1].equals("csv") && insOrder.getSampleType().equals("鏃犳簮鍣ㄤ欢")) {
dianLuUtils.readDianLuFile3(sampleId, insOrderFile);
}
+ // 鐢佃矾瀹為獙杩斿洖鏂囦欢鍚�
+ if(ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("鐢佃矾璇曢獙")){
+ return pathName;
+ }
+ // 闇囧姩doc鏂囦欢瑙f瀽
+ if(filename.toLowerCase().contains(".doc") && sonLaboratory.equals("鎸姩")){
+ return docAnalysis(urlString,orderId,sampleId,file.getOriginalFilename());
+ }
} catch (Exception e) {
throw new ErrorException(e.getMessage());
}
@@ -413,6 +425,7 @@
if (orderState.getInsState() == 6) {
orderState.setInsState(0);
orderState.setNum(orderState.getNum() + 1);//閫掑
+ orderState.setCreateTime(LocalDateTime.now());
insOrderStateMapper.updateById(orderState);
}
} else {
@@ -424,10 +437,17 @@
insOrderState.setNum(1);//鍒濆鏄涓�娆�
insOrderStateMapper.insert(insOrderState);
}
+ //鍚屼竴鏍峰搧鍦ㄥ叾浠栫珯鐐瑰叆搴撲箣鍚庨渶瑕佸皢鍏朵粬绔欑偣鐨勪换鍔′笉鏄剧ず
+ insOrderStateMapper.update(null,Wrappers.<InsOrderState>lambdaUpdate()
+ .eq(InsOrderState::getInsOrderId,insSample.getInsOrderId())
+ .eq(InsOrderState::getInsSampleId,insSample.getId())
+ .eq(InsOrderState::getInsState,6)//澶嶆牳缁х画璇曢獙
+ .ne(InsOrderState::getLaboratory,sonLaboratory)
+ .set(InsOrderState::getIsOut,1));//涓嶆樉绀�
return 1;
}
- //鎵爜鍑哄簱
+ //鎵爜鍑哄簱(鍙湁澶嶆牳缁撴潫鎵嶄細璋冪敤)
@Override
public int outInsOrderState(String sonLaboratory, String sampleCode, String entrustCode) {
//鍒ゆ柇璇ユ牱鍝佺殑妫�楠屼换鍔℃槸鍚﹀凡缁忕粨鏉�(缁х画璇曢獙鎴栬�呮槸缁撴潫璇曢獙)
@@ -442,22 +462,16 @@
if (!collect.contains(sonLaboratory)) {
throw new ErrorException("璇ユ牱鍝佹病鏈�" + sonLaboratory + "绔欑偣鐨勭浉鍏抽」鐩�,璇锋煡鐪嬩笅鍗曡鎯�!");
}
+ //鍒ゆ柇璇ヤ换鍔℃槸鍚︽槸缁撴潫璇曢獙
//鍒ゆ柇璇ヨ鍗曟槸鍚︾珯鐐逛换鍔℃湁(缁х画璇曢獙鎴栬�呮槸缁撴潫璇曢獙)
- List<InsOrderState> orderStates = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery()
- .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
- .eq(InsOrderState::getInsState, 5));//缁撴潫璇曢獙
- if (CollectionUtils.isEmpty(orderStates)) {
- List<InsOrderState> orderStates1 = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery()
- .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
- .eq(InsOrderState::getInsSampleId, insSample.getId())
- .eq(InsOrderState::getLaboratory, sonLaboratory)
- .eq(InsOrderState::getInsState, 6));//缁х画璇曢獙
- if (CollectionUtils.isEmpty(orderStates1)) {
- throw new ErrorException("璇ユ牱鍝佺殑妫�楠屼换鍔¤繕娌℃湁缁撴潫璇曢獙鎴栫户缁瘯楠�,鏆傛椂鏃犳硶鍑哄簱!");
- }
+ InsOrderState orderStates = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
+ .eq(InsOrderState::getLaboratory,sonLaboratory)
+ .eq(InsOrderState::getInsSampleId, insSample.getId())
+ .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()));
+ if (orderStates.getInsState()!=5) {
+ throw new ErrorException("褰撳墠鏍峰搧鐨勭珯鐐逛换鍔″苟涓嶆槸澶嶆牳鐨勭粨鏉熻瘯楠�,鏃犻渶鎵嬪姩鍑哄簱!");
}
- boolean a = true;
- warehouseService.outWarehouse(sampleCode, a, entrustCode);
+ warehouseService.outWarehouse(sampleCode, true, entrustCode);
return 0;
}
@@ -651,6 +665,16 @@
}
} catch (Exception e) {
result.setAfterCheck("");//''
+ }
+ //瀹為獙缁撴灉
+ try {
+ JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("testResult")));
+ if (resValue.get("v") != null) {
+ Object o = JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v");
+ result.setTestResult(o.equals("") ? null : (o.toString()));
+ }
+ } catch (Exception e) {
+ result.setTestResult("");//''
}
//璁惧缂栧彿
if (jo.get("equipValue") != null) {
@@ -894,6 +918,122 @@
return 1;
}
+ /**
+ * 闇囧姩doc鏂囦欢瑙f瀽
+ * @param urlString
+ * @param orderId
+ * @param sampleId
+ * @param originFileName
+ * @return
+ */
+ private Map<String, String> docAnalysis(String urlString,Integer orderId,Integer sampleId,String originFileName) {
+ Map<String, String> analysisMap = new HashMap<>();
+ try {
+ File file = new File(urlString);
+ HWPFDocument document = new HWPFDocument(new FileInputStream(file));
+ Range range = document.getRange();
+ TableIterator tableIterator = new TableIterator(range);
+ List<Table> tableList = new ArrayList<>();
+ while (tableIterator.hasNext()) {
+ tableList.add(tableIterator.next());
+ }
+ for (int tableIndex = 0; tableIndex < tableList.size(); tableIndex++) {
+ // 鍙栫涓�涓〃鍗曢檺鍒跺弬鏁扮殑 鎸姩鍙板瀷鍙枫�佽繍鍔ㄩ儴浠剁瓑鏁堣川閲忋�佽瘯浠惰川閲忔暟鍊�
+ if(tableIndex == 0){
+ Table table = tableList.get(0);
+ for (int i = 0; i < table.numRows(); i++) {
+ if(table.getRow(i).numCells() < 2){
+ continue;
+ }
+ String columnText = ObjectUtils.isEmpty(table.getRow(i).getCell(0))? "" : table.getRow(i).getCell(0).text();
+ String columnValue = ObjectUtils.isEmpty(table.getRow(i).getCell(1))? "" : table.getRow(i).getCell(1).text();
+ if(columnValue.contains("\u0007")){
+ columnValue = columnValue.replace("\u0007","");
+ }
+ if(columnText.contains("\u0007")){
+ columnText = columnText.replace("\u0007","");
+ }
+ if(columnText.equals("鎸姩鍙板瀷鍙�")){
+ analysisMap.put("11",columnValue);
+ }
+ if(columnText.equals("杩愬姩閮ㄤ欢绛夋晥璐ㄩ噺")){
+ analysisMap.put("12",columnValue);
+ }
+ if(columnText.equals("璇曚欢璐ㄩ噺")){
+ analysisMap.put("1",columnValue);
+ }
+ }
+ }
+ //鍙栫涓�涓〃鍗曡緭鍏ラ�氶亾鍙傛暟绗竴鏉℃暟鎹�
+ if(tableIndex == 1){
+ Table table = tableList.get(1);
+ if(ObjectUtils.isNotEmpty(table) && table.numRows() > 1 && table.getRow(1).numCells() >= 3){
+ String columnValue = ObjectUtils.isEmpty(table.getRow(1).getCell(2))? "" : table.getRow(1).getCell(2).text();
+ if(columnValue.contains("\u0007")){
+ columnValue = columnValue.replace("\u0007","");
+ }
+ analysisMap.put("9",columnValue);
+ }
+ }
+ // 鍙栨渶鍚庝竴涓〃鍗曠涓夌鍥涜淇℃伅
+ if(tableIndex == tableList.size() - 1){
+ Table table = tableList.get(tableIndex);
+ for (int i = 0; i < table.numRows(); i++) {
+ if(table.getRow(i).numCells() < 2){
+ continue;
+ }
+ String columnText = ObjectUtils.isEmpty(table.getRow(i).getCell(0))? "" : table.getRow(i).getCell(0).text();
+ String columnValue = ObjectUtils.isEmpty(table.getRow(i).getCell(1))? "" : table.getRow(i).getCell(1).text();
+ if(columnValue.contains("\u0007")){
+ columnValue = columnValue.replace("\u0007","");
+ }
+ if(columnText.contains("\u0007")){
+ columnText = columnText.replace("\u0007","");
+ }
+ if(columnText.contains("鎬昏繍琛屾椂闂�")){
+ analysisMap.put("13",columnValue);
+ }
+ if(columnText.contains("璇曢獙鎵鏁�")){
+ analysisMap.put("10",columnValue);
+ }
+ }
+ }
+ }
+ // 鍥剧墖缁戝畾
+ List<Picture> pictureList = document.getPicturesTable().getAllPictures();
+ String[] split = originFileName.split("\\.");
+ String docName = "";
+ if(null != split && split.length > 0){
+ docName = split[0];
+ }
+ for (Picture picture : pictureList) {
+ byte[] pictureData = picture.getContent();
+ File imgDir = new File(imgUrl);
+ if (!imgDir.exists()) {
+ imgDir.mkdirs();
+ }
+ String filename = docName + "_" + UUID.randomUUID()+".png";
+ File pictureFile = new File(imgUrl + File.separatorChar + filename);
+ // 鍒涘缓杈撳嚭娴佷互灏嗗浘鐗囨暟鎹啓鍏ュ埌鎸囧畾璺緞
+ try (OutputStream outputStream = new FileOutputStream(pictureFile)) {
+ // 鍐欏叆鏁版嵁
+ outputStream.write(pictureData);
+ }
+ InsOrderFile insOrderFile = new InsOrderFile();
+ insOrderFile.setInsOrderId(orderId);
+ insOrderFile.setInsSampleId(sampleId);
+ insOrderFile.setSonLaboratory("鎸姩");
+ insOrderFile.setType(1);
+ insOrderFile.setFileName(filename);
+ insOrderFile.setFileUrl(filename);
+ insOrderFileMapper.insert(insOrderFile);
+ }
+ }catch (Exception e){
+ log.error(e.getMessage());
+ }
+ return analysisMap;
+ }
+
//娓╂箍搴﹁瘯楠�+鍔熺巼璇曢獙鐨勪繚瀛樻楠屽唴瀹�
@Override
public int saveInsContext3(InsProductResult insProductResult) {
@@ -920,19 +1060,19 @@
}
}
// 澶勭悊鍏朵粬姣旇緝鏉′欢
- if (ask.startsWith(">")) {
+ if (ask.startsWith(">") || ask.startsWith("锛�")) {
double threshold = Double.parseDouble(ask.substring(1));
return s > threshold;
} else if (ask.startsWith("鈮�")) {
double threshold = Double.parseDouble(ask.substring(1));
return s >= threshold;
- } else if (ask.startsWith("<")) {
+ } else if (ask.startsWith("<")|| ask.startsWith("锛�")) {
double threshold = Double.parseDouble(ask.substring(1));
return s < threshold;
} else if (ask.startsWith("鈮�")) {
double threshold = Double.parseDouble(ask.substring(1));
return s <= threshold;
- } else if (ask.equals("=")) {
+ } else if (ask.equals("=")|| ask.startsWith("锛�")) {
double exactValue = Double.parseDouble(ask.substring(1));
return s == exactValue;
}
@@ -979,7 +1119,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell) throws IOException {
+ public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell) {
LocalDateTime now = LocalDateTime.now();
Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
List<InsUnPass> insUnPasses = new ArrayList<>();
@@ -1050,6 +1190,15 @@
.set(InsOrderState::getInsState, 6)
.set(InsOrderState::getVerifyTell, tell)
.set(InsOrderState::getVerifyUser, userId));
+ //缁х画璇曢獙鑷姩鍑哄簱
+ WarehouseHistory history = new WarehouseHistory();
+ history.setState(2);
+ history.setInsSampleId(sampleId);
+ history.setCellId(insSample.getCellId());
+ history.setWarehouseCode(warehouseHistoryMapper.selectOne(Wrappers.<WarehouseHistory>lambdaQuery()
+ .eq(WarehouseHistory::getInsSampleId, sampleId).select(WarehouseHistory::getWarehouseCode).orderByDesc(WarehouseHistory::getId).last("limit 1")).getWarehouseCode());
+ insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate().eq(InsSample::getId, sampleId).set(InsSample::getCellId, null));
+ warehouseHistoryMapper.insert(history);
break;
case 2:
//缁撴潫璇曢獙:姝ゅ鎵樺崟鍋滄璇曢獙(鏃犳硶鍐嶆妫�楠�)銆�
@@ -1060,13 +1209,9 @@
.set(InsOrderState::getInsState, 5)
.set(InsOrderState::getVerifyTell, tell)
.set(InsOrderState::getVerifyUser, userId));
- //濡傛灉璁㈠崟绫诲瀷鏄師鐞嗘牱鏈�,鍒欒璁㈠崟鐩存帴闂幆
- List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSample.getInsOrderId()));
- for (InsSample sample : insSamples) {
- outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
- }
- insOrder.setState(4);
- insOrderMapper.updateById(insOrder);
+ /*鐢熸垚瀵瑰簲鐨勬楠屾姤鍛�*/
+ List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId());
+ createReport(insOrder.getId(),insReportDto1s);
break;
}
}
@@ -1075,7 +1220,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) throws IOException {
+ public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) {
Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
InsSample insSample = insSampleMapper.selectById(sampleId);
InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
@@ -1088,11 +1233,6 @@
.orderByDesc(InsOrderState::getId)
.last("LIMIT 1")); // 纭繚鍙彇涓�鏉¤褰�
if (record != null) {
- //鏇存柊璁板綍
- insOrderUserMapper.update(null, Wrappers.<InsOrderUser>lambdaUpdate()
- .eq(InsOrderUser::getInsOrderStateId, record.getId())
- .eq(InsOrderUser::getNum, record.getNum())
- .set(InsOrderUser::getTell, tell));
switch (type) {
case 0:
//鍐嶆璇曢獙:璇ュ崟瀛愰��鍥炲埌妫�楠岀姸鎬�(鎺掑簭鏀规垚褰撳墠鐨勬渶鍚�),娆℃暟閫掑(淇濈暀浠ュ墠鐨勬暟鎹�)锛�
@@ -1104,7 +1244,6 @@
.set(InsOrderState::getVerifyUser, userId)
.set(InsOrderState::getNum, record.getNum() + 1)//娆℃暟鍔�1
.set(InsOrderState::getCreateTime, LocalDateTime.now()));
- insOrder.setState(3);
break;
case 1:
//缁х画璇曢獙:璇ユ牱鍝佽绔欑偣浠诲姟缁撴潫(鍙互鍐嶆鎵爜妫�楠�)锛�
@@ -1127,7 +1266,16 @@
.set(InsOrderState::getVerifyTell, tell)
.set(InsOrderState::getVerifyUser, userId));
}
- insOrder.setState(3);
+ //缁х画璇曢獙闇�瑕佸嚭搴�
+ WarehouseHistory history = new WarehouseHistory();
+ history.setState(2);
+ history.setInsSampleId(sampleId);
+ history.setCellId(insSample.getCellId());
+ history.setWarehouseCode(warehouseHistoryMapper.selectOne(Wrappers.<WarehouseHistory>lambdaQuery()
+ .eq(WarehouseHistory::getInsSampleId, sampleId).select(WarehouseHistory::getWarehouseCode).orderByDesc(WarehouseHistory::getId).last("limit 1")).getWarehouseCode());
+ insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate()
+ .eq(InsSample::getId, sampleId).set(InsSample::getCellId, null));
+ warehouseHistoryMapper.insert(history);
break;
case 2:
//缁撴潫璇曢獙:姝ゅ鎵樺崟鍋滄璇曢獙(鏃犳硶鍐嶆妫�楠�)銆�
@@ -1150,17 +1298,28 @@
.set(InsOrderState::getVerifyTell, tell)
.set(InsOrderState::getVerifyUser, userId));
}
- //鍑哄簱
- List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSample.getInsOrderId()));
- for (InsSample sample : insSamples) {
- outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
- }
- insOrder.setState(4);
+ /*鐢熸垚瀵瑰簲鐨勬楠屾姤鍛�*/
+ List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId());
+ createReport(insOrder.getId(),insReportDto1s);
break;
}
- insOrderMapper.updateById(insOrder);
}
return 1;
+ }
+
+
+ /*鐢熸垚瀵瑰簲鐨勬楠屾姤鍛�*/
+ private void createReport(Integer orderId,List<InsReportDto1> insReportDto1s){
+ for (InsReportDto1 insReportDto1 : insReportDto1s) {
+ if (ObjectUtils.isNotEmpty(insReportDto1.getInsReportDto2s())){
+ wordUtils.generateReport(orderId, insReportDto1);
+// try{
+// wordUtils.generateReport(orderId, insReportDto1);
+// }catch (Exception e){
+// throw new ErrorException("鎶ュ憡鏍煎紡鐢熸垚鏈夎,璇疯仈绯荤鐞嗗憳!");
+// }
+ }
+ }
}
private void getTemplateThing
@@ -1221,8 +1380,8 @@
String str = "";
int count = 0;
for (InsProduct product : insProducts) {
- //杈愬皠璇曢獙,娓╂箍搴﹁瘯楠�,鍔熺巼璇曢獙鐨勬楠岄」鐩�,涓嶉渶瑕佸幓鎵嬪姩濉啓妫�楠屽��,鍙渶瑕佷笂浼犺〃鏍兼枃浠跺氨鍙互浜�,鍚庡彴鎻愪氦鐨勬椂鍊欐牎楠岃烦杩囪繖涓楠岄」鐩�
- if (product.getInspectionItem().equals("杈愬皠璇曢獙") || product.getInspectionItem().equals("娓╂箍搴﹁瘯楠�") || product.getInspectionItem().equals("鍔熺巼璇曢獙")) {
+ //娓╂箍搴﹁瘯楠�,鍔熺巼璇曢獙鐨勬楠岄」鐩�,涓嶉渶瑕佸幓鎵嬪姩濉啓妫�楠屽��,鍙渶瑕佷笂浼犺〃鏍兼枃浠跺氨鍙互浜�,鍚庡彴鎻愪氦鐨勬椂鍊欐牎楠岃烦杩囪繖涓楠岄」鐩�
+ if ( product.getInspectionItem().equals("娓╂箍搴﹁瘯楠�") || product.getInspectionItem().equals("鍔熺巼璇曢獙")) {
product.setInsResult(3);//涓嶅垽瀹�
insProductMapper.updateById(product);
continue;
--
Gitblit v1.9.3