| | |
| | | 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.CombParam; |
| | |
| | | import com.zy.asrs.entity.param.OffSaleParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.common.constant.MesConstant; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 移动端服务核心类 |
| | |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WrkMastMapper wrkMastMapper; |
| | | |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void manualCallEmptyTray(int stnNo, Long userId) { |
| | | public R manualCallEmptyTray(int stnNo, Long userId) { |
| | | // 人工pda呼叫空托盘 |
| | | // 0.判断是否已存在该目标站点的空托盘出库任务,有则直接返回(状态不为15,或者为15但是任务号还在输送线上) |
| | | List<WrkMast> wrkMasts = wrkMastMapper.queryEmptyOutLocWork(stnNo); |
| | | if (!wrkMasts.isEmpty()) { |
| | | throw new CoolException("已存在该站点空托盘出库任务:" + stnNo); |
| | | } |
| | | |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type); |
| | | // 获取库位 |
| | | // LocMast locMast = locMastService.selectById(locNo); |
| | | // if (Cools.isEmpty(locMast)) { |
| | | // throw new CoolException(locNo + "库位不存在"); |
| | | // } |
| | | // if (!locMast.getLocSts().equals("D")) { |
| | | // throw new CoolException("所选库位存在状态不为D的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | // } |
| | | // // 获取源站 |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", 110) |
| | | // .eq("stn_no", param.getOutSite()) |
| | | // .eq("crn_no", locMast.getCrnNo()); |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (staDesc == null) { |
| | | // throw new CoolException("路径不存在"); |
| | | // } |
| | | // Integer sourceStaNo = staDesc.getCrnStn(); |
| | | // if (Cools.isEmpty(sourceStaNo)) { |
| | | // throw new CoolException("检索源站失败"); |
| | | // } |
| | | // Date now = new Date(); |
| | | // 保存工作档 |
| | | // WrkMast wrkMast = new WrkMast(); |
| | | // wrkMast.setWrkNo(workNo); |
| | | // wrkMast.setIoTime(now); |
| | | // wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | // wrkMast.setIoType(110); // 入出库状态: 110.空板出库 |
| | | // wrkMast.setIoPri(10D); |
| | | // wrkMast.setSourceStaNo(sourceStaNo); // 源站 |
| | | // wrkMast.setStaNo(param.getOutSite()); // 目标站 |
| | | // wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | // wrkMast.setSourceLocNo(locNo); // 源库位 |
| | | // wrkMast.setFullPlt("N"); // 满板:Y |
| | | // wrkMast.setPicking("N"); // 拣料 |
| | | // wrkMast.setExitMk("N"); // 退出 |
| | | // wrkMast.setEmptyMk("Y"); // 空板 |
| | | // wrkMast.setLinkMis("N"); |
| | | // wrkMast.setAppeUser(userId); |
| | | // wrkMast.setAppeTime(now); |
| | | // wrkMast.setModiUser(userId); |
| | | // wrkMast.setModiTime(now); |
| | | // boolean res = wrkMastService.insert(wrkMast); |
| | | // if (!res) { |
| | | // throw new CoolException("保存工作档失败"); |
| | | // } |
| | | // // 更新库位状态 D.空板 -> R.出库预约 |
| | | // if (locMast.getLocSts().equals("D")) { |
| | | // locMast.setLocSts("R"); |
| | | // locMast.setModiUser(userId); |
| | | // locMast.setModiTime(now); |
| | | // if (!locMastService.updateById(locMast)) { |
| | | // throw new CoolException("更新库位状态失败"); |
| | | // } |
| | | // } |
| | | //1.根据出库站点去寻找空托盘库位,先找浅库位 |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | EntityWrapper<LocMast> entityWrapper = new EntityWrapper<>(); |
| | | entityWrapper.eq("loc_sts","D").orderAsc(Arrays.asList("row1","lev1","bay1")); |
| | | if (stnNo == 100) { |
| | | entityWrapper.in("row1",2,3); |
| | | locMasts = locMastService.selectList(entityWrapper); |
| | | if (locMasts.isEmpty()) { |
| | | entityWrapper.in("row1",1,4); |
| | | locMasts = locMastService.selectList(entityWrapper); |
| | | } |
| | | } else if(stnNo == 102) { |
| | | entityWrapper.in("row1",6,7); |
| | | locMasts = locMastService.selectList(entityWrapper); |
| | | if (locMasts.isEmpty()) { |
| | | entityWrapper.in("row1",5,8); |
| | | locMasts = locMastService.selectList(entityWrapper); |
| | | } |
| | | } |
| | | if (locMasts.isEmpty()) { |
| | | throw new CoolException("没有找到空托盘,站点:" + stnNo); |
| | | } |
| | | |
| | | // 取第一个空库位 |
| | | LocMast locMast = locMasts.get(0); |
| | | |
| | | // 1.1.获取工作路径 |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("type_no", 110).eq("stn_no", |
| | | stnNo).eq("crn_no", locMast.getCrnNo())); |
| | | if (staDesc == null) { |
| | | throw new CoolException("路径不存在"); |
| | | } |
| | | Integer sourceStaNo = staDesc.getCrnStn(); |
| | | if (Cools.isEmpty(sourceStaNo)) { |
| | | throw new CoolException("检索源站失败"); |
| | | } |
| | | |
| | | //2.生成空托盘出库工作档 |
| | | Date now = new Date(); |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(commonService.getWorkNo(WorkNoType.PAKOUT.type)); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(110); // 入出库状态: 110.空板出库 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setSourceStaNo(sourceStaNo); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | // 3.更新库位状态 D.空板 -> R.出库预约 |
| | | if (locMast.getLocSts().equals("D")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新库位状态失败"); |
| | | } |
| | | } |
| | | |
| | | return R.ok("空托盘出库成功"); |
| | | } |
| | | } |