From 4eab53b44135f6381a7f2011ac17066412297f43 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 11 十月 2024 11:15:35 +0800
Subject: [PATCH] 电路试验的站点报告1.0
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java | 121 ++++++++++++++++++++++++++++++++-------
1 files changed, 98 insertions(+), 23 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
index 58e6d5f..e1d1bc2 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -1,5 +1,6 @@
package com.yuanchu.mom.service.impl;
+import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
@@ -20,6 +21,7 @@
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.*;
import com.yuanchu.mom.pojo.*;
+import com.yuanchu.mom.service.InsOrderPlanService;
import com.yuanchu.mom.service.InsOrderService;
import com.yuanchu.mom.service.InsProductService;
import com.yuanchu.mom.utils.GiveCode;
@@ -29,10 +31,14 @@
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDate;
@@ -48,37 +54,46 @@
* @createDate 2024-03-12 16:17:55
*/
@Service
-@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
-public class InsOrderServiceImpl extends ServiceImpl<InsOrderMapper, InsOrder>
- implements InsOrderService {
+public class InsOrderServiceImpl extends ServiceImpl<InsOrderMapper, InsOrder> implements InsOrderService {
+ @Resource
private GetLook getLook;
-
+ @Resource
private RoleMapper roleMapper;
-
+ @Resource
private InsOrderMapper insOrderMapper;
+ @Value("${file.path}")
+ private String imgUrl;
+
+ @Value("${wordUrl}")
+ private String wordUrl;
+ @Resource
+ private InsOrderFileMapper insOrderFileMapper;
+ @Resource
private InsSampleMapper insSampleMapper;
+ @Resource
private WarehouseHistoryMapper warehouseHistoryMapper;
-
+ @Resource
private InsProductMapper insProductMapper;
+ @Resource
private InsProductService insProductService;
-
+ @Resource
private InsProductUserMapper insProductUserMapper;
-
+ @Resource
private GiveCode giveCode;
-
+ @Resource
private InsSampleUserMapper insSampleUserMapper;
-
+ @Resource
private InsOrderStateMapper insOrderStateMapper;
-
+ @Resource
UserMapper userMapper;
-
+ @Resource
PowerMapper powerMapper;
-
+ @Resource
CustomMapper customMapper;
-
+ @Resource
QYWXApi qywxApi;
@@ -124,7 +139,7 @@
public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId, String sonLaboratory) {
InsOrder insOrder = new InsOrder();
insOrder.setId(orderId);
- insOrder.setAppointed(LocalDate.parse(appointed));
+ //insOrder.setAppointed(LocalDate.parse(appointed));
insOrder.setSendTime(LocalDateTime.now());
insOrderMapper.updateById(insOrder);
//淇敼鎴愬彧缁欏綋鍓嶉�夋嫨鐨勮瘯楠屽涓嬪彂鍗曞瓙
@@ -148,7 +163,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) {
+ public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing, List<MultipartFile> files) {
insOrder.setState(0);
//鍒ゆ柇閫夋嫨鐨勫鎵樺崟浣嶄笌鍒跺崟浜虹殑濮旀墭鍗曚綅鏄惁涓�鑷�
Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
@@ -181,7 +196,7 @@
a.setInsOrderId(insOrder.getId());
//鏍峰搧缂栧彿
if (StrUtil.isEmpty(a.getSampleCode())) {
- a.setSampleCode("YP-" + a.getModel()+"-" + giveCode.split("-")[2] + "-" + count.get());
+ a.setSampleCode("YP-" + a.getModel() + "-" + giveCode.split("-")[2] + "-" + count.get());
}
insSampleMapper.insert(a);
//鏍峰搧鐨勬楠岄」鐩�
@@ -230,6 +245,42 @@
insOrder.setState(1);
upInsOrderOfState(insOrder);
}
+ //濡傛灉鏈変笂浼犵殑闄勪欢
+ if (CollectionUtils.isNotEmpty(files)) {
+ for (MultipartFile file : files ) {
+ String urlString;
+ String pathName;
+ String path;
+ String filename = file.getOriginalFilename();
+ String contentType = file.getContentType();
+ InsOrderFile insOrderFile = new InsOrderFile();
+ insOrderFile.setInsOrderId(insOrder.getId());
+ insOrderFile.setFileName(filename);
+ if (contentType != null && contentType.startsWith("image/")) {
+ // 鏄浘鐗�
+ path = imgUrl;
+ insOrderFile.setType(1);
+ } else {
+ // 鏄枃浠�
+ path = wordUrl;
+ insOrderFile.setType(2);
+ }
+ try {
+ File realpath = new File(path);
+ if (!realpath.exists()) {
+ realpath.mkdirs();
+ }
+ pathName = UUID.randomUUID() + "_" + file.getOriginalFilename();
+ urlString = realpath + "/" + pathName;
+ file.transferTo(new File(urlString));
+ insOrderFile.setFileUrl(pathName);
+ insOrderFileMapper.insert(insOrderFile);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.err.println("闄勪欢涓婁紶閿欒");
+ }
+ }
+ }
return insOrder.getId();
}
@@ -271,9 +322,9 @@
if (insOrder.getState() == 1) {
//瀹℃牳閫氳繃鎵嶄細鐢熸垚濮旀墭缂栧彿
insOrder.setEntrustCode(giveCode.giveCode2("WT-", "ins_order", "-", "yyMMdd"));
- int day = insProductService.selectOrderManDay(insOrder.getId());//棰勮瀹屾垚鏃堕棿
//纭畾璁㈠崟鐨勪笅鍙戞椂闂村拰绾﹀畾鏃堕棿
- insOrder.setAppointed(LocalDate.parse(LocalDateTime.now().plusHours(day).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
+ //int day = insProductService.selectOrderManDay(insOrder.getId());//棰勮瀹屾垚鏃堕棿
+ //insOrder.setAppointed(LocalDate.parse(LocalDateTime.now().plusHours(day).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
insOrder.setSendTime(LocalDateTime.now());
/*todo 鏍规嵁璁㈠崟绫诲瀷鍒ゆ柇鏄惁闇�瑕佹帹閫佷紒涓氬井淇� @zss*/
if (!order.getFormType().equals("鍏朵粬鎴愬搧")) {
@@ -453,11 +504,7 @@
List<Integer> list = Arrays.stream(ids.split(",")).map(Integer::parseInt).collect(Collectors.toList());
List<SampleProductDto3> sampleProductDtos = insSampleMapper.selectSampleProductListByOrderId3(list);
Set<String> processedCodes = new HashSet<>();
- //濡傛灉鏄厜绾ゆ垨鑰呮槸鍏夌氦甯﹂粯璁ゅ彧鎵撳嵃绗竴涓�
List<SampleProductDto3> sampleProductDto3s = sampleProductDtos.stream().filter(sampleProductDto3 -> {
- if (!"鍏夌氦".equals(sampleProductDto3.getIoSampleType()) && !"鍏夌氦甯�".equals(sampleProductDto3.getIoSampleType())) {
- return true;
- }
if (processedCodes.contains(sampleProductDto3.getCode())) {
return false;
} else {
@@ -466,6 +513,26 @@
}
}).collect(Collectors.toList());
return sampleProductDto3s;
+ }
+
+ //鏍¢獙鐢垫満缂栧彿
+ @Override
+ public Map<String, List<InsSample>> checkNumber(String ids) {
+ List<InsSample> samples = new ArrayList<>();
+ List<Integer> list = Arrays.stream(ids.split(",")).map(Integer::parseInt).collect(Collectors.toList());
+ List<InsSample> sampleDtos = insSampleMapper.selectInsSample(list);
+ //鍒ゆ柇鏍峰搧鍨嬪彿鏄惁鏄疊Z
+ for (InsSample sampleDto : sampleDtos) {
+ if (sampleDto.getModel().contains("BZ")) {
+ if (ObjectUtils.isEmpty(sampleDto.getMotorNumber())) {
+ samples.add(sampleDto);
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(samples)) {
+ Map<String, List<InsSample>> collect = samples.stream().collect(Collectors.groupingBy(InsSample::getEntrustCode));
+ return collect;
+ } else return null;
}
@Override
@@ -518,6 +585,14 @@
throw new RuntimeException("瀵煎嚭澶辫触");
}
}
+
+ @Override
+ public int addNumber(List<InsSample> insSamples) {
+ for (InsSample insSample : insSamples) {
+ insSampleMapper.updateById(insSample);
+ }
+ return 0;
+ }
}
--
Gitblit v1.9.3