From 12ecef99059f411e802c6fbc6f9a641c422b1747 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期六, 03 八月 2024 22:34:20 +0800
Subject: [PATCH] 数采bug修复
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 190 ++++++++++++++++++++++++++++++++---------------
1 files changed, 129 insertions(+), 61 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 1042321..ed89e30 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
@@ -50,6 +50,7 @@
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@@ -79,6 +80,10 @@
private InsOrderStateMapper insOrderStateMapper;
@Resource
private InsProductMapper insProductMapper;
+ @Resource
+ private ShiftTimeMapper shiftTimeMapper;
+ @Resource
+ private PerformanceShiftMapper performanceShiftMapper;
@Value("${wordUrl}")
private String wordUrl;
@@ -100,6 +105,9 @@
@Resource
AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
+
+ @Resource
+ AuxiliaryOutputWorkingHoursService auxiliaryOutputWorkingHoursService;
@Resource
private InformationNotificationService informationNotificationService;
@@ -131,14 +139,27 @@
public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
Map<String, Object> map = new HashMap<>();
map.put("head", PrintChina.printChina(InsOrderPlanVO.class));
- Integer userId = null;
+ Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
+ User user = userMapper.selectById(map1.get("userId"));//褰撳墠鐧诲綍鐨勪汉
+
+ //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
+ String departLimsId = user.getDepartLimsId();
+ String laboratory = null;
+ if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) {
+ String[] split = departLimsId.split(",");
+ //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
+ String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
+ if (departLims.contains("瀹為獙瀹�")) {
+ laboratory = departLims;
+ }
+ }
+ Integer userId =null;
if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId()) ) {
- Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
- userId = map1.get("userId");
+ userId = map1.get("userId");
insOrderPlanDTO.setUserId(userId.longValue());
}
String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
- IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
+ IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory,laboratory);
map.put("body", insOrderPage);
return map;
}
@@ -149,11 +170,24 @@
map.put("head", PrintChina.printChina(InsOrderPlanTaskSwitchVo.class));
Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
Integer userId = map1.get("userId");
+ User user = userMapper.selectById(map1.get("userId"));//褰撳墠鐧诲綍鐨勪汉
+
+ //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
+ String departLimsId = user.getDepartLimsId();
+ String laboratory = null;
+ if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) {
+ String[] split = departLimsId.split(",");
+ //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
+ String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
+ if (departLims.contains("瀹為獙瀹�")) {
+ laboratory = departLims;
+ }
+ }
if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
insOrderPlanDTO.setUserId(userId.longValue());
}
String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
- IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
+ IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory,laboratory);
map.put("body", insOrderPage);
return map;
}
@@ -204,8 +238,6 @@
insProducts = insSampleMapper.getInsProduct3(id);
break;
}
- // 鏁伴噰鏂板
- getDeviceMessage(insProducts, request);
Set<Integer> set = new HashSet<>();
Map<Integer, String> map2 = new HashMap<>();
@@ -214,29 +246,6 @@
return insProducts;
}
- private List<InsProduct> getDeviceMessage(List<InsProduct> insProducts, HttpServletRequest request) {
- String ipAddress = request.getRemoteAddr();
- // 闃叉鍥炵幆鍦板潃鍙樹负IPv6
- String ip = ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress;
- insProducts.forEach(i -> {
- Map<String, Object> devices = baseMapper.getDeviceMessage(ip, i.getInspectionItem(), i.getInspectionItemSubclass());
- if (ObjectUtils.isNotEmpty(devices) && (ObjectUtils.isNotEmpty(devices.get("file_type")) || ObjectUtils.isNotEmpty(devices.get("collect_url")))) {
- InsProductResult insProductResult = i.getInsProductResult();
- List<Object> list = new ArrayList<>();
- Map<Object, Object> hashMap = new HashMap<>();
- hashMap.put("v", devices.get("device_name"));
- list.add(hashMap);
- insProductResult.setEquipName(JSON.toJSON(list).toString());
- List<Object> listValue = new ArrayList<>();
- Map<Object, Object> hashMapValue = new HashMap<>();
- hashMapValue.put("v", devices.get("management_number"));
- listValue.add(hashMapValue);
- insProductResult.setEquipName(JSON.toJSON(list).toString());
- insProductResult.setEquipValue(JSON.toJSON(listValue).toString());
- }
- });
- return insProducts;
- }
@Override
public List<String> checkSubmitPlan(Integer orderId, String laboratory) {
List<String> collect = new ArrayList<>();
@@ -387,7 +396,7 @@
ProductVo productVo = new ProductVo();
productVo.setCode(insFiber.getCode());
productVo.setColor(fiber.getColor());
- productVo.setBushColor(fiber.getBushColor());
+ productVo.setBushColor(insBushing.getColor());
if (ObjectUtils.isNotEmpty(insProductResult)) {
insProduct.setInsProductResult(insProductResult);
}
@@ -420,7 +429,7 @@
for (InsProduct insProduct : insProducts) {
InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId()));
ProductVo productVo = new ProductVo();
- productVo.setCode("/");
+ productVo.setCode("-");
productVo.setColor(fiber.getColor());
productVo.setBushColor(fiber.getBushColor());
insProduct.setInsProductResult(insProductResult);
@@ -485,6 +494,7 @@
result = results.get(0);
}
result.setInsProductId(Integer.parseInt(k));
+ InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, Integer.parseInt(k)));
if (jo.get("insValue") != null) {
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue")));
List<Map<String, Object>> iv = new ArrayList<>();
@@ -494,6 +504,7 @@
map.put("v", JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v"));
map.put("r", JSON.toJSONString(insValue.get("r")));
map.put("c", JSON.toJSONString(insValue.get("c")));
+ map.put("w", insValue.get("w"));
try {
if ((insValue.get("u") == null || insValue.get("u").equals("")) && StrUtil.isNotEmpty(JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v").toString())) {
map.put("u", userId + "");
@@ -571,31 +582,83 @@
//鏌ヨ妫�楠屽崟淇℃伅
InsOrder insOrder = insOrderMapper.selectById(insSampleMapper.selectById(insProduct.getInsSampleId()).getInsOrderId());
//鏍¢獙濡傛灉杩欎釜浜鸿繖涓娴嬮」鐩凡缁忔坊鍔犺繃浜嗗垯涓嶉渶瑕佸啀鏂板
- Long count = auxiliaryOutputWorkingHoursMapper.selectCount(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
- .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
- .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
- .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
- .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()));
- if (count == 0 && ObjectUtils.isNotEmpty(insProduct.getManHour())) {
- //娣诲姞姣忎釜浜虹殑浜ч噺宸ユ椂,瑕佸垽鏂綋鍓嶆椂闂存槸鍚︽槸杩欎釜浜虹殑鎺掔彮鏃堕棿,濡傛灉涓嶆槸鍒欐槸鍔犵彮
- AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
- auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
- auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
- auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//鏍峰搧缂栧彿
- auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙�
- auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//闈炲姞鐝伐鏃�
- auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲�
- auxiliaryOutputWorkingHours.setOutputWorkTime(insProduct.getManHour());//浜ч噺宸ユ椂
- auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡
- LocalDateTime localDateTime = LocalDateTime.now();
- DateTime parse = DateUtil.parse(localDateTime.format(formatter));
- auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡
- auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
- auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
- auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
+ //棣栧厛鍒ゆ柇褰撳墠浜虹殑褰撳墠鏃堕棿鏄惁鏄帓鐝椂闂村唴,濡傛灉涓嶆槸灏辨槸鍔犵彮
+ LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT);
+ PerformanceShift performanceShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery()
+ .eq(PerformanceShift::getUserId, userId)
+ .eq(PerformanceShift::getWorkTime, today));
+ if (ObjectUtils.isNotEmpty(performanceShift)){
+ ShiftTime shiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, performanceShift.getShift()));
+ if (ObjectUtils.isNotEmpty(shiftTime)){
+ DateTimeFormatter forma = DateTimeFormatter.ofPattern("HH:mm");
+ LocalTime now = LocalTime.now();
+ LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma);
+ LocalTime endTime = LocalTime.parse(shiftTime.getEndTime(), forma);
+ // 妫�鏌ュ綋鍓嶆椂闂存槸鍚﹀湪鑼冨洿鍐咃紙鍖呮嫭杈圭晫锛�
+ boolean isWithinRange;
+ if (endTime.isAfter(startTime)) {
+ // 涓嶈法澶╃殑鎯呭喌
+ isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime);
+ } else {
+ // 璺ㄥぉ鐨勬儏鍐�
+ isWithinRange = !now.isBefore(startTime) || !now.isAfter(endTime);
+ }
+ //鍔犵彮
+ AuxiliaryOutputWorkingHours count1 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
+ .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
+ .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
+ .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
+ .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()));
+ //闈炲姞鐝�
+ AuxiliaryOutputWorkingHours count2 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
+ .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
+ .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
+ .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
+ .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()));
+ if (ObjectUtils.isNotEmpty(insProduct.getManHour())&& ObjectUtils.isEmpty(count2) && ObjectUtils.isEmpty(count1)) {
+ AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
+ if (isWithinRange) {
+ //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮
+ auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
+ auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
+ auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//鏍峰搧缂栧彿
+ auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙�
+ auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//闈炲姞鐝伐鏃�
+ auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲�
+ auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime())?auxiliaryOutputWorkingHours.getOvertimeWorkTime():0)+(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime())?auxiliaryOutputWorkingHours.getWorkTime():0));//浜ч噺宸ユ椂
+ auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡
+ LocalDateTime localDateTime = LocalDateTime.now();
+ DateTime parse = DateUtil.parse(localDateTime.format(formatter));
+ auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡
+ auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
+ auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
+ } else {
+ //鍔犵彮
+ auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
+ auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
+ auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//鏍峰搧缂栧彿
+ auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//鍔犵彮濮旀墭鍗曞彿
+ auxiliaryOutputWorkingHours.setOvertimeWorkTime(insProduct.getManHour());//鍔犵彮宸ユ椂
+ auxiliaryOutputWorkingHours.setOvertimeAmount(1);//鍔犵彮鏁伴噺
+ auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime())?auxiliaryOutputWorkingHours.getOvertimeWorkTime():0)+(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime())?auxiliaryOutputWorkingHours.getWorkTime():0));//浜ч噺宸ユ椂
+ auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡
+ LocalDateTime localDateTime = LocalDateTime.now();
+ DateTime parse = DateUtil.parse(localDateTime.format(formatter));
+ auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡
+ auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
+ auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
+ }
+ if (ObjectUtils.isEmpty(insProductResult) && !result.getInsValue().equals("[]") || (ObjectUtils.isNotEmpty(insProductResult) && !insProductResult.getInsValue().equals(result.getInsValue()) && !insProductResult.getInsValue().equals("[]"))) {
+ auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
+ }
+ }
+ }
}
InsSample insSample = insSampleMapper.selectById(insProductMapper.selectById(insProduct.getId()).getInsSampleId());
@@ -1697,7 +1760,7 @@
} catch (Exception e) {
throw new ErrorException("鎵句笉鍒版楠屼汉鐨勭鍚�");
}
- if (signatureUrl.equals("")) {
+ if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) {
throw new ErrorException("鎵句笉鍒版楠屼汉鐨勭鍚�");
}
//Custom custom = customMapper.selectById(user.get("company"));
@@ -3388,6 +3451,11 @@
throw new RuntimeException(e);
}
}
+ else {
+ //澶嶆牳涓嶉�氳繃灏嗘妸澶嶆牳鐨勮礋璐d汉鍘绘帀
+ Integer id = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getId).last("limit 1")).getId();
+ insSampleUserMapper.deleteById(id);
+ }
return 1;
}
@@ -3418,7 +3486,7 @@
}
@Override
- public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode, String sampleCode) {
+ public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) {
List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId));
List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList());
List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
@@ -3508,8 +3576,8 @@
return null;
});
// 鍒犻櫎鏁伴噰閲囬泦娆℃暟
- String key = "frequency" + ":" + entrustCode + ":" + sampleCode;
- RedisUtil.del(key);
+ String key = "frequency" + ":" + entrustCode + ":*";
+ RedisUtil.delsLike(key);
return 1;
}
--
Gitblit v1.9.3