Merge branch 'master' of http://47.111.78.178:8012/liuxy/HuaDongYiYaoWMS
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
package org.nl.wms.pda.general_management.service.dao.mapper;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CommonMapper extends BaseMapper<JSONObject> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.nl.wms.pda.general_management.service.dao.mapper.CommonMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -26,6 +26,7 @@ import org.nl.wms.pda.general_management.service.dto.AssemblyBagParam;
|
|||||||
import org.nl.wms.pda.general_management.service.dto.AssemblyBucketParam;
|
import org.nl.wms.pda.general_management.service.dto.AssemblyBucketParam;
|
||||||
import org.nl.wms.pda.general_management.service.dto.AssemblyPalletParam;
|
import org.nl.wms.pda.general_management.service.dto.AssemblyPalletParam;
|
||||||
import org.nl.wms.pda.util.PdaResponse;
|
import org.nl.wms.pda.util.PdaResponse;
|
||||||
|
import org.nl.wms.pda.util.SectMaterialCheck;
|
||||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||||
@@ -98,6 +99,9 @@ public class PdaCommonServiceImpl implements PdaCommonService {
|
|||||||
@Resource
|
@Resource
|
||||||
private EmpStackPlatesTask empStackPlatesTask;
|
private EmpStackPlatesTask empStackPlatesTask;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SectMaterialCheck sectMaterialCheck;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public PdaResponse callEmptyVehicle(JSONObject param) {
|
public PdaResponse callEmptyVehicle(JSONObject param) {
|
||||||
@@ -186,11 +190,13 @@ public class PdaCommonServiceImpl implements PdaCommonService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public PdaResponse confirmPalletAssembly(AssemblyPalletParam param) {
|
public PdaResponse confirmPalletAssembly(AssemblyPalletParam param) {
|
||||||
// 判断此载具状态
|
// 判断此载具状态
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("vehicle_code", param.getVehicle_code());
|
jsonObject.put("vehicle_code", param.getVehicle_code());
|
||||||
groupplateService.checkVehicle(jsonObject);
|
groupplateService.checkVehicle(jsonObject);
|
||||||
|
|
||||||
|
// 判断库区是否一致
|
||||||
|
sectMaterialCheck.chackAllMaterialAndSect(param);
|
||||||
|
|
||||||
// 调用PC组盘功能
|
// 调用PC组盘功能
|
||||||
GroupPlate groupPlate = new GroupPlate();
|
GroupPlate groupPlate = new GroupPlate();
|
||||||
groupPlate.setVehicle_code(param.getVehicle_code());
|
groupPlate.setVehicle_code(param.getVehicle_code());
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package org.nl.wms.pda.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.system.service.dict.ISysDictService;
|
||||||
|
import org.nl.system.service.dict.dao.Dict;
|
||||||
|
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||||
|
import org.nl.wms.basedata_manage.service.IMdPbClassstandardService;
|
||||||
|
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleinfoService;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.MdPbClassstandard;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo;
|
||||||
|
import org.nl.wms.pda.general_management.service.dao.mapper.CommonMapper;
|
||||||
|
import org.nl.wms.pda.general_management.service.dto.AssemblyPalletParam;
|
||||||
|
import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料-库区映射检测
|
||||||
|
* @author: lyd
|
||||||
|
* @date: 2026/1/23
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SectMaterialCheck {
|
||||||
|
/**
|
||||||
|
* 字典服务
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private ISysDictService dictService;
|
||||||
|
/**
|
||||||
|
* 分类的服务
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private IMdPbClassstandardService classstandardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料服务
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private IMdMeMaterialbaseService materialbaseService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 载具服务(用于获取载具库区sect_code)
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private IMdPbStoragevehicleinfoService storagevehicleinfoService;
|
||||||
|
/**
|
||||||
|
* 通用的mapper
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private CommonMapper commonMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取托盘对应的sect_code,比较所有param对应的物料的类型, 与字典表MATERIAL_SECT(label:物料类型,value:库区)是否匹配.
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
public void chackAllMaterialAndSect(AssemblyPalletParam param) {
|
||||||
|
if (ObjectUtil.isEmpty(param) || ObjectUtil.isEmpty(param.getVehicle_code())) {
|
||||||
|
throw new BadRequestException("托盘码不能为空!");
|
||||||
|
}
|
||||||
|
List<GroupPlate> groupPlates = param.getGroup_plates();
|
||||||
|
if (ObjectUtil.isEmpty(groupPlates)) {
|
||||||
|
throw new BadRequestException("组盘信息不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1) 获取托盘(载具)对应库区
|
||||||
|
MdPbStoragevehicleinfo vehicleDao = storagevehicleinfoService.getByCode(param.getVehicle_code());
|
||||||
|
String sectCode = vehicleDao.getSect_code();
|
||||||
|
if (ObjectUtil.isEmpty(sectCode)) {
|
||||||
|
throw new BadRequestException("载具【" + param.getVehicle_code() + "】未维护库区(sect_code)!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) 获取字典:MATERIAL_SECT(label:物料类型编码class_code,value:库区sect_code)
|
||||||
|
List<Dict> dictList = dictService.getDictByName("MATERIAL_SECT");
|
||||||
|
if (ObjectUtil.isEmpty(dictList)) {
|
||||||
|
throw new BadRequestException("字典【MATERIAL_SECT】未配置,无法校验物料类型与库区匹配关系!");
|
||||||
|
}
|
||||||
|
Map<String, String> materialSectMap = dictList.stream()
|
||||||
|
.filter(d -> ObjectUtil.isNotEmpty(d.getLabel()) && ObjectUtil.isNotEmpty(d.getValue()))
|
||||||
|
.collect(Collectors.toMap(Dict::getLabel, Dict::getValue, (a, b) -> a));
|
||||||
|
|
||||||
|
// 3) 根据组盘明细批量获取物料 -> 分类 -> 物料类型编码(class_code)
|
||||||
|
Set<String> materialIds = groupPlates.stream()
|
||||||
|
.map(GroupPlate::getMaterial_id)
|
||||||
|
.filter(ObjectUtil::isNotEmpty)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (ObjectUtil.isEmpty(materialIds)) {
|
||||||
|
throw new BadRequestException("组盘明细物料不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MdMeMaterialbase> materialList = materialbaseService.listByIds(materialIds);
|
||||||
|
Map<String, MdMeMaterialbase> materialMap = materialList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_id, Function.identity(), (a, b) -> a));
|
||||||
|
|
||||||
|
// 校验物料都存在
|
||||||
|
for (String materialId : materialIds) {
|
||||||
|
if (!materialMap.containsKey(materialId)) {
|
||||||
|
throw new BadRequestException("物料不存在【material_id=" + materialId + "】");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> classIds = materialMap.values().stream()
|
||||||
|
.map(MdMeMaterialbase::getMaterial_type_id)
|
||||||
|
.filter(ObjectUtil::isNotEmpty)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (ObjectUtil.isEmpty(classIds)) {
|
||||||
|
throw new BadRequestException("物料未配置分类(物料类型)信息,无法校验库区!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MdPbClassstandard> classList = classstandardService.listByIds(classIds);
|
||||||
|
Map<String, MdPbClassstandard> classMap = classList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(MdPbClassstandard::getClass_id, Function.identity(), (a, b) -> a));
|
||||||
|
|
||||||
|
// 4) 逐条校验:物料类型(class_code) -> 字典映射库区 是否等于 托盘库区
|
||||||
|
for (GroupPlate gp : groupPlates) {
|
||||||
|
if (ObjectUtil.isEmpty(gp) || ObjectUtil.isEmpty(gp.getMaterial_id())) {
|
||||||
|
throw new BadRequestException("组盘明细物料不能为空!");
|
||||||
|
}
|
||||||
|
MdMeMaterialbase mater = materialMap.get(gp.getMaterial_id());
|
||||||
|
if (ObjectUtil.isEmpty(mater) || ObjectUtil.isEmpty(mater.getMaterial_type_id())) {
|
||||||
|
throw new BadRequestException("物料【" + gp.getMaterial_id() + "】未配置分类(物料类型)信息!");
|
||||||
|
}
|
||||||
|
MdPbClassstandard cls = classMap.get(mater.getMaterial_type_id());
|
||||||
|
if (ObjectUtil.isEmpty(cls) || ObjectUtil.isEmpty(cls.getClass_code())) {
|
||||||
|
throw new BadRequestException("物料【" + gp.getMaterial_id() + "】分类信息异常,请检查分类表配置!");
|
||||||
|
}
|
||||||
|
|
||||||
|
String classCode = cls.getClass_code();
|
||||||
|
String expectSect = materialSectMap.get(classCode);
|
||||||
|
if (ObjectUtil.isEmpty(expectSect)) {
|
||||||
|
throw new BadRequestException("物料类型【" + classCode + "】未配置字典【MATERIAL_SECT】映射库区,无法组盘!");
|
||||||
|
}
|
||||||
|
if (!sectCode.equals(expectSect)) {
|
||||||
|
throw new BadRequestException("物料类型【" + classCode + "】只能组到库区【" + expectSect + "】,当前托盘库区为【" + sectCode + "】!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user