| | |
| | | import com.zy.asrs.entity.param.PickParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.web.BaseController; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Synchronized; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | String orderNo = params.get("orderNo"); |
| | | String threeCode = params.get("threeCode"); |
| | | String matnr = params.get("matnr"); |
| | | String floor = params.get("floor"); |
| | | |
| | | Wrapper<AgvLocDetl> wrapper = new EntityWrapper<AgvLocDetl>().eq("matnr", matnr); |
| | | |
| | |
| | | wrapper = Cools.isEmpty(threeCode) ? wrapper.isNull("three_code") : wrapper.eq("three_code",threeCode); |
| | | |
| | | if (threeCode.substring(0,2).equals(30)) { |
| | | wrapper.isNull("specs").or().eq("specs",""); |
| | | wrapper.isNull("specs").or().eq("specs","").eq("floor",1); |
| | | } |
| | | List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(wrapper); |
| | | |
| | | List<AgvLocDetl> locDetls = new ArrayList<>(); |
| | | for (AgvLocDetl agvLocDetl : agvLocDetls) { |
| | | AgvLocMast locNo = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocDetl.getLocNo())); |
| | | agvLocDetl.setLocSts(locNo.getLocSts()); |
| | | agvLocDetl.setLocSts$(locNo.getLocSts$()); |
| | | AgvLocMast agvLocMast = new AgvLocMast(); |
| | | if (Cools.isEmpty(floor)) { |
| | | agvLocMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocDetl.getLocNo()).notLike("loc_no","F1")); |
| | | } else { |
| | | agvLocMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocDetl.getLocNo()).like("loc_no",floor)); |
| | | } |
| | | |
| | | if (Cools.isEmpty(agvLocMast)) continue; |
| | | agvLocDetl.setLocSts(agvLocMast.getLocSts()); |
| | | agvLocDetl.setLocSts$(agvLocMast.getLocSts$()); |
| | | locDetls.add(agvLocDetl); |
| | | } |
| | | |
| | | return R.ok(agvLocDetls); |
| | | |
| | | return R.ok(locDetls); |
| | | } |
| | | |
| | | /* |
| | |
| | | wrapper.in("source",docIds); |
| | | Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); |
| | | for (OrderDetl record : page.getRecords()) { |
| | | Double sumAnfme = agvLocDetlService.getSumAnfme(record.getMatnr(), record.getThreeCode()); |
| | | Double sumAnfme = agvLocDetlService.getSumAnfmeDb(record.getMatnr(), record.getThreeCode(),1); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | return R.ok(page); |
| | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderDetl/pakout/list/authV4") |
| | | @ManagerAuth |
| | | public R pakoutList4(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convertLike(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { |
| | | wrapper.orderBy("create_time", false); |
| | | } |
| | | List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | for (DocType pakin : pakins) { |
| | | if (pakin.getDocId() == 34) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | } |
| | | |
| | | wrapper.in("source",docIds); |
| | | Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); |
| | | for (OrderDetl record : page.getRecords()) { |
| | | Double sumAnfme = agvLocDetlService.getSumAnfme(record.getMatnr(), record.getThreeCode()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | String val = String.valueOf(entry.getValue()); |
| | |
| | | @Select("select sum(a.anfme) as sum from agv_loc_detl a left join agv_loc_mast b on a.loc_no = b.loc_no where b.loc_sts = 'F' and a.matnr = #{matnr} AND a.three_code = #{threeCode}") |
| | | Double selectSumAnfmeByMatnr(@Param("matnr") String matnr,@Param("threeCode") String threeCode); |
| | | |
| | | @Select("select sum(a.anfme) as sum from agv_loc_detl a left join agv_loc_mast b on a.loc_no = b.loc_no where (b.loc_sts = 'F' or b.loc_sts = 'R') and b.floor = #{floor} and a.matnr = #{matnr} AND a.three_code = #{threeCode}") |
| | | Double selectSumAnfmeByMatnr2(@Param("matnr") String matnr,@Param("threeCode") String threeCode,@Param("floor") Integer floor); |
| | | |
| | | @Select("SELECT SUM(anfme) FROM agv_loc_detl") |
| | | Integer sum(); |
| | | |
| | |
| | | |
| | | Double getSumAnfme(String matnr, String threeCode); |
| | | |
| | | Double getSumAnfmeDb(String matnr, String threeCode, Integer floor); |
| | | |
| | | Integer sum(); |
| | | |
| | | List<AgvLocDetl> getStockStatisExcel(); |
| | |
| | | return this.baseMapper.selectSumAnfmeByMatnr(matnr, threeCode); |
| | | } |
| | | |
| | | @Override |
| | | public Double getSumAnfmeDb(String matnr, String threeCode,Integer floor) { |
| | | return this.baseMapper.selectSumAnfmeByMatnr2(matnr, threeCode, floor); |
| | | } |
| | | |
| | | /* |
| | | 获取库存总数 |
| | | */ |
| | |
| | | |
| | | for (PickParam.Pick pick : pickParams.getPicks()) { |
| | | if (pick.getCount().equals(0D)) continue; |
| | | AgvWrkDetl wrkDetl = new AgvWrkDetl(); |
| | | Mat mat = matService.selectByMatnr(pick.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(pick.getMatnr() + "商品不存在"); |
| | | AgvWrkDetl agvWrkDetl = agvWrkDetlService.selectOne(new EntityWrapper<AgvWrkDetl>().eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode())); |
| | | if (Cools.isEmpty(agvWrkDetl)) { |
| | | AgvWrkDetl wrkDetl = new AgvWrkDetl(); |
| | | Mat mat = matService.selectByMatnr(pick.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(pick.getMatnr() + "商品不存在"); |
| | | } |
| | | wrkDetl.sync(mat); |
| | | wrkDetl.setWrkNo(pickParams.getWrkNo()); |
| | | wrkDetl.setOrderNo(pick.getOrderNo()); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setAnfme(pick.getCount()); // 数量 |
| | | wrkDetl.setSuppCode(pick.getSuppCode()); // 托盘条码 |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setThreeCode(pick.getThreeCode()); |
| | | agvWrkDetlService.insert(wrkDetl); |
| | | } else { |
| | | Double anfme = agvWrkDetl.getAnfme() + pick.getCount(); |
| | | agvWrkDetl.setAnfme(anfme); |
| | | agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>().eq("matnr",agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode())); |
| | | |
| | | } |
| | | wrkDetl.sync(mat); |
| | | wrkDetl.setWrkNo(pickParams.getWrkNo()); |
| | | wrkDetl.setOrderNo(pick.getOrderNo()); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setAnfme(pick.getCount()); // 数量 |
| | | wrkDetl.setSuppCode(pick.getSuppCode()); // 托盘条码 |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setThreeCode(pick.getThreeCode()); |
| | | agvWrkDetlService.insert(wrkDetl); |
| | | |
| | | |
| | | // 更新订单 |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code",pick.getThreeCode())); |
| | |
| | | .or().eq("io_type",57) |
| | | .or().eq("io_type",10) |
| | | .or().eq("io_type",11) |
| | | .or().eq("io_type",108)); |
| | | .or().eq("io_type",108) |
| | | .or().eq("io_type",109)); |
| | | if(!Cools.isEmpty(agvWrkMastList)){ |
| | | agvWrkMastList.stream().forEach(agvWrkMast -> { |
| | | agvWrkMastHandler.completedPutWayWrk(agvWrkMast); |
| | |
| | | .or().eq("io_type", 1) |
| | | .or().eq("io_type", 10) |
| | | .or().eq("io_type", 57) |
| | | .or().eq("io_type", 109) |
| | | .or().eq("io_type", 108)).getRecords(); |
| | | |
| | | if(!Cools.isEmpty(agvWrkMastList)){ |
| | |
| | | // 查询 不为1楼的空货架 |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList( |
| | | new EntityWrapper<AgvLocMast>() |
| | | .ne("floor", 3) |
| | | .ne("floor", 1) |
| | | .eq("loc_sts","D") |
| | | .eq("loc_type1",3)); |
| | | if (agvLocMasts.isEmpty()) { |
| | | return; |
| | | } |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | ReturnT<String> returnT = autoMoveHandler.start(agvLocMast); |
| | | ReturnT<String> returnT = autoMoveHandler.autoEmptyBack(agvLocMast); |
| | | } |
| | | |
| | | } |
| | |
| | | agvWrkMastService.updateById(agvWrkMast); |
| | | // 空板入库 设置库位状态为D.空桶/空栈板 |
| | | String locSts = agvWrkMast.getIoType() == 10 ? "D" : "F"; |
| | | agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),locSts,agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue()); |
| | | if (agvWrkMast.getIoType() == 10 || agvWrkMast.getIoType() == 109) { |
| | | agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue()); |
| | | } else { |
| | | agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue()); |
| | | } |
| | | |
| | | //生成AGV工作历史档 |
| | | agvWrkMastLogService.save(agvWrkMast); |
| | | //生成AGV工作明细历史档 |
| | |
| | | throw new CoolException("当前"+agvLocMast.getBarcode()+"货架码已在工作档中"); |
| | | } |
| | | //检索库位,选择合适的库位 |
| | | AgvLocMast LocMast = agvCommonService.getLocNo(3,agvLocMast.getLocType3()); |
| | | AgvLocMast LocMast = agvCommonService.getLocNo(3,1); |
| | | //生成工作档 |
| | | AgvWrkMast mast = new AgvWrkMast(); |
| | | //工作状态 |
| | |
| | | if (!agvWrkMastService.insertByIncrease(mast)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | //更新目标库位状态 |
| | | updateAgvLocMast(agvLocMast,"R"); |
| | | updateAgvLocMast(LocMast,"S"); |
| | | return SUCCESS; |
| | | } |
| | | } |