diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml index ac5c249..a180d01 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/basedata_manage/service/dao/mapper/MdPbStoragevehicleextMapper.xml @@ -205,12 +205,17 @@ INNER JOIN st_ivt_structattr attr ON ext.storagevehicle_code = attr.storagevehicle_code INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id - 1 = 1 and ext.`status`='01' + 1 = 1 and ext.`status`='02' AND attr.stor_id = #{param.stor_id} + + AND + ext.group_id = #{param.storagevehicleext_id} + + AND attr.stor_code = #{param.stor_code} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/dto/mes/MesCallMaterialRequestDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/dto/mes/MesCallMaterialRequestDto.java index cfc89da..7c27e46 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/dto/mes/MesCallMaterialRequestDto.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/dto/mes/MesCallMaterialRequestDto.java @@ -7,26 +7,10 @@ public class MesCallMaterialRequestDto { @NotBlank(message = "设备号不可为空") private String device_code; - @NotBlank(message = "货位号不可为空") - private String struct_code; - - @NotBlank(message = "物料编码不可为空") - private String material_code; - - @NotBlank(message = "料桶号不可为空") - private String vehicle_code; @NotBlank(message = "组盘标识不可为空") private String storagevehicleext_id; - @NotBlank(message = "物料编码不可为空") - private String pcsn; - - private String qty_unit_name; - - private String qty; - - private String remark; @NotBlank(message = "任务号不可为空") private String task_code; @@ -34,12 +18,6 @@ public class MesCallMaterialRequestDto { @NotBlank(message = "任务类型不可为空") private String task_type; - @NotBlank(message = "供应商编码不可为空") - private String supp_code; - - @NotBlank(message = "供应商名称不可为空") - private String supp_name; - /** * 是否是人工发起,如果是,则不需要反馈给MES * diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java index 23336dc..345fa6c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java @@ -27,6 +27,7 @@ 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; import org.nl.wms.ext_manage.service.MesToWmsService; +import org.nl.wms.ext_manage.service.util.AcsResponse; import org.nl.wms.pda_manage.ios_manage.service.PdaIosInService; import org.nl.wms.sch_manage.enums.StatusEnum; import org.nl.wms.sch_manage.enums.TaskStatus; @@ -136,10 +137,19 @@ public class MesToWmsServiceImpl implements MesToWmsService { public MesResponse callMaterial(MesCallMaterialRequestDto dto) { log.info("MES下发设备叫料信息输入参数:-------------------: {}", dto); - if(dto.getIsManual() != null && dto.getIsManual()){ + if (dto.getIsManual() != null && dto.getIsManual()) { dto.setTask_code(CodeUtil.getNewCode("TASK_CODE")); } + JSONObject whereJson = new JSONObject(); + whereJson.put("storagevehicleext_id", dto.getStoragevehicleext_id()); + List jsonObjectList = mdPbStoragevehicleextMapper.queryAllIn(whereJson); + if (CollectionUtils.isEmpty(jsonObjectList)) { + throw new BadRequestException("组盘ID有误!"); + } + + GroupPlate groupPlate = JSONObject.toJavaObject(jsonObjectList.get(0), GroupPlate.class); + RLock lock = redissonClient.getLock(dto.getTask_code()); boolean tryLock = lock.tryLock(1, TimeUnit.SECONDS); try { @@ -151,24 +161,24 @@ public class MesToWmsServiceImpl implements MesToWmsService { throw new BadRequestException("设备【" + pointCode + "】不存在!"); } - if(!"1".equals(outPoint.getPoint_type())){ - throw new BadRequestException("设备【" + dto.getStruct_code() + "】有误,请传入作业区设备!"); + if (!"1".equals(outPoint.getPoint_type())) { + throw new BadRequestException("设备【" + groupPlate.getStruct_code() + "】有误,请传入作业区设备!"); } // 出库的仓位 - Structattr outStructAttr = structattrService.getByCode(dto.getStruct_code()); + Structattr outStructAttr = structattrService.getByCode(groupPlate.getStruct_code()); if (ObjectUtil.isEmpty(outStructAttr)) { - throw new BadRequestException("仓位【" + dto.getStruct_code() + "】不存在!"); + throw new BadRequestException("仓位【" + groupPlate.getStruct_code() + "】不存在!"); } - if(3 != outStructAttr.getOccupancy_state()|| StringUtils.isBlank(outStructAttr.getStoragevehicle_code())){ - throw new BadRequestException("仓位【" + dto.getStruct_code() + "】上没有料,无法叫料!"); + if (3 != outStructAttr.getOccupancy_state() || StringUtils.isBlank(outStructAttr.getStoragevehicle_code())) { + throw new BadRequestException("仓位【" + groupPlate.getStruct_code() + "】上没有料,无法叫料!"); } - //只有料桶缓存库区的料才能被叫料 - if(!"LT".equals(outStructAttr.getStor_code())){ - throw new BadRequestException("只有料桶缓存库区的料才能被叫料!"); - } + //只有料桶缓存库区的料才能被叫料 + if (!"LT".equals(outStructAttr.getStor_code())) { + throw new BadRequestException("只有料桶缓存库区的料才能被叫料!"); + } List taskList = taskService.list(new QueryWrapper().lambda() .eq(SchBaseTask::getExt_task_code, dto.getTask_code())); @@ -180,13 +190,13 @@ public class MesToWmsServiceImpl implements MesToWmsService { //根据料桶号去载具表匹配料桶类型 MdPbStoragevehicleinfo mdPbStoragevehicleinfo = iMdPbStoragevehicleinfoService.getByCode(outStructAttr.getStoragevehicle_code()); - if(mdPbStoragevehicleinfo == null){ + if (mdPbStoragevehicleinfo == null) { throw new BadRequestException("未找到" + outStructAttr.getStruct_code() + "点位上的的载具!"); } //通过料桶号的料桶类型,匹配确认入库库区 - Dict dict= dictService.getDictByCodeAndValue("storagevehicle_type",mdPbStoragevehicleinfo.getStoragevehicle_type()); - if(dict==null){ + Dict dict = dictService.getDictByCodeAndValue("storagevehicle_type", mdPbStoragevehicleinfo.getStoragevehicle_type()); + if (dict == null) { throw new BadRequestException("未找到载具编码为" + outStructAttr.getStoragevehicle_code() + "的载具库区,请检查字典中是否维护!只允许料桶叫料!"); } @@ -198,33 +208,27 @@ public class MesToWmsServiceImpl implements MesToWmsService { } //1、单独上料,2、下空桶上满料 - if("1".equals(dto.getTask_type())){ + if ("1".equals(dto.getTask_type())) { log.info("单独上料叫料,请求参数:【{}】", JSONObject.toJSONString(dto)); //判断点位和仓位是否有正在执行的任务 List schBaseTaskList = iSchBaseTaskService.list(new LambdaQueryWrapper() .eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO) - .and(wp -> wp + .and(wp -> wp .eq(SchBaseTask::getPoint_code2, pointCode) .or() - .eq(SchBaseTask::getPoint_code1, dto.getStruct_code()) + .eq(SchBaseTask::getPoint_code1, groupPlate.getStruct_code()) ) .le(SchBaseTask::getTask_status, TaskStatus.EXECUTING.getCode())); - if(CollectionUtils.isNotEmpty(schBaseTaskList)){ + if (CollectionUtils.isNotEmpty(schBaseTaskList)) { throw new BadRequestException("存在正在执行的点位,请核对!"); } - MdMeMaterialbase materialbase = materialbaseService.getByCode(dto.getMaterial_code(),false); + MdMeMaterialbase materialbase = materialbaseService.getByCode(groupPlate.getMaterial_code(), false); if (ObjectUtil.isEmpty(materialbase)) { - throw new BadRequestException("物料【" + dto.getMaterial_code() + "】不存在!"); - } - GroupPlate groupPlate = iMdPbGroupplateService.getOne(new LambdaQueryWrapper() - .eq(GroupPlate::getStoragevehicle_code, outStructAttr.getStoragevehicle_code()) - .eq(GroupPlate::getStatus, "02")); - if (ObjectUtil.isEmpty(groupPlate)) { - throw new BadRequestException("托盘[" + outStructAttr.getStoragevehicle_code() + "]组盘信息不存在!"); + throw new BadRequestException("物料【" + groupPlate.getMaterial_code() + "】不存在!"); } - if(!"1".equals(outPoint.getPoint_status())){ + if (!"1".equals(outPoint.getPoint_status())) { throw new BadRequestException("设备【" + outPoint.getPoint_code() + "】有托盘或有料,请执行下空桶上满料!"); } @@ -288,20 +292,20 @@ public class MesToWmsServiceImpl implements MesToWmsService { // 创建任务 JSONObject taskParam = new JSONObject(); taskParam.put("iostorinv_id", invId); - taskParam.put("point_code", dto.getStruct_code()); - taskParam.put("point_code2", pointCode ); - taskParam.put("group_id", groupPlate.getGroup_id() ); - taskParam.put("task_code", dto.getTask_code() ); - if(dto.getIsManual() != null && dto.getIsManual()){ - taskParam.put("create_mode", "手动" ); - } else{ - taskParam.put("create_mode", "自动" ); + taskParam.put("point_code", groupPlate.getStruct_code()); + taskParam.put("point_code2", pointCode); + taskParam.put("group_id", groupPlate.getGroup_id()); + taskParam.put("task_code", dto.getTask_code()); + if (dto.getIsManual() != null && dto.getIsManual()) { + taskParam.put("create_mode", "手动"); + } else { + taskParam.put("create_mode", "自动"); } outBillService.allSetPoint(taskParam); return MesResponse.requestOk(); - } else if("2".equals(dto.getTask_type())){ + } else if ("2".equals(dto.getTask_type())) { - if(StringUtils.isBlank(outPoint.getVehicle_code())){ + if (StringUtils.isBlank(outPoint.getVehicle_code())) { throw new BadRequestException("设备【" + pointCode + "】不存在料桶,请核对!"); } @@ -322,15 +326,15 @@ public class MesToWmsServiceImpl implements MesToWmsService { //得到作业区下面的两个 List sonSchBasePointList = pointService.getSonPointList(queryPoint); - if(!(sonSchBasePointList!=null&&sonSchBasePointList.size()==2)){ - throw new BadRequestException("作业位"+ outPoint.getPoint_code()+"的周转位不为2个,请核对!"); + if (!(sonSchBasePointList != null && sonSchBasePointList.size() == 2)) { + throw new BadRequestException("作业位" + outPoint.getPoint_code() + "的周转位不为2个,请核对!"); } //判断点位和仓位是否有正在执行的任务 List schBaseTaskList = iSchBaseTaskService.list(new LambdaQueryWrapper() .eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO) .and(wp -> wp - .eq(SchBaseTask::getPoint_code1, dto.getStruct_code()) + .eq(SchBaseTask::getPoint_code1, groupPlate.getStruct_code()) .or() .eq(SchBaseTask::getPoint_code2, dto.getDevice_code()) .or() @@ -343,19 +347,14 @@ public class MesToWmsServiceImpl implements MesToWmsService { throw new BadRequestException("存在正在执行的点位,请核对!"); } - MdMeMaterialbase materialbase = materialbaseService.getByCode(dto.getMaterial_code(),false); + MdMeMaterialbase materialbase = materialbaseService.getByCode(groupPlate.getMaterial_code(), false); if (ObjectUtil.isEmpty(materialbase)) { - throw new BadRequestException("物料【" + dto.getMaterial_code() + "】不存在!"); + throw new BadRequestException("物料【" + groupPlate.getMaterial_code() + "】不存在!"); } - if("1".equals(outPoint.getPoint_status())){ - throw new BadRequestException("设备【" + dto.getStruct_code() + "】是空位,请执行单独上料!"); - } - GroupPlate groupPlate = iMdPbGroupplateService.getOne(new LambdaQueryWrapper() - .eq(GroupPlate::getStoragevehicle_code, outStructAttr.getStoragevehicle_code()) - .eq(GroupPlate::getStatus, "02")); - if (ObjectUtil.isEmpty(groupPlate)) { - throw new BadRequestException("托盘[" + outStructAttr.getStoragevehicle_code() + "]组盘信息不存在!"); + if ("1".equals(outPoint.getPoint_status())) { + throw new BadRequestException("设备【" + groupPlate.getStruct_code() + "】是空位,请执行单独上料!"); } + // 1、创建出库单、明细、分配明细 JSONObject insertInvObj = new JSONObject(); JSONArray tableData = new JSONArray(); @@ -416,16 +415,16 @@ public class MesToWmsServiceImpl implements MesToWmsService { // 创建任务 JSONObject taskParam = new JSONObject(); taskParam.put("iostorinv_id", invId); - taskParam.put("point_code", dto.getStruct_code()); - taskParam.put("point_code2", sonSchBasePointList.get(0).getPoint_code() ); - taskParam.put("point_code3", dto.getDevice_code() ); - taskParam.put("point_code4", sonSchBasePointList.get(1).getPoint_code() ); - taskParam.put("group_id", groupPlate.getGroup_id() ); - taskParam.put("task_code", dto.getTask_code() ); - if(dto.getIsManual() != null && dto.getIsManual()){ - taskParam.put("create_mode", "手动" ); - } else{ - taskParam.put("create_mode", "自动" ); + taskParam.put("point_code", groupPlate.getStruct_code()); + taskParam.put("point_code2", sonSchBasePointList.get(0).getPoint_code()); + taskParam.put("point_code3", dto.getDevice_code()); + taskParam.put("point_code4", sonSchBasePointList.get(1).getPoint_code()); + taskParam.put("group_id", groupPlate.getGroup_id()); + taskParam.put("task_code", dto.getTask_code()); + if (dto.getIsManual() != null && dto.getIsManual()) { + taskParam.put("create_mode", "手动"); + } else { + taskParam.put("create_mode", "自动"); } outBillService.allSetPoint(taskParam); return MesResponse.requestOk(); @@ -451,8 +450,8 @@ public class MesToWmsServiceImpl implements MesToWmsService { dto.setQty_unit_name("桶"); //退料需要判断 - if("1".equals(dto.getTask_type())){ - if(StringUtils.isEmpty(dto.getQty())){ + if ("1".equals(dto.getTask_type())) { + if (StringUtils.isEmpty(dto.getQty())) { throw new BadRequestException("数量不可为空"); } } @@ -470,70 +469,70 @@ public class MesToWmsServiceImpl implements MesToWmsService { //根据料桶号去载具表匹配料桶类型 MdPbStoragevehicleinfo mdPbStoragevehicleinfo = iMdPbStoragevehicleinfoService.getByCode(point.getVehicle_code()); - if(mdPbStoragevehicleinfo == null){ - throw new BadRequestException("机台"+dto.getDevice_code()+"上没有载具的载具!"); + if (mdPbStoragevehicleinfo == null) { + throw new BadRequestException("机台" + dto.getDevice_code() + "上没有载具的载具!"); } - //通过料桶号的料桶类型,匹配确认入库库区 - Dict dict= dictService.getDictByCodeAndValue("storagevehicle_type",mdPbStoragevehicleinfo.getStoragevehicle_type()); - if(dict==null){ + //通过料桶号的料桶类型,匹配确认入库库区 + Dict dict = dictService.getDictByCodeAndValue("storagevehicle_type", mdPbStoragevehicleinfo.getStoragevehicle_type()); + if (dict == null) { throw new BadRequestException("未找到载具编码为" + point.getVehicle_code() + "的载具入库库区,请检查字典中是否维护!"); } //查询库区 Sectattr sectattr = sectattrService.findByCode(dict.getPara1()); - if(sectattr==null){ + if (sectattr == null) { throw new BadRequestException("未找到载具编码为" + point.getVehicle_code() + "的载具入库库区,请检查字典中是否维护!"); } JSONObject param = new JSONObject(); - if(dto.getIsManual() != null && dto.getIsManual()){ - param.put("create_mode", "手动" ); + if (dto.getIsManual() != null && dto.getIsManual()) { + param.put("create_mode", "手动"); param.put("is_manual", true); - } else{ - param.put("create_mode", "自动" ); + } else { + param.put("create_mode", "自动"); } param.put("task_code", dto.getTask_code()); //退料 - if("1".equals(dto.getTask_type())){ + if ("1".equals(dto.getTask_type())) { //查询组盘 GroupPlate groupPlate = iMdPbGroupplateService.getOne(new LambdaQueryWrapper() .eq(GroupPlate::getStoragevehicle_code, point.getVehicle_code()) .eq(GroupPlate::getStatus, "03")); if (ObjectUtil.isEmpty(groupPlate)) { - throw new BadRequestException("点位"+point.getPoint_code()+"上的托盘不存在组盘信息!"); + throw new BadRequestException("点位" + point.getPoint_code() + "上的托盘不存在组盘信息!"); } MdMeMaterialbase materDao = iMdMeMaterialbaseService.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("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",dto.getDevice_code()); - param.put("material_id",materDao.getMaterial_code()); - param.put("material_code",materDao.getMaterial_code()); - param.put("pcsn",groupPlate.getPcsn()); - param.put("qty",dto.getQty()); - param.put("qty_unit_name",dto.getQty_unit_name()); - param.put("stor_id",sectattr.getStor_id()); - param.put("supp_code",groupPlate.getSupp_code()); - param.put("supp_name",groupPlate.getSupp_name()); + param.put("site_code", dto.getDevice_code()); + param.put("material_id", materDao.getMaterial_code()); + param.put("material_code", materDao.getMaterial_code()); + param.put("pcsn", groupPlate.getPcsn()); + param.put("qty", dto.getQty()); + param.put("qty_unit_name", dto.getQty_unit_name()); + param.put("stor_id", sectattr.getStor_id()); + param.put("supp_code", groupPlate.getSupp_code()); + param.put("supp_name", groupPlate.getSupp_name()); pdaIosInService.zwConfirmReturnMaterial(param); - } else if("2".equals(dto.getTask_type())){ + } else if ("2".equals(dto.getTask_type())) { //退空桶 - param.put("vehicle_code",point.getVehicle_code()); + param.put("vehicle_code", point.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()); - param.put("back_material_flag",true); + param.put("site_code", dto.getDevice_code()); + param.put("sect_id", sectattr.getSect_id()); + param.put("sect_code", sectattr.getSect_code()); + param.put("back_material_flag", true); pdaIosInService.vehicleInConfirm(param); - } else{ + } else { throw new BadRequestException("任务类型有误!请传入1或2"); } return MesResponse.requestOk(); @@ -549,16 +548,17 @@ public class MesToWmsServiceImpl implements MesToWmsService { @Override public MesResponse getStructivt(JSONObject whereJson) { - return MesResponse.requestParamOk(mdPbStoragevehicleextMapper.queryAllIn(whereJson)); + return MesResponse.requestParamOk(mdPbStoragevehicleextMapper.queryAllIn(whereJson)); } /** * 组织入库插入数据 + * * @param whereJson { * storagevehicle_code:载具编码 * point_code:点位编码 * sect_code:库区 - * } + * } * @return Map */ private Map organizeInsertData(JSONObject whereJson) { @@ -584,7 +584,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { 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 (!jsonMst.containsKey("bill_type")) { jsonMst.put("bill_type", StatusEnum.IOBILL_TYPE_IN.code("来料入库")); } jsonMst.put("biz_date", DateUtil.now()); @@ -604,7 +604,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { dtl.put("plan_qty", String.valueOf(total_qty)); // 调用新增 tableData.add(dtl); - jsonMst.put("tableData",tableData); + jsonMst.put("tableData", tableData); return jsonMst; } }