| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | 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.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.Comb; |
| | | import zy.cloud.wms.manager.entity.LocDetl; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.entity.param.StockInParam; |
| | | import zy.cloud.wms.manager.service.CombService; |
| | | import zy.cloud.wms.manager.service.LocDetlService; |
| | | import zy.cloud.wms.manager.service.NodeService; |
| | | import zy.cloud.wms.manager.service.WorkService; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/2/25 |
| | |
| | | |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private CombService combService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stockIn(StockInParam param, Long userId) { |
| | | Node node = nodeService.selectByUuid(param.getNodeId()); |
| | | if (node == null) { |
| | | return R.error("货位不存在"); |
| | | } |
| | | System.out.println(JSON.toJSONString(param)); |
| | | List<Comb> combs = combService.selectList(new EntityWrapper<Comb>().eq("zpallet", param.getZpallet()).eq("io_status", 1)); |
| | | if (Cools.isEmpty(combs)) { |
| | | return R.error("物料不存在"); |
| | | } |
| | | Date now = new Date(); |
| | | for (Comb comb : combs) { |
| | | // 改变组托档状态 |
| | | comb.setIoStatus(4); |
| | | comb.setUpdateBy(userId); |
| | | comb.setUpdateTime(now); |
| | | boolean update = combService.update(comb, new EntityWrapper<Comb>().eq("zpallet", param.getZpallet()).eq("matnr", comb.getMatnr())); |
| | | if (!update) { |
| | | throw new CoolException("修改托盘资料档失败"); |
| | | } |
| | | // 更新货位库存明细 |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.setLocNo(node.getName()); |
| | | locDetl.setNodeId(node.getId()); |
| | | locDetl.setZpallet(param.getZpallet()); |
| | | locDetl.setAnfme(comb.getAnfme()); |
| | | VersionUtils.setLocDetl(locDetl, comb); |
| | | locDetl.setStatus(1); |
| | | locDetl.setCreateBy(userId); |
| | | locDetl.setCreateTime(now); |
| | | locDetl.setUpdateBy(userId); |
| | | locDetl.setUpdateTime(now); |
| | | boolean insert = locDetlService.insert(locDetl); |
| | | if (!insert) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |