| | |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | | import com.yuanchu.mom.service.*; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.MatrixToImageWriter; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.utils.RedisUtil; |
| | | import com.yuanchu.mom.utils.*; |
| | | import com.yuanchu.mom.vo.*; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | * 检验任务-业务实现层 |
| | | */ |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class InsOrderPlanServiceImpl extends ServiceImpl<InsOrderMapper, InsOrder> implements InsOrderPlanService { |
| | | |
| | | @Resource |
| | |
| | | AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; |
| | | |
| | | @Resource |
| | | AuxiliaryOutputWorkingHoursService auxiliaryOutputWorkingHoursService; |
| | | QYWXApi qywxApi; |
| | | |
| | | @Resource |
| | | private InformationNotificationService informationNotificationService; |
| | |
| | | insProductResultMapper.deleteById(insProductResultss.get(i)); |
| | | } |
| | | } |
| | | //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"))); |
| | |
| | | result.setUpdateTime(LocalDateTime.now()); |
| | | insProductResultMapper.updateById(result); |
| | | } |
| | | |
| | | /*如果是第一次选择设备信息,且还有其余样品也有同一个经验项目,那么所有样品的该项目都用这个设备信息*/ |
| | | //先查询是否还有其余样品 |
| | | |
| | | /*//先查询是否还有其余样品 |
| | | Integer insSampleId = product.getInsSampleId(); |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSampleMapper.selectById(insSampleId).getInsOrderId())); |
| | | //如果有多个样品或者是不是采集类型就同一个设备 |
| | | //如果有多个样品或者不是采集类型就同一个设备 |
| | | if (insSamples.size() > 1 && !product.getInspectionItemType().equals("1")) { |
| | | //存在其余样品,查询是否有同一种检验项目 |
| | | for (InsSample sample : insSamples.stream().filter(insSample -> !insSample.getId().equals(insSampleId)).collect(Collectors.toList())) { |
| | |
| | | .eq(InsProduct::getStandardMethodListId, product.getStandardMethodListId()) |
| | | .eq(InsProduct::getInsBushId, product.getInsBushId()) |
| | | .eq(InsProduct::getInsFibersId, product.getInsFibersId()) |
| | | .eq(InsProduct::getInsFiberId, product.getInsFiberId()) |
| | | ); |
| | | .eq(InsProduct::getInsFiberId, product.getInsFiberId())); |
| | | if (ObjectUtils.isNotEmpty(product1)) { |
| | | //如果存在项目,查询是否有表 |
| | | InsProductResult productResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery() |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | }*/ |
| | | insProduct.setUpdateUser(userId); |
| | | insProductMapper.updateById(insProduct); |
| | | insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId())); |
| | | |
| | | insProduct = insProductMapper.selectById(insProduct); |
| | | |
| | | /*生成产量工时*/ |
| | | //查询检验单信息 |
| | | InsOrder insOrder = insOrderMapper.selectById(insSampleMapper.selectById(insProduct.getInsSampleId()).getInsOrderId()); |
| | | //校验如果这个人这个检测项目已经添加过了则不需要再新增 |
| | |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | } else { |
| | | } |
| | | else { |
| | | //加班 |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | |
| | | auxiliaryOutputWorkingHours.setCheck(userId);//检测人 |
| | | } |
| | | try { |
| | | if (CollectionUtils.isEmpty(insProductResultss) && !result.getInsValue().equals("[]") || (CollectionUtils.isNotEmpty(insProductResultss) && !insProductResultss.get(0).getInsValue().equals(result.getInsValue()) && !insProductResultss.get(0).getInsValue().equals("[]"))) { |
| | | //这个检验项目还没有填写过检验值且这次这个检验项目填写的检验值不为空 |
| | | if (CollectionUtils.isEmpty(insProductResultss) && jo.get("insValue") != null |
| | | //这个检验项目还没有填写过检验值且这次这个检验项目填写的计算值不为空但是检验值为空 |
| | | || CollectionUtils.isEmpty(insProductResultss) && jo.get("insValue") == null && jo.get("comValue") != null |
| | | //这个检验项目有填写过检验值且这次填写的检验值和原来的检验值不相等,且这次的检验值不等于空 |
| | | || (CollectionUtils.isNotEmpty(insProductResultss) && !insProductResultss.get(0).getInsValue().equals(result.getInsValue()) && jo.get("insValue") != null) |
| | | //这个检验项目有填写过检验值且这次填写的计算值和原来的计算值不相等,且这次的计算值不等于空,且这次的检验值等于空 |
| | | || (CollectionUtils.isNotEmpty(insProductResultss) && !insProductResultss.get(0).getComValue().equals(result.getComValue()) && jo.get("insValue") == null && jo.get("comValue") != null)) { |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | .ne(InsProduct::getInsResult, 2) |
| | | )); |
| | | if (l == l1) { |
| | | //如果所有项目都有结论,那么该样品状态已检 |
| | | insSample.setInsState(2); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | |
| | | .or() |
| | | .eq(InsProduct::getInsResult, 2) |
| | | ) |
| | | //.isNull(InsProduct::getInsResult) |
| | | .eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory()) |
| | | .eq(InsProduct::getState, 1)); |
| | | if (count == 0) { |
| | |
| | | List<TableRenderData> tables1 = new ArrayList<>(); |
| | | tableRenderData.setRows(new ArrayList<>()); |
| | | int totalHeight = 0; |
| | | int pageHeightLimit = 500; // 假设每页的高度限制为500单位 |
| | | int pageHeightLimit = 450; // 假设每页的高度限制为500单位 |
| | | int rowHeight = 0; |
| | | List<RowRenderData> firstTwoRows = new ArrayList<>(); // 保存前两行以便复制到新表格 |
| | | List<RowRenderData> endRows = new ArrayList<>(); // 保存前两行以便复制到新表格 |
| | | List<RowRenderData> endRows = new ArrayList<>(); // 保存最后一行备注以便复制到新表格 |
| | | // 保存前两行以便复制到新表格 |
| | | if (rows.size() >= 3) { |
| | | firstTwoRows.add(rows.get(0)); |
| | |
| | | .set(InsOrderState::getInsTime, LocalDateTime.now()) |
| | | .set(InsOrderState::getInsState, 3) |
| | | .set(InsOrderState::getVerifyUser, verifyUser)); |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | InformationNotification info = new InformationNotification(); |
| | | info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); |
| | | info.setMessageType("2"); |
| | | info.setTheme("复核通知"); |
| | | info.setContent("您有一条检验任务待复核消息"); |
| | | info.setSenderId(userId); |
| | | info.setConsigneeId(verifyUser); |
| | | info.setViewStatus(false); |
| | | info.setJumpPath("b1-inspect-order-plan"); |
| | | informationNotificationService.addInformationNotification(info); |
| | | /*如果是C类订单且是下发到质量部,则直接复核通过(结束试验)*/ |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | if (insOrder.getOrderType().equals("C") && insOrder.getDepartmentLims().equals("质量部")) { |
| | | verifyPlan(orderId, laboratory, 2, null); |
| | | }else { |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | //LIMS系统消息推送 |
| | | InformationNotification info = new InformationNotification(); |
| | | info.setCreateUser(insProductMapper.selectUserById(userId).get("name")); |
| | | info.setMessageType("2"); |
| | | info.setTheme("复核通知"); |
| | | info.setContent("您有一条检验任务待复核消息"); |
| | | info.setSenderId(userId); |
| | | info.setConsigneeId(verifyUser); |
| | | info.setViewStatus(false); |
| | | info.setJumpPath("b1-inspect-order-plan"); |
| | | informationNotificationService.addInformationNotification(info); |
| | | //todo 企业微信消息推送@zss |
| | | /* HashMap<String, Object> map = new HashMap<>(); |
| | | String account = userMapper.selectById(userId).getAccount(); |
| | | map.put("touser", *//*account*//*"ZT-012117");//接收消息成员的账号'ZT-031292'这种类型(如果有多个用'|'分隔) |
| | | map.put("toparty", "");//接收部门id |
| | | map.put("totag", "");//消息标签id |
| | | map.put("msgtype", "text");//消息类型 text:文本 |
| | | map.put("agentid", 1000513);//应用id |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("content", "您有一条检验任务待复核消息,请前往LIMS系统查看。<a href=\"http://10.1.13.77/enter\"> </a>"); |
| | | map.put("text", JSONArray.toJSONString(hashMap));//消息内容 |
| | | map.put("safe", 0);//是否保密消息.0否 |
| | | map.put("enable_id_trans", 0);//是否开启id转译.0否 |
| | | map.put("enable_duplicate_check", 0);//是否开启重复消息检查.0否 |
| | | qywxApi.send(map);*/ |
| | | } |
| | | //复核人--检验单相关负责人 |
| | | InsSampleUser insSampleUser = new InsSampleUser(); |
| | | insSampleUser.setUserId(verifyUser); |
| | |
| | | insSampleUser.setState(1); |
| | | insSampleUser.setSonLaboratory(laboratory); |
| | | insSampleUserMapper.insert(insSampleUser); |
| | | /*如果是C类订单且是下发到质量部,则直接复核通过(结束试验)*/ |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | if (insOrder.getOrderType().equals("C") && insOrder.getDepartmentLims().equals("质量部")) { |
| | | verifyPlan(orderId, laboratory, 2, null); |
| | | } |
| | | /*校验一下result表*/ |
| | | CompletableFuture.supplyAsync(() -> { |
| | | List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList()); |
| | |
| | | String key = "frequency" + ":" + entrustCode + ":*"; |
| | | RedisUtil.delsLike(key); |
| | | return 1; |
| | | } |
| | | |
| | | public int pxToCm(int px) { |
| | | return px / 9; |
| | | } |
| | | |
| | | // 获取两个localDateTime的每一天 |