|
|
|
|
@@ -1,6 +1,8 @@
|
|
|
|
|
package org.nl.b_lms.pda.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
@@ -15,30 +17,36 @@ import org.nl.b_lms.sch.point.service.IschBasePointService;
|
|
|
|
|
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
|
|
|
|
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
|
|
|
|
import org.nl.b_lms.sch.tasks.TwoInEmpExcepTask;
|
|
|
|
|
import org.nl.b_lms.sch.tasks.TwoOutTask;
|
|
|
|
|
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService;
|
|
|
|
|
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvOutService;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.mapper.StIvtIostorinvdisMapper;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.impl.StIvtIostorinvOutServiceImpl;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBoxManageService;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBussManageService;
|
|
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InVehicleManageService;
|
|
|
|
|
import org.nl.common.enums.SpecEnum;
|
|
|
|
|
import org.nl.common.utils.SecurityUtils;
|
|
|
|
|
import org.nl.modules.common.exception.BadRequestException;
|
|
|
|
|
import org.nl.modules.wql.core.bean.WQLObject;
|
|
|
|
|
import org.nl.modules.wql.util.SpringContextHolder;
|
|
|
|
|
import org.nl.system.service.param.dao.Param;
|
|
|
|
|
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
|
|
|
|
import org.nl.wms.basedata.st.service.StructattrService;
|
|
|
|
|
import org.nl.wms.basedata.st.service.dto.StructattrDto;
|
|
|
|
|
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
|
|
|
|
import org.nl.wms.ext.mes.service.LmsToMesService;
|
|
|
|
|
import org.nl.wms.sch.manage.TaskStatusEnum;
|
|
|
|
|
import org.nl.wms.util.TranUtil;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@@ -69,8 +77,6 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private LmsToMesService lmsToMesService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 点位服务
|
|
|
|
|
*/
|
|
|
|
|
@@ -82,6 +88,15 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPdmBiContainerinboundService iPdmBiContainerinboundService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IStIvtIostorinvOutService iStIvtIostorinvOutService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StIvtIostorinvdisMapper stIvtIostorinvdisMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StructattrService structattrService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public JSONObject vehicleIn(JSONObject whereJson) {
|
|
|
|
|
@@ -183,9 +198,9 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
public JSONObject boxIn(JSONObject whereJson) {
|
|
|
|
|
// 调用接口
|
|
|
|
|
String startCode = whereJson.getString("point_code");
|
|
|
|
|
if ("MXRKW1".equals(startCode)){
|
|
|
|
|
if ("MXRKW1".equals(startCode)) {
|
|
|
|
|
inBoxManageService.boxBinVehicle(whereJson);
|
|
|
|
|
}else if ("THRKDJW1".equals(startCode)){
|
|
|
|
|
} else if ("THRKDJW1".equals(startCode)) {
|
|
|
|
|
inBoxManageService.boxBinVehicleByTHRK(whereJson);
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
@@ -211,10 +226,11 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
String a = JSONObject.toJSONString(msg);
|
|
|
|
|
List<String> list = JSONObject.parseObject(a, List.class);
|
|
|
|
|
Optional<String> 称重 = list.stream().filter(m -> m.contains("称重")).findAny();
|
|
|
|
|
if (称重.isPresent()){
|
|
|
|
|
if (称重.isPresent()) {
|
|
|
|
|
System.out.println(称重.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public JSONObject reback(JSONObject whereJson) {
|
|
|
|
|
@@ -223,25 +239,25 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
String bill_type = whereJson.getString("bill_type");
|
|
|
|
|
whereJson.put("material_barcode", whereJson.getString("box_no"));
|
|
|
|
|
whereJson.put("device_code", whereJson.getString("point_code"));
|
|
|
|
|
if ("RK1002".equals(whereJson.getString("point_code"))){
|
|
|
|
|
if ("RK1002".equals(whereJson.getString("point_code"))) {
|
|
|
|
|
List<SchBaseTask> list = ischBaseTaskService.list(new QueryWrapper<SchBaseTask>()
|
|
|
|
|
.select("task_id")
|
|
|
|
|
.eq("point_code2", "RK1004")
|
|
|
|
|
.eq("task_type", "010706")
|
|
|
|
|
.eq("is_delete", "0")
|
|
|
|
|
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)){
|
|
|
|
|
throw new BadRequestException("稍后再试,异常口存在正在执行的任务"+ list.stream().map(SchBaseTask::getTask_id).collect(Collectors.joining(",")));
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new BadRequestException("稍后再试,异常口存在正在执行的任务" + list.stream().map(SchBaseTask::getTask_id).collect(Collectors.joining(",")));
|
|
|
|
|
}
|
|
|
|
|
Param forceWeight = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("force_weight");
|
|
|
|
|
if (forceWeight!=null && "1".equals(forceWeight.getValue())){
|
|
|
|
|
if (forceWeight != null && "1".equals(forceWeight.getValue())) {
|
|
|
|
|
PdmBiContainerinbound one = iPdmBiContainerinboundService.getOne(new QueryWrapper<PdmBiContainerinbound>()
|
|
|
|
|
.eq("box", whereJson.getString("box_no")));
|
|
|
|
|
if (one!=null && !StringUtils.isEmpty(one.getRemark())){
|
|
|
|
|
if (one != null && !StringUtils.isEmpty(one.getRemark())) {
|
|
|
|
|
List<String> remark = JSONObject.parseObject(one.getRemark(), List.class);
|
|
|
|
|
Optional<String> 称重 = remark.stream().filter(m -> m.contains("称重")).findAny();
|
|
|
|
|
if (称重.isPresent()){
|
|
|
|
|
throw new BadRequestException("开启称重强制校验"+称重.get());
|
|
|
|
|
if (称重.isPresent()) {
|
|
|
|
|
throw new BadRequestException("开启称重强制校验" + 称重.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -254,12 +270,21 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
whereJson.put("bill_type", IOSEnum.IN_TYPE.code("生产入库"));
|
|
|
|
|
} else if (bill_type.equals("0009")) {
|
|
|
|
|
whereJson.put("bill_type", IOSEnum.IN_TYPE.code("手工入库"));
|
|
|
|
|
} else if (bill_type.equals("0012")) {
|
|
|
|
|
whereJson.put("bill_type", IOSEnum.IN_TYPE.code("换标入库"));
|
|
|
|
|
}
|
|
|
|
|
whereJson.put("box_no", whereJson.getString("box_no"));
|
|
|
|
|
JSONArray resultJSONArray = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + whereJson.getString("material_barcode") + "' AND status in ('0','1')").getResultJSONArray(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(resultJSONArray)) {
|
|
|
|
|
throw new BadRequestException("未查询到子卷包装信息!");
|
|
|
|
|
}
|
|
|
|
|
String sub_type = resultJSONArray.getJSONObject(0).getString("sub_type");
|
|
|
|
|
if (ObjectUtil.isNotEmpty(sub_type) && sub_type.equals("9") && !bill_type.equals("0012")) {
|
|
|
|
|
throw new BadRequestException("当前木箱是换标进行出库的,只能进行换标入库!");
|
|
|
|
|
}
|
|
|
|
|
if ((ObjectUtil.isEmpty(sub_type) || !sub_type.equals("9")) && bill_type.equals("0012")) {
|
|
|
|
|
throw new BadRequestException("当前木箱不是换标进行出库的,不能进行换标入库!");
|
|
|
|
|
}
|
|
|
|
|
String material_barcode = "";
|
|
|
|
|
List<String> subs = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < resultJSONArray.size(); i++) {
|
|
|
|
|
@@ -305,30 +330,140 @@ public class VehicleTwoServiceImpl implements VehicleTwoService {
|
|
|
|
|
// 更新载具对应木箱信息
|
|
|
|
|
JSONObject jsonExt = extTab.query("storagevehicle_code = '" + whereJson.getString("vehicle_code") + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonExt)) {
|
|
|
|
|
throw new BadRequestException("载具不存在!"+whereJson.getString("vehicle_code"));
|
|
|
|
|
throw new BadRequestException("载具不存在!" + whereJson.getString("vehicle_code"));
|
|
|
|
|
}
|
|
|
|
|
int hasTask = ischBaseTaskService.count(new QueryWrapper<SchBaseTask>()
|
|
|
|
|
.eq("is_delete", "0")
|
|
|
|
|
.eq("vehicle_code2", whereJson.getString("vehicle_code"))
|
|
|
|
|
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
|
|
|
|
|
if (hasTask>0){
|
|
|
|
|
throw new BadRequestException("托盘"+whereJson.getString("vehicle_code")+"存在执行的任务");
|
|
|
|
|
if (hasTask > 0) {
|
|
|
|
|
throw new BadRequestException("托盘" + whereJson.getString("vehicle_code") + "存在执行的任务");
|
|
|
|
|
}
|
|
|
|
|
String pcsn = jsonExt.getString("pcsn");
|
|
|
|
|
if (StringUtils.isNotEmpty(pcsn)){
|
|
|
|
|
if (StringUtils.isNotEmpty(pcsn)) {
|
|
|
|
|
JSONArray stIvtStructattr = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + pcsn + "'").getResultJSONArray(0);
|
|
|
|
|
if (stIvtStructattr != null && stIvtStructattr.size() > 0) {
|
|
|
|
|
throw new BadRequestException("当前托盘"+whereJson.getString("vehicle_code")+"已经绑定木箱"+pcsn);
|
|
|
|
|
throw new BadRequestException("当前托盘" + whereJson.getString("vehicle_code") + "已经绑定木箱" + pcsn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jsonExt.put("pcsn", whereJson.getString("box_no"));
|
|
|
|
|
extTab.update(jsonExt);
|
|
|
|
|
|
|
|
|
|
inBussManageService.inTask(whereJson);
|
|
|
|
|
PdmProductSpecServiceImpl.doRecord(SpecEnum.RK_YC,null,Boolean.TRUE,null,subs);
|
|
|
|
|
HashMap sub_map = new HashMap();
|
|
|
|
|
sub_map.put("sub_type", "0");
|
|
|
|
|
WQLObject.getWQLObject("pdm_bi_subpackagerelation").update(sub_map, "package_box_sn = '" + whereJson.getString("box_no")+"'");
|
|
|
|
|
PdmProductSpecServiceImpl.doRecord(SpecEnum.RK_YC, null, Boolean.TRUE, null, subs);
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
result.put("message", "入库成功!");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject relabel(JSONObject whereJson) {
|
|
|
|
|
String box_no = whereJson.getString("box_no");
|
|
|
|
|
|
|
|
|
|
JSONObject jsonMst = new JSONObject();
|
|
|
|
|
jsonMst.put("detail_count", 1);
|
|
|
|
|
jsonMst.put("bill_status", "10");
|
|
|
|
|
jsonMst.put("create_mode", "03");
|
|
|
|
|
jsonMst.put("bill_type", "1012");
|
|
|
|
|
jsonMst.put("biz_date", DateUtil.now());
|
|
|
|
|
jsonMst.put("user", "sap");
|
|
|
|
|
|
|
|
|
|
JSONArray dtls = new JSONArray();
|
|
|
|
|
if (StrUtil.isEmpty("package_box_sn")) {
|
|
|
|
|
throw new BadRequestException("输入的木箱号不能为空!");
|
|
|
|
|
}
|
|
|
|
|
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("package_box_sn = '" + box_no + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(sub_jo)) {
|
|
|
|
|
throw new BadRequestException("LMS中不存在木箱号为【" + box_no + "】的包装关系");
|
|
|
|
|
}
|
|
|
|
|
String container_name = sub_jo.getString("container_name");
|
|
|
|
|
JSONObject struct_ivt = WQLObject.getWQLObject("st_ivt_structivt").query("pcsn = '" + container_name + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(struct_ivt)) {
|
|
|
|
|
throw new BadRequestException("子卷号为【" + container_name + "】的成品卷不存在或已经出库!");
|
|
|
|
|
} else {
|
|
|
|
|
if (struct_ivt.getDoubleValue("frozen_qty") > 0) {
|
|
|
|
|
throw new BadRequestException("子卷号为【" + container_name + "】的成品卷已经被分配或出库中");
|
|
|
|
|
} else {
|
|
|
|
|
JSONObject dtl = new JSONObject();
|
|
|
|
|
//查询该物料
|
|
|
|
|
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + sub_jo.getString("product_name") + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(mater_jo)) {
|
|
|
|
|
throw new BadRequestException("未查询到物料:" + sub_jo.getString("product_name") + ",信息!");
|
|
|
|
|
}
|
|
|
|
|
dtl.put("material_id", mater_jo.getString("material_id"));
|
|
|
|
|
dtl.put("pcsn", container_name);
|
|
|
|
|
dtl.put("box_no", sub_jo.getString("package_box_sn"));
|
|
|
|
|
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(unit)) {
|
|
|
|
|
throw new BadRequestException("未查询到物料计量单位:" + mater_jo.getString("base_unit_id") + ",信息!");
|
|
|
|
|
}
|
|
|
|
|
dtl.put("qty_unit_id", unit.getString("measure_unit_id"));
|
|
|
|
|
dtl.put("qty_unit_name", unit.getString("unit_name"));
|
|
|
|
|
dtl.put("plan_qty", sub_jo.getString("net_weight"));
|
|
|
|
|
dtls.add(dtl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructattrDto structCode = structattrService.findByCode(struct_ivt.getString("struct_code"));
|
|
|
|
|
jsonMst.put("stor_id", structCode.getStor_id());
|
|
|
|
|
jsonMst.put("stor_code", structCode.getStor_code());
|
|
|
|
|
jsonMst.put("stor_name", structCode.getStor_name());
|
|
|
|
|
jsonMst.put("tableData", dtls);
|
|
|
|
|
if (!structCode.getSect_code().equals("BZC01")){
|
|
|
|
|
throw new BadRequestException("只能针对兰州二期仓库的木箱进行换标出库!");
|
|
|
|
|
}
|
|
|
|
|
String iostorinv_id = iStIvtIostorinvOutService.insertMst(jsonMst);
|
|
|
|
|
|
|
|
|
|
//调用自动分配
|
|
|
|
|
JSONObject out_jo = new JSONObject();
|
|
|
|
|
out_jo.put("iostorinv_id", iostorinv_id);
|
|
|
|
|
out_jo.put("div_type", "1");
|
|
|
|
|
iStIvtIostorinvOutService.allDiv(out_jo);
|
|
|
|
|
whereJson.put("iostorinv_id", iostorinv_id);
|
|
|
|
|
StIvtIostorinvOutServiceImpl bean = SpringContextHolder.getBean(StIvtIostorinvOutServiceImpl.class);
|
|
|
|
|
//调用下发任务逻辑
|
|
|
|
|
ArrayList<String> arr = new ArrayList<>();
|
|
|
|
|
TranUtil.openTransaction((req, allTransactionConsumer) -> {
|
|
|
|
|
// 查询此明细所有未生成的分配明细
|
|
|
|
|
List<JSONObject> disDaoList = stIvtIostorinvdisMapper.getNotCreateDis(whereJson);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(disDaoList)) {
|
|
|
|
|
throw new BadRequestException("当前没有可设置的分配明细!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 下发任务
|
|
|
|
|
* 1.根据木箱 长、宽、高、订单号、物料分组
|
|
|
|
|
* 2.相同木箱规格、订单号、物料的木箱一个任务组
|
|
|
|
|
*/
|
|
|
|
|
// 定义一个函数,将需要分组的元素映射到一个建的集合里
|
|
|
|
|
Function<JSONObject, List<String>> compositeKey = row ->
|
|
|
|
|
Arrays.asList(row.getString("box_length"), row.getString("box_width"),
|
|
|
|
|
row.getString("box_high"), row.getString("sale_order_name"),
|
|
|
|
|
row.getString("material_id")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Map<List<String>, List<JSONObject>> groupingDisMap =
|
|
|
|
|
disDaoList.stream().collect(Collectors.groupingBy(compositeKey, Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
for (List<JSONObject> disLikeList : groupingDisMap.values()) {
|
|
|
|
|
// 调用任务生成处理
|
|
|
|
|
List<JSONObject> taskMangeList = bean.createTaskMange2(disLikeList, iostorinv_id, allTransactionConsumer);
|
|
|
|
|
|
|
|
|
|
// 创建任务并下发一组任务
|
|
|
|
|
bean.createTask2(taskMangeList, disLikeList, "RK1003", allTransactionConsumer);
|
|
|
|
|
|
|
|
|
|
allTransactionConsumer.accept("finish");
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
}, new JSONArray());
|
|
|
|
|
SpringContextHolder.getBean(TwoOutTask.class).immediateNotifyAcs(null);
|
|
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
result.put("message", "出库成功!");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|