|
|
|
@ -2,6 +2,7 @@ package com.glxp.api.service.thrsys.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
@ -17,6 +18,7 @@ import com.glxp.api.dao.thrsys.ThrInvOrderMapper;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicSkProjectDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
|
|
@ -45,6 +47,7 @@ import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -153,7 +156,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
handleExternalConvertThrInvGhOrderDetail(list, thrInvOrderDetails, billNo, thirdSys, thrInvOrder);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(thrInvOrderDetails)) {
|
|
|
|
|
handleExternalConvertThrInvOrder(billNo, filterInvProductRequest, thrInvOrder, list.get(0),Constant.THR_INV_PH_ORDER_TYPE);
|
|
|
|
|
handleExternalConvertThrInvOrder(billNo, filterInvProductRequest, thrInvOrder, list.get(0), Constant.THR_INV_GH_ORDER_TYPE);
|
|
|
|
|
|
|
|
|
|
//保存数据
|
|
|
|
|
thrInvOrderMapper.insert(thrInvOrder);
|
|
|
|
@ -165,6 +168,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理高耗
|
|
|
|
|
*
|
|
|
|
|
* @param list
|
|
|
|
|
* @param thrInvOrderDetails
|
|
|
|
|
* @param billNo
|
|
|
|
@ -172,24 +176,49 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
* @param thrInvOrder
|
|
|
|
|
*/
|
|
|
|
|
private void handleExternalConvertThrInvGhOrderDetail(List<ThrInvResultResponse> list, List<ThrInvOrderDetail> thrInvOrderDetails, String billNo, String thirdSys, ThrInvOrder thrInvOrder) {
|
|
|
|
|
StringBuilder exmsg = new StringBuilder("");
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
String udiCode = item.getUdiCode();
|
|
|
|
|
UdiEntity udi = FilterUdiUtils.getUdi(udiCode);
|
|
|
|
|
/**
|
|
|
|
|
* udi 的 产品编号 获取产品信息 包装
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// TODO: 2024/3/4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail();
|
|
|
|
|
String udiCode = item.getUdiCode();
|
|
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(udiCode);
|
|
|
|
|
String nameCode = udiEntity.getUdi();
|
|
|
|
|
List<BasicProductsEntity> productsEntities = udiRelevanceDao.getProductsEntitiesByNameCode(nameCode);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(productsEntities)) {
|
|
|
|
|
BasicProductsEntity basicProductsEntity = productsEntities.get(0);
|
|
|
|
|
String mainAction = item.getMainAction();
|
|
|
|
|
String thrCode = item.getThrCode();
|
|
|
|
|
Long relId = basicProductsEntity.getId();
|
|
|
|
|
Integer count;
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(mainAction)) {
|
|
|
|
|
count = Integer.valueOf(item.getInCount());
|
|
|
|
|
} else {
|
|
|
|
|
count = Integer.valueOf(item.getOutCount());
|
|
|
|
|
}
|
|
|
|
|
BeanUtils.copyProperties(item, thrInvOrderDetail);
|
|
|
|
|
thrInvOrderDetail.setOrderIdFk(billNo);
|
|
|
|
|
thrInvOrderDetail.setNameCode(nameCode);
|
|
|
|
|
thrInvOrderDetail.setRelId(relId);
|
|
|
|
|
thrInvOrderDetail.setUdiCode(udiCode);
|
|
|
|
|
thrInvOrderDetail.setThrCode(thrCode);
|
|
|
|
|
thrInvOrderDetail.setReCount(String.valueOf(count));
|
|
|
|
|
thrInvOrderDetail.setBatchNo(udiEntity.getBatchNo());
|
|
|
|
|
thrInvOrderDetail.setProductionDate(udiEntity.getProduceDate());
|
|
|
|
|
thrInvOrderDetail.setExpireDate(udiEntity.getExpireDate());
|
|
|
|
|
thrInvOrderDetail.setSerialNo(udiEntity.getSerialNo());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetails.add(thrInvOrderDetail);
|
|
|
|
|
} else {
|
|
|
|
|
exmsg.append(udiCode + ",");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exmsg.length() > 0) {
|
|
|
|
|
exmsg.deleteCharAt(exmsg.length() - 1);
|
|
|
|
|
exmsg.insert(0, "以下UDI码未匹配成功:");
|
|
|
|
|
thrInvOrder.setExMsg(String.valueOf(exmsg));
|
|
|
|
|
}else {
|
|
|
|
|
thrInvOrder.setExMsg("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -318,6 +347,13 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean generateGhOrder(GenerateOrderRequest generateOrderRequest) {
|
|
|
|
|
String billNo = generateOrderRequest.getBillNo();
|
|
|
|
|
// TODO: 2024/3/5
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public boolean refreshOrder(RefreshOrderRequest refreshOrderRequest) {
|
|
|
|
|
String billNo = refreshOrderRequest.getBillNo();
|
|
|
|
@ -429,6 +465,54 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean refreshGhOrder(RefreshOrderRequest refreshOrderRequest) {
|
|
|
|
|
String billNo = refreshOrderRequest.getBillNo();
|
|
|
|
|
//通过单号获取单据信息
|
|
|
|
|
QueryWrapper<ThrInvOrder> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq("billNo", billNo);
|
|
|
|
|
ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw);
|
|
|
|
|
if (Objects.isNull(thrInvOrder)) return false;
|
|
|
|
|
|
|
|
|
|
//通过单号获取单据明细信息
|
|
|
|
|
QueryWrapper<ThrInvOrderDetail> qwd = new QueryWrapper<>();
|
|
|
|
|
qwd.eq("orderIdFk", billNo);
|
|
|
|
|
List<ThrInvOrderDetail> thrInvOrderDetails = thrInvOrderDetailMapper.selectList(qwd);
|
|
|
|
|
if (CollectionUtil.isEmpty(thrInvOrderDetails)) return false;
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails = new ArrayList<>();
|
|
|
|
|
StringBuilder exmsg = new StringBuilder("");
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetails.forEach(item -> {
|
|
|
|
|
Long relId = item.getRelId();
|
|
|
|
|
if (ObjectUtil.isNull(relId)) {
|
|
|
|
|
String nameCode = item.getNameCode();
|
|
|
|
|
List<BasicProductsEntity> productsEntities = udiRelevanceDao.getProductsEntitiesByNameCode(nameCode);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(productsEntities)) {
|
|
|
|
|
BasicProductsEntity basicProductsEntity = productsEntities.get(0);
|
|
|
|
|
item.setRelId(basicProductsEntity.getId());
|
|
|
|
|
updateThrInvOrderDetails.add(item);
|
|
|
|
|
} else {
|
|
|
|
|
exmsg.append(nameCode + ",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (exmsg.length() > 0) {
|
|
|
|
|
exmsg.deleteCharAt(exmsg.length() - 1);
|
|
|
|
|
exmsg.insert(0, "以下UDI码未匹配成功:");
|
|
|
|
|
thrInvOrder.setExMsg(String.valueOf(exmsg));
|
|
|
|
|
}else {
|
|
|
|
|
thrInvOrder.setExMsg("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新单据信息
|
|
|
|
|
thrInvOrderMapper.updateById(thrInvOrder);
|
|
|
|
|
//更新明细
|
|
|
|
|
if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验relId字段有空返回false
|
|
|
|
|
*
|
|
|
|
|