| | |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.AgvLocDetl; |
| | | import com.zy.asrs.entity.AgvLocMast; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.AgvBasDevpService; |
| | | import com.zy.asrs.service.AgvLocDetlService; |
| | |
| | | return R.ok().add(agvBasDevpService.getAvailableEmptyInSite()); |
| | | } |
| | | |
| | | @RequestMapping("/empty/plate/in/start") |
| | | @ManagerAuth(memo = "空板入库") |
| | | public R emptyPlateInStart(@RequestParam String sourceStaNo, String containerCode) { |
| | | return R.ok("入库启动成功").add(agvWorkService.emptyPlateIn(sourceStaNo,containerCode,getUserId())); |
| | | } |
| | | // @RequestMapping("/empty/plate/in/start") |
| | | // @ManagerAuth(memo = "空板入库") |
| | | // public R emptyPlateInStart(@RequestParam String sourceStaNo, String containerCode) { |
| | | // return R.ok("入库启动成功").add(agvWorkService.emptyPlateIn(sourceStaNo,containerCode,getUserId())); |
| | | // } |
| | | |
| | | @RequestMapping("/empty/plate/out/start") |
| | | @ManagerAuth(memo = "空板出库") |
| | | public R emptyPlateOutStart(EmptyPlateOutParam param) { |
| | | agvWorkService.emptyPlateOut(param, getUserId()); |
| | | return R.ok("出库启动成功"); |
| | | } |
| | | // @RequestMapping("/empty/plate/out/start") |
| | | // @ManagerAuth(memo = "空板出库") |
| | | // public R emptyPlateOutStart(EmptyPlateOutParam param) { |
| | | // agvWorkService.emptyPlateOut(param, getUserId()); |
| | | // return R.ok("出库启动成功"); |
| | | // } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | |
| | | } |
| | | |
| | | /* |
| | | 空板出库 |
| | | 入库 |
| | | */ |
| | | @PostMapping("/pakin/empty/auth") |
| | | @Synchronized |
| | | public R pakinEmpty(@RequestBody List<AgvMobileStartParam> params){ |
| | | |
| | | for (AgvMobileStartParam param : params){ |
| | | workService.emptyPlateIn(param.getDevNo(),param.getContainerCode(),getUserId()); |
| | | workService.emptyPlateIn(param.getDevNo(),param.getContainerCode(),param.getContainerType(), getUserId()); |
| | | } |
| | | |
| | | return R.ok(); |
| | |
| | | */ |
| | | @PostMapping("/pakout/empty/auth") |
| | | @Synchronized |
| | | public R pakoutEmpty(@RequestBody Map<String,Object> map){ |
| | | public R pakoutEmpty(@RequestBody List<AgvMobileStartParam> params){ |
| | | |
| | | String devNo = map.get("devNo").toString(); |
| | | |
| | | for (AgvMobileStartParam param : params){ |
| | | workService.emptyPlateOut(param.getDevNo(),param.getContainerType(), getUserId()); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | |
| | | //站点 |
| | | private String devNo; |
| | | //任务类型 |
| | | private String type; |
| | | private int type; |
| | | //容器码 |
| | | private String containerCode; |
| | | //容器类型 |
| | | private String containerType; |
| | | private int containerType; |
| | | |
| | | } |
| | |
| | | // 库位类型: 1、待包装成品,2、原材料,3、箱壳 |
| | | private Integer locType; |
| | | |
| | | //第二单位数量 |
| | | private Double anfme; |
| | | |
| | | private List<CombMat> combMats; |
| | | |
| | | @Data |
| | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.zy.asrs.entity.AgvWaitPakin; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface AgvWaitPakinMapper extends BaseMapper<AgvWaitPakin> { |
| | | |
| | | @Update("UPDATE agv_cust_wait_pakin SET io_status = ${ioStatus} WHERE supp_code = '${containerCode}'") |
| | | int updateIoStatus(@Param("containerCode")String containerCode, @Param("ioStatus")String ioStatus); |
| | | |
| | | } |
| | |
| | | |
| | | List<AgvLocMast> selectLocByLevAndFloor(int lev, int floor); |
| | | |
| | | AgvLocMast selectEmptyZpallet(int type); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.zy.asrs.entity.AgvWaitPakin; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface AgvWaitPakinService extends IService<AgvWaitPakin> { |
| | | |
| | | public void updateIoStatus(int wrkNo, String ioStatus); |
| | | |
| | | public AgvWaitPakin selectByContainerCode(String containerCode); |
| | | public void updateIoStatus(String containerCode, String ioStatus); |
| | | |
| | | public List<AgvWaitPakin> selectByContainerCode(String containerCode); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import com.zy.asrs.entity.AgvBasDevp; |
| | | import com.zy.asrs.entity.AgvWrkMast; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.param.LocDetlAdjustParam; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.common.model.StartupDto; |
| | |
| | | /* |
| | | 空板入库 |
| | | */ |
| | | String emptyPlateIn(String sourceStaion,String containerCode, Long userId); |
| | | String emptyPlateIn(String station,String containerCode,int containerType, Long userId); |
| | | |
| | | void emptyPlateOut(EmptyPlateOutParam param, Long userId); |
| | | void emptyPlateOut(String station, int containerType, Long userId); |
| | | |
| | | /** |
| | | * 库存明细调整 |
| | |
| | | //return this.agvLocMastMapper.selectLocByLevAndFloor(lev,floor); |
| | | } |
| | | |
| | | @Override |
| | | public AgvLocMast selectEmptyZpallet(int type) { |
| | | |
| | | return this.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_sts","D").eq("loc_type2",type)); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AgvWaitPakin selectByContainerCode(String containerCode) { |
| | | return this.selectOne(new EntityWrapper<AgvWaitPakin>().eq("supp_code",containerCode)); |
| | | public void updateIoStatus(String containerCode, String ioStatus) { |
| | | this.baseMapper.updateIoStatus(containerCode,ioStatus); |
| | | } |
| | | |
| | | @Override |
| | | public List<AgvWaitPakin> selectByContainerCode(String containerCode) { |
| | | return this.selectList(new EntityWrapper<AgvWaitPakin>().eq("supp_code",containerCode).eq("io_status","N")); |
| | | } |
| | | } |
| | |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.param.LocDetlAdjustParam; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.*; |
| | |
| | | List<AgvWaitPakin> agvWaitPakinList = agvWaitPakinService.selectList(new EntityWrapper<AgvWaitPakin>().eq("supp_code", agvBasDevp.getBarcode())); |
| | | |
| | | //检索库位,选择合适的库位 |
| | | AgvLocMast agvLocMast = agvCommonService.getLocNo(agvWaitPakinList, agvBasDevp.getFloor()); |
| | | AgvLocMast agvLocMast = agvCommonService.getLocNo(agvBasDevp.getLocType1()); |
| | | //生成工作档 |
| | | AgvWrkMast wrkMast = createWrkMast(1,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),agvBasDevp.getBarcode(),now,userId, isConveyor); |
| | | //标记是否为输送线入库 |
| | |
| | | } |
| | | |
| | | /* |
| | | 空板入库 |
| | | 入库 |
| | | */ |
| | | @Transactional |
| | | public String emptyPlateIn(String sourceStaion,String containerCode, Long userId) { |
| | | |
| | | if(!pakinCheck()){ |
| | | |
| | | } |
| | | public String emptyPlateIn(String station,String containerCode,int containerType, Long userId) { |
| | | |
| | | Date now = new Date(); |
| | | // 源站点状态检测 |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectById(sourceStaion); |
| | | if(!agvBasDevp.getLocSts().equals("O")){ |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectById(station); |
| | | |
| | | //初始定义为空板入库类型 |
| | | int ioType = 10; |
| | | |
| | | if(!Cools.eq(agvBasDevp.getBarcode(),containerCode) || !agvBasDevp.getLocSts().equals("O")){ |
| | | throw new CoolException("当前工作位状态为" + agvBasDevp.getLocSts()+",无法进行空板入库"); |
| | | } |
| | | //判断当前容器是否存在任务 |
| | | |
| | | //查询工作档 |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectByContainerCode(containerCode); |
| | | if(!Cools.isEmpty(agvWrkMast)){ |
| | | |
| | | throw new CoolException("当前容器已有入库任务,无法进行入库"); |
| | | } |
| | | |
| | | //检索库位,选择合适的库位 |
| | | AgvLocMast agvLocMast = agvLocMast = agvCommonService.getLocNo(agvBasDevp.getLocType1()); |
| | | |
| | | // 检索库位 |
| | | AgvLocMast locMast = agvCommonService.getLocNo(null, agvBasDevp.getFloor()); |
| | | // 生成工作档 10.空板入库 |
| | | createWrkMast(10,201L,agvBasDevp.getDevNo(),locMast.getLocNo(),null,now,userId,false); |
| | | //查询入库通知档 |
| | | List<AgvWaitPakin> agvWaitPakinList = agvWaitPakinService.selectByContainerCode(containerCode); |
| | | if(!Cools.isEmpty(agvWaitPakinList)){ |
| | | //生成工作档 |
| | | AgvWrkMast wrkMast = createWrkMast(1,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),containerCode,now,userId, false); |
| | | //生成工作档明细 |
| | | agvWaitPakinList.forEach(wp -> { |
| | | createWrkDetlReWrite(wp.getMatnr(),wrkMast.getWrkNo(),wp.getOrderNo(),wp.getBatch(),wp.getAnfme(),wp.getSuppCode(),now,userId,wp.getThreeCode(),wp.getDeadTime()); |
| | | }); |
| | | //修改入库通知档状态 |
| | | agvWaitPakinService.updateIoStatus(containerCode,"Y"); |
| | | }else { |
| | | // 生成工作档 10.空板入库 |
| | | createWrkMast(10,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),containerCode,now,userId,false); |
| | | } |
| | | |
| | | //更新源站点状态 |
| | | updateAgvBasDevp(agvBasDevp,"R"); |
| | | //更新目标库位状态 |
| | | updateAgvLocMast(locMast,"S"); |
| | | return locMast.getLocNo(); |
| | | //更新目标库位状态和信息 |
| | | updateAgvLocMast(agvLocMast,"S", (short) containerType); |
| | | return agvLocMast.getLocNo(); |
| | | } |
| | | |
| | | /* |
| | | 空板出库 |
| | | */ |
| | | @Transactional |
| | | public void emptyPlateOut(EmptyPlateOutParam param, Long userId) { |
| | | public void emptyPlateOut(String station, int containerType, Long userId) { |
| | | Date now = new Date(); |
| | | //判断所选工作站空余工作位数量是否满足出库数量 |
| | | List<AgvBasDevp> agvBasDevpList = agvBasDevpService.selectList(new EntityWrapper<AgvBasDevp>() |
| | | .eq("station_code", param.getStationCode()) |
| | | .eq("loc_sts","O")); |
| | | if(agvBasDevpList.size() < param.getLocNos().size()){ |
| | | throw new CoolException("当前工作站可出库工作位数量为"+ agvBasDevpList.size() + ",小于要出库的库位数量,请重新选择出库库位"); |
| | | |
| | | // 站点检测 |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectById(station); |
| | | if(!agvBasDevp.getLocSts().equals("O")){ |
| | | throw new CoolException("当前工作位状态为" + agvBasDevp.getLocSts()+",无法进行空板出库"); |
| | | } |
| | | param.getLocNos().forEach(locNo -> { |
| | | AgvLocMast agvLocMast = agvLocMastService.selectById(locNo); |
| | | if(!agvLocMast.getLocSts().equals("D")){ |
| | | throw new CoolException(agvLocMast.getLocNo() + "库位状态已经不为D.空桶/空栈板,请重新选择库位进行空板出库"); |
| | | } |
| | | //检索工作位 |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>() |
| | | .eq("station_code", param.getStationCode()) |
| | | .eq("loc_sts", "O")); |
| | | //生成工作档 |
| | | createWrkMast(110,21L,locNo,agvBasDevp.getDevNo(),null,now,userId,false); |
| | | //修改源库位状态 |
| | | updateAgvLocMast(agvLocMast,"R"); |
| | | //修改目标工作位状态 |
| | | updateAgvBasDevp(agvBasDevp,"S"); |
| | | }); |
| | | |
| | | //寻找相应类型的空托盘 |
| | | AgvLocMast agvLocMast = agvLocMastService.selectEmptyZpallet(containerType); |
| | | |
| | | //生成工作档 |
| | | createWrkMast(110,21L,agvLocMast.getLocNo(),agvBasDevp.getDevNo(),agvLocMast.getBarcode(),now,userId,false); |
| | | |
| | | //修改源库位状态 |
| | | updateAgvLocMast(agvLocMast,"R"); |
| | | |
| | | //修改站点状态 |
| | | updateAgvBasDevp(agvBasDevp,"S"); |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | |
| | | } |
| | | |
| | | /* |
| | | 更新目标库位信息和库位托盘类型 |
| | | */ |
| | | private void updateAgvLocMast(AgvLocMast locMast, String locSts, short type){ |
| | | locMast.setLocSts(locSts); |
| | | locMast.setLocType2(type); |
| | | agvLocMastService.updateById(locMast); |
| | | } |
| | | |
| | | /* |
| | | 更新源站点信息 |
| | | */ |
| | | private void updateAgvBasDevp(AgvBasDevp agvBasDevp, String locSts){ |
| | |
| | | agvBasDevp.setInQty(agvBasDevp.getInQty() + 1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //入库前检查 |
| | | private boolean pakinCheck(){ |
| | | |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | } |
| | |
| | | * 检索库位号 |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public AgvLocMast getLocNo(List<AgvWaitPakin> agvWaitPakinList, int floor) { |
| | | public AgvLocMast getLocNo(int type) { |
| | | // 目标库位 |
| | | AgvLocMast locMast = null; |
| | | if(Cools.isEmpty(agvWaitPakinList)){ |
| | | return getLocNoRule(floor); // 1. 随机库位 |
| | | } |
| | | // if(Cools.isEmpty(agvWaitPakinList)){ |
| | | // return getLocNoRule(type); // 1. 随机库位 |
| | | // } |
| | | |
| | | //库位规则 |
| | | locMast = getLocByLocRule(agvWaitPakinList.get(0),floor); // 2. 按库位规则搜索 |
| | | if(!Cools.isEmpty(locMast)){ |
| | | return locMast; |
| | | } |
| | | |
| | | |
| | | //库位编码规则 |
| | | locMast = getLocByLocCodeRule(agvWaitPakinList.get(0),floor); |
| | | if(!Cools.isEmpty(locMast)){ |
| | | return locMast; |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | locMast = getLocByProximityRule(); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | //return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | //根据物料频率搜索库位,频率高则搜索离缓存货架最近库位,频率低则搜索最远库位 |
| | | Mat mat = matService.selectByMatnr(agvWaitPakinList.get(0).getMatnr()); |
| | | if(Cools.isEmpty(mat.getBeBatch())){ |
| | | mat.setBeBatch(0); |
| | | } |
| | | locMast = getLocByFre(mat.getBeBatch(), floor); |
| | | if (locMast != null) { |
| | | return locMast; |
| | | } |
| | | // //库位规则 |
| | | // locMast = getLocByLocRule(agvWaitPakinList.get(0),floor); // 2. 按库位规则搜索 |
| | | // if(!Cools.isEmpty(locMast)){ |
| | | // return locMast; |
| | | // } |
| | | // |
| | | // |
| | | // //库位编码规则 |
| | | // locMast = getLocByLocCodeRule(agvWaitPakinList.get(0),floor); |
| | | // if(!Cools.isEmpty(locMast)){ |
| | | // return locMast; |
| | | // } |
| | | // |
| | | // // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | // locMast = getLocByProximityRule(); |
| | | // if (locMast != null) { |
| | | // //找到库位,返回dto |
| | | // //return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | // } |
| | | // |
| | | // //根据物料频率搜索库位,频率高则搜索离缓存货架最近库位,频率低则搜索最远库位 |
| | | // Mat mat = matService.selectByMatnr(agvWaitPakinList.get(0).getMatnr()); |
| | | // if(Cools.isEmpty(mat.getBeBatch())){ |
| | | // mat.setBeBatch(0); |
| | | // } |
| | | // locMast = getLocByFre(mat.getBeBatch(), floor); |
| | | // if (locMast != null) { |
| | | // return locMast; |
| | | // } |
| | | |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | locMast = getLocNoRule(floor); |
| | | locMast = getLocNoRule(type); |
| | | if (locMast != null) { |
| | | return locMast; |
| | | } |
| | |
| | | } |
| | | |
| | | //随机取一个货位 |
| | | private AgvLocMast getLocNoRule(int floor){ |
| | | private AgvLocMast getLocNoRule(int type){ |
| | | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() |
| | | .eq("floor",floor) |
| | | .eq("loc_sts","O") |
| | | .eq(false,"loc_type2",1)); |
| | | .eq(false,"loc_type1",type)); |
| | | } |
| | | |
| | | |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/10/30 |
| | |
| | | if(Cools.isEmpty(agvBasDevp) || !"O".equals(agvBasDevp.getLocSts())){ |
| | | throw new CoolException("当前站点不存在或者站点不为空"); |
| | | } |
| | | |
| | | AgvWaitPakin agvWaitPakin = agvWaitPakinService.selectByContainerCode(containerCode); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", containerCode)); |
| | | |
| | | //拣料、盘点完成任务 |