rev:MES接口

This commit is contained in:
2026-06-23 10:42:13 +08:00
parent 047663f37c
commit 7c367b3cdf
7 changed files with 142 additions and 6 deletions

View File

@@ -19,4 +19,6 @@ public interface StructattrMapper extends BaseMapper<Structattr>{
List<StructattrVechielDto> collectVehicleNoGroup(Map query);
List<Map<String, Object>> queryEmptyLocation();
}

View File

@@ -87,4 +87,20 @@
</if>
</where>
</select>
<select id="queryEmptyLocation" resultType="java.util.Map">
SELECT DISTINCT
ivt.struct_code,
ivt.struct_name
FROM st_ivt_structattr ivt
<where>
ivt.is_used = 1
AND ivt.lock_type = '0'
AND ivt.occupancy_state = 1
AND (ivt.storagevehicle_code IS NULL OR ivt.storagevehicle_code = '')
AND (ivt.task_code IS NULL OR ivt.task_code = '')
AND ivt.stor_code = 'LT'
</where>
ORDER BY ivt.struct_code
</select>
</mapper>

View File

@@ -58,6 +58,13 @@ public class MesToWmsController {
return new ResponseEntity<>(mesToWmsService.getStructivt(whereJson), HttpStatus.OK);
}
@PostMapping("/getLocation")
@Log("查询空仓位")
@SaIgnore
public ResponseEntity<Object> getLocation() {
return new ResponseEntity<>(mesToWmsService.getLocation(), HttpStatus.OK);
}
@PostMapping("/updateTask")
@Log("修改任务")

View File

@@ -34,4 +34,9 @@ public class MesBackMaterialRequestDto {
*
*/
private Boolean mes_is_manual;
/**
* 手工或AGV任务都可以指定库位
*/
private String struct_code;
}

View File

@@ -36,6 +36,13 @@ public interface MesToWmsService {
*/
MesResponse getStructivt(JSONObject whereJson);
/**
* MES 查询空仓位
* @param whereJson
* @return MesResponse
*/
MesResponse getLocation();
/**
* MES 更新任务
* @param

View File

@@ -23,6 +23,7 @@ import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo;
import org.nl.wms.basedata_manage.service.dao.Sectattr;
import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
import org.nl.wms.basedata_manage.service.dao.mapper.StructattrMapper;
import org.nl.wms.ext_manage.dto.mes.MesBackMaterialRequestDto;
import org.nl.wms.ext_manage.dto.mes.MesCallMaterialRequestDto;
import org.nl.wms.ext_manage.dto.mes.MesResponse;
@@ -83,6 +84,9 @@ public class MesToWmsServiceImpl implements MesToWmsService {
@Autowired
private IStructattrService structattrService;
@Resource
private StructattrMapper structattrMapper;
@Autowired
private ISectattrService sectattrService;
@@ -504,6 +508,8 @@ public class MesToWmsServiceImpl implements MesToWmsService {
throw new BadRequestException("未找到载具编码为" + point.getVehicle_code() + "的载具入库库区,请检查字典中" + dict.getCode() + "是否维护参数1");
}
Structattr targetStruct = resolveBackTargetStruct(dto, sectattr);
JSONObject param = new JSONObject();
if (dto.getIsManual() != null && dto.getIsManual()) {
param.put("create_mode", IOSEnum.CREATE_MODE.code("手动"));
@@ -514,6 +520,13 @@ public class MesToWmsServiceImpl implements MesToWmsService {
param.put("mes_is_manual",dto.getMes_is_manual());
param.put("ext_task_code", dto.getTask_code());
param.put("struct_id", targetStruct.getStruct_id());
param.put("struct_code", targetStruct.getStruct_code());
param.put("struct_name", targetStruct.getStruct_name());
param.put("sect_id", targetStruct.getSect_id());
param.put("sect_code", targetStruct.getSect_code());
param.put("stor_id", targetStruct.getStor_id());
param.put("stor_code", targetStruct.getStor_code());
//退料
if ("1".equals(dto.getTask_type())) {
//查询组盘
@@ -535,8 +548,6 @@ public class MesToWmsServiceImpl implements MesToWmsService {
MdMeMaterialbase materDao = materialbaseService.getByCode(groupPlate.getMaterial_id(), true);
//通过托盘号查找组盘信息
param.put("sect_code", sectattr.getSect_code());
param.put("sect_id", sectattr.getSect_id());
param.put("vehicle_code", point.getVehicle_code());
param.put("storagevehicle_code", param.getString("vehicle_code"));
param.put("site_code", pointCode);
@@ -546,7 +557,6 @@ public class MesToWmsServiceImpl implements MesToWmsService {
param.put("group_id", groupPlate.getGroup_id());
param.put("qty", dto.getQty());
param.put("qty_unit_name", groupPlate.getQty_unit_name());
param.put("stor_id", sectattr.getStor_id());
param.put("supp_code", groupPlate.getSupp_code());
param.put("supp_name", groupPlate.getSupp_name());
return MesResponse.requestParamOk(pdaIosInService.zwConfirmReturnMaterial(param));
@@ -556,8 +566,6 @@ public class MesToWmsServiceImpl implements MesToWmsService {
param.put("vehicle_code", point.getVehicle_code());
param.put("storagevehicle_code", param.getString("vehicle_code"));
param.put("site_code", pointCode);
param.put("sect_id", sectattr.getSect_id());
param.put("sect_code", sectattr.getSect_code());
param.put("back_material_flag", true);
pdaIosInService.vehicleInConfirm(param);
} else {
@@ -576,11 +584,71 @@ public class MesToWmsServiceImpl implements MesToWmsService {
}
}
private Structattr resolveBackTargetStruct(MesBackMaterialRequestDto dto, Sectattr defaultSect) {
boolean mesManual = Boolean.TRUE.equals(dto.getMes_is_manual());
String structCode = StringUtils.trimToEmpty(dto.getStruct_code());
if (mesManual && StringUtils.isBlank(structCode)) {
throw new BadRequestException("人工搬运时目标仓位struct_code不可为空");
}
if (!mesManual && StringUtils.isBlank(structCode)) {
return findAvailableTargetStruct(defaultSect.getSect_code(), Collections.singleton("LT"), Collections.singleton("LTXN"));
}
Structattr targetStruct = structattrService.getOne(new QueryWrapper<Structattr>()
.eq("struct_code", structCode)
.eq("is_used", 1)
.eq("lock_type", "0")
.eq("occupancy_state", 1)
.and(wrapper -> wrapper.isNull("task_code").or().eq("task_code", ""))
.and(wrapper -> wrapper.isNull("storagevehicle_code").or().eq("storagevehicle_code", "")));
if (ObjectUtil.isEmpty(targetStruct)) {
throw new BadRequestException("目标仓位【" + structCode + "】不是可入库空仓位,请核对!");
}
if (!mesManual) {
if (!"LT".equals(targetStruct.getStor_code())) {
throw new BadRequestException("AGV搬运时目标仓位【" + structCode + "】只能属于料筒库(LT)");
}
if ("LTXN".equals(targetStruct.getSect_code())) {
throw new BadRequestException("AGV搬运时目标仓位【" + structCode + "】不能属于虚拟区(LTXN)");
}
}
return targetStruct;
}
private Structattr findAvailableTargetStruct(String sectCode, Set<String> allowStorCodes, Set<String> excludeSectCodes) {
QueryWrapper<Structattr> queryWrapper = new QueryWrapper<Structattr>()
.eq("is_used", 1)
.eq("lock_type", "0")
.eq("occupancy_state", 1)
.eq("sect_code", sectCode)
.in("stor_code", allowStorCodes)
.and(wrapper -> wrapper.isNull("task_code").or().eq("task_code", ""))
.and(wrapper -> wrapper.isNull("storagevehicle_code").or().eq("storagevehicle_code", ""))
.last("order by struct_code limit 1");
if (excludeSectCodes != null && !excludeSectCodes.isEmpty()) {
queryWrapper.notIn("sect_code", excludeSectCodes);
}
Structattr targetStruct = structattrService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(targetStruct)) {
throw new BadRequestException("当前库区【" + sectCode + "】无可用空仓位,请核对!");
}
return targetStruct;
}
@Override
public MesResponse getStructivt(JSONObject whereJson) {
return MesResponse.requestParamOk(mdPbStoragevehicleextMapper.queryAllIn(whereJson));
}
@Override
public MesResponse getLocation() {
return MesResponse.requestParamOk(structattrMapper.queryEmptyLocation());
}
@Override
public MesResponse getTaskList(MesUpdateTaskDto dto) {
return MesResponse.requestParamOk(iSchBaseTaskService.list(new LambdaQueryWrapper<SchBaseTask>()

View File

@@ -821,7 +821,12 @@ public class PdaIosInServiceImpl implements PdaIosInService {
params.put("pcsn", whereJson.getString("pcsn"));
params.put("stragegy_type", whereJson.getString("stragegy_type"));
params.put("is_empty_vehicle", true);
Structattr attrDao = iRawAssistIStorService.getStructattr(params);
Structattr attrDao;
if (StringUtils.isNotBlank(whereJson.getString("struct_code"))) {
attrDao = getSpecifiedTargetStruct(whereJson);
} else {
attrDao = iRawAssistIStorService.getStructattr(params);
}
//确定起点
SchBasePoint schBasePoint = iSchBasePointService.getOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, whereJson.getString("site_code")));
if (ObjectUtil.isEmpty(schBasePoint)) {
@@ -1310,11 +1315,37 @@ public class PdaIosInServiceImpl implements PdaIosInService {
disDtl.forEach(item -> {
tableMater.add(JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class));
});
if (StringUtils.isNotBlank(whereJson.getString("struct_code")) && !tableMater.isEmpty()) {
Structattr targetStruct = getSpecifiedTargetStruct(whereJson);
jsonMst.put("checked", false);
LinkedHashMap<String, Object> row = tableMater.get(0);
row.put("sect_id", targetStruct.getSect_id());
row.put("sect_code", targetStruct.getSect_code());
row.put("sect_name", targetStruct.getSect_name());
row.put("struct_id", targetStruct.getStruct_id());
row.put("struct_code", targetStruct.getStruct_code());
row.put("struct_name", targetStruct.getStruct_name());
}
jsonMst.put("tableMater", tableMater);
return jsonMst;
}
private Structattr getSpecifiedTargetStruct(JSONObject whereJson) {
String structCode = whereJson.getString("struct_code");
Structattr targetStruct = iStructattrService.getOne(new QueryWrapper<Structattr>()
.eq("struct_code", structCode)
.eq("is_used", 1)
.eq("lock_type", "0")
.eq("occupancy_state", 1)
.and(wrapper -> wrapper.isNull("task_code").or().eq("task_code", ""))
.and(wrapper -> wrapper.isNull("storagevehicle_code").or().eq("storagevehicle_code", "")));
if (ObjectUtil.isEmpty(targetStruct)) {
throw new BadRequestException("目标仓位【" + structCode + "】不是可入库空仓位,请核对!");
}
return targetStruct;
}
/**
* 下发任务
* @param whereJson {