| | |
| | | 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; |
| | |
| | | @Resource |
| | | FuSheUtils fuSheUtils; |
| | | |
| | | @Resource |
| | | DianLuUtils dianLuUtils; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | 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()) |
| | |
| | | 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; |
| | | } |
| | | |
| | | @Override |
| | | public int uploadFile(Integer orderId, MultipartFile file, String sonLaboratory, Integer sampleId) { |
| | | public Object uploadFile(Integer orderId, MultipartFile file, String sonLaboratory, Integer sampleId) { |
| | | String urlString; |
| | | String pathName; |
| | | String path; |
| | |
| | | insOrderFile.setInsOrderId(orderId); |
| | | if (ObjectUtils.isNotEmpty(sampleId)) { |
| | | insOrderFile.setInsSampleId(sampleId); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(sonLaboratory)) { |
| | | insOrderFile.setSonLaboratory(sonLaboratory); |
| | | } |
| | | insOrderFile.setFileName(filename); |
| | | if (contentType != null && contentType.startsWith("image/")) { |
| | |
| | | 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); |
| | | insOrderFileMapper.insert(insOrderFile); |
| | | //如果是辐射试验(近场/远程上传的csv文件) |
| | | String[] split = filename.split("\\."); |
| | | if (ObjectUtils.isNotEmpty(sonLaboratory) && (sonLaboratory.equals("近场") || sonLaboratory.equals("远场")) && |
| | | split[split.length - 1].equals("csv")) { |
| | | //判断是哪种csv文件,是否有—— |
| | | if (sonLaboratory.equals("近场")) { |
| | | fuSheUtils.getFuSheWord1(sonLaboratory, insOrderFile); |
| | | } else { |
| | | fuSheUtils.getFuSheWord2(sonLaboratory, insOrderFile); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("近场") && split[split.length - 1].equals("csv")) { |
| | | fuSheUtils.getFuSheWord1(sonLaboratory, insOrderFile); |
| | | } else if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("远场") && split[split.length - 1].equals("xlsx")) { |
| | | fuSheUtils.getFuSheWord2(sonLaboratory, insOrderFile); |
| | | }else if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("电路试验") && split[split.length - 1].equals("xlsx") && filename.contains("交调")) { |
| | | dianLuUtils.readDianLuFile1(sampleId,insOrderFile); |
| | | } |
| | | } catch (Exception e) { |
| | | System.err.println("附件上传错误"); |
| | |
| | | |
| | | //扫码报检 |
| | | @Override |
| | | public int scanInsOrderState(String sonLaboratory, String sampleCode, String trees) { |
| | | public int scanInsOrderState(String sonLaboratory, String sampleCode, String trees, String entrustCode) { |
| | | /*样品入库*/ |
| | | warehouseService.inWarehouse(trees, sampleCode); |
| | | warehouseService.inWarehouse(trees, sampleCode, entrustCode); |
| | | /*新增检验任务*/ |
| | | //先判断该样品是否有这个站点的项目 |
| | | InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getSampleCode, sampleCode)); |
| | | List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getEntrustCode, entrustCode)); |
| | | InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getSampleCode, sampleCode) |
| | | .eq(InsSample::getInsOrderId, insOrders.get(0).getId())); |
| | | List<String> collect = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsSampleId, insSample.getId())).stream().map(InsProduct::getSonLaboratory).collect(Collectors.toList()); |
| | |
| | | } else { |
| | | InsOrderState insOrderState = new InsOrderState(); |
| | | insOrderState.setInsOrderId(insSample.getInsOrderId()); |
| | | insOrderState.setInsOrderId(insSample.getId()); |
| | | insOrderState.setInsSampleId(insSample.getId()); |
| | | insOrderState.setLaboratory(sonLaboratory); |
| | | insOrderState.setInsState(0); |
| | | insOrderState.setNum(1);//初始是第一次 |
| | |
| | | |
| | | //扫码出库 |
| | | @Override |
| | | public int outInsOrderState(String sonLaboratory, String sampleCode) { |
| | | public int outInsOrderState(String sonLaboratory, String sampleCode, String entrustCode) { |
| | | //判断该样品的检验任务是否已经结束(继续试验或者是结束试验) |
| | | //先判断该样品是否有这个站点的项目 |
| | | InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getSampleCode, sampleCode)); |
| | | List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getEntrustCode, entrustCode)); |
| | | InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getSampleCode, sampleCode) |
| | | .eq(InsSample::getInsOrderId, insOrders.get(0).getId())); |
| | | List<String> collect = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsSampleId, insSample.getId())).stream().map(InsProduct::getSonLaboratory).collect(Collectors.toList()); |
| | |
| | | } |
| | | } |
| | | boolean a = true; |
| | | warehouseService.outWarehouse(sampleCode, a); |
| | | warehouseService.outWarehouse(sampleCode, a, entrustCode); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | //获取最后一行的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"); |
| | |
| | | throw new ErrorException("频率不能为空"); |
| | | } |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | //查询样品信息 |
| | | InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId()); |
| | | //查询检验单信息 |
| | | InsOrder insOrder = insOrderMapper.selectById(insProductResultDtos.getOrderId()); |
| | | InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() |
| | | .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId()) |
| | | .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()) |
| | | .eq(InsOrderState::getInsSampleId, insProductResultDtos.getSampleId()) |
| | | .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory()) |
| | | .orderByDesc(InsOrderState::getId) |
| | | .last("LIMIT 1"));// 确保只取一条记录 |
| | | //查询样品信息 |
| | | InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId()); |
| | | List<Integer> list = new ArrayList<>(); |
| | | /*新增检验项目检验值记录表(采取先删后增)*/ |
| | | insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery() |
| | |
| | | //结论 |
| | | 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; //不判定 |
| | |
| | | insSampleMapper.updateById(insSample); |
| | | } |
| | | /*判断该站点的检验项目是否全部已检*/ |
| | | int count = insProductMapper.selectInsProductCountByOrderId(insProductResultDtos.getOrderId()); |
| | | int count = insProductMapper.selectInsProductCountByOrderId(insSample.getInsOrderId()); |
| | | if (count == 0) { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId()) |
| | | .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()) |
| | | .eq(InsOrderState::getInsSampleId, insProductResultDtos.getSampleId()) |
| | | .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory()) |
| | | .set(InsOrderState::getInsState, 2)); |
| | |
| | | .set(InsOrderState::getCreateTime, LocalDateTime.now())); |
| | | break; |
| | | case 1: |
| | | //继续试验:该站点任务结束(可以再次扫码检验); |
| | | //继续试验:该样品该站点任务结束(可以再次扫码检验); |
| | | insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()) |
| | | .eq(InsOrderState::getInsSampleId, sampleId) |
| | |
| | | if (insOrder.getFormType().equals("原理样机")) { |
| | | //出库 |
| | | try { |
| | | outInsOrderState(laboratory, insSample.getSampleCode()); |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSample.getInsOrderId())); |
| | | for (InsSample sample : insSamples) { |
| | | outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode()); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getSonLaboratory, submitPlanDto.getLaboratory()) |
| | | .and(wrapper -> wrapper |
| | | .isNull(InsProduct::getInsResult) |
| | | .or() |
| | | .eq(InsProduct::getInsResult, 2) |
| | | ) |
| | | .eq(InsProduct::getState, 1)); |
| | | if (insProducts.size() > 0) { |
| | | String str = ""; |
| | |
| | | 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); |
| | |
| | | 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);//是否开启id转译.0否 |
| | |
| | | throw new ErrorException("电路试验的站点报告生成有误,请联系开发人员调整!"); |
| | | } |
| | | } |
| | | /*// 删除数采采集次数 |
| | | String key = "frequency" + ":" + submitPlanDto.getEntrustCode() + ":*"; |
| | | RedisUtil.delsLike(key);*/ |
| | | |
| | | /*生成产量工时*/ |
| | | //校验如果这个人这个检测项目已经添加过了则不需要再新增 |
| | |
| | | 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);//todo 检测人(后面要去掉由前端传入) |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } |