From 37c0a1b706f4a16cc3df7e03bbbaec204f897e8e Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期三, 04 十二月 2024 16:50:32 +0800 Subject: [PATCH] 调整检验任务的检验时间 --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 116 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 86 insertions(+), 30 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 e7fd46d..2f368f1 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 @@ -27,6 +27,9 @@ import com.yuanchu.mom.service.*; import com.yuanchu.mom.utils.*; import com.yuanchu.mom.vo.*; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Value; @@ -182,6 +185,12 @@ if (BeanUtil.isEmpty(order.getInsTime())) { insOrder.setInsTime(LocalDateTime.now());//璁㈠崟鐨勬楠屾椂闂� insOrderMapper.updateById(insOrder); + } + InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() + .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()) + .eq(InsOrderState::getInsSampleId, sampleId) + .eq(InsOrderState::getLaboratory, laboratory)); + if (ObjectUtils.isEmpty(orderState.getInsTime())){ //鏇存柊妫�楠屼换鍔¤〃鐨勬楠屾椂闂� insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate() .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()) @@ -295,7 +304,7 @@ sampleId = insOrderFile.getInsSampleId(); insOrderFile.setInsSampleId(null); } - IPage<InsOrderFile> insOrderFileIPage = insOrderFileMapper.getFileList(page, QueryWrappers.queryWrappers(insOrderFile), insOrderId, sonLaboratory,sampleId); + IPage<InsOrderFile> insOrderFileIPage = insOrderFileMapper.getFileList(page, QueryWrappers.queryWrappers(insOrderFile), insOrderId, sonLaboratory, sampleId); map.put("body", insOrderFileIPage); return map; } @@ -330,7 +339,7 @@ if (!realpath.exists()) { realpath.mkdirs(); } - pathName = UUID.randomUUID() + "_"+file.getOriginalFilename().replace("#", "&"); + pathName = UUID.randomUUID() + "_" + file.getOriginalFilename().replace("#", "&"); urlString = realpath + "/" + pathName; file.transferTo(new File(urlString)); insOrderFile.setFileUrl(pathName); @@ -483,11 +492,60 @@ //鑾峰彇鏈�鍚庝竴琛岀殑num锛屽嵆鎬昏鏁般�傛澶勪粠0寮�濮� int maxRow = sheet.getLastRowNum(); for (int row = 0; row <= maxRow; row++) { + XSSFRow xssfRow = sheet.getRow(row); //鑾峰彇鏈�鍚庡崟鍏冩牸num锛屽嵆鎬诲崟鍏冩牸鏁� ***娉ㄦ剰锛氭澶勪粠1寮�濮嬭鏁�*** int maxRol = sheet.getRow(row).getLastCellNum(); StringBuilder aLine = new StringBuilder(); - for (int rol = 0; rol < maxRol; rol++) { + /*for (int rol = 0; rol < maxRol; rol++) { aLine.append(sheet.getRow(row).getCell(rol)).append(","); + }*/ + for (int rol = 0; rol < maxRol; rol++) { + XSSFCell cell = xssfRow.getCell(rol); + if (cell == null) { + aLine.append(","); + } else { + switch (cell.getCellType()) { + case FORMULA: + // 璁$畻鍏紡骞惰幏鍙栫粨鏋� + CellValue cellValue = xssfWorkbook.getCreationHelper().createFormulaEvaluator().evaluate(cell); + switch (cellValue.getCellType()) { + case NUMERIC: + String formattedValue = String.format("%.4f", cellValue.getNumberValue()); + aLine.append(formattedValue); + break; + case STRING: + aLine.append(cellValue.getStringValue()); + break; + case BOOLEAN: + aLine.append(cellValue.getBooleanValue()); + break; + case ERROR: + aLine.append("#ERR!"); + break; + default: + aLine.append(""); + break; + } + break; + case NUMERIC: + String formattedValue = String.format("%.4f", cell.getNumericCellValue()); + aLine.append(formattedValue); + break; + case STRING: + aLine.append(cell.getStringCellValue()); + break; + case BOOLEAN: + aLine.append(cell.getBooleanCellValue()); + break; + case ERROR: + aLine.append("#ERR!"); + break; + default: + aLine.append(""); + break; + } + aLine.append(","); + } } String substring = aLine.substring(0, aLine.length() - 1); result.append(substring).append("\n"); @@ -737,7 +795,7 @@ //缁撹 int ressult = 1; String valueStr = insProductResult2.getValue(); - String regex ="[\u4e00-\u9fa5]"; + String regex = "[\u4e00-\u9fa5]"; if (!insProduct.getAsk().contains(",")) { if (insProduct.getAsk().equals("/") || Pattern.compile(regex).matcher(insProduct.getAsk()).find()) { ressult = 3; //涓嶅垽瀹� @@ -1091,7 +1149,7 @@ info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); info.setMessageType("2"); info.setTheme("澶嶆牳閫氱煡"); - info.setContent("鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅"); + info.setContent("鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample()); info.setSenderId(userId); info.setConsigneeId(submitPlanDto.getVerifyUser()); info.setViewStatus(false); @@ -1106,12 +1164,13 @@ map.put("msgtype", "text");//娑堟伅绫诲瀷 text:鏂囨湰 map.put("agentid", 1000517);//搴旂敤id HashMap<String, Object> hashMap = new HashMap<>(); - hashMap.put("content", "鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",璇峰墠寰�LIMS绯荤粺鏌ョ湅銆�<a href=\"https://ztwxlims.ztt.cn:7443/enter\">涓ぉ閫氫俊LIMS绯荤粺 </a>"); + hashMap.put("content", "鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample() + + ",璇峰墠寰�LIMS绯荤粺鏌ョ湅銆傝鐐瑰嚮<a href=\"https://ztwxlims.ztt.cn:7443/enter\">涓ぉ閫氫俊LIMS绯荤粺 </a>"); map.put("text", hashMap);//娑堟伅鍐呭 map.put("safe", 0);//鏄惁淇濆瘑娑堟伅.0鍚� map.put("enable_id_trans", 0);//鏄惁寮�鍚痠d杞瘧.0鍚� map.put("enable_duplicate_check", 0);//鏄惁寮�鍚噸澶嶆秷鎭鏌�.0鍚� - //qywxApi.send(map); + qywxApi.send(map); //澶嶆牳浜�--妫�楠屽崟鐩稿叧璐熻矗浜� InsSampleUser insSampleUser = new InsSampleUser(); insSampleUser.setUserId(submitPlanDto.getVerifyUser()); @@ -1129,9 +1188,6 @@ throw new ErrorException("鐢佃矾璇曢獙鐨勭珯鐐规姤鍛婄敓鎴愭湁璇�,璇疯仈绯诲紑鍙戜汉鍛樿皟鏁�!"); } } - /*// 鍒犻櫎鏁伴噰閲囬泦娆℃暟 - String key = "frequency" + ":" + submitPlanDto.getEntrustCode() + ":*"; - RedisUtil.delsLike(key);*/ /*鐢熸垚浜ч噺宸ユ椂*/ //鏍¢獙濡傛灉杩欎釜浜鸿繖涓娴嬮」鐩凡缁忔坊鍔犺繃浜嗗垯涓嶉渶瑕佸啀鏂板 @@ -1158,26 +1214,26 @@ } for (AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours : submitPlanDto.getAuxiliaryOutputWorkingHoursList()) { InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours.getInsProductId()); - if (isWithinRange) { - //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮 - auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙� - auxiliaryOutputWorkingHours.setWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//闈炲姞鐝伐鏃� - auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲� - } else { - //鍔犵彮 - auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//鍔犵彮濮旀墭鍗曞彿 - auxiliaryOutputWorkingHours.setOvertimeWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//鍔犵彮宸ユ椂 - auxiliaryOutputWorkingHours.setOvertimeAmount(1);//鍔犵彮鏁伴噺 - } - 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))));//鍛ㄦ - auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); + if (isWithinRange) { + //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮 + auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙� + auxiliaryOutputWorkingHours.setWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//闈炲姞鐝伐鏃� + auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲� + } else { + //鍔犵彮 + auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//鍔犵彮濮旀墭鍗曞彿 + auxiliaryOutputWorkingHours.setOvertimeWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//鍔犵彮宸ユ椂 + auxiliaryOutputWorkingHours.setOvertimeAmount(1);//鍔犵彮鏁伴噺 + } + 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))));//鍛ㄦ + auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); } } } -- Gitblit v1.9.3