自动化立体仓库 - WMS系统
#
mrzhssss
2022-09-12 126c31c4e088602d76b559bc7ab4add27c18963f
src/main/java/com/zy/asrs/service/impl/NodeServiceImpl.java
@@ -9,6 +9,7 @@
import com.zy.asrs.entity.ManLocDetl;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.Node;
import com.zy.asrs.entity.param.InitPakoutParam;
import com.zy.asrs.entity.param.MatnrDto;
import com.zy.asrs.entity.param.PakinParam;
import com.zy.asrs.entity.result.Pakin;
@@ -16,11 +17,15 @@
import com.zy.asrs.service.ManLocDetlService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.NodeService;
import com.zy.asrs.utils.SaasUtils;
import com.zy.asrs.utils.VersionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.beans.Transient;
import java.util.Date;
import java.util.List;
@Service("nodeService")
public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements NodeService {
@@ -105,9 +110,61 @@
            manLocDetl.setCreateTime(now);
            manLocDetl.setModiTime(now);
            manLocDetl.setCreateBy(userId);
            SaasUtils.insertLog(0,manLocDetl.getLocNo(),manLocDetl.getMatnr(), manLocDetl.getAnfme());
            manLocDetlService.insert(manLocDetl);
        }
        return R.ok("入库成功");
    }
    @Transactional
    @Override
    public R initPakout(List<InitPakoutParam> params, Long userId, Long hostId) {
        if (!Cools.isEmpty(params)) {
            Date now = new Date();
            for (InitPakoutParam param : params) {
                ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>()
                        .eq("node_id", param.getNodeId())
                        .eq("matnr", param.getMatnr()));
                Node node = nodeService.selectOne(new EntityWrapper<Node>()
                        .eq("id", param.getNodeId()));
                if (node == null) {
                    return R.error("找不到该库位,请联系管理员:" + param.getNodeId() );
                }
                if (manLocDetl == null) {
                    return R.error("物料:"+ param.getMatnr() + " 在库位中不存在");
                }
                if (manLocDetl.getAnfme() - param.getCount() < 0) {
                    return R.error("物料:"+ param.getMatnr() + " 在库位中数量不足");
                }else {
                    manLocDetl.setAnfme(manLocDetl.getAnfme() - param.getCount());
                    manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>()
                            .eq("loc_no",node.getUuid())
                            .eq("matnr",param.getMatnr()));
                    SaasUtils.insertLog(1,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme());
                }
            }
        }
        return R.ok("出库成功");
    }
    @Transactional
    @Override
    public void locMove(String sourceLocNo, String targetLocNo, Long userId) {
        List<ManLocDetl> targets = manLocDetlService.selectList(new EntityWrapper<ManLocDetl>()
                .like("loc_no", sourceLocNo));
        for (ManLocDetl target : targets) {
            Node uuid = nodeService.selectOne(new EntityWrapper<Node>()
                    .eq("uuid", targetLocNo));
            if (uuid == null || uuid.equals("")) {
                throw new RuntimeException("无法查询到移库的目标库位");
            }
            manLocDetlService.deleteById(target);
            target.setLocNo(uuid.getUuid());
            target.setNodeId(uuid.getId());
            SaasUtils.insertLog(2,target.getLocNo(), target.getMatnr(), target.getAnfme());
            manLocDetlService.insert(target);
        }
    }
}