| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import zy.cloud.wms.manager.entity.LocDetl; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.entity.ReceiveDetl; |
| | | import zy.cloud.wms.manager.entity.ReceiveLog; |
| | | import zy.cloud.wms.manager.entity.dto.PutShelfDTO; |
| | | import zy.cloud.wms.manager.service.LocDetlService; |
| | | import zy.cloud.wms.manager.service.NodeService; |
| | | import zy.cloud.wms.manager.service.ReceiveDetlService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import zy.cloud.wms.manager.service.ReceiveLogService; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ReceiveDetlService receiveDetlService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private ReceiveLogService receiveLogService; |
| | | |
| | | @RequestMapping(value = "/receiveDetl/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 上架动作,插入库存明细,更新单据明细 |
| | | * @param putShelfDTO |
| | | * @return |
| | | */ |
| | | @RequestMapping("/receiveDetl/addIn") |
| | | public R addIn(@RequestBody ReceiveDetl receiveDetl){ |
| | | System.out.println("receiveDetl = " + receiveDetl); |
| | | return R.ok(); |
| | | @ManagerAuth |
| | | public R addIn(@RequestBody PutShelfDTO putShelfDTO){ |
| | | /** |
| | | * 控管与数据初始化 |
| | | */ |
| | | if (Cools.isEmpty(putShelfDTO.getId(),putShelfDTO.getBatch(),putShelfDTO.getRemain(),putShelfDTO.getSelect())){ |
| | | return R.error("输入数据有误,请重新输入"); |
| | | } |
| | | Date date = new Date(); |
| | | double remain = Double.parseDouble(putShelfDTO.getRemain()); |
| | | double anfme = Double.parseDouble(putShelfDTO.getAnfme()); |
| | | double inQty = Double.parseDouble(putShelfDTO.getInQty()); |
| | | if (anfme - (remain + inQty) < 0){ |
| | | return R.error("本次入库数量大于所需入库数量"); |
| | | } |
| | | Node targetLoc = nodeService.selectOne(new EntityWrapper<Node>() |
| | | .eq("id", putShelfDTO.getSelect())); |
| | | |
| | | |
| | | /** |
| | | * 更新库存 |
| | | */ |
| | | LocDetl checkLoc = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", targetLoc.getName()) |
| | | .eq("matnr", putShelfDTO.getMatnr()) |
| | | .eq("batch", putShelfDTO.getBatch())); |
| | | if (Cools.isEmpty(checkLoc)) { |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.setHostId(getHostId()); |
| | | locDetl.setLocNo(targetLoc.getName()); |
| | | locDetl.setNodeId(targetLoc.getId()); |
| | | locDetl.setAnfme(remain); |
| | | locDetl.setMatnr(putShelfDTO.getMatnr()); |
| | | locDetl.setMaktx(putShelfDTO.getMaktx()); |
| | | locDetl.setCreateBy(getUserId()); |
| | | locDetl.setCreateTime(date); |
| | | locDetl.setUpdateBy(getUserId()); |
| | | locDetl.setUpdateTime(date); |
| | | locDetl.setBatch(putShelfDTO.getBatch()); |
| | | locDetlService.insert(locDetl); |
| | | }else { |
| | | checkLoc.setAnfme(checkLoc.getAnfme() + remain); |
| | | locDetlService.update(checkLoc,new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", targetLoc.getName()) |
| | | .eq("matnr", putShelfDTO.getMatnr()) |
| | | .eq("batch", putShelfDTO.getBatch())); |
| | | } |
| | | |
| | | /** |
| | | * 反写订单数量 |
| | | */ |
| | | |
| | | ReceiveDetl targetRece = receiveDetlService.selectOne(new EntityWrapper<ReceiveDetl>() |
| | | .eq("id", putShelfDTO.getId())); |
| | | targetRece.setInQty((int) (targetRece.getInQty() + remain)); |
| | | receiveDetlService.update(targetRece,new EntityWrapper<ReceiveDetl>() |
| | | .eq("id",targetRece.getId())); |
| | | |
| | | /** |
| | | * 上架完成之后,存放数据至上架统计表 man_receive_log |
| | | */ |
| | | ReceiveLog receiveLog = new ReceiveLog(); |
| | | receiveLog.setOrderNo(putShelfDTO.getOrderNo()); |
| | | receiveLog.setNodeId(targetLoc.getId()); |
| | | receiveLog.setNodeName(targetLoc.getName()); |
| | | receiveLog.setMatnr(putShelfDTO.getMatnr()); |
| | | receiveLog.setAnfme(remain); |
| | | receiveLog.setBatch(putShelfDTO.getBatch()); |
| | | receiveLog.setCreateBy(getUserId()); |
| | | receiveLog.setUpdateBy(getUserId()); |
| | | receiveLogService.insert(receiveLog); |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | } |