| | |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | 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 zy.cloud.wms.manager.service.*; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | |
| | | 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.*; |
| | | |
| | |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private ReceiveLogService receiveLogService; |
| | | @Autowired |
| | | private ReceiveService receiveService; |
| | | |
| | | @RequestMapping(value = "/receiveDetl/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | return R.ok(receiveDetlService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/receiveDetl/list/auth") |
| | | @RequestMapping(value ="/receiveDetl/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<ReceiveDetl> wrapper = new EntityWrapper<>(); |
| | | param.values(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(receiveDetlService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | return R.ok(receiveDetlService.selectPage(new Page<>(curr, limit), wrapper.orderBy("id",false))); |
| | | } |
| | | |
| | | private void convert(Map<String, Object> map, EntityWrapper wrapper){ |
| | |
| | | /** |
| | | * 控管与数据初始化 |
| | | */ |
| | | if (Cools.isEmpty(putShelfDTO.getId(),putShelfDTO.getBatch(),putShelfDTO.getRemain(),putShelfDTO.getSelect())){ |
| | | if (Cools.isEmpty(putShelfDTO.getId(),putShelfDTO.getRemain(),putShelfDTO.getSelect())){ |
| | | return R.error("输入数据有误,请重新输入"); |
| | | } |
| | | Date date = new Date(); |
| | |
| | | } |
| | | Node targetLoc = nodeService.selectOne(new EntityWrapper<Node>() |
| | | .eq("id", putShelfDTO.getSelect())); |
| | | |
| | | |
| | | /** |
| | | * 更新库存 |
| | | */ |
| | |
| | | |
| | | ReceiveDetl targetRece = receiveDetlService.selectOne(new EntityWrapper<ReceiveDetl>() |
| | | .eq("id", putShelfDTO.getId())); |
| | | targetRece.setInQty((int) (targetRece.getInQty() + remain)); |
| | | targetRece.setInQty((targetRece.getInQty() + remain)); |
| | | receiveDetlService.update(targetRece,new EntityWrapper<ReceiveDetl>() |
| | | .eq("id",targetRece.getId())); |
| | | /** |
| | | * 反写订单状态 |
| | | */ |
| | | if(!Cools.isEmpty(putShelfDTO.getOrderNo())){ |
| | | List<ReceiveDetl> list = receiveDetlService.selectList(new EntityWrapper<ReceiveDetl>().eq("order_no",putShelfDTO.getOrderNo())); |
| | | boolean flag = true; |
| | | |
| | | if(list.size()>0){ |
| | | for (ReceiveDetl receiveDetl : list){ |
| | | if(receiveDetl.getInQty() < receiveDetl.getCount()){ |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(flag){ |
| | | Receive receive = receiveService.selectOne(new EntityWrapper<Receive>().eq("order_no",putShelfDTO.getOrderNo())); |
| | | receive.setSettle(Long.valueOf(4)); |
| | | receiveService.updateById(receive); |
| | | } |
| | | // ReceiveDetl receiveDetl = receiveDetlService.selectOne(new EntityWrapper<ReceiveDetl>().eq("order_no",putShelfDTO.getOrderNo()).eq("matnr",putShelfDTO.getMatnr())); |
| | | // for(int i=0;i<list.size();i++){ |
| | | // if(list.get(i).getMatnr().equals(receiveDetl.getMatnr())){ |
| | | // if(list.get(i).getInQty()>=list.get(i).getCount()){ |
| | | // Receive receive = receiveService.selectOne(new EntityWrapper<Receive>().eq("order_no",putShelfDTO.getOrderNo())); |
| | | // receive.setSettle(Long.valueOf(4)); |
| | | // receiveService.updateById(receive); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | /** |
| | | * 上架完成之后,存放数据至上架统计表 man_receive_log |
| | | */ |
| | |
| | | receiveLog.setBatch(putShelfDTO.getBatch()); |
| | | receiveLog.setCreateBy(getUserId()); |
| | | receiveLog.setUpdateBy(getUserId()); |
| | | receiveLog.setIoType(1); |
| | | receiveLogService.insert(receiveLog); |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 撤销上架操作 |
| | | */ |
| | | @RequestMapping("/receiveDetl/renew/auth") |
| | | @ManagerAuth |
| | | @Transactional |
| | | public R renew(@RequestBody ReceiveDetl receiveDetl){ |
| | | /** |
| | | * 控管 |
| | | */ |
| | | if (receiveDetl.getInQty() <= 0){ |
| | | return R.error("没有上架记录,无法撤回"); |
| | | } |
| | | Receive receive = receiveService.selectOne(new EntityWrapper<Receive>() |
| | | .eq("id", receiveDetl.getOrderId())); |
| | | if (Cools.isEmpty(receive)) { |
| | | return R.error("找不到该单据,请联系管理员"); |
| | | } |
| | | if (receive.getSettle() == 4){ |
| | | return R.error("该单据已经完结"); |
| | | } |
| | | |
| | | /** |
| | | * 修改库存数量,同时撤回上架完成后,将操作记录反写回上架统计表 man_receive_log |
| | | */ |
| | | List<ReceiveLog> receiveLogs = receiveLogService.selectList(new EntityWrapper<ReceiveLog>() |
| | | .eq("order_no", receiveDetl.getOrderNo()) |
| | | .eq("matnr", receiveDetl.getMatnr()) |
| | | .eq("batch", receiveDetl.getBatch()) |
| | | .eq("io_type", 1)); |
| | | if (Cools.isEmpty(receiveLogs)) { |
| | | return R.error("找不到入库记录"); |
| | | } |
| | | for (ReceiveLog receiveLog : receiveLogs) { |
| | | locDetlService.delete(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no",receiveLog.getNodeName()) |
| | | .eq("matnr",receiveLog.getMatnr()) |
| | | .eq("batch",receiveLog.getBatch())); |
| | | receiveLog.setIoType(101); |
| | | receiveLog.setCreateBy(getUserId()); |
| | | receiveLog.setUpdateBy(getUserId()); |
| | | receiveLogService.insert(receiveLog); |
| | | } |
| | | |
| | | /** |
| | | * 反写回入库档 |
| | | */ |
| | | receiveDetl.setInQty(0.0); |
| | | receiveDetl.setUpdateTime(new Date()); |
| | | receiveDetl.setUpdateBy(getUserId()); |
| | | receiveDetlService.update(receiveDetl,new EntityWrapper<ReceiveDetl>() |
| | | .eq("id",receiveDetl.getId())); |
| | | return R.ok("撤回成功"); |
| | | } |
| | | |
| | | } |