立体仓优化

This commit is contained in:
mashuai 2026-02-10 18:04:30 +08:00
parent c06be418c2
commit b2db646d30
7 changed files with 206 additions and 168 deletions

View File

@ -174,4 +174,9 @@ public class MaterialConstants {
* 立体库生产环境建立入库单路径key
*/
public static final String PROD_CREATE_IN_KEY = "sys.automated.docInStorage";
/**
* 立体库生产环境开关控制
*/
public static final String PROD_AUTOMATED_SWITCH = "sys.automated.button";
}

View File

@ -1629,51 +1629,55 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
tmTask.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
result = tmTaskMapper.updateTmTask(tmTask);
if (result > GlobalConstants.INT_0) {
// 同步数据到立体仓
// 根据parentId查询属于立体仓的数据
List<LeaseApplyDetails> detailsList = leaseApplyInfoMapper.selectLeaseApplyInfoByParentId(leaseApplyInfo.getId());
if (!CollectionUtils.isEmpty(detailsList)) {
log.info("----------------开始同步数据到立体仓----------------");
// 向第三方发送出库请求创建出库单
ArrayList<AutomaticOutPutDto> list = new ArrayList<>();
// 数量出库
for (int i = 0; i < detailsList.size(); i++) {
AutomaticOutPutDto automaticOutPutDto = new AutomaticOutPutDto();
automaticOutPutDto.setMaterialName(detailsList.get(i).getMaTypeName());
automaticOutPutDto.setUnitCode(detailsList.get(i).getUnitName());
automaticOutPutDto.setOutQty(detailsList.get(i).getPreNum());
automaticOutPutDto.setLineNum( i + 1);
automaticOutPutDto.setTypeId(detailsList.get(i).getTypeId());
automaticOutPutDto.setSpecification(detailsList.get(i).getTypeName());
list.add(automaticOutPutDto);
}
Map<String, Object> map = new HashMap<>();
map.put("ExternalNo", leaseApplyInfo.getCode());
map.put("taskId", leaseApplyInfo.getTaskId());
map.put("parentId", leaseApplyInfo.getId());
// 是否指定托盘出库true=指定托盘false= 不指定托盘
map.put("IsAppointTray", false);
map.put("OutDes", "领料出库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立出库单接口路径
//String url = MaterialConstants.TEST_CREATE_OUT_URL;
// 立体库生产建立出库单接口路径
//String url = MaterialConstants.PROD_CREATE_OUT_URL;
String url = typeService.getAsOutUrl();
log.info("立体仓建立出库单路径:{}", url);
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
log.info("传输立体仓返回data:{}", data);
if (StringUtils.isEmpty(data)) {
System.err.println("立体仓出库单创建失败");
throw new RuntimeException("立体仓出库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String code = object.getString("code");
log.info("传输立体仓返回code:{}", code);
if (!"0".equals(code)) {
System.err.println("立体仓出库单创建失败");
throw new RuntimeException("立体仓出库单创建失败");
// 立体库开关控制
String button = typeService.getAsSwitch();
if ("true".equals(button)) {
// 同步数据到立体仓
// 根据parentId查询属于立体仓的数据
List<LeaseApplyDetails> detailsList = leaseApplyInfoMapper.selectLeaseApplyInfoByParentId(leaseApplyInfo.getId());
if (!CollectionUtils.isEmpty(detailsList)) {
log.info("----------------开始同步数据到立体仓----------------");
// 向第三方发送出库请求创建出库单
ArrayList<AutomaticOutPutDto> list = new ArrayList<>();
// 数量出库
for (int i = 0; i < detailsList.size(); i++) {
AutomaticOutPutDto automaticOutPutDto = new AutomaticOutPutDto();
automaticOutPutDto.setMaterialName(detailsList.get(i).getMaTypeName());
automaticOutPutDto.setUnitCode(detailsList.get(i).getUnitName());
automaticOutPutDto.setOutQty(detailsList.get(i).getPreNum());
automaticOutPutDto.setLineNum(i + 1);
automaticOutPutDto.setTypeId(detailsList.get(i).getTypeId());
automaticOutPutDto.setSpecification(detailsList.get(i).getTypeName());
list.add(automaticOutPutDto);
}
Map<String, Object> map = new HashMap<>();
map.put("ExternalNo", leaseApplyInfo.getCode());
map.put("taskId", leaseApplyInfo.getTaskId());
map.put("parentId", leaseApplyInfo.getId());
// 是否指定托盘出库true=指定托盘false= 不指定托盘
map.put("IsAppointTray", false);
map.put("OutDes", "领料出库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立出库单接口路径
//String url = MaterialConstants.TEST_CREATE_OUT_URL;
// 立体库生产建立出库单接口路径
//String url = MaterialConstants.PROD_CREATE_OUT_URL;
String url = typeService.getAsOutUrl();
log.info("立体仓建立出库单路径:{}", url);
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
log.info("传输立体仓返回data:{}", data);
if (StringUtils.isEmpty(data)) {
System.err.println("立体仓出库单创建失败");
throw new RuntimeException("立体仓出库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String code = object.getString("code");
log.info("传输立体仓返回code:{}", code);
if (!"0".equals(code)) {
System.err.println("立体仓出库单创建失败");
throw new RuntimeException("立体仓出库单创建失败");
}
}
}
}

View File

@ -1211,29 +1211,33 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
throw new RuntimeException("发布失败,请联系管理员");
}
}
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = new HashMap<>();
map.put("ExternalNo", code);
map.put("taskId", leaseApplyInfo.getTaskId());
map.put("parentId", parentId);
// 是否指定托盘出库true=指定托盘false= 不指定托盘
map.put("IsAppointTray", false);
map.put("OutDes", "领料出库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立出库单接口路径
//String url = MaterialConstants.TEST_CREATE_OUT_URL;
// 立体库生产建立出库单接口路径
//String url = MaterialConstants.PROD_CREATE_OUT_URL;
String url = typeService.getAsOutUrl();
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
if (StringUtils.isEmpty(data)) {
throw new RuntimeException("立体仓出库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String res = object.getString("code");
if (!"0".equals(res)) {
throw new RuntimeException("立体仓出库单创建失败");
// 立体库开关控制
String button = typeService.getAsSwitch();
if ("true".equals(button)) {
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = new HashMap<>();
map.put("ExternalNo", code);
map.put("taskId", leaseApplyInfo.getTaskId());
map.put("parentId", parentId);
// 是否指定托盘出库true=指定托盘false= 不指定托盘
map.put("IsAppointTray", false);
map.put("OutDes", "领料出库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立出库单接口路径
//String url = MaterialConstants.TEST_CREATE_OUT_URL;
// 立体库生产建立出库单接口路径
//String url = MaterialConstants.PROD_CREATE_OUT_URL;
String url = typeService.getAsOutUrl();
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
if (StringUtils.isEmpty(data)) {
throw new RuntimeException("立体仓出库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String res = object.getString("code");
if (!"0".equals(res)) {
throw new RuntimeException("立体仓出库单创建失败");
}
}
}
} catch (Exception e) {

View File

@ -202,4 +202,10 @@ public interface ITypeService {
* @return
*/
String getAsInUrl();
/**
* 立体库生产环境开关
* @return
*/
String getAsSwitch();
}

View File

@ -1210,4 +1210,14 @@ public class TypeServiceImpl implements ITypeService {
String key = MaterialConstants.PROD_CREATE_IN_KEY;
return typeMapper.getAsUrl(key);
}
/**
* 立体库生产环境开关
* @return
*/
@Override
public String getAsSwitch() {
String key = MaterialConstants.PROD_AUTOMATED_SWITCH;
return typeMapper.getAsUrl(key);
}
}

View File

@ -242,59 +242,64 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
return AjaxResult.error("该设备已全部入库,请勿重复操作");
}
}
if (purchaseDto.getIsRs() != null && purchaseDto.getIsRs() == 1) {
Integer manageType = null;
ArrayList<AutomaticInPutDto> list = new ArrayList<>();
//数量入库
if (CollectionUtils.isEmpty(purchaseDto.getInPutList())) {
manageType = 1;
AutomaticInPutDto automaticInPutDto = new AutomaticInPutDto();
automaticInPutDto.setMaterialName(purchaseDto.getMaTypeName());
automaticInPutDto.setSpecification(purchaseDto.getTypeModelName());
automaticInPutDto.setUnitCode(purchaseDto.getUnitName());
automaticInPutDto.setInQty(purchaseDto.getInputNum());
automaticInPutDto.setLineNum(1);
automaticInPutDto.setPurchaseId(purchaseDto.getPurchaseId());
automaticInPutDto.setTypeId(Long.valueOf(purchaseDto.getTypeId()));
list.add(automaticInPutDto);
} else {
manageType = 0;
for (int i = 0; i < purchaseDto.getInPutList().size(); i++) {
// 立体库开关控制
String button = typeService.getAsSwitch();
if ("true".equals(button)) {
// 立体库数据推送
if (purchaseDto.getIsRs() != null && purchaseDto.getIsRs() == 1) {
Integer manageType = null;
ArrayList<AutomaticInPutDto> list = new ArrayList<>();
//数量入库
if (CollectionUtils.isEmpty(purchaseDto.getInPutList())) {
manageType = 1;
AutomaticInPutDto automaticInPutDto = new AutomaticInPutDto();
automaticInPutDto.setMaterialName(purchaseDto.getMaTypeName());
automaticInPutDto.setSpecification(purchaseDto.getTypeModelName());
automaticInPutDto.setUnitCode(purchaseDto.getUnitName());
automaticInPutDto.setInQty(BigDecimal.ONE);
automaticInPutDto.setMaterialCode(purchaseDto.getInPutList().get(i).getMaCode());
automaticInPutDto.setLineNum(i + 1);
automaticInPutDto.setInQty(purchaseDto.getInputNum());
automaticInPutDto.setLineNum(1);
automaticInPutDto.setPurchaseId(purchaseDto.getPurchaseId());
automaticInPutDto.setTypeId(Long.valueOf(purchaseDto.getTypeId()));
list.add(automaticInPutDto);
} else {
manageType = 0;
for (int i = 0; i < purchaseDto.getInPutList().size(); i++) {
AutomaticInPutDto automaticInPutDto = new AutomaticInPutDto();
automaticInPutDto.setMaterialName(purchaseDto.getMaTypeName());
automaticInPutDto.setSpecification(purchaseDto.getTypeModelName());
automaticInPutDto.setUnitCode(purchaseDto.getUnitName());
automaticInPutDto.setInQty(BigDecimal.ONE);
automaticInPutDto.setMaterialCode(purchaseDto.getInPutList().get(i).getMaCode());
automaticInPutDto.setLineNum(i + 1);
automaticInPutDto.setPurchaseId(purchaseDto.getPurchaseId());
automaticInPutDto.setTypeId(Long.valueOf(purchaseDto.getTypeId()));
list.add(automaticInPutDto);
}
}
Map<String, Object> map = new HashMap<>();
map.put("ExternalNo", purchaseDto.getCode());
map.put("taskId", purchaseDto.getTaskId());
map.put("manageType", manageType);
map.put("InDes", "采购入库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立入库单接口路径
//String url = MaterialConstants.TEST_CREATE_IN_URL;
// 立体库生产建立入库单接口路径
//String url = MaterialConstants.PROD_CREATE_IN_URL;
String url = typeService.getAsInUrl();
log.info("立体库获取建立新购入库单路径:{}", url);
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
log.info("立体库建立新购入库单返回data{}", data);
if (StringUtils.isEmpty(data)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String code = object.getString("code");
log.info("立体库建立新购入库单返回code{}", code);
if (!"0".equals(code)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
}
Map<String, Object> map = new HashMap<>();
map.put("ExternalNo", purchaseDto.getCode());
map.put("taskId", purchaseDto.getTaskId());
map.put("manageType", manageType);
map.put("InDes", "采购入库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立入库单接口路径
//String url = MaterialConstants.TEST_CREATE_IN_URL;
// 立体库生产建立入库单接口路径
//String url = MaterialConstants.PROD_CREATE_IN_URL;
String url = typeService.getAsInUrl();
log.info("立体库获取建立新购入库单路径:{}", url);
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
log.info("立体库建立新购入库单返回data{}", data);
if (StringUtils.isEmpty(data)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String code = object.getString("code");
log.info("立体库建立新购入库单返回code{}", code);
if (!"0".equals(code)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
}
//判断为数量还是编码入库

View File

@ -628,69 +628,73 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
}
}
// 立体仓修试入库
if (repairInputDetails.getIsRs() != null && repairInputDetails.getIsRs() == 1) {
Integer manageType = null;
ArrayList<AutomaticInPutDto> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(repairInputDetails.getMaCodeList())) {
// 编码修试入库
manageType = 0;
for (int i = 0; i < repairInputDetails.getMaCodeList().size(); i++) {
repairInputDetails.getMaCodeList().get(i).setTaskId(repairInputDetails.getTaskId());
repairInputDetails.getMaCodeList().get(i).setTypeId(repairInputDetails.getTypeId());
// 根据taskId以及typeId查询该设备是否已经入库
RepairInputDetails info = repairInputDetailsMapper.selectInfoNum(repairInputDetails.getMaCodeList().get(i));
if (info != null) {
if (info.getInputNum().compareTo(info.getRepairNum()) >= 0) {
throw new ServiceException("该设备已经入库,请勿重复入库");
// 立体库开关控制
String button = typeService.getAsSwitch();
if ("true".equals(button)) {
if (repairInputDetails.getIsRs() != null && repairInputDetails.getIsRs() == 1) {
Integer manageType = null;
ArrayList<AutomaticInPutDto> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(repairInputDetails.getMaCodeList())) {
// 编码修试入库
manageType = 0;
for (int i = 0; i < repairInputDetails.getMaCodeList().size(); i++) {
repairInputDetails.getMaCodeList().get(i).setTaskId(repairInputDetails.getTaskId());
repairInputDetails.getMaCodeList().get(i).setTypeId(repairInputDetails.getTypeId());
// 根据taskId以及typeId查询该设备是否已经入库
RepairInputDetails info = repairInputDetailsMapper.selectInfoNum(repairInputDetails.getMaCodeList().get(i));
if (info != null) {
if (info.getInputNum().compareTo(info.getRepairNum()) >= 0) {
throw new ServiceException("该设备已经入库,请勿重复入库");
}
}
AutomaticInPutDto automaticInPutDto = new AutomaticInPutDto();
automaticInPutDto.setMaterialName(repairInputDetails.getMaTypeName());
automaticInPutDto.setUnitCode(repairInputDetails.getUnitName());
automaticInPutDto.setInQty(BigDecimal.ONE);
automaticInPutDto.setMaterialCode(repairInputDetails.getMaCodeList().get(i).getMaCode());
automaticInPutDto.setLineNum(i + 1);
automaticInPutDto.setTypeId(repairInputDetails.getTypeId());
automaticInPutDto.setPendingInputNum(BigDecimal.ONE);
automaticInPutDto.setMaId(repairInputDetails.getMaCodeList().get(i).getMaId());
list.add(automaticInPutDto);
}
} else {
// 数量修试入库
AutomaticInPutDto automaticInPutDto = new AutomaticInPutDto();
manageType = 1;
automaticInPutDto.setMaterialName(repairInputDetails.getMaTypeName());
automaticInPutDto.setUnitCode(repairInputDetails.getUnitName());
automaticInPutDto.setInQty(BigDecimal.ONE);
automaticInPutDto.setMaterialCode(repairInputDetails.getMaCodeList().get(i).getMaCode());
automaticInPutDto.setLineNum(i + 1);
automaticInPutDto.setInQty(repairInputDetails.getInputNum());
automaticInPutDto.setLineNum(1);
automaticInPutDto.setTypeId(repairInputDetails.getTypeId());
automaticInPutDto.setPendingInputNum(BigDecimal.ONE);
automaticInPutDto.setMaId(repairInputDetails.getMaCodeList().get(i).getMaId());
automaticInPutDto.setPendingInputNum(repairInputDetails.getPendingInputNum());
list.add(automaticInPutDto);
}
} else {
// 数量修试入库
AutomaticInPutDto automaticInPutDto = new AutomaticInPutDto();
manageType = 1;
automaticInPutDto.setMaterialName(repairInputDetails.getMaTypeName());
automaticInPutDto.setUnitCode(repairInputDetails.getUnitName());
automaticInPutDto.setInQty(repairInputDetails.getInputNum());
automaticInPutDto.setLineNum(1);
automaticInPutDto.setTypeId(repairInputDetails.getTypeId());
automaticInPutDto.setPendingInputNum(repairInputDetails.getPendingInputNum());
list.add(automaticInPutDto);
}
Map<String, Object> map = new HashMap<>();
map.put("agreementId", repairInputDetails.getAgreementId());
map.put("ExternalNo", repairInputDetails.getInputCode());
map.put("taskId", repairInputDetails.getTaskId());
map.put("manageType", manageType);
map.put("InDes", "修试入库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立入库单接口路径
//String url = MaterialConstants.TEST_CREATE_IN_URL;
// 立体库生产建立入库单接口路径
//String url = MaterialConstants.PROD_CREATE_IN_URL;
String url = typeService.getAsInUrl();
log.info("立体库获取建立修试入库单路径:{}", url);
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
log.info("立体库建立修试入库单返回data{}", data);
if (StringUtils.isEmpty(data)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String code = object.getString("code");
log.info("立体库建立修试入库单返回code{}", code);
if (!"0".equals(code)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
Map<String, Object> map = new HashMap<>();
map.put("agreementId", repairInputDetails.getAgreementId());
map.put("ExternalNo", repairInputDetails.getInputCode());
map.put("taskId", repairInputDetails.getTaskId());
map.put("manageType", manageType);
map.put("InDes", "修试入库");
map.put("DtlList", list);
String body = JSONObject.toJSONString(map);
// 立体库本地建立入库单接口路径
//String url = MaterialConstants.TEST_CREATE_IN_URL;
// 立体库生产建立入库单接口路径
//String url = MaterialConstants.PROD_CREATE_IN_URL;
String url = typeService.getAsInUrl();
log.info("立体库获取建立修试入库单路径:{}", url);
String data = automaticHttpHelper.sendHttpPostPushCost(url, body);
log.info("立体库建立修试入库单返回data{}", data);
if (StringUtils.isEmpty(data)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
JSONObject object = JSONObject.parseObject(data);
String code = object.getString("code");
log.info("立体库建立修试入库单返回code{}", code);
if (!"0".equals(code)) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败");
}
}
}
repairInputDetails.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString());