代码备份。。
parent
0fd194c2f3
commit
9bca7f4729
@ -0,0 +1,146 @@
|
|||||||
|
package com.glxp.sale.admin.controller.sync;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.glxp.sale.admin.constant.FileConstant;
|
||||||
|
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
|
||||||
|
import com.glxp.sale.admin.http.SpPostHttp;
|
||||||
|
import com.glxp.sale.admin.req.sync.SpsSyncDataRequest;
|
||||||
|
import com.glxp.sale.admin.res.sync.*;
|
||||||
|
import com.glxp.sale.admin.service.param.SystemParamConfigService;
|
||||||
|
import com.glxp.sale.admin.util.CustomUtil;
|
||||||
|
import com.glxp.sale.admin.util.DateUtil;
|
||||||
|
import com.glxp.sale.admin.util.FileUtils;
|
||||||
|
import com.glxp.sale.admin.util.RedisUtil;
|
||||||
|
import com.glxp.sale.common.enums.ResultEnum;
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
import com.glxp.sale.common.util.ResultVOUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
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 java.util.Date;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class SpsSyncDataController {
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
SystemParamConfigService systemParamConfigService;
|
||||||
|
@Resource
|
||||||
|
SpPostHttp spPostHttp;
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SpsSyncDataController.class);
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder");
|
||||||
|
String filePath = systemParamConfigEntity.getParamValue();
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("sps/sync/basic")
|
||||||
|
public BaseResponse getProductInfo(SpsSyncDataRequest spsSyncDataRequest) {
|
||||||
|
SpsSyncDataResponse spsSyncDataResponse = (SpsSyncDataResponse) redisUtil.get(spsSyncDataRequest.getId() + "");
|
||||||
|
return ResultVOUtils.success(spsSyncDataResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("sps/sync/busType")
|
||||||
|
public BaseResponse getBusType(SpsSyncDataRequest spsSyncDataRequest) {
|
||||||
|
SpsSyncBusResponse spsSyncDataResponse = (SpsSyncBusResponse) redisUtil.get(spsSyncDataRequest.getId() + "");
|
||||||
|
return ResultVOUtils.success(spsSyncDataResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("sps/sync/order")
|
||||||
|
public BaseResponse getOrder(SpsSyncDataRequest spsSyncDataRequest) {
|
||||||
|
SpsSyncOrderResponse spsSyncDataResponse = (SpsSyncOrderResponse) redisUtil.get(spsSyncDataRequest.getId() + "");
|
||||||
|
return ResultVOUtils.success(spsSyncDataResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/sps/sync/basic/upload")
|
||||||
|
public BaseResponse postAllBase(@RequestBody SpsSyncDataResponse syncDataResponse,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.lowerWaitCopy_products + "BaseData_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
|
||||||
|
String datas = JSON.toJSONString(syncDataResponse);
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
|
||||||
|
} else {
|
||||||
|
//上游通
|
||||||
|
return spPostHttp.postAllDatas(syncDataResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sps/sync/order/upload")
|
||||||
|
public BaseResponse postAllOrders(@RequestBody SpsSyncOrderResponse spsSyncOrderResponse,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.lowerWaitCopy_products + "order_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
|
||||||
|
String datas = JSON.toJSONString(spsSyncOrderResponse);
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
|
||||||
|
} else {
|
||||||
|
//上游通
|
||||||
|
return spPostHttp.postAllOrders(spsSyncOrderResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/sps/sync/busType/upload")
|
||||||
|
public BaseResponse postAllBus(@RequestBody SpsSyncBusResponse spsSyncBusResponse,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.lowerWaitCopy_products + "BusType_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
|
||||||
|
String datas = JSON.toJSONString(spsSyncBusResponse);
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
|
||||||
|
} else {
|
||||||
|
//上游通
|
||||||
|
return spPostHttp.postAllBus(spsSyncBusResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("sps/sync/schedule/upload")
|
||||||
|
public BaseResponse dealSchedule(@RequestBody SpsSyncScheduleResponse spsSyncScheduleResponse) {
|
||||||
|
|
||||||
|
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.lowerWaitCopy_products + "ScheduleList_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
|
||||||
|
String datas = JSON.toJSONString(spsSyncScheduleResponse);
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
|
||||||
|
} else {
|
||||||
|
//上游通
|
||||||
|
return spPostHttp.postAllSchedule(spsSyncScheduleResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BasicExportStatusTimeEntity {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String lastUpdateTime;
|
||||||
|
private String key;
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BussinessLocalTypeEntity {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String action;
|
||||||
|
private String name;
|
||||||
|
private String localAction;
|
||||||
|
private String originAction;
|
||||||
|
private String mainAction;
|
||||||
|
private String localName;
|
||||||
|
private String remark;
|
||||||
|
private boolean checkEnable;
|
||||||
|
private boolean advanceType;
|
||||||
|
private boolean changeEnable;
|
||||||
|
private boolean spUse;
|
||||||
|
private String storageCode;
|
||||||
|
private int corpType;
|
||||||
|
private String defaultUnit;
|
||||||
|
private boolean genUnit;
|
||||||
|
private String thirdAction;
|
||||||
|
private String thirdSys;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BussinessOriginTypeEntity {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String action;
|
||||||
|
private String thirdSys;
|
||||||
|
private String thirdSysName;
|
||||||
|
private Boolean enable;
|
||||||
|
private String remark;
|
||||||
|
private String mainAction;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BussinessTypeEntity {
|
||||||
|
private Integer id;
|
||||||
|
private String action;
|
||||||
|
private String name;
|
||||||
|
private Boolean enable;
|
||||||
|
private String remark;
|
||||||
|
private String mainAction;
|
||||||
|
private String thirdSysFk;
|
||||||
|
private String localAction;
|
||||||
|
private String localName;
|
||||||
|
private boolean checkEnable;
|
||||||
|
private boolean advanceType;
|
||||||
|
private boolean genUnit;
|
||||||
|
private boolean innerOrder;
|
||||||
|
private boolean secCheckEnable;
|
||||||
|
private Boolean spUse;
|
||||||
|
private String defaultUnit;
|
||||||
|
private Integer index;
|
||||||
|
private boolean checkUdims;
|
||||||
|
private boolean checkPdaEd;
|
||||||
|
private boolean checkPdaUn;
|
||||||
|
private boolean checkPc;
|
||||||
|
private boolean checkWebNew;
|
||||||
|
private boolean checkChange;
|
||||||
|
|
||||||
|
|
||||||
|
private boolean secCheckUdims;
|
||||||
|
private boolean secCheckPdaEd;
|
||||||
|
private boolean secCheckPdaUn;
|
||||||
|
private boolean secCheckPc;
|
||||||
|
private boolean secCheckWebNew;
|
||||||
|
private boolean secCheckChange;
|
||||||
|
|
||||||
|
private boolean checkBalacne;
|
||||||
|
private boolean secCheckBalacne;
|
||||||
|
|
||||||
|
private int corpType;
|
||||||
|
private String storageCode;
|
||||||
|
|
||||||
|
//补单类型
|
||||||
|
private String supplementOrderType;
|
||||||
|
private String thirdAction;
|
||||||
|
private String thirdSys;
|
||||||
|
private boolean useDyCount;
|
||||||
|
private boolean changeEnable;
|
||||||
|
|
||||||
|
private boolean expireTip;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CompanyProductRelevanceEntity {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private Long customerId;
|
||||||
|
private Long productId;
|
||||||
|
private Long enterpriseId;
|
||||||
|
private Long registrationId;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date create_time;
|
||||||
|
private Date update_time;
|
||||||
|
private String auditStatus;
|
||||||
|
private String productUuid;
|
||||||
|
private Integer udiRlIdFk;
|
||||||
|
private String unitFk;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProductInfoEntity {
|
||||||
|
private Integer id;
|
||||||
|
private String nameCode;
|
||||||
|
private String packRatio;
|
||||||
|
private String packLevel;
|
||||||
|
private Integer bhxjsl;
|
||||||
|
private Integer bhzxxsbzsl;
|
||||||
|
private Integer zxxsbzbhsydysl;
|
||||||
|
private String bhxjcpbm;
|
||||||
|
private String sjcpbm; //
|
||||||
|
private String bzcj;
|
||||||
|
private String thirdProductNo;
|
||||||
|
private String thirdProductName;
|
||||||
|
private String addType;
|
||||||
|
private String deviceRecordKey;
|
||||||
|
private Integer isUseDy;
|
||||||
|
private String cpmctymc;
|
||||||
|
private String cplb;
|
||||||
|
private String flbm;
|
||||||
|
private String ggxh;
|
||||||
|
private String qxlb;
|
||||||
|
private String tyshxydm;
|
||||||
|
private String ylqxzcrbarmc;
|
||||||
|
private String zczbhhzbapzbh;
|
||||||
|
private String ylqxzcrbarywmc;
|
||||||
|
private String sydycpbs;
|
||||||
|
private String uuid;
|
||||||
|
private Integer versionNumber;
|
||||||
|
private Integer diType;
|
||||||
|
|
||||||
|
private String scbssfbhph;
|
||||||
|
private String scbssfbhxlh;
|
||||||
|
private String scbssfbhscrq;
|
||||||
|
private String scbssfbhsxrq;
|
||||||
|
|
||||||
|
private String ybbm;
|
||||||
|
private String spmc;
|
||||||
|
private String cphhhbh;
|
||||||
|
private String cpms;
|
||||||
|
private String cpbsbmtxmc;
|
||||||
|
|
||||||
|
private String batchNo;
|
||||||
|
private String produceDate;
|
||||||
|
private String expireDate;
|
||||||
|
|
||||||
|
private Boolean isNewest;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private String cplx;
|
||||||
|
private String hchzsb;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.glxp.sale.admin.entity.sync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UdiCompanyEntity {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String tyshxydm;
|
||||||
|
private String ylqxzcrbarmc;
|
||||||
|
private String ylqxzcrbarywmc;
|
||||||
|
private String qylxrdh;
|
||||||
|
private String qylxrcz;
|
||||||
|
private String qylxryx;
|
||||||
|
private String deviceRecordKey;
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.glxp.sale.admin.req.sync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpsSyncDataRequest {
|
||||||
|
|
||||||
|
private String lastUpdateTime;
|
||||||
|
private String id;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.glxp.sale.admin.res.sync;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.entity.sync.BussinessLocalTypeEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.BussinessOriginTypeEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.BussinessTypeEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpsSyncBusResponse {
|
||||||
|
|
||||||
|
private List<BussinessTypeEntity> bussinessTypeEntities;
|
||||||
|
private List<BussinessOriginTypeEntity> bussinessOriginTypeEntities;
|
||||||
|
private List<BussinessLocalTypeEntity> bussinessLocalTypeEntities;
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.glxp.sale.admin.res.sync;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.entity.info.CompanyProductRelevanceEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpsSyncDataResponse {
|
||||||
|
|
||||||
|
List<InvWarehouseEntity> invWarehouseEntities;
|
||||||
|
List<UdiInfoEntity> udiInfoEntities;
|
||||||
|
List<BasicUnitMaintainEntity> basicUnitMaintainEntities;
|
||||||
|
List<ThrInvWarehouseEntity> thrInvWarehouseEntities;
|
||||||
|
List<ThrCorpEntity> thrCorpEntities;
|
||||||
|
List<ThrProductsEntity> thrProductsEntities;
|
||||||
|
List<ThrOrderDetailEntity> thrOrderDetailEntities;
|
||||||
|
List<ThrOrderEntity> thrOrderEntities;
|
||||||
|
List<CompanyProductRelevanceEntity> companyProductRelevanceEntities;
|
||||||
|
List<UdiRelevanceEntity> udiRelevanceEntities;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.glxp.sale.admin.res.sync;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.entity.sync.ErpOrderEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.OrderEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.WarehouseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpsSyncOrderResponse {
|
||||||
|
|
||||||
|
List<OrderEntity> orderEntities;
|
||||||
|
List<ErpOrderEntity> orderDetailEntityList;
|
||||||
|
List<WarehouseEntity> warehouseEntityList;
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.glxp.sale.admin.res.sync;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpsSyncScheduleResponse {
|
||||||
|
List<BasicExportStatusEntity> basicExportStatusEntities;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,290 @@
|
|||||||
|
package com.glxp.sale.admin.thread;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.glxp.sale.admin.constant.BasicProcessStatus;
|
||||||
|
import com.glxp.sale.admin.constant.FileConstant;
|
||||||
|
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.ThrImportLogEntity;
|
||||||
|
import com.glxp.sale.admin.http.SpGetHttp;
|
||||||
|
import com.glxp.sale.admin.req.sync.BasicExportStatusRequest;
|
||||||
|
import com.glxp.sale.admin.req.sync.SpsSyncDataRequest;
|
||||||
|
import com.glxp.sale.admin.res.sync.SpsSyncBusResponse;
|
||||||
|
import com.glxp.sale.admin.res.sync.SpsSyncDataResponse;
|
||||||
|
import com.glxp.sale.admin.res.sync.SpsSyncOrderResponse;
|
||||||
|
import com.glxp.sale.admin.res.sync.SpsSyncScheduleResponse;
|
||||||
|
import com.glxp.sale.admin.service.param.SystemParamConfigService;
|
||||||
|
import com.glxp.sale.admin.service.sync.BasicExportService;
|
||||||
|
import com.glxp.sale.admin.service.sync.ThrImportLogService;
|
||||||
|
import com.glxp.sale.admin.util.CustomUtil;
|
||||||
|
import com.glxp.sale.admin.util.DateUtil;
|
||||||
|
import com.glxp.sale.admin.util.FileUtils;
|
||||||
|
import com.glxp.sale.admin.util.RedisUtil;
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DlAllDataService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SpGetHttp spGetHttp;
|
||||||
|
@Resource
|
||||||
|
SystemParamConfigService systemParamConfigService;
|
||||||
|
@Resource
|
||||||
|
BasicExportService basicExportService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
|
public void dllNewAllData() {
|
||||||
|
BasicExportStatusRequest basicExportStatusRequest = new BasicExportStatusRequest();
|
||||||
|
basicExportStatusRequest.setIdDatas("AutoDownloadAllData");
|
||||||
|
basicExportStatusRequest.setStatus(0);
|
||||||
|
basicExportStatusRequest.setType(BasicProcessStatus.NEW_ALL_DATA);
|
||||||
|
basicExportStatusRequest.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
|
||||||
|
BaseResponse<List<BasicExportStatusEntity>> basicStatuss = spGetHttp.getBasicStatus(basicExportStatusRequest);
|
||||||
|
if (CollUtil.isNotEmpty(basicStatuss.getData())) {
|
||||||
|
List<BasicExportStatusEntity> basicExportStatusEntities = basicStatuss.getData();
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("1")) {
|
||||||
|
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
|
||||||
|
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
|
||||||
|
BaseResponse<SpsSyncDataResponse> baseResponse = null;
|
||||||
|
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
|
||||||
|
if (basicExportStatusEntity.getFromType() == 0) {
|
||||||
|
BaseResponse<String> response = spGetHttp.getLastUpdateTime("AutoDownloadAllData");
|
||||||
|
String lastUpdateTime = response.getData();
|
||||||
|
spsSyncDataRequest.setLastUpdateTime(lastUpdateTime);
|
||||||
|
baseResponse = spGetHttp.getAllNewData(spsSyncDataRequest);
|
||||||
|
} else {
|
||||||
|
spsSyncDataRequest.setId(basicExportStatusEntity.getId());
|
||||||
|
baseResponse = spGetHttp.getAllNewData(spsSyncDataRequest);
|
||||||
|
}
|
||||||
|
if (baseResponse.getCode() == 20000) {
|
||||||
|
SpsSyncDataResponse syncOrderResponse = baseResponse.getData();
|
||||||
|
if (syncOrderResponse != null &&
|
||||||
|
(CollUtil.isNotEmpty(syncOrderResponse.getBasicUnitMaintainEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getInvWarehouseEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getThrCorpEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getCompanyProductRelevanceEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getThrOrderDetailEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getThrInvWarehouseEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getThrOrderEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getThrProductsEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getUdiInfoEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getUdiRelevanceEntities()))
|
||||||
|
) {
|
||||||
|
if (downstream.getParamValue().equals("1")) {
|
||||||
|
String key = "BaseAllData" + System.currentTimeMillis();
|
||||||
|
redisUtil.set(key, baseResponse.getData());
|
||||||
|
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
|
||||||
|
myEntity.setId(key);
|
||||||
|
myEntity.setStatus(0);
|
||||||
|
myEntity.setUpdateTime(new Date());
|
||||||
|
myEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
|
||||||
|
basicExportService.insertExportStatus(myEntity);
|
||||||
|
} else {
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.upWaitCopy_products + "BaseData_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
|
||||||
|
String datas = JSON.toJSONString(baseResponse.getData());
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (basicExportStatusEntity.getFromType() == 0) {
|
||||||
|
BasicExportStatusEntity basicExportStatusEntity1 = basicExportStatusEntities.get(0);
|
||||||
|
basicExportStatusEntity1.setStatus(1);
|
||||||
|
spGetHttp.postUpdateBasicStatus(basicExportStatusEntity1);
|
||||||
|
spGetHttp.updateLastTime("AutoDownloadAllData", DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
} else {
|
||||||
|
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dllNewAllOrder() {
|
||||||
|
BasicExportStatusRequest basicExportStatusRequest = new BasicExportStatusRequest();
|
||||||
|
basicExportStatusRequest.setIdDatas("AutoDownloadOrder");
|
||||||
|
basicExportStatusRequest.setStatus(0);
|
||||||
|
basicExportStatusRequest.setType(BasicProcessStatus.NEW_ALL_ORDER);
|
||||||
|
basicExportStatusRequest.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
|
||||||
|
BaseResponse<List<BasicExportStatusEntity>> basicStatuss = spGetHttp.getBasicStatus(basicExportStatusRequest);
|
||||||
|
if (CollUtil.isNotEmpty(basicStatuss.getData())) {
|
||||||
|
List<BasicExportStatusEntity> basicExportStatusEntities = basicStatuss.getData();
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("1")) {
|
||||||
|
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
|
||||||
|
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
|
||||||
|
|
||||||
|
BaseResponse<SpsSyncOrderResponse> baseResponse = null;
|
||||||
|
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
|
||||||
|
if (basicExportStatusEntity.getFromType() == 0) {
|
||||||
|
BaseResponse<String> response = spGetHttp.getLastUpdateTime("AutoDownloadOrder");
|
||||||
|
String lastUpdateTime = response.getData();
|
||||||
|
spsSyncDataRequest.setLastUpdateTime(lastUpdateTime);
|
||||||
|
baseResponse = spGetHttp.getAllOrder(spsSyncDataRequest);
|
||||||
|
} else {
|
||||||
|
spsSyncDataRequest.setId(basicExportStatusEntity.getId());
|
||||||
|
baseResponse = spGetHttp.getAllOrder(spsSyncDataRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (baseResponse.getCode() == 20000) {
|
||||||
|
SpsSyncOrderResponse syncOrderResponse = baseResponse.getData();
|
||||||
|
if (syncOrderResponse != null &&
|
||||||
|
(CollUtil.isNotEmpty(syncOrderResponse.getOrderEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getOrderDetailEntityList())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getWarehouseEntityList()))
|
||||||
|
) {
|
||||||
|
if (downstream.getParamValue().equals("1")) {
|
||||||
|
String key = "BaseAllOrder" + System.currentTimeMillis();
|
||||||
|
redisUtil.set(key, baseResponse.getData());
|
||||||
|
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
|
||||||
|
myEntity.setId(key);
|
||||||
|
myEntity.setStatus(0);
|
||||||
|
myEntity.setUpdateTime(new Date());
|
||||||
|
myEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
|
||||||
|
basicExportService.insertExportStatus(myEntity);
|
||||||
|
} else {
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.upWaitCopy_products + "order_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
|
||||||
|
String datas = JSON.toJSONString(baseResponse.getData());
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (basicExportStatusEntity.getFromType() == 0) {
|
||||||
|
BasicExportStatusEntity basicExportStatusEntity1 = basicExportStatusEntities.get(0);
|
||||||
|
basicExportStatusEntity1.setStatus(1);
|
||||||
|
spGetHttp.postUpdateBasicStatus(basicExportStatusEntity1);
|
||||||
|
spGetHttp.updateLastTime("AutoDownloadOrder", DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
} else {
|
||||||
|
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dllNewAllBusType() {
|
||||||
|
|
||||||
|
BasicExportStatusRequest basicExportStatusRequest = new BasicExportStatusRequest();
|
||||||
|
basicExportStatusRequest.setIdDatas("AutoDownloadBusType");
|
||||||
|
basicExportStatusRequest.setStatus(0);
|
||||||
|
basicExportStatusRequest.setType(BasicProcessStatus.NEW_ALL_BUS);
|
||||||
|
basicExportStatusRequest.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
|
||||||
|
BaseResponse<List<BasicExportStatusEntity>> basicStatuss = spGetHttp.getBasicStatus(basicExportStatusRequest);
|
||||||
|
if (CollUtil.isNotEmpty(basicStatuss.getData())) {
|
||||||
|
List<BasicExportStatusEntity> basicExportStatusEntities = basicStatuss.getData();
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("1")) {
|
||||||
|
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
|
||||||
|
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
|
||||||
|
BaseResponse<SpsSyncBusResponse> baseResponse = null;
|
||||||
|
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
|
||||||
|
if (basicExportStatusEntity.getFromType() == 0) {
|
||||||
|
BaseResponse<String> response = spGetHttp.getLastUpdateTime("AutoDownloadBusType");
|
||||||
|
String lastUpdateTime = response.getData();
|
||||||
|
spsSyncDataRequest.setLastUpdateTime(lastUpdateTime);
|
||||||
|
baseResponse = spGetHttp.getAllBus(spsSyncDataRequest);
|
||||||
|
} else {
|
||||||
|
spsSyncDataRequest.setId(basicExportStatusEntity.getId());
|
||||||
|
baseResponse = spGetHttp.getAllBus(spsSyncDataRequest);
|
||||||
|
}
|
||||||
|
if (baseResponse.getCode() == 20000) {
|
||||||
|
SpsSyncBusResponse syncOrderResponse = baseResponse.getData();
|
||||||
|
if (syncOrderResponse != null &&
|
||||||
|
(CollUtil.isNotEmpty(syncOrderResponse.getBussinessTypeEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getBussinessOriginTypeEntities())
|
||||||
|
|| CollUtil.isNotEmpty(syncOrderResponse.getBussinessLocalTypeEntities()))
|
||||||
|
) {
|
||||||
|
if (downstream.getParamValue().equals("1")) {
|
||||||
|
String key = "BaseAllBusType" + System.currentTimeMillis();
|
||||||
|
redisUtil.set(key, baseResponse.getData());
|
||||||
|
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
|
||||||
|
myEntity.setId(key);
|
||||||
|
myEntity.setStatus(0);
|
||||||
|
myEntity.setUpdateTime(new Date());
|
||||||
|
myEntity.setType(BasicProcessStatus.NEW_ALL_BUS);
|
||||||
|
basicExportService.insertExportStatus(myEntity);
|
||||||
|
} else {
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.upWaitCopy_products + "BusType_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
|
||||||
|
String datas = JSON.toJSONString(baseResponse.getData());
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (basicExportStatusEntity.getFromType() == 0) {
|
||||||
|
BasicExportStatusEntity basicExportStatusEntity1 = basicExportStatusEntities.get(0);
|
||||||
|
basicExportStatusEntity1.setStatus(1);
|
||||||
|
spGetHttp.postUpdateBasicStatus(basicExportStatusEntity1);
|
||||||
|
spGetHttp.updateLastTime("AutoDownloadBusType", DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
} else {
|
||||||
|
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dlScheduleStatus() {
|
||||||
|
BasicExportStatusRequest basicExportStatusRequest = new BasicExportStatusRequest();
|
||||||
|
basicExportStatusRequest.setScheduleType(BasicProcessStatus.SCHEDULE_TRANSFER);
|
||||||
|
BaseResponse<List<BasicExportStatusEntity>> basicStatuss = spGetHttp.getBasicStatus(basicExportStatusRequest);
|
||||||
|
if (CollUtil.isNotEmpty(basicStatuss.getData())) {
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("1")) {
|
||||||
|
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
|
||||||
|
if (downstream.getParamValue().equals("1")) {
|
||||||
|
for (BasicExportStatusEntity basicExportStatusEntity : basicStatuss.getData()) {
|
||||||
|
basicExportService.insertExportStatus(basicExportStatusEntity);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.upWaitCopy_products + "ScheduleList_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
|
||||||
|
SpsSyncScheduleResponse spsSyncScheduleResponse = new SpsSyncScheduleResponse();
|
||||||
|
spsSyncScheduleResponse.setBasicExportStatusEntities(basicStatuss.getData());
|
||||||
|
String datas = JSON.toJSONString(spsSyncScheduleResponse);
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
}
|
||||||
|
for (BasicExportStatusEntity basicExportStatusEntity : basicStatuss.getData()) {
|
||||||
|
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder");
|
||||||
|
String filePath = systemParamConfigEntity.getParamValue();
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package com.glxp.sale.admin.thread.didl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.glxp.sale.admin.constant.FileConstant;
|
||||||
|
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.UdiCompanyEntity;
|
||||||
|
import com.glxp.sale.admin.service.param.SystemParamConfigService;
|
||||||
|
import com.glxp.sale.admin.service.sync.BasicExportService;
|
||||||
|
import com.glxp.sale.admin.util.FileUtils;
|
||||||
|
import com.glxp.sale.admin.util.RedisUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AsyncCompanyDlService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AsyncCompanyDlService.class);
|
||||||
|
@Resource
|
||||||
|
SystemParamConfigService systemParamConfigService;
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
BasicExportService basicExportService;
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder");
|
||||||
|
String filePath = systemParamConfigEntity.getParamValue();
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void asyncDiByTime(String updateTime) {
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("1")) {
|
||||||
|
|
||||||
|
AsyncDiDlHelper asyncDiDlHelper = new AsyncDiDlHelper();
|
||||||
|
List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>();
|
||||||
|
int page = 1;
|
||||||
|
int limit = 300;
|
||||||
|
while (true) {
|
||||||
|
logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
|
||||||
|
List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(null, page, limit, updateTime);
|
||||||
|
if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) {
|
||||||
|
mUdiCompanyEntities.addAll(udiCompanyEntities);
|
||||||
|
if (udiCompanyEntities.size() < limit) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("更新时间:" + updateTime + "----" + "下载结束");
|
||||||
|
|
||||||
|
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
|
||||||
|
String key = "dlcompany" + System.currentTimeMillis();
|
||||||
|
String datas = JSON.toJSON(mUdiCompanyEntities).toString();
|
||||||
|
if (downstream.getParamValue().equals("1")) {
|
||||||
|
redisUtil.set(key, datas);
|
||||||
|
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
|
||||||
|
myEntity.setId(key);
|
||||||
|
basicExportService.insertExportStatus(myEntity);
|
||||||
|
} else {
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.upWaitCopy_products + "同步库企业信息_" + key + ".udi";
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.glxp.sale.admin.thread.didl;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.dao.info.ScheduledDao;
|
||||||
|
import com.glxp.sale.admin.entity.info.ScheduledEntity;
|
||||||
|
import com.glxp.sale.admin.req.info.ScheduledRequest;
|
||||||
|
import com.glxp.sale.admin.util.DateUtil;
|
||||||
|
import com.glxp.sale.admin.util.RedisUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
import org.springframework.scheduling.support.CronTrigger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@EnableScheduling
|
||||||
|
public class AsyncCompanyDlTask implements SchedulingConfigurer {
|
||||||
|
|
||||||
|
final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class);
|
||||||
|
@Resource
|
||||||
|
AsyncCompanyDlService udiCompanyTask;
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ScheduledDao scheduledDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
||||||
|
scheduledTaskRegistrar.addTriggerTask(() -> process(),
|
||||||
|
triggerContext -> {
|
||||||
|
ScheduledRequest scheduledRequest = new ScheduledRequest();
|
||||||
|
scheduledRequest.setCronName("syncCompany");
|
||||||
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
||||||
|
String cron = scheduledEntity.getCron();//"0 55 5 * * ?";
|
||||||
|
if (cron.isEmpty()) {
|
||||||
|
logger.error("cron is null");
|
||||||
|
}
|
||||||
|
return new CronTrigger(cron).nextExecutionTime(triggerContext);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void process() {
|
||||||
|
|
||||||
|
String lastUpDiTime = (String) redisUtil.get("lastUpCompanyTime");
|
||||||
|
if (lastUpDiTime == null) {
|
||||||
|
lastUpDiTime = DateUtil.getLastDayFormat(-10);
|
||||||
|
}
|
||||||
|
udiCompanyTask.asyncDiByTime(lastUpDiTime);
|
||||||
|
redisUtil.set("lastUpCompanyTime", DateUtil.formatDate(new Date()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.glxp.sale.admin.thread.didl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.glxp.sale.admin.entity.sync.ProductInfoEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.UdiCompanyEntity;
|
||||||
|
import com.glxp.sale.admin.http.UHttpClient;
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AsyncDiDlHelper {
|
||||||
|
@Value("${SPMS_IP}")
|
||||||
|
private String spmsUrl;
|
||||||
|
@Value("${API_KEY}")
|
||||||
|
private String apiKey;
|
||||||
|
@Value("${API_SECRET}")
|
||||||
|
private String apiSecret;
|
||||||
|
|
||||||
|
public HttpHeaders getHeaders() {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Content-Type", "application/json");
|
||||||
|
headers.add("api_key", apiKey);
|
||||||
|
headers.add("secret_key", apiSecret);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProductInfoEntity> dlByTime(String udiUrl, int page, int limit, String updateTime) {
|
||||||
|
Map<String, Object> paramMap = new HashMap<>(16);
|
||||||
|
paramMap.put("page", page);
|
||||||
|
paramMap.put("limit", limit);
|
||||||
|
paramMap.put("updateTime", updateTime);
|
||||||
|
String response = UHttpClient.mipsGetHead(spmsUrl + "/udidl/udiwms/syncUdi", paramMap, getHeaders());
|
||||||
|
try {
|
||||||
|
BaseResponse<List<ProductInfoEntity>> udiDlDeviceResponse = (BaseResponse<List<ProductInfoEntity>>) JSONObject.parseObject(response, BaseResponse.class);
|
||||||
|
List<ProductInfoEntity> udiInfoEntities = udiDlDeviceResponse.getData();
|
||||||
|
return udiInfoEntities;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<UdiCompanyEntity> dlCompanyByTime(String udiUrl, int page, int limit, String updateTime) {
|
||||||
|
Map<String, Object> paramMap = new HashMap<>(16);
|
||||||
|
paramMap.put("page", page);
|
||||||
|
paramMap.put("limit", limit);
|
||||||
|
paramMap.put("updateTime", updateTime);
|
||||||
|
String response = UHttpClient.mipsGetHead(spmsUrl + "/udidl/udiwms/syncCompany", paramMap, getHeaders());
|
||||||
|
try {
|
||||||
|
BaseResponse<List<UdiCompanyEntity>> baseResponse = (BaseResponse<List<UdiCompanyEntity>>) JSONObject.parseObject(response, BaseResponse.class);
|
||||||
|
List<UdiCompanyEntity> udiCompanyEntities = baseResponse.getData();
|
||||||
|
return udiCompanyEntities;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.glxp.sale.admin.thread.didl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.glxp.sale.admin.constant.FileConstant;
|
||||||
|
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.ProductInfoEntity;
|
||||||
|
import com.glxp.sale.admin.entity.sync.ThrImportLogEntity;
|
||||||
|
import com.glxp.sale.admin.service.param.SystemParamConfigService;
|
||||||
|
import com.glxp.sale.admin.service.sync.BasicExportService;
|
||||||
|
import com.glxp.sale.admin.util.CustomUtil;
|
||||||
|
import com.glxp.sale.admin.util.FileUtils;
|
||||||
|
import com.glxp.sale.admin.util.RedisUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AsyncDiDlService {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SystemParamConfigService systemParamConfigService;
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
BasicExportService basicExportService;
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AsyncDiDlService.class);
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void asyncDiByTime(String updateTime) {
|
||||||
|
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
|
||||||
|
if (systemParamConfigEntity.getParamValue().equals("1")) {
|
||||||
|
AsyncDiDlHelper asyncDiDlHelper = new AsyncDiDlHelper();
|
||||||
|
List<ProductInfoEntity> mProductInfoEntities = new ArrayList<>();
|
||||||
|
int page = 1;
|
||||||
|
int limit = 200;
|
||||||
|
while (true) {
|
||||||
|
logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
|
||||||
|
List<ProductInfoEntity> productInfoEntityList = asyncDiDlHelper.dlByTime(null, page, limit, updateTime);
|
||||||
|
if (productInfoEntityList != null && productInfoEntityList.size() > 0) {
|
||||||
|
mProductInfoEntities.addAll(productInfoEntityList);
|
||||||
|
if (productInfoEntityList.size() < limit) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
|
||||||
|
String key = "dlDi" + System.currentTimeMillis();
|
||||||
|
String datas = JSON.toJSON(mProductInfoEntities).toString();
|
||||||
|
if (downstream.getParamValue().equals("1")) {
|
||||||
|
redisUtil.set(key, datas);
|
||||||
|
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
|
||||||
|
myEntity.setId(key);
|
||||||
|
basicExportService.insertExportStatus(myEntity);
|
||||||
|
} else {
|
||||||
|
String path = getPath();
|
||||||
|
String fileName = path + FileConstant.upWaitCopy_products + "同步库DI信息_" + key + ".udi";
|
||||||
|
FileUtils.SaveFileAs(datas, fileName);
|
||||||
|
}
|
||||||
|
logger.info("更新时间:" + updateTime + "----" + "下载结束");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder");
|
||||||
|
String filePath = systemParamConfigEntity.getParamValue();
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.glxp.sale.admin.thread.didl;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.dao.info.ScheduledDao;
|
||||||
|
import com.glxp.sale.admin.entity.info.ScheduledEntity;
|
||||||
|
import com.glxp.sale.admin.req.info.ScheduledRequest;
|
||||||
|
import com.glxp.sale.admin.util.DateUtil;
|
||||||
|
import com.glxp.sale.admin.util.RedisUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
import org.springframework.scheduling.support.CronTrigger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@EnableScheduling
|
||||||
|
public class AsyncDiDlTask implements SchedulingConfigurer {
|
||||||
|
|
||||||
|
final Logger logger = LoggerFactory.getLogger(AsyncDiDlTask.class);
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
private ScheduledDao scheduledDao;
|
||||||
|
@Resource
|
||||||
|
AsyncDiDlService asyncDiDlService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
||||||
|
scheduledTaskRegistrar.addTriggerTask(() -> process(),
|
||||||
|
triggerContext -> {
|
||||||
|
ScheduledRequest scheduledRequest = new ScheduledRequest();
|
||||||
|
scheduledRequest.setCronName("syncDi");
|
||||||
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
||||||
|
String cron = scheduledEntity.getCron();//"0 55 5 * * ?";
|
||||||
|
if (cron.isEmpty()) {
|
||||||
|
logger.error("cron is null");
|
||||||
|
}
|
||||||
|
return new CronTrigger(cron).nextExecutionTime(triggerContext);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void process() {
|
||||||
|
String day = DateUtil.getLastDayFormat(-1);
|
||||||
|
asyncDiDlService.asyncDiByTime(day);
|
||||||
|
|
||||||
|
|
||||||
|
String lastUpDiTime = (String) redisUtil.get("lastDiUpTime");
|
||||||
|
if (lastUpDiTime == null) {
|
||||||
|
lastUpDiTime = DateUtil.getLastDayFormat(-10);
|
||||||
|
}
|
||||||
|
asyncDiDlService.asyncDiByTime(lastUpDiTime);
|
||||||
|
redisUtil.set("lastDiUpTime", DateUtil.formatDate(new Date()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue