feat: 三方出入库明细功能

dev_20240306
chenhc 1 year ago
parent 96dba85918
commit 8c0e5a73ba

@ -53,7 +53,9 @@ public interface ThirdSysConstant {
/**
*
*/
String INV_ORDER_QUERY_URL = "invOrderUrl";
String INV_SF_ORDER_QUERY_URL = "invSfOrderUrl";
String INV_PH_ORDER_QUERY_URL = "invPhOrderUrl";
String INV_GH_ORDER_QUERY_URL = "invGhOrderUrl";
}

@ -75,7 +75,7 @@ public class TestController {
public BaseResponse downloadInvOrder() {
ThrSystemDetailEntity thrSystemDetailEntity = new ThrSystemDetailEntity();
thrSystemDetailEntity.setThirdSysFk("thirdId");
thrInvOrderService.downloadInvOrder(thrSystemDetailEntity);
thrInvOrderService.downloadInvSfOrder(thrSystemDetailEntity);
return ResultVOUtils.success("");
}

@ -150,6 +150,11 @@ public class ThrInvOrderDetail implements Serializable {
*/
private String remark;
/**
* udiCode
*/
private String udiCode;
private static final long serialVersionUID = 1L;

@ -78,7 +78,7 @@ public class ErpInvClient {
return responseList;
}
public BaseResponse<PageSimpleResponse<ThrInvResultResponse>> getInvResultSf(FilterInvProductRequest invProductRequest) {
public BaseResponse<PageSimpleResponse<ThrInvResultResponse>> getInvSfResult(FilterInvProductRequest invProductRequest) {
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(invProductRequest.getThirdSys());
// String url = basicThirdSysEntity.getThridUrl() + invProductRequest.getThirdSysUrlValue();
String url = "http://192.168.0.166:9997/udiwms/erp/inv/getInvResult";
@ -94,7 +94,7 @@ public class ErpInvClient {
}
}
public BaseResponse<PageSimpleResponse<ThrInvResultResponse>> getInvResultPh(FilterInvProductRequest invProductRequest) {
public BaseResponse<PageSimpleResponse<ThrInvResultResponse>> getInvPhResult(FilterInvProductRequest invProductRequest) {
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(invProductRequest.getThirdSys());
// String url = basicThirdSysEntity.getThridUrl() + invProductRequest.getThirdSysUrlValue();
String url = "http://192.168.0.166:9997/udiwms/erp/inv/getInvResult";
@ -110,7 +110,7 @@ public class ErpInvClient {
}
}
public BaseResponse<PageSimpleResponse<ThrInvResultResponse>> getInvResultGh(FilterInvProductRequest invProductRequest) {
public BaseResponse<PageSimpleResponse<ThrInvResultResponse>> getInvGhResult(FilterInvProductRequest invProductRequest) {
ThrSystemEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(invProductRequest.getThirdSys());
// String url = basicThirdSysEntity.getThridUrl() + invProductRequest.getThirdSysUrlValue();
String url = "http://192.168.0.166:9997/udiwms/erp/inv/getInvResult";

@ -150,5 +150,10 @@ public class ThrInvResultResponse {
*/
private BigDecimal amount;
/**
* udiCode
*/
private String udiCode;
}

@ -139,7 +139,7 @@ public class StockCompareServiceImpl extends CustomServiceImpl<StockCompareMappe
@Override
public void dlThrProduct(FilterInvProductRequest filterInvProductRequest) {
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvResultSf(filterInvProductRequest);
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvSfResult(filterInvProductRequest);
if (baseResponse.getCode() == 20000) {
List<ThrInvResultResponse> list = baseResponse.getData().getList();
list.forEach(item -> {

@ -12,16 +12,25 @@ import java.util.List;
public interface ThrInvOrderService {
/**
*
*
*/
public void handleExternalThrInvOrderSf(FilterInvProductRequest filterInvProductRequest);
public void handleExternalThrInvSfOrder(FilterInvProductRequest filterInvProductRequest);
/**
*
*
*/
public void handleExternalThrInvOrderPh(FilterInvProductRequest filterInvProductRequest);
public void handleExternalThrInvPhOrder(FilterInvProductRequest filterInvProductRequest);
void downloadInvOrder(ThrSystemDetailEntity thrSystemDetailEntity);
/**
*
*/
public void handleExternalThrInvGhOrder(FilterInvProductRequest filterInvProductRequest);
void downloadInvSfOrder(ThrSystemDetailEntity thrSystemDetailEntity);
void downloadInvPhOrder(ThrSystemDetailEntity thrSystemDetailEntity);
void downloadInvGhOrder(ThrSystemDetailEntity thrSystemDetailEntity);
/**
*

@ -16,6 +16,7 @@ import com.glxp.api.dao.thrsys.ThrInvOrderDetailMapper;
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.inout.IoOrderDetailBizEntity;
import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.entity.system.SystemParamConfigEntity;
@ -42,6 +43,7 @@ import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.service.thrsys.ThrInvOrderService;
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.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -89,8 +91,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
@Override
public void handleExternalThrInvOrderSf(FilterInvProductRequest filterInvProductRequest) {
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvResultSf(filterInvProductRequest);
public void handleExternalThrInvSfOrder(FilterInvProductRequest filterInvProductRequest) {
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvSfResult(filterInvProductRequest);
if (baseResponse.getCode() == 20000) {
List<ThrInvResultResponse> list = baseResponse.getData().getList();
if (CollectionUtil.isNotEmpty(list)) {
@ -114,8 +116,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
}
@Override
public void handleExternalThrInvOrderPh(FilterInvProductRequest filterInvProductRequest) {
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvResultPh(filterInvProductRequest);
public void handleExternalThrInvPhOrder(FilterInvProductRequest filterInvProductRequest) {
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvPhResult(filterInvProductRequest);
if (baseResponse.getCode() == 20000) {
List<ThrInvResultResponse> list = baseResponse.getData().getList();
if (CollectionUtil.isNotEmpty(list)) {
@ -138,7 +140,61 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
}
@Override
public void downloadInvOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
public void handleExternalThrInvGhOrder(FilterInvProductRequest filterInvProductRequest) {
BaseResponse<PageSimpleResponse<ThrInvResultResponse>> baseResponse = erpInvClient.getInvGhResult(filterInvProductRequest);
if (baseResponse.getCode() == 20000) {
List<ThrInvResultResponse> list = baseResponse.getData().getList();
if (CollectionUtil.isNotEmpty(list)) {
String billNo = generateBillNo(filterInvProductRequest);//单据号
//处理 返回实体 转换成 单据 和 单据明细
ThrInvOrder thrInvOrder = new ThrInvOrder();
List<ThrInvOrderDetail> thrInvOrderDetails = new ArrayList<>();
String thirdSys = filterInvProductRequest.getThirdSys();
handleExternalConvertThrInvGhOrderDetail(list, thrInvOrderDetails, billNo, thirdSys,thrInvOrder);
if (CollectionUtil.isNotEmpty(thrInvOrderDetails)) {
handleExternalConvertThrInvOrder(billNo, filterInvProductRequest, thrInvOrder, list.get(0),Constant.THR_INV_PH_ORDER_TYPE);
//保存数据
thrInvOrderMapper.insert(thrInvOrder);
thrInvOrderDetailMapper.insertBatch(thrInvOrderDetails);
}
}
}
}
/**
*
* @param list
* @param thrInvOrderDetails
* @param billNo
* @param thirdSys
* @param thrInvOrder
*/
private void handleExternalConvertThrInvGhOrderDetail(List<ThrInvResultResponse> list, List<ThrInvOrderDetail> thrInvOrderDetails, String billNo, String thirdSys, ThrInvOrder thrInvOrder) {
list.forEach( item -> {
String udiCode = item.getUdiCode();
UdiEntity udi = FilterUdiUtils.getUdi(udiCode);
/**
* udi
*
*/
// TODO: 2024/3/4
ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail();
});
}
@Override
public void downloadInvSfOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
log.info("自动抓取第三方收费出入库明细生成单据定时任务开始");
FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
filterInvProductRequest.setThirdSys(thrSystemDetailEntity.getThirdSysFk());
@ -147,11 +203,42 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
filterInvProductRequest.setStartDate(stringToDate(days + " 00:00:00"));
filterInvProductRequest.setEndDate(stringToDate(days + " 23:59:59"));
handleExternalThrInvOrderSf(filterInvProductRequest);
handleExternalThrInvSfOrder(filterInvProductRequest);
log.info("自动抓取第三方收费出入库明细生成单据定时任务结束");
}
@Override
public void downloadInvPhOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
log.info("自动抓取第三方普耗出入库明细生成单据定时任务开始");
FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
filterInvProductRequest.setThirdSys(thrSystemDetailEntity.getThirdSysFk());
filterInvProductRequest.setThirdSysUrlValue(thrSystemDetailEntity.getValue());
String days = getBeginAndEndDateByDays(1);
filterInvProductRequest.setStartDate(stringToDate(days + " 00:00:00"));
filterInvProductRequest.setEndDate(stringToDate(days + " 23:59:59"));
handleExternalThrInvPhOrder(filterInvProductRequest);
log.info("自动抓取第三方普耗出入库明细生成单据定时任务结束");
}
@Override
public void downloadInvGhOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
log.info("自动抓取第三方高耗出入库明细生成单据定时任务开始");
FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
filterInvProductRequest.setThirdSys(thrSystemDetailEntity.getThirdSysFk());
filterInvProductRequest.setThirdSysUrlValue(thrSystemDetailEntity.getValue());
String days = getBeginAndEndDateByDays(1);
filterInvProductRequest.setStartDate(stringToDate(days + " 00:00:00"));
filterInvProductRequest.setEndDate(stringToDate(days + " 23:59:59"));
handleExternalThrInvGhOrder(filterInvProductRequest);
log.info("自动抓取第三方高耗出入库明细生成单据定时任务结束");
}
@Override
public List<ThrInvOrder> filterThrInvOrder(FilterThrInvOrderRequest filterThrInvOrderRequest) {
if (filterThrInvOrderRequest == null) {
@ -293,22 +380,23 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
String thirdSysFk = thrInvOrder.getThirdSysFk();
List<String> thrCodes = thrInvOrderDetails.stream().filter(x->ObjectUtil.isNull(x.getRelId()))
.map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList());
MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk);
Map<String, Long> mainIdRelIdMap = map.getMainIdRelIdMap();
thrInvOrderDetails.forEach(item -> {
if (ObjectUtil.isNull(item.getRelId())){
String thrCode = item.getThrCode();
Long relId = mainIdRelIdMap.get(thrCode);
if (ObjectUtil.isNotNull(relId)){
item.setRelId(relId);
updateThrInvOrderDetails.add(item);
}else {
exmsg.append(thrCode+",");
if (CollectionUtil.isNotEmpty(thrCodes)) {
MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk);
Map<String, Long> mainIdRelIdMap = map.getMainIdRelIdMap();
thrInvOrderDetails.forEach(item -> {
if (ObjectUtil.isNull(item.getRelId())){
String thrCode = item.getThrCode();
Long relId = mainIdRelIdMap.get(thrCode);
if (ObjectUtil.isNotNull(relId)){
item.setRelId(relId);
updateThrInvOrderDetails.add(item);
}else {
exmsg.append(thrCode+",");
}
}
}
});
});
}
if (exmsg.length() > 0){
exmsg.deleteCharAt(exmsg.length()-1);

@ -141,9 +141,17 @@ public class SyncThirdSysTask implements SchedulingConfigurer {
//下载患者信息
downloadSicker(thrSystemDetailEntity);
break;
case ThirdSysConstant.INV_ORDER_QUERY_URL:
//下载出入库明细
downloadInvOrder(thrSystemDetailEntity);
case ThirdSysConstant.INV_SF_ORDER_QUERY_URL:
//下载出入库明细收费
downloadInvSfOrder(thrSystemDetailEntity);
break;
case ThirdSysConstant.INV_PH_ORDER_QUERY_URL:
//下载出入库明细普耗
downloadInvPhOrder(thrSystemDetailEntity);
break;
case ThirdSysConstant.INV_GH_ORDER_QUERY_URL:
//下载出入库明细高耗
downloadInvGhOrder(thrSystemDetailEntity);
break;
default:
//其他接口暂不处理
@ -183,23 +191,66 @@ public class SyncThirdSysTask implements SchedulingConfigurer {
*
* @param thrSystemDetailEntity
*/
private void downloadInvOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
private void downloadInvSfOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
//校验任务并更新redis数据执行标识
if (verifyTask(thrSystemDetailEntity)) {
getExecutor().submit(() -> {
log.info("开始下载三方出入库明细");
log.info("开始下载三方出入库明细收费");
try {
thrInvOrderService.downloadInvOrder(thrSystemDetailEntity);
thrInvOrderService.downloadInvSfOrder(thrSystemDetailEntity);
} catch (Exception e) {
log.error("下载三方出入库明细异常", ExceptionUtils.getStackTrace(e));
log.error("下载三方出入库明细收费异常", ExceptionUtils.getStackTrace(e));
} finally {
updateTask(getTaskKey(thrSystemDetailEntity));
}
log.info("下载三方出入库明细完成");
log.info("下载三方出入库明细收费完成");
});
}
}
/**
*
*
* @param thrSystemDetailEntity
*/
private void downloadInvPhOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
//校验任务并更新redis数据执行标识
if (verifyTask(thrSystemDetailEntity)) {
getExecutor().submit(() -> {
log.info("开始下载三方出入库明细普耗");
try {
thrInvOrderService.downloadInvPhOrder(thrSystemDetailEntity);
} catch (Exception e) {
log.error("下载三方出入库明细普耗异常", ExceptionUtils.getStackTrace(e));
} finally {
updateTask(getTaskKey(thrSystemDetailEntity));
}
log.info("下载三方出入库明细普耗完成");
});
}
}
/**
*
*
* @param thrSystemDetailEntity
*/
private void downloadInvGhOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
//校验任务并更新redis数据执行标识
if (verifyTask(thrSystemDetailEntity)) {
getExecutor().submit(() -> {
log.info("开始下载三方出入库明细高耗");
try {
thrInvOrderService.downloadInvGhOrder(thrSystemDetailEntity);
} catch (Exception e) {
log.error("下载三方出入库明细高耗异常", ExceptionUtils.getStackTrace(e));
} finally {
updateTask(getTaskKey(thrSystemDetailEntity));
}
log.info("下载三方出入库明细高耗完成");
});
}
}
/**
*

@ -31,13 +31,14 @@
<result column="mainAction" jdbcType="VARCHAR" property="mainAction" />
<result column="manufacturer" jdbcType="VARCHAR" property="manufacturer" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="udiCode" jdbcType="VARCHAR" property="udiCode" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, orderIdFk, cpmctymc, relId, thrCode, nameCode, ggxh, batchNo, measname, price,
productionDate, expireDate, ylqxzcrbarmc, zczbhhzbapzbh, inCount, outCount, supName,
deptName, deptCode, invName, invCode, spaceCode, spaceName, reCount, mainAction,
manufacturer, remark
manufacturer, remark,udiCode
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
@ -61,7 +62,7 @@
supName, deptName, deptCode,
invName, invCode, spaceCode,
spaceName, reCount, mainAction,
manufacturer, remark)
manufacturer, remark,udiCode)
values (#{orderIdFk,jdbcType=VARCHAR}, #{cpmctymc,jdbcType=VARCHAR}, #{relId,jdbcType=INTEGER},
#{thrCode,jdbcType=VARCHAR}, #{nameCode,jdbcType=VARCHAR}, #{ggxh,jdbcType=VARCHAR},
#{batchNo,jdbcType=VARCHAR}, #{measname,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL},
@ -70,7 +71,7 @@
#{supName,jdbcType=VARCHAR}, #{deptName,jdbcType=VARCHAR}, #{deptCode,jdbcType=VARCHAR},
#{invName,jdbcType=VARCHAR}, #{invCode,jdbcType=VARCHAR}, #{spaceCode,jdbcType=VARCHAR},
#{spaceName,jdbcType=VARCHAR}, #{reCount,jdbcType=VARCHAR}, #{mainAction,jdbcType=VARCHAR},
#{manufacturer,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR})
#{manufacturer,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{udiCode,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrInvOrderDetail" useGeneratedKeys="true">
<!--@mbg.generated-->
@ -154,6 +155,9 @@
<if test="remark != null">
remark,
</if>
<if test="udiCode != null">
udiCode,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderIdFk != null">
@ -234,6 +238,9 @@
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="udiCode != null">
#{udiCode,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.glxp.api.entity.thrsys.ThrInvOrderDetail">
@ -318,6 +325,9 @@
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="udiCode != null">
udiCode = #{udiCode,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
@ -349,7 +359,8 @@
reCount = #{reCount,jdbcType=VARCHAR},
mainAction = #{mainAction,jdbcType=VARCHAR},
manufacturer = #{manufacturer,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR}
remark = #{remark,jdbcType=VARCHAR},
udiCode = #{udiCode,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>

@ -592,3 +592,4 @@ VALUES (2089, '高耗出入库明细', 2086, 1, 'thirdSys/invOrder/thrInvGhOrder
CALL Pro_Temp_ColumnWork('thr_inv_order', 'sourceType', ' int(0) NULL DEFAULT NULL COMMENT ''来源类型1收费2普耗3高耗'' AFTER `remark`', 1);
CALL Pro_Temp_ColumnWork('thr_inv_order', 'exMsg', ' varchar(510) NULL DEFAULT NULL COMMENT ''单据异常信息'' AFTER `remark`', 1);
CALL Pro_Temp_ColumnWork('thr_inv_order', 'skProject',' int(0) NULL DEFAULT NULL COMMENT ''是否组套'' AFTER `remark`', 1);
CALL Pro_Temp_ColumnWork('thr_inv_order_detail', 'udiCode',' varchar(255) NULL DEFAULT NULL COMMENT ''udiCode'' AFTER `remark`', 1);

Loading…
Cancel
Save