新增第三方单据自动下载与配置,日志生成等

dev
anthonywj 2 years ago
parent 660d748cfa
commit d53c9e87ab

@ -103,6 +103,7 @@ public class ThrSystemController {
ThrSystemEntity thrSystemEntity = thrSystemService.selectByThirdId(filterBasicThirdSysDetailRequest.getThirdSysFk());
return ResultVOUtils.success(thrSystemEntity);
}
//接口设置编辑
@PostMapping("/udiwms/basic/thirdsys/update")
public BaseResponse save(@RequestBody @Valid ThrSystemEntity thrSystemEntity,
@ -235,7 +236,6 @@ public class ThrSystemController {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrSystemBusApiEntity> basicThirdSysEntities = thrSystemBusApiService.filterSysBusApi(filterBasicThirdSysDetailRequest);
PageInfo<ThrSystemBusApiEntity> pageInfo;
pageInfo = new PageInfo<>(basicThirdSysEntities);
PageSimpleResponse<ThrSystemBusApiEntity> pageSimpleResponse = new PageSimpleResponse<>();

@ -30,6 +30,9 @@ public class ThrSystemBusApiEntity {
@TableField(value = "url")
private String url;
/**
* 1:2
*/
@TableField(value = "`type`")
private Integer type;

@ -25,6 +25,7 @@ public class ThrSystemDetailEntity {
*
*/
private Integer time;
private Integer dlLastTime;
public String getValue() {
if (value == null)

@ -710,7 +710,7 @@ public class IoOrderServiceImpl implements IoOrderService {
if (filterOrderRequest.getVueType() == null)
return null;
bussinessTypeEntities = basicBussinessTypeService.findByVueType(filterOrderRequest.getVueType());
if(CollectionUtils.isEmpty(bussinessTypeEntities)){
if (CollectionUtils.isEmpty(bussinessTypeEntities)) {
return null;
}
actions = bussinessTypeEntities.stream().map(BasicBussinessTypeEntity::getAction).collect(Collectors.toList());
@ -893,7 +893,7 @@ public class IoOrderServiceImpl implements IoOrderService {
public BaseResponse submitOrderToThrSys(ThrSystemDetailEntity thrSystemDetailEntity) {
//查询可以提交到第三方系统的单据
SyncUploadDataSetEntity syncUploadDataSetEntity = syncUploadDataSetService.selectSet();
List<String> billNos = orderDao.selectWaitSubmitOrder(thrSystemDetailEntity.getThirdSysFk(),syncUploadDataSetEntity.getOrderStartTime());
List<String> billNos = orderDao.selectWaitSubmitOrder(thrSystemDetailEntity.getThirdSysFk(), syncUploadDataSetEntity.getOrderStartTime());
if (CollUtil.isNotEmpty(billNos)) {
log.info("开始提交单据到第三方系统,本次提交单据数量:{}", billNos.size());
for (String billNo : billNos) {

@ -2,6 +2,7 @@ package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
@ -34,4 +35,7 @@ public interface ThrOrderService {
boolean deleteAll();
void downloadThrOrder(ThrSystemDetailEntity thrSystemDetailEntity);
}

@ -46,10 +46,6 @@ public class ThrOrdersDlService {
private ThrOrderImportLogService thrOrderImportLogService;
@Resource
ThrOrderExportLogService thrOrderExportLogService;
@Resource
ThrOrderImportDetailService thrOrderImportDetailService;
// @Resource
// ThrOrderImportService thrOrderImportService;
@Resource
private ErpOrderClient erpOrderClient;
@ -88,7 +84,6 @@ public class ThrOrdersDlService {
}
thrOrderImportLogService.importThrOrder(genKey);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
}

@ -1,12 +1,14 @@
package com.glxp.api.service.thrsys;
import com.baomidou.mybatisplus.extension.service.IService;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.api.req.thrsys.FilterBasicThirdSysDetailRequest;
import java.util.List;
public interface ThrSystemBusApiService {
public interface ThrSystemBusApiService extends IService<ThrSystemBusApiEntity> {
boolean insertSysBusApi(ThrSystemBusApiEntity basicThirdSysEntity);

@ -1,17 +1,27 @@
package com.glxp.api.service.thrsys.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.dao.thrsys.ThrOrderDao;
import com.glxp.api.dao.thrsys.ThrOrderDetailDao;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.entity.thrsys.*;
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.thrsys.ThrOrderImportLogService;
import com.glxp.api.service.thrsys.ThrOrderService;
import com.glxp.api.service.thrsys.ThrOrdersDlService;
import com.glxp.api.service.thrsys.ThrSystemBusApiService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.MsDateUtil;
import com.glxp.api.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -19,8 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class ThrOrderServiceImpl implements ThrOrderService {
@ -28,6 +40,14 @@ public class ThrOrderServiceImpl implements ThrOrderService {
private ThrOrderDao thrOrderDao;
@Resource
private ThrOrderDetailDao thrOrderDetailDao;
@Resource
ThrSystemBusApiService thrSystemBusApiService;
@Resource
private ThrOrderImportLogService thrOrderImportLogService;
@Resource
ThrOrdersDlService thrOrdersDlService;
@Resource
RedisUtil redisUtil;
@Override
public List<ThrOrderEntity> filterThrOrder(FilterThrOrderRequest filterThrOrderRequest) {
@ -171,4 +191,41 @@ public class ThrOrderServiceImpl implements ThrOrderService {
public boolean deleteAll() {
return thrOrderDao.deleteAll();
}
@Override
public void downloadThrOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
String data = (String) redisUtil.get(Constant.dlThrOrders);
if ((data != null && data.equals("true"))) {
log.error("当前任务正在下载更新业务单据信息,请稍后重试!");
return;
} else {
redisUtil.set(Constant.dlThrOrders, "true", 1);
List<ThrSystemBusApiEntity> thrSystemBusApiEntities = thrSystemBusApiService.list(new QueryWrapper<ThrSystemBusApiEntity>().eq("thirdSys", "thirdId").eq("type", 1));
if (CollUtil.isNotEmpty(thrSystemBusApiEntities)) {
for (ThrSystemBusApiEntity thrSystemBusApiEntity : thrSystemBusApiEntities) {
if (StrUtil.isNotEmpty(thrSystemBusApiEntity.getUrl()) && StrUtil.isNotEmpty(thrSystemBusApiEntity.getThirdBuyCode())) {
FilterThrOrderRequest filterErpOrderRequest = new FilterThrOrderRequest();
filterErpOrderRequest.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
if (thrSystemDetailEntity.getDlLastTime() == null)
thrSystemDetailEntity.setDlLastTime(3 * 24);
Date stateDate = MsDateUtil.getBeforeDay(new Date(), IntUtil.value(thrSystemDetailEntity.getDlLastTime()));
filterErpOrderRequest.setStartDate(MsDateUtil.formatDate(stateDate));
filterErpOrderRequest.setEndDate(MsDateUtil.formatDate(new Date()));
filterErpOrderRequest.setBillAction(thrSystemBusApiEntity.getThirdBuyCode());
ThrOrderImportLogEntity thrOrderImportLogEntity = new ThrOrderImportLogEntity();
String genKey = CustomUtil.getId();
thrOrderImportLogEntity.setGenKey(genKey);
thrOrderImportLogEntity.setFromType("后台自动下载");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogEntity.setThirdSysFk("thirdId");
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
thrOrdersDlService.importOrders(genKey, filterErpOrderRequest.getBillAction(), filterErpOrderRequest);
}
}
}
}
}
}

@ -2,7 +2,10 @@ package com.glxp.api.service.thrsys.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.dao.thrsys.ThrProductsDao;
import com.glxp.api.dao.thrsys.ThrSystemBusApiDao;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.api.req.thrsys.FilterBasicThirdSysDetailRequest;
import com.glxp.api.service.thrsys.ThrSystemBusApiService;
@ -14,7 +17,7 @@ import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class ThrSystemBusApiServiceImpl implements ThrSystemBusApiService {
public class ThrSystemBusApiServiceImpl extends ServiceImpl<ThrSystemBusApiDao, ThrSystemBusApiEntity> implements ThrSystemBusApiService {
@Resource
ThrSystemBusApiDao thrSystemBusApiDao;

@ -14,10 +14,7 @@ import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.res.thrsys.ThirdSysInterfaceExecuteVo;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.thrsys.IThrBusTypeOriginService;
import com.glxp.api.service.thrsys.ThrCorpService;
import com.glxp.api.service.thrsys.ThrInvWarehouseService;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.glxp.api.service.thrsys.*;
import com.glxp.api.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
@ -59,7 +56,8 @@ public class SyncThirdSysTask implements SchedulingConfigurer {
private IThrBusTypeOriginService thrBusTypeOriginService;
@Resource
private IoOrderService orderService;
@Resource
ThrOrderService thrOrderService;
final Logger logger = LoggerFactory.getLogger(SyncHeartTask.class);
@Resource
@ -124,6 +122,9 @@ public class SyncThirdSysTask implements SchedulingConfigurer {
//提交单据
submitOrder(thrSystemDetailEntity);
break;
case ThirdSysConstant.ORDER_QUERY_URL:
downloadThrOrder(thrSystemDetailEntity);
break;
default:
//其他接口暂不处理
break;
@ -246,6 +247,28 @@ public class SyncThirdSysTask implements SchedulingConfigurer {
}
}
/**
*
*
* @param thrSystemDetailEntity
*/
private void downloadThrOrder(ThrSystemDetailEntity thrSystemDetailEntity) {
//校验任务并更新redis数据执行标识
if (verifyTask(thrSystemDetailEntity)) {
getExecutor().submit(() -> {
log.info("开始下载第三方业务单据");
try {
thrOrderService.downloadThrOrder(thrSystemDetailEntity);
} catch (Exception e) {
log.error("下载第三方业务单据", e);
} finally {
updateTask(getTaskKey(thrSystemDetailEntity));
}
log.info("第三方业务单据下载完成");
});
}
}
/**
*
*

@ -46,7 +46,7 @@
ORDER BY thr_order.updateTime DESC
</select>
<insert id="insertThrOrder" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrOrderEntity">
<insert id="insertThrOrder" parameterType="com.glxp.api.entity.thrsys.ThrOrderEntity">
replace
INTO thr_order
(id, billFlag, billNo, billdate, billType, corpId, corpName, inoutType, deptCode,

@ -2,21 +2,41 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrSystemDetailDao">
<update id="updateBasicThirdSysDetail" parameterType="com.glxp.api.entity.thrsys.ThrSystemDetailEntity">
UPDATE thr_system_detail
<trim prefix="set" suffixOverrides=",">
<if test="value != null">value=#{value},</if>
<if test="enabled != null">enabled=#{enabled},</if>
<if test="itrCache != null">itrCache=#{itrCache},</if>
<if test="guideUrl != null">guideUrl=#{guideUrl},</if>
<if test="remark != null">remark=#{remark},</if>
<if test="name != null">name=#{name},</if>
<if test="fromType != null">fromType=#{fromType},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="time != null">time=#{time},</if>
<if test="value != null">
value=#{value},
</if>
<if test="enabled != null">
enabled=#{enabled},
</if>
<if test="itrCache != null">
itrCache=#{itrCache},
</if>
<if test="guideUrl != null">
guideUrl=#{guideUrl},
</if>
<if test="remark != null">
remark=#{remark},
</if>
<if test="name != null">
name=#{name},
</if>
<if test="fromType != null">
fromType=#{fromType},
</if>
<if test="thirdSysFk != null">
thirdSysFk=#{thirdSysFk},
</if>
<if test="time != null">
time=#{time},
</if>
<if test="dlLastTime != null">
dlLastTime=#{dlLastTime},
</if>
</trim>
WHERE id=#{id}
WHERE id = #{id}
</update>
<select id="filterBasicThirdSysDetail" parameterType="com.glxp.api.req.thrsys.FilterBasicThirdSysRequest"
@ -40,7 +60,7 @@
resultType="com.glxp.api.entity.thrsys.ThrSystemDetailEntity">
select thr_system_detail.*, thr_system.thridUrl
FROM thr_system_detail
inner join thr_system on thr_system_detail.thirdSysFk = thr_system.thirdId
inner join thr_system on thr_system_detail.thirdSysFk = thr_system.thirdId
WHERE thr_system_detail.key = #{key}
and thr_system_detail.thirdSysFk = #{thirdSys}
and thr_system.enabled = 1
@ -50,11 +70,11 @@
SELECT tsd.*,
ts.thridUrl
FROM thr_system_detail tsd
INNER JOIN thr_system ts ON tsd.thirdSysFk = ts.thirdId
INNER JOIN thr_system ts ON tsd.thirdSysFk = ts.thirdId
WHERE ts.enabled = 1
AND tsd.fromType = 3
AND tsd.enabled = 1
AND (tsd.`value` is not null and tsd.`value` != '')
AND tsd.time > 0
</select>
</mapper>
</mapper>

@ -504,7 +504,6 @@ call Modify_index('basic_products', 'nameCode', 'idex_nameCode', 'BTREE');
CALL Pro_Temp_ColumnWork('basic_products', 'sfwblztlcp', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_products', 'cgzmraqxgxx', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_products', 'sfbjwycxsy', 'varchar(255)', 1);
@ -514,6 +513,9 @@ CALL Pro_Temp_ColumnWork('basic_products', 'syqsfxyjxmj', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_products', 'mjfs', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_products', 'categoryName', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('thr_system_detail', 'dlLastTime', 'int', 1);
INSERT ignore INTO `sys_param_config`(id, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`,
`paramType`,
`paramExplain`, `updateTime`)

Loading…
Cancel
Save