| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.Task.BatchInfo; |
| | | import com.yuanchu.mom.Task.SyncOrder; |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | |
| | | RawInspectVo rawInspectVo = new RawInspectVo(); |
| | | List<Map<String, Object>> mapList = SyncOrder.ifsInterfaces(); |
| | | for (Map<String, Object> map : mapList) { |
| | | //todo: 后续需要将状态改成待检验 |
| | | // todo: 后续需要将状态改成待检验 |
| | | if (map.get("STATE").equals("已接收")) { |
| | | if (map.get("PART_NO").toString().equals(code)) { |
| | | rawInspectVo.setCode(map.get("PART_NO").toString()); //原材料编码 |
| | |
| | | rawInspectVo.setNumber(Integer.parseInt(String.valueOf(map.get("QTY_TO_INSPECT")))); //数量 |
| | | rawInspectVo.setFormTime(DateUtil.parse(map.get("APPROVED_DATE").toString())); //来料日期 |
| | | rawInspectVo.setSupplier(map.get("SUPPLIER_NAME").toString()); //供应商 |
| | | String orderNo = map.get("ORDER_NO").toString();//订单号 |
| | | String releaseNo = map.get("RELEASE_NO").toString();//下达号 |
| | | String lineNo = map.get("LINE_NO").toString();//行号 |
| | | String lotBatchNo = map.get("LOT_BATCH_NO").toString();//批号 |
| | | String locationNo = map.get("LOCATION_NO").toString();//库位号 |
| | | rawInspectVo.setMessage(orderNo+","+releaseNo+","+lineNo+","+lotBatchNo+","+locationNo); |
| | | } |
| | | } |
| | | } |
| | | //查询该原材料是否有检验项目记录 |
| | | RawInspect rawInspect = rawInspectMapper.selOneByCode(code); |
| | | if (ObjectUtils.isNotEmpty(rawInspect)){ |
| | | if (ObjectUtils.isNotEmpty(rawInspect)) { |
| | | List<RawInsProduct> rawInsProductList = rawInsProductMapper.selectList(Wrappers.<RawInsProduct>query().eq("raw_inspect_id", rawInspect.getId())); |
| | | List<RawInsProductVo> rawInsProductVos = rawInsProductList.stream().map(rawInsProduct -> { |
| | | RawInsProductVo rawInsProductVo = new RawInsProductVo(); |
| | |
| | | //更新检验状态(上报) |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String updateRawInspectsById(Integer id,Integer number) { |
| | | public String updateRawInspectsById(Integer id, Integer number) { |
| | | /*更新检验单里面的检验结论*/ |
| | | //先判断检验结果 |
| | | List<Integer> results = rawInsProductMapper.getresult(id); |
| | |
| | | } else return "项目未检验完!"; |
| | | /*如果检验结论为不合格,则需要新增不合格检验单*/ |
| | | if (rawInspect.getJudgeState() == 0) { |
| | | //查询该检验单哪些检验项目不合格 |
| | | List<RawInsProduct> rawInsProductList = rawInsProductMapper.selectList(Wrappers.<RawInsProduct>query() |
| | | .eq("raw_inspect_id", id) |
| | | .eq("test_state", 0)); |
| | | String msg = null; |
| | | for (RawInsProduct rawInsProduct : rawInsProductList) { |
| | | msg+=rawInsProduct.getName(); |
| | | } |
| | | InspectUnaccepted rawUnaccepted = InspectUnaccepted.builder() |
| | | .reason(rawInspectMapper.selectById(id).getName() + "不合格") //暂且定义为原材料不合格 |
| | | .reason(msg + "不合格") //定义为不合格的项目+不合格 |
| | | .number(number) |
| | | .rawInspectId(id) |
| | | .dealReasult(1) |
| | | .type(0) //类型为原材料 |
| | | .build(); |
| | | inspectUnacceptedMapper.insert(rawUnaccepted); |
| | | } |
| | | /*检验完成后,无论合格与否,将IFS报检状态更改为已接收*/ |
| | | //根据检验单id查询原材料检验单 |
| | | RawInspect rawIns = rawInspectMapper.selectById(id); |
| | | String[] split = rawIns.getMessage().split(","); |
| | | BatchInfo batchInfo = new BatchInfo(); |
| | | batchInfo.setOrderNo(split[0]); |
| | | batchInfo.setReleaseNo(split[1]); |
| | | batchInfo.setLineNo(split[2]); |
| | | batchInfo.setPartNo(rawIns.getCode()); |
| | | batchInfo.setLotBatchNo(split[3]); |
| | | batchInfo.setLocationNo(split[4]); |
| | | if (ObjectUtils.isEmpty(number)) { |
| | | //如果不合格的数量为空null |
| | | number=0; |
| | | } |
| | | batchInfo.setQtyToReceive(rawIns.getNumber()-number); //要接收的数量 |
| | | batchInfo.setQtyToInspect(rawIns.getNumber()); //要检验的数量 |
| | | batchInfo.setReceiveCase("接收到来料区"); |
| | | List<BatchInfo> batchInfos = Arrays.asList(batchInfo); |
| | | //发送IFS请求 |
| | | String s = SyncOrder.importPolReceive(batchInfos); |
| | | System.out.println(s); |
| | | System.out.println("'''''''''''''''''''''''"); |
| | | return rawInspect.getJudgeState().toString(); |
| | | } |
| | | |