| | |
| | | import com.zy.api.controller.params.ReceviceTaskParams; |
| | | import com.zy.api.controller.params.WorkTaskParams; |
| | | import com.zy.api.service.WcsApiService; |
| | | import com.zy.asrs.entity.BasDevice; |
| | | import com.zy.asrs.entity.LocAroundBind; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.MatServiceImpl; |
| | | import com.zy.asrs.service.impl.WrkDetlServiceImpl; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | /** |
| | | * 通知WCS锁定库位,及禁止当前库位的一切操作 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R receviceTaskFromWcs(ReceviceTaskParams params) { |
| | | if (Objects.isNull(params.getDevice())) { |
| | | throw new CoolException("设备号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getSuperTaskNo())) { |
| | | if (Objects.isNull(params.getWrkNo())) { |
| | | throw new CoolException("WMS任务号不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getMsgType())) { |
| | | if (Objects.isNull(params.getNotifyType())) { |
| | | throw new CoolException("动作类型不能为空!!"); |
| | | } |
| | | WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getSuperTaskNo())); |
| | | WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getWrkNo())); |
| | | if (Objects.isNull(mast)) { |
| | | throw new CoolException("任务档不存在!!"); |
| | | } |
| | | if (!Objects.isNull(params.getMsgType()) && params.getMsgType().equals("task")) { |
| | | throw new CoolException("消息不能为空!!"); |
| | | } |
| | | if ( params.getNotifyType().equals("task")) { |
| | | //任务 |
| | | if (params.getMsgType().equals("task_complete")) { |
| | | mast.setWrkSts(4L); |
| | | if (!wrkMastService.updateById(mast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } else if (params.getMsgType().equals("task_cancel")){ |
| | | |
| | | if (params.getMsgType().equals("task_complete")) { |
| | | mast.setWrkSts(4L); |
| | | if (!wrkMastService.updateById(mast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } else if (params.getMsgType().equals("task_cancel")){ |
| | | |
| | | } else if (params.getNotifyType().equals("weight")) { |
| | | //称重 |
| | | if (mast.getWrkSts() == 2) { |
| | | WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", mast.getWrkNo())); |
| | | if (Objects.isNull(wrkDetl)) { |
| | | throw new CoolException("数据错误,任务明细不存在!!"); |
| | | } |
| | | Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", wrkDetl.getMatnr())); |
| | | if (Objects.isNull(matnr)) { |
| | | throw new CoolException("物料基础信息不存在!!"); |
| | | } |
| | | Double val = Math.round((params.getWeight() - matnr.getSafeQty()) * 10000) / 10000.0; |
| | | if (val.compareTo(0.0) > 0) { |
| | | //余料长度 |
| | | wrkDetl.setRealQty(val * matnr.getVolume()); |
| | | } else { |
| | | //空板 |
| | | wrkDetl.setRealQty(0.0); |
| | | } |
| | | wrkDetl.setWeight(params.getWeight()); |
| | | if (!wrkDetlService.update(wrkDetl, new EntityWrapper<WrkDetl>().eq("wrk_no", mast.getWrkNo()).eq("matnr", wrkDetl.getMatnr()).eq("barcode", wrkDetl.getBarcode()))) { |
| | | throw new CoolException("任务档明细修改失败!!"); |
| | | } |
| | | } else { |
| | | throw new CoolException("数据错误,当前任务状态有误 !"); |
| | | } |
| | | } |
| | | |
| | | // if (!wrkMastService.updateById(mast)) { |
| | | // throw new CoolException("任务状态修改失败!!"); |
| | | // } |
| | | |
| | | return R.ok(); |
| | | } |
| | | } |