New file |
| | |
| | | package zy.cloud.wms.manager.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import zy.cloud.wms.common.model.param.ReplenishParam; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.LocDetl; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.entity.Prior; |
| | | import zy.cloud.wms.manager.service.LocDetlService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | import zy.cloud.wms.manager.service.NodeService; |
| | | import zy.cloud.wms.manager.service.PriorService; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/5/27 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/open/api") |
| | | public class OpenController { |
| | | |
| | | @Autowired |
| | | private PriorService priorService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @PostMapping("/replenish") |
| | | @Transactional |
| | | public R asrsReplenish(@RequestBody List<ReplenishParam> params){ |
| | | if (Cools.isEmpty(params)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | Date now = new Date(); |
| | | for (ReplenishParam param : params) { |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | List<Prior> priors = priorService.selectList(new EntityWrapper<Prior>().eq("matnr", param.getMatnr())); |
| | | // 有推荐货位 |
| | | if (!Cools.isEmpty(priors)) { |
| | | Prior prior = priors.get(0); |
| | | Node node = nodeService.selectById(prior.getNodeId()); |
| | | |
| | | LocDetl locDetl = locDetlService.getLocDetl(node.getId(), param.getMatnr()); |
| | | if (locDetl == null) { |
| | | locDetl = new LocDetl(); |
| | | locDetl.setLocNo(node.getName()); |
| | | locDetl.setNodeId(node.getId()); |
| | | locDetl.setAnfme(param.getCount()); |
| | | VersionUtils.setLocDetl(locDetl, mat); |
| | | locDetl.setStatus(1); |
| | | locDetl.setCreateBy(9527L); |
| | | locDetl.setCreateTime(now); |
| | | locDetl.setUpdateBy(9527L); |
| | | locDetl.setUpdateTime(now); |
| | | boolean insert = locDetlService.insert(locDetl); |
| | | if (!insert) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } else { |
| | | if (!locDetlService.incrementStock(node.getId(), param.getMatnr(), param.getCount())) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } |
| | | |
| | | // 没有推荐货物 |
| | | } else { |
| | | Node node = nodeService.selectByUuid("A00"); // todo |
| | | |
| | | LocDetl locDetl = locDetlService.getLocDetl(node.getId(), param.getMatnr()); |
| | | if (locDetl == null) { |
| | | locDetl = new LocDetl(); |
| | | locDetl.setLocNo(node.getName()); |
| | | locDetl.setNodeId(node.getId()); |
| | | locDetl.setAnfme(param.getCount()); |
| | | VersionUtils.setLocDetl(locDetl, mat); |
| | | locDetl.setStatus(1); |
| | | locDetl.setCreateBy(9527L); |
| | | locDetl.setCreateTime(now); |
| | | locDetl.setUpdateBy(9527L); |
| | | locDetl.setUpdateTime(now); |
| | | boolean insert = locDetlService.insert(locDetl); |
| | | if (!insert) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } else { |
| | | if (!locDetlService.incrementStock(node.getId(), param.getMatnr(), param.getCount())) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |