fix:退料/退空桶

This commit is contained in:
zhengxuming
2025-08-11 08:44:18 +08:00
parent 396ee40aec
commit 5072986d72
10 changed files with 213 additions and 32 deletions

View File

@@ -10,6 +10,7 @@ import org.nl.wms.basedata_manage.service.IStructattrService;
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo;
import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.decision_manage.service.strategyConfig.decisioner.Decisioner;
import org.nl.wms.sch_manage.enums.StatusEnum;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDis;
import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper;
import org.springframework.stereotype.Service;
@@ -36,22 +37,55 @@ public class UnpackingRuleHandler extends Decisioner<Structattr, JSONObject> {
@Override
public List<Structattr> handler(List<Structattr> list, JSONObject param) {
IOStorInvDis dis = disMapper.selectById(param.getString("dis_id"));
MdPbStoragevehicleinfo vinfo = iMdPbStoragevehicleinfoService.getByCode(dis.getStoragevehicle_code());
if (ObjectUtil.isEmpty(vinfo)) {
throw new BadRequestException("载具号【" + dis.getStoragevehicle_code() + "】未维护信息!");
MdPbStoragevehicleinfo vinfo = new MdPbStoragevehicleinfo();
if(null!=dis) {
vinfo = iMdPbStoragevehicleinfoService.getByCode(dis.getStoragevehicle_code());
if (ObjectUtil.isEmpty(vinfo)) {
throw new BadRequestException("载具号【" + dis.getStoragevehicle_code() + "】未维护信息!");
}
}
// 获取仓库中对应托盘类型的可出的空桶点位
List<Structattr> outPoints = iStructattrService.list(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getOccupancy_state, 2)
.eq(Structattr::getStoragevehicle_type, vinfo.getStoragevehicle_type())
.eq(Structattr::getLock_type, "0")
.eq(Structattr::getSect_code, param.getString("sect_code"))
.eq(Structattr::getStor_id, param.getString("stor_code"))
.isNotNull(Structattr::getStoragevehicle_code)
.isNull(Structattr::getTask_code));
if (outPoints.size() == 0) {
throw new BadRequestException("当前出库策略:解包入库,库存分配失败,失败原因:料桶缓存库无空桶!");
if(StatusEnum.IOBILL_TYPE_IN.code("余料入库").equals( param.getString("stragegyType"))){
// 获取仓库中对应托盘类型的可出的空桶点位
List<Structattr> outPoints = iStructattrService.list(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getOccupancy_state, 1)
.eq(Structattr::getLock_type, "0")
.eq(Structattr::getSect_code, param.getString("sect_code"))
.eq(Structattr::getStor_code, param.getString("stor_code"))
.isNull(Structattr::getStoragevehicle_code)
.isNull(Structattr::getTask_code));
if (outPoints.size() == 0) {
throw new BadRequestException("当前出库策略:余料入库,库存分配失败,失败原因:料桶缓存库无空位!");
}
return outPoints;
} else if(StatusEnum.IOBILL_TYPE_IN.code("空桶入库").equals( param.getString("stragegyType"))){
// 获取仓库中对应托盘类型的可出的空桶点位
List<Structattr> outPoints = iStructattrService.list(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getOccupancy_state, 1)
.eq(Structattr::getLock_type, "0")
.eq(Structattr::getSect_code, param.getString("sect_code"))
.eq(Structattr::getStor_code, param.getString("stor_code"))
.isNull(Structattr::getStoragevehicle_code)
.isNull(Structattr::getTask_code));
if (outPoints.size() == 0) {
throw new BadRequestException("当前出库策略:空桶入库,库存分配失败,失败原因:料桶缓存库无空位!");
}
return outPoints;
} else {
// 获取仓库中对应托盘类型的可出的空桶点位
List<Structattr> outPoints = iStructattrService.list(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getOccupancy_state, 2)
.eq(Structattr::getStoragevehicle_type, vinfo.getStoragevehicle_type())
.eq(Structattr::getLock_type, "0")
.eq(Structattr::getSect_code, param.getString("sect_code"))
.eq(Structattr::getStor_id, param.getString("stor_code"))
.isNotNull(Structattr::getStoragevehicle_code)
.isNull(Structattr::getTask_code));
if (outPoints.size() == 0) {
throw new BadRequestException("当前出库策略:解包入库,库存分配失败,失败原因:料桶缓存库无空桶!");
}
return outPoints;
}
return outPoints;
}
}

View File

@@ -117,6 +117,12 @@ public class MesToWmsServiceImpl implements MesToWmsService {
@Autowired
private IInBillService iRawAssistIStorService;
/**
* 基础物料服务
*/
@Autowired
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
/**
* 字典服务
*/
@@ -424,8 +430,16 @@ public class MesToWmsServiceImpl implements MesToWmsService {
if (tryLock) {
log.info("MES下发设备退料信息输入参数--------------------------------------" + MesResponse.requestOk());
if(dto.getIsManual() != null && dto.getIsManual()){
if (dto.getIsManual() != null && dto.getIsManual()) {
dto.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
//如果是手工,则需要判断是否已经组盘
List<GroupPlate> groupList = iMdPbGroupplateService.list(new QueryWrapper<GroupPlate>()
.eq("storagevehicle_code", dto.getVehicle_code())
.eq("status", IOSEnum.GROUP_PLATE_STATUS.code("组盘")));
if (CollectionUtils.isEmpty(groupList)) {
throw new BadRequestException("手工退料需要先组盘,请先组盘");
}
}
//根据料桶号去载具表匹配料桶类型
@@ -447,23 +461,34 @@ public class MesToWmsServiceImpl implements MesToWmsService {
JSONObject param = new JSONObject();
if(dto.getIsManual() != null && dto.getIsManual()){
param.put("create_mode", "手动" );
param.put("is_manual", true);
} else{
param.put("create_mode", "自动" );
}
param.put("task_code", dto.getTask_code());
//退料
if("1".equals(dto.getTask_type())){
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getByCode(dto.getMaterial_code(), true);
param.put("sect_code",sectattr.getSect_code());
param.put("sect_id",sectattr.getSect_id());
param.put("vehicle_code",dto.getVehicle_code());
param.put("storagevehicle_code", param.getString("vehicle_code"));
param.put("qty","1");
param.put("site_code",dto.getDevice_code());
param.put("material_id",materDao.getMaterial_code());
param.put("material_code",materDao.getMaterial_code());
param.put("pcsn",dto.getPcsn());
param.put("qty",dto.getQty());
param.put("qty_unit_name",dto.getQty_unit_name());
param.put("stor_id",sectattr.getStor_id());
pdaIosInService.confirmReturnMaterial(param);
param.put("supp_code",dto.getSupp_code());
param.put("supp_name",dto.getSupp_name());
pdaIosInService.zwConfirmReturnMaterial(param);
} else if("2".equals(dto.getTask_type())){
//退空桶
param.put("vehicle_code",dto.getVehicle_code());
param.put("storagevehicle_code", param.getString("vehicle_code"));
param.put("site_code",dto.getDevice_code());
param.put("sect_id",sectattr.getSect_id());
param.put("sect_code",sectattr.getSect_code());

View File

@@ -161,6 +161,17 @@ public interface PdaIosInService {
*/
PdaResponse confirmReturnMaterial(JSONObject whereJson);
/**
* 余料回库确认
*
* @param whereJson {
* vehicle_code载具编码
* sect_code库区
* }
* @return PdaResponse
*/
PdaResponse zwConfirmReturnMaterial(JSONObject whereJson);
/**
* 空载具入库确认

View File

@@ -232,7 +232,7 @@ public class PdaIosInServiceImpl implements PdaIosInService {
GroupPlate groupDao = GroupPlate.builder()
.group_id(IdUtil.getStringId())
.material_id(materDao.getMaterial_code())
.material_id(materDao.getMaterial_id())
.storagevehicle_code(vehicleDao.getStoragevehicle_code())
.pcsn(pcsn)
.qty_unit_id(unitDao.getMeasure_unit_id())
@@ -242,6 +242,8 @@ public class PdaIosInServiceImpl implements PdaIosInService {
.ext_code(whereJson.getString("ext_code"))
.create_id(SecurityUtils.getCurrentUserId())
.create_name(SecurityUtils.getCurrentNickName())
.supp_code(whereJson.getString("supp_code"))
.supp_name(whereJson.getString("supp_name"))
.create_time(DateUtil.now())
.build();
@@ -438,6 +440,59 @@ public class PdaIosInServiceImpl implements PdaIosInService {
return PdaResponse.requestOk();
}
/**
* 余料回库确认
*
* @param whereJson {
* vehicle_code载具编码
* sect_code库区
* }
* @return PdaResponse
*/
@Override
@Transactional
public PdaResponse zwConfirmReturnMaterial(JSONObject whereJson) {
// 生成回库任务
whereJson.put("config_code", IOSConstant.BACK_IN_TASK);
whereJson.put("Priority", TaskEnum.ACS_PRIORITY.code("1"));
//入库分配
//手工的,需要更新组盘表
if(!whereJson.containsKey("is_manual") || !whereJson.getBoolean("is_manual")){
groupPlate(whereJson);
}
whereJson.put("bill_type",StatusEnum.IOBILL_TYPE_IN.code("余料入库"));
whereJson.put("stragegy_type",StatusEnum.IOBILL_TYPE_IN.code("余料入库"));
//获取起点
SchBasePoint schBasePoint = iSchBasePointService
.getOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getVehicle_code, whereJson.getString("vehicle_code")));
if (ObjectUtil.isEmpty(schBasePoint)) {
throw new BadRequestException("未找到载具所在的点位信息,请检查该载具是否绑定点位");
}
whereJson.put("point_code",whereJson.getString("site_code"));
// 预组织出入库单据实体
Map<String, Object> jsonMst = organizeInsertData(whereJson);
// 调用服务新增出入库单
String iostorinv_id = iRawAssistIStorService.insertDtl(jsonMst);
// 预组织出入库单据明细的分配数据
whereJson.put("iostorinv_id", iostorinv_id);
Map<String, Object> jsonDtl = organizeDivData(whereJson);
jsonDtl.put("stragegy_type",StatusEnum.IOBILL_TYPE_IN.code("余料入库"));
// 调用分配,默认自动分配库位
iRawAssistIStorService.divStruct(new JSONObject(jsonDtl));
// 下发任务
sendTask(whereJson);
//更新组盘表状态
mdPbGroupplateMapper.update(new GroupPlate(), new LambdaUpdateWrapper<GroupPlate>()
.set(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
.eq(GroupPlate::getStoragevehicle_code, whereJson.getString("storagevehicle_code"))
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("组盘")));
return PdaResponse.requestOk();
}
@Override
@Transactional
public PdaResponse vehicleInConfirm(JSONObject whereJson) {
@@ -448,7 +503,6 @@ public class PdaIosInServiceImpl implements PdaIosInService {
throw new BadRequestException("库区" + whereJson.getString("sect_code") +"不存在");
}
whereJson.put("stor_id",sectattr.getStor_id());
whereJson.put("qty", 1);
//得到当前点位的载具编号
List<SchBasePoint> schBasePointList = iSchBasePointService.list(new LambdaQueryWrapper<SchBasePoint>()
@@ -478,12 +532,14 @@ public class PdaIosInServiceImpl implements PdaIosInService {
whereJson.put("pcsn", "空料桶入库");
}
//组盘
groupPlate(whereJson);
// 生成空载具入库任务
whereJson.put("config_code", IOSConstant.VEHICLE_IN_TASK);
whereJson.put("qty", "1");
whereJson.put("vehicle_code", whereJson.getString("vehicle_code"));
whereJson.put("Priority", TaskEnum.ACS_PRIORITY.code("1"));
whereJson.put("stragegy_type", StatusEnum.IOBILL_TYPE_IN.code("空桶入库"));
//组盘
groupPlate(whereJson);
//入库分配
divStructNoBills(whereJson);
return PdaResponse.requestOk();
@@ -513,6 +569,7 @@ public class PdaIosInServiceImpl implements PdaIosInService {
params.put("material_code", whereJson.getString("material_code"));
params.put("qty", whereJson.getString("qty"));
params.put("pcsn", whereJson.getString("pcsn"));
params.put("stragegy_type", whereJson.getString("stragegy_type"));
Structattr attrDao = iRawAssistIStorService.getStructattr(params);
//确定起点
SchBasePoint schBasePoint = iSchBasePointService.getOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, whereJson.getString("site_code")));
@@ -528,6 +585,7 @@ public class PdaIosInServiceImpl implements PdaIosInService {
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.set(SchBasePoint::getIos_id, null)
.set(SchBasePoint::getIng_task_code, taskId)
.eq(SchBasePoint::getPoint_code, schBasePoint.getPoint_code())
);
// 更新终点锁定状态
@@ -991,8 +1049,10 @@ public class PdaIosInServiceImpl implements PdaIosInService {
jsonMst.put("bill_status", IOSEnum.BILL_STATUS.code("生成"));
jsonMst.put("total_qty", total_qty);
jsonMst.put("detail_count", 1);
if(!jsonMst.containsKey("bill_type")) {
if(!whereJson.containsKey("bill_type")) {
jsonMst.put("bill_type", StatusEnum.IOBILL_TYPE_IN.code("来料入库"));
} else{
jsonMst.put("bill_type", whereJson.getString("bill_type"));
}
jsonMst.put("biz_date", DateUtil.now());
// 组织明细数据

View File

@@ -29,7 +29,7 @@ public enum StatusEnum {
*/
IOBILL_TYPE_IN(ForkMap.of("生产入库", "10", "inStorageTask", "调拨入库", "11", "inStorageTask", "退货入库", "12", "inStorageTask", "拣选回库",
"13", "inStorageTask", "盘点入库", "14", "inStorageTask", "托盘入库", "30", "inStorageTask", "二楼CTU入库", "80", "inStorageTask","来料入库",
"1013", "inStorageTask", "解包退回", "0012", "inStorageTask" , "解包入库", "0011", "inStorageTask")),
"1013", "inStorageTask", "解包退回", "0012", "inStorageTask" , "解包入库", "0011", "inStorageTask", "余料入库", "0014", "inStorageTask", "空桶入库", "0015", "inStorageTask")),
IOBILL_TYPE_OUT(ForkMap.of("销售出库", "20", "outStorageTask", "生产出库", "21", "outStorageTask", "调拨出库", "22", "outStorageTask",
"拣选出库", "23", "conveyorOutStorageTask", "盘点出库", "24", "outStorageTask", "出库拣选", "25", "toPickPlatformTask",
"退货出库", "26", "outStorageTask", "托盘出库", "40", "outStorageTask", "二楼CTU出库", "81", "inStorageTask", "二楼出库AGV搬运",
@@ -98,7 +98,7 @@ public enum StatusEnum {
"解绑", "0", null, "绑定", "1", null, "不操作", "3", null
)),
VEHICLE_TYPE(ForkMap.of(
"空托盘", "KT001", null, "空料箱", "KL001", null
"空托盘", "KT001", null, "空料箱", "KL001", null, "空料桶", "KLT001", null
));
/**

View File

@@ -3,6 +3,7 @@ package org.nl.wms.sch_manage.service.util.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
@@ -20,6 +21,8 @@ import org.nl.wms.sch_manage.service.util.AbstractTask;
import org.nl.wms.sch_manage.service.util.AcsTaskDto;
import org.nl.wms.sch_manage.service.util.TaskType;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -59,6 +62,9 @@ public class BackInTask extends AbstractTask {
@Autowired
private WmsToMesService wmsToMesService;
@Resource
private IMdPbGroupplateService iMdPbGroupplateService;
@Override
public String create(JSONObject json) {
@@ -155,15 +161,25 @@ public class BackInTask extends AbstractTask {
.eq(Structattr::getStruct_code, taskObj.getPoint_code2())
.set(Structattr::getStoragevehicle_code, taskObj.getVehicle_code())
.set(Structattr::getTask_code, null)
.set(Structattr::getOccupancy_state,"3")
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
);
// 更新起点
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
.set(SchBasePoint::getVehicle_code, null)
.set(SchBasePoint::getIos_id, null)
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
.set(SchBasePoint::getIng_task_code, null)
.set(SchBasePoint::getPoint_status,"1")
.set(SchBasePoint::getVehicle_code, null)
.set(SchBasePoint::getIos_id, null)
);
//更新组盘表
iMdPbGroupplateService.update(new GroupPlate(), new LambdaUpdateWrapper<GroupPlate>()
.set(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
.eq(GroupPlate::getStoragevehicle_code, taskObj.getVehicle_code())
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("组盘")));
// 更新任务
taskObj.setRemark("已完成");
taskObj.setTask_status(TaskStatus.FINISHED.getCode());

View File

@@ -162,6 +162,7 @@ public class VehicleInTask extends AbstractTask {
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
.set(SchBasePoint::getVehicle_code, null)
.set(SchBasePoint::getIos_id, null)
.set(SchBasePoint::getPoint_status,"1")
);
// 更新任务
taskObj.setRemark("已完成");

View File

@@ -160,6 +160,14 @@ public class VehicleOutTask extends AbstractTask {
.eq(Structattr::getStruct_code, taskObj.getPoint_code1())
.set(Structattr::getOccupancy_state, 1)
);
// 更新终点
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
.set(SchBasePoint::getVehicle_code, null)
.set(SchBasePoint::getIos_id, null)
.set(SchBasePoint::getPoint_status,"2"));
}
@Transactional(rollbackFor = Exception.class)

View File

@@ -20,7 +20,7 @@ public class MesManualBackMaterialRequestDto {
private String qty_unit_name;
@NotBlank(message = "数量不可为空")
private String qty;

View File

@@ -32,6 +32,7 @@ import org.nl.wms.sch_manage.enums.StatusEnum;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
import org.nl.wms.sch_manage.service.util.tasks.BackInTask;
import org.nl.wms.sch_manage.service.util.tasks.StInTask;
import org.nl.wms.sch_manage.service.util.tasks.jb.JbBackAgvTask;
import org.nl.wms.sch_manage.service.util.tasks.jb.JbDownAgvTask;
@@ -99,6 +100,9 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
@Resource
private InBillTask inBillTask;
@Resource
private BackInTask backInTask;
@Override
public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page) {
HashMap<String, String> map = new HashMap<>();
@@ -373,6 +377,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
.qty(new BigDecimal(param.getString("qty")))
.pcsn(param.getString("pcsn"))
.dis_id(map.get("iostorinvdis_id"))
.stragegyType(param.getString("stragegy_type"))
.build());
Structattr struct = structattrs.get(0);
sect_id = struct.getSect_id();
@@ -583,6 +588,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
.material_code(param.getString("material_code"))
.qty(new BigDecimal(param.getString("qty")))
.pcsn(param.getString("pcsn"))
.stragegyType(param.getString("stragegy_type"))
.build());
if (CollectionUtils.isEmpty(structattrs)) {
throw new BadRequestException("无可用货位");
@@ -776,9 +782,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
} else if (StatusEnum.IOBILL_TYPE_IN.code("来料入库").equals(invObj.getBill_type())) {
// 获取组盘信息
GroupPlate groupPlate = mdPbGroupplateService.getOne(new LambdaQueryWrapper<GroupPlate>()
.eq(GroupPlate::getStoragevehicle_code, whereJson.get("vehicle_code"))
.eq(GroupPlate::getStoragevehicle_code, ioStorInvDis.getStoragevehicle_code())
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库")));
JSONObject task = new JSONObject();
task.put("config_code", IOSConstant.IN_BILL_TASK);
task.put("group_id", groupPlate.getGroup_id());
@@ -797,6 +802,27 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
task.put("vehicle_code", ioStorInvDis.getStoragevehicle_code());
task.put("vehicle_code2", whereJson.get("vehicle_code"));
task_id = inBillTask.create(task);
} else if (StatusEnum.IOBILL_TYPE_IN.code("余料入库").equals(invObj.getBill_type())) {
// 获取组盘信息
GroupPlate groupPlate = mdPbGroupplateService.getOne(new LambdaQueryWrapper<GroupPlate>()
.eq(GroupPlate::getStoragevehicle_code, ioStorInvDis.getStoragevehicle_code())
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库")));
JSONObject task = new JSONObject();
task.put("config_code", IOSConstant.BACK_IN_TASK);
task.put("group_id", groupPlate.getGroup_id());
task.put("priority",whereJson.get("priority"));
task.put("task_group_seq",whereJson.get("task_group_seq"));
task.put("task_group_id",whereJson.get("task_group_id"));
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
task.put("point_code1",whereJson.get("point_code"));
task.put("point_code2", ioStorInvDis.getStruct_code());
task.put("form_data_code", whereJson.get("form_data_code"));
//第一个载具为计算得到的,第二个载具为起始点载具
task.put("vehicle_code", ioStorInvDis.getStoragevehicle_code());
task_id = backInTask.create(task);
} else {
//创建任务
JSONObject task_form = new JSONObject();