Merge remote-tracking branch 'origin/master'

master
郑明梁 2 years ago
commit be77e4a07a

@ -2,17 +2,43 @@ package com.glxp.api.controller.sync;
import cn.hutool.core.collection.CollUtil;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.dao.inout.IoCodeTempDao;
import com.glxp.api.dao.inout.IoOrderDao;
import com.glxp.api.dao.inout.IoOrderDetailBizDao;
import com.glxp.api.dao.inout.IoOrderDetailCodeDao;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.sync.BasicDownloadStatusEntity;
import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.entity.sync.SyncDataBustypeEntity;
import com.glxp.api.entity.sync.SyncDataSetEntity;
import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.res.sync.SpsSyncOrderResponse;
import com.glxp.api.res.system.SyncDataSetResponse;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.sync.BasicDownloadService;
import com.glxp.api.service.sync.BasicExportService;
import com.glxp.api.service.sync.SpsSyncDownloadService;
import com.glxp.api.util.CustomUtil;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@RestController
public class SpsSyncDownloadController {
@ -21,7 +47,15 @@ public class SpsSyncDownloadController {
SpsSyncDownloadService spsSyncDownloadService;
@Resource
BasicExportService basicExportService;
@Resource
BasicDownloadService basicDownloadService;
@Resource
SqlSessionFactory sqlSessionFactory;
@Resource
IoOrderService orderService;
// 下发单据生成单据任务由中继服务UDI管理系统下载
@AuthRuleAnnotation("")
@GetMapping("sps/sync/order")
public BaseResponse findOrder(SpsSyncDataRequest spsSyncDataRequest) {
@ -44,5 +78,94 @@ public class SpsSyncDownloadController {
return baseResponse;
}
// 接收中继服务、UDI管理系统上传单据
@AuthRuleAnnotation("sps/sync/order/upload")
@PostMapping("/sps/sync/order/upload")
public BaseResponse save(@RequestBody @Valid SpsSyncOrderResponse syncDataResponse) {
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(syncDataResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER);
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT); //下载中
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuffer remark = new StringBuffer();
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) {
try {
List<IoOrderEntity> orderEntities = syncDataResponse.getOrderEntities();
IoOrderDao mapper = batchSession.getMapper(IoOrderDao.class);
for (IoOrderEntity orderEntity : orderEntities) {
orderEntity.setUpdateTime(null);
orderEntity.setFromType(ConstantStatus.FROM_UDISP);
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
IoOrderEntity temp = orderService.findById(orderEntity.getBillNo());
if (temp == null) {
orderEntity.setId(null);
mapper.insert(orderEntity);
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) {
IoCodeTempDao codeMappert = batchSession.getMapper(IoCodeTempDao.class);
List<IoCodeEntity> warehouseEntityList = syncDataResponse.getCodeEntities();
for (IoCodeEntity warehouseEntity : warehouseEntityList) {
if (warehouseEntity.getOrderId().equals(orderEntity.getBillNo())) {
IoCodeTempEntity codeTempEntity = new IoCodeTempEntity();
BeanUtils.copyProperties(warehouseEntity, codeTempEntity);
codeTempEntity.setId(null);
codeMappert.insert(codeTempEntity);
}
}
}
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) {
IoOrderDetailBizDao orderDetailBizDao = batchSession.getMapper(IoOrderDetailBizDao.class);
List<IoOrderDetailBizEntity> orderDetailBizEntities = syncDataResponse.getOrderDetailBizEntities();
for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) {
if (bizEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderDetailBizDao.insert(bizEntity);
}
}
}
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) {
IoOrderDetailCodeDao orderDetailCodeDao = batchSession.getMapper(IoOrderDetailCodeDao.class);
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = syncDataResponse.getOrderDetailCodeEntities();
for (IoOrderDetailCodeEntity detailCodeEntity : orderDetailCodeEntities) {
if (detailCodeEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderDetailCodeDao.insert(detailCodeEntity);
}
}
}
batchSession.commit();
}
}
batchSession.commit();
String logs = "";
if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities()))
logs = logs + "单据:" + syncDataResponse.getOrderEntities().size() + "条\n";
if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities()))
logs = logs + "单据详情:" + syncDataResponse.getOrderDetailBizEntities().size() + "条\n";
if (CollUtil.isNotEmpty(syncDataResponse.getCodeEntities()))
logs = logs + "单据条码信息:" + syncDataResponse.getCodeEntities().size() + "条\n";
remark.append(logs);
} catch (Exception e) {
e.printStackTrace();
}
}
batchSession.close();
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS);
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
return ResultVOUtils.success("上传成功!");
}
}

@ -27,5 +27,10 @@ public interface SysLogininforMapper {
*/
void insertLogininfor(SysLogininfor logininfor);
/**
*
*
* @param date
*/
void deleteByDate(@Param("date") String date);
}

@ -25,4 +25,5 @@ public interface SysOperLogMapper {
SysOperLog selectById(Long id);
void deleteByDate(@Param("date") String date);
}

@ -22,4 +22,5 @@ public interface BasicDownloadDao {
boolean updateDownloadStatus(BasicDownloadStatusEntity basicDownloadStatusEntity);
void deleteByDate(@Param("date") String date);
}

@ -21,4 +21,5 @@ public interface BasicExportDao {
boolean updateExportStatus(BasicExportStatusEntity warehouseEntity);
void deleteByDate(@Param("date") String date);
}

@ -23,4 +23,11 @@ public interface ThrCorpExportLogDao {
boolean deleteByTime();
String selectFilePathById(@Param("id") String id);
/**
*
*
* @param date
*/
void deleteByDate(@Param("date") String date);
}

@ -3,7 +3,6 @@ package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.req.thrsys.FilterThrProductsImportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -22,4 +21,5 @@ public interface ThrCorpImportLogDao {
boolean deleteByTime();
void deleteByDate(@Param("date") String date);
}

@ -17,4 +17,6 @@ public interface ThrInvProductsExportLogDao {
boolean updateThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity);
boolean deleteById(@Param("id") String id);
void deleteByDate(@Param("date") String date);
}

@ -19,4 +19,5 @@ public interface ThrInvProductsImportLogDao {
boolean deleteById(@Param("id") String id);
void deleteByDate(@Param("date") String date);
}

@ -20,4 +20,6 @@ public interface ThrOrderExportLogDao {
boolean deleteById(@Param("id") String id);
boolean deleteByTime();
void deleteByDate(@Param("date") String date);
}

@ -21,4 +21,6 @@ public interface ThrOrderImportLogDao {
boolean deleteByTime();
void deleteByDate(@Param("date") String date);
}

@ -28,4 +28,6 @@ public interface ThrProductsExportLogDao {
String selectFilePathById(@Param("id") String id);
boolean deleteByTime();
void deleteByDate(@Param("date") String date);
}

@ -19,4 +19,6 @@ public interface ThrProductsImportLogDao {
boolean deleteById(@Param("id") String id);
boolean deleteByTime();
void deleteByDate(@Param("date") String date);
}

@ -69,16 +69,16 @@ public class IdcServiceImpl implements IdcService {
/*同步表,格式:同步设置表列名/同步设置表列名(子表时设置,主表不设置)/主表唯一列(多列逗号分隔)/主表关联列/子表关联列/数据库实际表/时间列/图片或文件列/数据条件/说明*/
private final String[] SYNC_TABLES= {
"entrustAction/////////委托验收","basicProducts//basic_udirel/uuid///updateTime///耗材字典","/basicProducts/basic_products/uuid,nameCode/uuid/uuid////耗材字典信息详情",
"entrustAction//basic_entrust_accept/id//////委托验收","basicProducts//basic_udirel/id///updateTime///耗材字典","/basicProducts/basic_products/id/uuid/uuid////耗材字典信息详情",
"//company_product_relevance////updateTime///供应商关联信息",
"basicCorp//basic_corp/erpId///updateTime///往来单位","typeThird//thr_bustype_origin/action,thirdSys///updateTime///第三方单据类型",
"basicThirdCorp//thr_corp/unitId,thirdSysFk///updateTime///第三方往来单位","//thr_dept/code,thirdSysFk///updateTime///第三方部门",
"//thr_inv_products/inventoryCode,batchNo,warehouseCode,spaceCode,thirdSysFk///updateTime///第三方库存","basicThirdInv//thr_inv_warehouse/code,thirdSysFk//////第三方仓库",
"basicThirdBusOrder//thr_order/billNo,thirdSysFk///updateTime///第三方业务单据","/basicThirdBusOrder/thr_order_detail/productId,orderIdFk,thirdSysFk///updateTime///第三方单据详情",
"basicThirdProducts//thr_products/code,thirdSysFk///updateTime///第三方产品信息","//sup_cert////updateTime/filePath//资质证书信息",
"//sup_cert_set////updateTime///供应商资质证书设置","companyCert//sup_company////updateTime///配送企业",
"manufacturerCert//sup_manufacturer////updateTime///生产企业","productCert//sup_product/productId,manufacturerIdFk,customerId///updateTime///产品资质信息",
"dbDiProducts//productinfo/nameCode,uuid,diType///updateTime///DI产品信息//udicompany/tyshxydm///updateTime///国际库医疗器械注册人信息"};
"basicCorp//basic_corp/id///updateTime///往来单位","typeThird//thr_bustype_origin/id///updateTime///第三方单据类型",
"basicThirdCorp//thr_corp/id///updateTime///第三方往来单位","//thr_dept/id///updateTime///第三方部门",
"//thr_inv_products/id///updateTime///第三方库存","basicThirdInv//thr_inv_warehouse/id//////第三方仓库",
"basicThirdBusOrder//thr_order/id///updateTime///第三方业务单据","/basicThirdBusOrder/thr_order_detail/orderIdFk///updateTime///第三方单据详情",
"basicThirdProducts//thr_products/id///updateTime///第三方产品信息","//sup_cert/id///updateTime/filePath//资质证书信息",
"//sup_cert_set/id///updateTime///供应商资质证书设置","companyCert//sup_company/customerId///updateTime///配送企业",
"manufacturerCert//sup_manufacturer/id///updateTime///生产企业","productCert//sup_product/id///updateTime///产品资质信息",
"dbDiProducts//productinfo/id///updateTime///DI产品信息","//udicompany/id///updateTime///国际库医疗器械注册人信息"};
private int orderNum=0;
@ -436,6 +436,7 @@ public class IdcServiceImpl implements IdcService {
String messageType = params.get("messageType").toString();
saveIdcLog(messageType,"",tableName +">"+where,0,total);
if(total>0) {
success = true;
@ -548,7 +549,7 @@ public class IdcServiceImpl implements IdcService {
private void analyData(String tableName,String uniqueColumn,List<Map<String,Object>> list) {
String tName = DBAUtils.tableRealName(tableName);
String sql="insert into "+tName +"(";
String sql="replace "+tName +"(";
String del="delete from "+tName+" where ";
String upd="update "+tName+" set ";
String[] keyColumn=new String[30];
@ -560,16 +561,15 @@ public class IdcServiceImpl implements IdcService {
if(col>0)
sql+=",";
columnList.get(i).put("attrName", columnList.get(i).get("columnName"));
String extra = columnList.get(i).get("extra")!=null&&columnList.get(i).get("extra").toLowerCase().contains("auto_i") ? "A" : "N";
sql+=extra.equals("N") ? columnList.get(i).get("columnName").toString() : "";
col+=extra.equals("N") ? 1 : 0;
sql+= columnList.get(i).get("columnName").toString() ;
col++;
if(uniqueColumn!=null&&columnList.get(i).get("columnKey")!=null&&(","+uniqueColumn+",").contains(","+columnList.get(i).get("columnName")+",")) {
keyColumn[key] = columnList.get(i).get("columnName").toString();
keyDataType[key]=columnList.get(i).get("dataType").toString().contains("char") ? "C" : columnList.get(i).get("dataType").toString().contains("date") ? "D" : "N";
key++;
} else {
if(columnList.get(i).get("columnKey")!=null&&!StringUtils.isEmpty(columnList.get(i).get("columnKey").toString())&&
("PRI,UNI,MUL".contains(columnList.get(i).get("columnKey").toString()))&&extra.equals("N")) {
("PRI".contains(columnList.get(i).get("columnKey").toString()))) {
keyColumn[key] = columnList.get(i).get("columnName").toString();
keyDataType[key]=columnList.get(i).get("dataType").toString().contains("char") ? "C" : columnList.get(i).get("dataType").toString().contains("date") ? "D" : "N";
key++;
@ -594,9 +594,11 @@ public class IdcServiceImpl implements IdcService {
updateWhere+=keyColumn[z]+" = "+(keyDataType[z].equals("C") ? "'" :"") +value +(keyDataType[z].equals("C") ? "'" :"");
}
}
if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere))
dbDao.delete(del+updateWhere);
}
/*A 新增 U 更新*/
if("A,U".contains(operateMode)) {
sql+=n>0 ? "," : "";
@ -604,13 +606,12 @@ public class IdcServiceImpl implements IdcService {
int m = 0;
int h = 0;
for(int k=0;k<columnList.size();k++) {
String extra = columnList.get(k).get("extra")!=null&&columnList.get(k).get("extra").toLowerCase().contains("auto") ? "A" : "N";
String attrName = columnList.get(k).get("attrName");
String value = list.get(i).get(attrName) !=null ? list.get(i).get(attrName).toString() : "";
value = DBAUtils.escape(value);
String dataType = columnList.get(k).get("dataType").toLowerCase().contains("char") || columnList.get(k).get("dataType").toLowerCase().contains("text") ?
"C" : columnList.get(k).get("dataType").toLowerCase().contains("date") ? "D" : "N" ;
if(extra.equals("N")) {
sql+=m>0 ? "," : "";
boolean ups = list.get(i).containsKey(attrName) ? true : false ;
updateSet+=ups&&h>0 ? "," : "";
@ -638,12 +639,12 @@ public class IdcServiceImpl implements IdcService {
dbDao.update(upd + updateSet+" where "+updateWhere);
h+=ups ? 1 : 0;
}
}
sql+=")";
n++;
}
for(int m=0;m<6;m++) {
for(int m=0;m<30;m++) {
if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) {
Object obj = list.get(i).get("data"+m);
List<Map<String,Object>> chList = new ArrayList<Map<String,Object>>();
@ -651,6 +652,8 @@ public class IdcServiceImpl implements IdcService {
chList.add((Map<String,Object>)o);
}
analyData(list.get(i).get("tableName"+m).toString(),"",chList);
} else {
break;
}
}

@ -1,6 +1,7 @@
package com.glxp.api.service.inout;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
@ -64,12 +65,11 @@ public class IoChangeInoutService {
List<IoCodeEntity> codeEnttities = codeService.findByOrderId(orderEntity.getBillNo());
if (basicBusTypePreEntity != null) {
buildInOrder(basicBusTypePreEntity, codeEnttities, orderEntity);
}else {
} else {
//结束,不生成库存,
}
}
@ -141,6 +141,12 @@ public class IoChangeInoutService {
//生成单据
public void buildInOrder(BasicBusTypePreEntity bussinessChangeTypeEntity, List<IoCodeEntity> useInList, IoOrderEntity orderEntity) {
if (StrUtil.isEmpty(orderEntity.getRelKey())) {
orderEntity.setRelKey(UUID.fastUUID().toString(true));
orderService.update(orderEntity);
}
if (useInList.size() <= 0) {
return;
}

@ -1,6 +1,7 @@
package com.glxp.api.service.inout;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.ConstantStatus;
@ -716,6 +717,11 @@ public class IoCheckInoutService {
}
}
if (preInOrder.size() > 0) {
if (StrUtil.isEmpty(orderEntity.getRelKey())) {
orderEntity.setRelKey(UUID.fastUUID().toString(true));
}
String preInBillNo = "";
boolean isBreak = false;
for (String key : preInOrder.keySet()) {
@ -723,6 +729,7 @@ public class IoCheckInoutService {
preInBillNo = preInBillNo + "," + key;
IoOrderEntity preInEntity = orderService.findByBillNo(key);
preInEntity.setPreOutBillNo(orderEntity.getBillNo());
preInEntity.setRelKey(orderEntity.getRelKey());
orderService.update(preInEntity);
BasicBussinessTypeEntity preBusType = basicBussinessTypeService.findByAction(preInEntity.getAction());
//预验收不删除单号,方便后续查询

@ -22,6 +22,9 @@ public interface IoOrderService {
IoOrderEntity findByBillNo(String billNO);
List<IoOrderEntity> findByStatus(String action, Integer status);
int insertOrder(IoOrderEntity orderEntity);
int insertOrUpdate(IoOrderEntity orderEntity);

@ -135,6 +135,11 @@ public class IoOrderServiceImpl implements IoOrderService {
return orderDao.selectOne(new QueryWrapper<IoOrderEntity>().eq("billNo", billNO));
}
@Override
public List<IoOrderEntity> findByStatus(String action, Integer status) {
return orderDao.selectList(new QueryWrapper<IoOrderEntity>().eq("action", action).eq("status", status));
}
@Override
public int insertOrder(IoOrderEntity orderEntity) {
orderEntity.setId(null);
@ -698,28 +703,31 @@ public class IoOrderServiceImpl implements IoOrderService {
* @return
*/
private List<IoOrderEntity> getAllOrder(IoOrderEntity order) {
Set<String> billNos = new HashSet<>();
billNos.add(order.getBillNo());
getLinkedBillNo(order.getBillNo(), billNos);
//去除本单的单据号
Iterator<String> iterator = billNos.iterator();
while (iterator.hasNext()) {
if (iterator.next().equals(order.getBillNo())) {
iterator.remove();
break;
}
}
ArrayList<IoOrderEntity> orders = new ArrayList<>();
if (CollUtil.isNotEmpty(billNos)) {
List<IoOrderEntity> list = orderDao.selectList(new QueryWrapper<IoOrderEntity>().in("billNo", billNos).orderByDesc("id"));
orders.addAll(list);
}
// Set<String> billNos = new HashSet<>();
// billNos.add(order.getBillNo());
List<IoOrderEntity> orderEntities = orderDao.selectList(new QueryWrapper<IoOrderEntity>().eq("relKey", order.getRelKey()));
// getLinkedBillNo(order.getBillNo(), billNos);
//
// //去除本单的单据号
// Iterator<String> iterator = billNos.iterator();
// while (iterator.hasNext()) {
// if (iterator.next().equals(order.getBillNo())) {
// iterator.remove();
// break;
// }
// }
//
// ArrayList<IoOrderEntity> orders = new ArrayList<>();
// if (CollUtil.isNotEmpty(billNos)) {
// List<IoOrderEntity> list = orderDao.selectList(new QueryWrapper<IoOrderEntity>().in("billNo", billNos).orderByDesc("id"));
// orders.addAll(list);
// }
//将查询入口单据放在第一位的顺序
orders.add(0, order);
return orders;
// orders.add(0, order);
return orderEntities;
}
/**

@ -75,86 +75,16 @@ public class SpsSyncDownloadService {
//查询数据同步设置
SyncDataSetResponse syncDataSetEntity = syncDataSetService.selectSet();
List<IoOrderEntity> orderEntities = new ArrayList<>();
//待校验
if (syncDataSetEntity.isOrderUnCheck()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<IoOrderEntity> temps = orderService.findByStatus(syncDataBustypeEntity.getAction(), syncDataBustypeEntity.getOrderStatus());
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
//待核对
if (syncDataSetEntity.isOrderUnCheck()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_CHECK_SUCCESS);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
//待审核
if (syncDataSetEntity.isOrderUnReceive()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_CHECK_REW);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
//已完成
if (syncDataSetEntity.isOrderScanFinish()) {
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
List<String> filterList = new ArrayList<>();
filterList.add(syncDataBustypeEntity.getAction());
orderFilterRequest.setActions(filterList);
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_AUDITED);
List<IoOrderEntity> temps = orderService.filterOrderList(orderFilterRequest);
if (CollUtil.isNotEmpty(temps)) {
orderEntities.addAll(temps);
}
}
}
}
syncOrderResponse.setOrderEntities(orderEntities);
List<IoCodeEntity> codeEntities = new ArrayList<>();
List<IoOrderDetailBizEntity> orderDetailBizEntities = new ArrayList<>();

@ -36,7 +36,7 @@ public class AsyncSpsTask implements SchedulingConfigurer {
scheduledRequest.setCronName("syncIdcSps");
logger.info("syncIdcSps----------------");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "* 0/30 * * * ?";
String cron = scheduledEntity != null ? scheduledEntity.getCron() : "* 0/30 * * * ?";
if (cron.isEmpty()) {
logger.error("cron is null");
@ -47,9 +47,8 @@ public class AsyncSpsTask implements SchedulingConfigurer {
}
private void process() {
logger.info("syncIdcSps----process------------");
idcService.asyncSpsTask();
}
logger.info("syncIdcSps----process------------");
idcService.asyncSpsTask();
}
}

@ -0,0 +1,154 @@
package com.glxp.api.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.dao.monitor.SysLogininforMapper;
import com.glxp.api.dao.monitor.SysOperLogMapper;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.dao.schedule.SystemParamConfigDao;
import com.glxp.api.dao.sync.BasicDownloadDao;
import com.glxp.api.dao.sync.BasicExportDao;
import com.glxp.api.dao.thrsys.*;
import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.req.system.ScheduledRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
/**
*
*/
@Slf4j
@Component
@Transactional(rollbackFor = Exception.class)
public class CleanLogTask implements SchedulingConfigurer {
@Resource
private ScheduledDao scheduledDao;
@Resource
private SystemParamConfigDao systemParamConfigDao;
@Resource
private SysOperLogMapper sysOperLogMapper;
@Resource
private SysLogininforMapper sysLogininforMapper;
@Resource
private ThrCorpExportLogDao thrCorpExportLogDao;
@Resource
private ThrCorpImportLogDao thrCorpImportLogDao;
@Resource
private ThrInvProductsExportLogDao thrInvProductsExportLogDao;
@Resource
private ThrInvProductsImportLogDao thrInvProductsImportLogDao;
@Resource
private ThrOrderExportLogDao thrOrderExportLogDao;
@Resource
private ThrOrderImportLogDao thrOrderImportLogDao;
@Resource
private ThrProductsExportLogDao thrProductsExportLogDao;
@Resource
private ThrProductsImportLogDao thrProductsImportLogDao;
@Resource
private BasicDownloadDao basicDownloadDao;
@Resource
private BasicExportDao basicExportDao;
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.addTriggerTask(this::process, triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("clean_log_task");
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity.getCron();
if (StrUtil.isBlank(cron)) {
log.error("清理日志定时任务参数未配置");
}
return new CronTrigger(cron).nextExecutionTime(triggerContext);
});
}
private void process() {
//查询删除日志时间配置
String value = systemParamConfigDao.selectValueByParamKey("clean_log_days");
if (StrUtil.isBlank(value)) {
log.info("删除日志天数参数未配置,结束任务");
} else {
int days = Integer.parseInt(value);
if (days > 0) {
String date = DateUtil.offsetDay(new Date(), -days).toString("yyyy-MM-dd");
//查询系统日志删除是否开启
String cleanSystemLogValue = systemParamConfigDao.selectValueByParamKey("clean_system_log");
if ("1".equals(cleanSystemLogValue)) {
cleanSystemLog(date);
}
String cleanThrLogValue = systemParamConfigDao.selectValueByParamKey("clean_thr_log");
if ("1".equals(cleanThrLogValue)) {
cleanThrLog(date);
}
String cleanSyncLogValue = systemParamConfigDao.selectValueByParamKey("clean_sync_log");
if ("1".equals(cleanSyncLogValue)) {
cleanSyncLog(date);
}
} else {
log.info("配置删除日志天数为0不进行删除");
}
}
}
/**
*
*
* @param date
*/
private void cleanSystemLog(String date) {
//删除操作系统日志
sysOperLogMapper.deleteByDate(date);
//删除系统访问日志
sysLogininforMapper.deleteByDate(date);
}
/**
*
*
* @param date
*/
private void cleanThrLog(String date) {
log.info("删除第三方系统日志");
//删除第三方往来单位导出日志
thrCorpExportLogDao.deleteByDate(date);
//删除第三方往来单位导入日志
thrCorpImportLogDao.deleteByDate(date);
//删除第三方库存产品导出日志
thrInvProductsExportLogDao.deleteByDate(date);
//删除第三方库存产品导入日志
thrInvProductsImportLogDao.deleteByDate(date);
//删除第三方单据导出日志
thrOrderExportLogDao.deleteByDate(date);
//删除第三方单据导入日志
thrOrderImportLogDao.deleteByDate(date);
//删除第三方产品导出日志
thrProductsExportLogDao.deleteByDate(date);
//删除第三方产品导入日志
thrProductsImportLogDao.deleteByDate(date);
log.info("第三方系统日志删除完成");
}
/**
*
*
* @param date
*/
private void cleanSyncLog(String date) {
log.info("开始删除同步日志");
//删除下载日志
basicDownloadDao.deleteByDate(date);
//删除上传日志
basicExportDao.deleteByDate(date);
}
}

@ -75,4 +75,7 @@
</delete>
<delete id="deleteByDate">
delete from monitor_login_log where date_format(#{date}, '%Y-%m-%d') >= date_format(login_time, '%Y-%m-%d')
</delete>
</mapper>

@ -108,4 +108,7 @@
</delete>
<delete id="deleteByDate">
delete from monitor_oper_log where date_format(#{date}, '%Y-%m-%d') >= date_format(oper_time, '%Y-%m-%d')
</delete>
</mapper>

@ -75,5 +75,7 @@
#{paramExplain})
</insert>
<select id="selectValueByParamKey" resultType="java.lang.String">
select paramValue from sys_param_config where paramKey = #{key}
</select>
</mapper>

@ -86,4 +86,8 @@
From basic_download_status
where date(startTime) &lt;= date(DATE_SUB(NOW(), INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from basic_download_status where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -94,4 +94,8 @@
From basic_export_status
where date(startTime) &lt;= date(DATE_SUB(NOW(), INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from basic_export_status where date_format(#{date}, '%Y-%m-%d') >= date_format(startTime, '%Y-%m-%d')
</delete>
</mapper>

@ -64,4 +64,7 @@
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from thr_corp_export_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -67,4 +67,7 @@
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from thr_corp_import_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -55,4 +55,7 @@
WHERE genKey = #{genKey}
</update>
<delete id="deleteByDate">
delete from thr_inv_products_export_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -61,4 +61,7 @@
WHERE genKey = #{genKey}
</update>
<delete id="deleteByDate">
delete from thr_inv_products_import_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -56,4 +56,7 @@
</delete>
<delete id="deleteByDate">
delete from thr_order_export_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -59,4 +59,7 @@
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from thr_order_import_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -64,4 +64,7 @@
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from thr_products_export_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>

@ -65,4 +65,7 @@
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
<delete id="deleteByDate">
delete from thr_products_import_log where date_format(#{date}, '%Y-%m-%d') >= date_format(updateTime, '%Y-%m-%d')
</delete>
</mapper>
Loading…
Cancel
Save