| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private TagService tagService; |
| | | @Autowired |
| | | private BasBoxTypeService basBoxTypeService; |
| | | @Autowired |
| | | private WrkMastLogService wrkMastLogService; |
| | | |
| | | @Resource |
| | | private OpenServiceImpl openServiceImpl; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R pdckqr(PdckqrParam param) { |
| | | WrkMast wrkMast = wrkMastService.selectById(param.getWorkNo()); |
| | | if (wrkMast == null) { |
| | | throw new CoolException("工作档不存在:" + param.getWorkNo()); |
| | | } |
| | | if (wrkMast.getIoType() != 107 || wrkMast.getWrkSts() != 2) { |
| | | throw new CoolException(param.getWorkNo() + "工作档类型:" + wrkMast.getIoType() + "工作状态:" + wrkMast.getWrkSts() + ",不匹配"); |
| | | } |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(param.getWorkNo()); |
| | | List<PdckqrParam.Material> materials = param.getMaterials(); |
| | | |
| | | boolean isFullyCancelled = compareAndCheckCancellation(wrkDetls, materials); |
| | | if (isFullyCancelled) { // 盘点物料确成功,工作档转换 盘点出库->盘点再入库,下发回库命令 |
| | | // 保存工作主档历史档 |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", wrkMast.getIoType() - 50) |
| | | .eq("stn_no", wrkMast.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("入库路径不存在"); |
| | | } |
| | | Date now = new Date(); |
| | | // 堆垛机站点(目标站) |
| | | Integer staNo = staDesc.getCrnStn(); |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(14L); // 工作状态: 14.已出库未确认 |
| | | wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站 |
| | | wrkMast.setStaNo(staNo); // 目标站 |
| | | wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setSourceLocNo(""); // 源库位清空 |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | |
| | | // 推送给gwcs执行命令 |
| | | openServiceImpl.pushStaNoToGwcs(wrkMast.getSourceStaNo(),wrkMast.getStaNo(),wrkMast.getWrkNo()); |
| | | |
| | | return R.ok("盘点确认成功"); |
| | | |
| | | } else { // 物料不一致 |
| | | // todo 不一致的处理处理方法待定 |
| | | |
| | | } |
| | | |
| | | return R.error("盘点确认异常"); |
| | | } |
| | | |
| | | /** |
| | | * 比较两个集合的类的属性,相同则抵消,最后判断两个集合是否完全抵消 |
| | | */ |
| | | public boolean compareAndCheckCancellation(List<WrkDetl> list1, List<PdckqrParam.Material> list2) { |
| | | if (list1.size() != list2.size()) { |
| | | return false; // If lists are not of the same size, cancellation is not possible |
| | | } |
| | | |
| | | List<PdckqrParam.Material> remainingList2 = new ArrayList<>(list2); |
| | | |
| | | // Compare and cancel out elements |
| | | for (WrkDetl p1 : list1) { |
| | | boolean cancelled = false; |
| | | for (PdckqrParam.Material p2 : remainingList2) { |
| | | if (p1.getBatch().equals(p2.getBoxNo()) && p1.getModel().equals(p2.getRollNo())) { // 卷号和箱号相同 |
| | | remainingList2.remove(p2); |
| | | cancelled = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!cancelled) { |
| | | return false; // If any element in list1 cannot be cancelled, return false |
| | | } |
| | | } |
| | | |
| | | return remainingList2.isEmpty(); // Return true if all elements in list1 were cancelled out |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<Map<String, Object>> boxTypeComb() { |
| | | EntityWrapper<BasBoxType> wrapper = new EntityWrapper<>(); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |