同步服务完结,代码备份

version1
anthonyywj2 3 years ago
parent 3f6be920d0
commit fe39577398

@ -21,6 +21,19 @@ public class BasicProcessStatus {
public static final int DATA_TYPE_UDI = 1;
public static final int DATA_TYPE_SP = 2;
//导出数据类型
public static final int BASIC_UDI = 1; //耗材字典
public static final int BASIC_INV = 2; //仓库字典
public static final int BASIC_CORP = 3; //往来单位
public static final int BASIC_THIRD_PRODUCTS = 4; //往来单位
public static final int BASIC_THIRD_CORP = 5; //往来单位
public static final int BASIC_THIRD_ORDER = 6; //往来单位
public static final int IMPORT_LOG_TYPE_ORDER = 1;//单据
public static final int IMPORT_LOG_TYPE_UDIINFO = 2;//耗材字典
public static final int IMPORT_LOG_TYPE_CORP = 3;//往来单位
public static final int IMPORT_LOG_TYPE_INV = 4;//仓库字典
}

@ -0,0 +1,78 @@
package com.glxp.sale.admin.controller.sync;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.sale.admin.annotation.AuthRuleAnnotation;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.req.info.DeleteRequest;
import com.glxp.sale.admin.req.sync.BasicExportStatusRequest;
import com.glxp.sale.admin.req.sync.FilterUdiInfoRequest;
import com.glxp.sale.admin.res.sync.BasicUnitMaintainExportResponse;
import com.glxp.sale.admin.res.sync.InvWarehouseExportResponse;
import com.glxp.sale.admin.res.sync.UdiRelevanceExportJsonResponse;
import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.util.RedisUtil;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
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.List;
@RestController
public class BasicDowmloadController {
@Resource
BasicExportService basicExportService;
@Resource
RedisUtil redisUtil;
@GetMapping("/spssync/basic/udiinfo/getStatus")
public BaseResponse getStatus(BasicExportStatusRequest basicExportStatusRequest) {
List<BasicExportStatusEntity> basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest);
return ResultVOUtils.success(basicExportStatusEntities);
}
@PostMapping("/spssync/basic/udiinfo/downloadByStatus")
public BaseResponse downloadByStatus(@RequestBody BasicExportStatusRequest basicExportStatusRequest) {
if (basicExportStatusRequest.getType() == BasicProcessStatus.BASIC_UDI) {//基础信息下载
String data = (String) redisUtil.get(basicExportStatusRequest.getId() + "");
UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = JSONObject.parseObject(data, new TypeReference<UdiRelevanceExportJsonResponse>() {
});
return ResultVOUtils.success(udiRelevanceExportJsonResponse);
} else if (basicExportStatusRequest.getType() == BasicProcessStatus.BASIC_CORP) {//基础信息下载
String data = (String) redisUtil.get(basicExportStatusRequest.getId() + "");
BasicUnitMaintainExportResponse basicUnitMaintainExportResponse = JSONObject.parseObject(data, new TypeReference<BasicUnitMaintainExportResponse>() {
});
return ResultVOUtils.success(basicUnitMaintainExportResponse);
} else if (basicExportStatusRequest.getType() == BasicProcessStatus.BASIC_INV) {//基础信息下载
String data = (String) redisUtil.get(basicExportStatusRequest.getId() + "");
InvWarehouseExportResponse invWarehouseExportResponse = JSONObject.parseObject(data, new TypeReference<InvWarehouseExportResponse>() {
});
return ResultVOUtils.success(invWarehouseExportResponse);
}
return ResultVOUtils.error(500, "数据不存在!");
}
@PostMapping("/spssync/basic/udiinfo/deleteByStatus")
public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) {
boolean b = basicExportService.deleteById(Integer.parseInt(deleteRequest.getId()));
redisUtil.del(deleteRequest.getId());
if (b)
return ResultVOUtils.success("删除成功!");
else
return ResultVOUtils.error(500, "删除失败!");
}
}

@ -0,0 +1,191 @@
package com.glxp.sale.admin.controller.sync;
import com.alibaba.fastjson.JSON;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity;
import com.glxp.sale.admin.http.SpPostHttp;
import com.glxp.sale.admin.req.sync.PostThrCorpRequest;
import com.glxp.sale.admin.req.sync.PostThrProductsRequest;
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.FileUtils;
import com.glxp.sale.common.enums.ResultEnum;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
import org.springframework.beans.factory.annotation.Value;
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;
/**
*
*/
@RestController
public class BasicExportUploadController {
@Value("${file_path_dupp_udiinfo}")
private String udiFilePath;
@Value("${back_file_path}")
private String backFilePath;
@Resource
SystemParamConfigService systemParamConfigService;
@Resource
SpPostHttp spPostHttp;
@PostMapping("/spssync/basic/udiinfo/upload")
public BaseResponse postUdiInfo(@RequestBody UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse,
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 key = CustomUtil.getId();
String fileName = udiFilePath + "耗材字典" + key + ".udi";
String backFileName = backFilePath + "耗材字典" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
String datas = JSON.toJSONString(udiRelevanceExportJsonResponse);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
return spPostHttp.postUdiInfo(udiRelevanceExportJsonResponse);
}
}
@PostMapping("/spssync/basic/corp/upload")
public BaseResponse postCorp(@RequestBody BasicUnitMaintainExportResponse basicUnitMaintainExportResponse,
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 key = CustomUtil.getId();
String fileName = udiFilePath + "往来单位" + key + ".udi";
String backFileName = backFilePath + "往来单位" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
String datas = JSON.toJSONString(basicUnitMaintainExportResponse);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
return spPostHttp.postCorp(basicUnitMaintainExportResponse);
}
}
@PostMapping("/spssync/basic/inv/upload")
public BaseResponse postInv(@RequestBody InvWarehouseExportResponse invWarehouseExportResponse,
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 key = CustomUtil.getId();
String fileName = udiFilePath + "仓库字典" + key + ".udi";
String backFileName = backFilePath + "仓库字典" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
String datas = JSON.toJSONString(invWarehouseExportResponse);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
return spPostHttp.postInv(invWarehouseExportResponse);
}
}
@PostMapping("/spssync/thirdsys/products/upload")
public BaseResponse postThirdProducts(@RequestBody PostThrProductsRequest postThrProductsRequest,
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 key = CustomUtil.getId();
String fileName = udiFilePath + "第三方产品信息" + key + ".udi";
String backFileName = backFilePath + "第三方产品信息" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
String datas = JSON.toJSONString(postThrProductsRequest);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
return spPostHttp.postThirdProducts(postThrProductsRequest);
}
}
@PostMapping("/spssync/thirdsys/corp/upload")
public BaseResponse postThridCorp(@RequestBody PostThrCorpRequest postThrCorpRequest,
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 key = CustomUtil.getId();
String fileName = udiFilePath + "第三方往来单位" + key + ".udi";
String backFileName = backFilePath + "第三方往来单位" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
String datas = JSON.toJSONString(postThrCorpRequest);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
return spPostHttp.postThirdCorps(postThrCorpRequest);
}
}
@PostMapping("/spssync/thirdsys/order/upload")
public BaseResponse postThridOrder(@RequestBody ThrOrderExportJsonResponse thrOrderExportJsonResponse,
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 key = CustomUtil.getId();
String fileName = udiFilePath + "第三方业务单据" + key + ".udi";
String backFileName = backFilePath + "第三方业务单据" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
String datas = JSON.toJSONString(thrOrderExportJsonResponse);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
return spPostHttp.postThirdOrders(thrOrderExportJsonResponse);
}
}
}

@ -106,9 +106,7 @@ public class ThrProductsImportLogController {
if ("1".equals(value)) {
return postSmpHttp.postThrProducts(postThrProductsRequest);
} else {
List<ErpProductsResponse> erpProductsResponses = postThrProductsRequest.getDatas();
String genKey = postThrProductsRequest.getGenKey();
if (genKey == null) {
genKey = CustomUtil.getId();

@ -0,0 +1,22 @@
package com.glxp.sale.admin.dao.sync;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.req.sync.BasicExportStatusRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface BasicExportDao {
List<BasicExportStatusEntity> filterExportStatus(BasicExportStatusRequest basicExportStatusRequest);
boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity);
boolean deleteById(@Param("id") Integer id);
boolean updateExportStatus(BasicExportStatusEntity warehouseEntity);
}

@ -0,0 +1,14 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class BasicExportStatusEntity {
private String id;
private String idDatas;
private Integer status;
private Integer type;
private Date updateTime;
}

@ -0,0 +1,37 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class BasicUnitMaintainEntity {
private Integer id;
private String erpId;
private String name;
private String spell;
private String addr;
private String status;
private String type;
private String creditNo;
private String contact;
private String mobile;
private String thirdId;
private String thirdId1;
private String thirdId2;
private String thirdId3;
private String thirdId4;
private String thirdName;
private String thirdName1;
private String thirdName2;
private String thirdName3;
private String thirdName4;
private Date updateTime;
private int corpType;
}

@ -0,0 +1,32 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class InvWarehouseEntity {
private Integer id;
private Integer pid;
private String code;
private String name;
private Boolean advanceType;
private Boolean isDefault;
private Integer status;
private Date updateTime;
private String remark;
private Integer level;
private String pcode;
/**
* ID
*/
private String thirdId;
private String thirdId1;
private String thirdId2;
private String thirdId3;
private String thirdId4;
}

@ -0,0 +1,23 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class ThrCorpEntity {
private String id;
private String unitId;
private String name;
private String spell;
private String addr;
private String creditNo;
private String contact;
private String mobile;
private String thirdSysFk;
private Boolean checked;
private Date updateTime;
}

@ -0,0 +1,32 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
/**
*
*/
@Data
public class ThrInvWarehouseEntity {
private Integer id;
private Integer pid;
private String code;
private String name;
private Boolean advanceType;
private Boolean isDefault;
private Integer status;
private Date updateTime;
private String remark;
/**
*
*/
private Integer level;
/**
*
*/
private String pcode;
}

@ -0,0 +1,22 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class ThrOrderDetailEntity {
private Integer id;
private String productId;
private String productName;
private String spec;
private String batchNo;
private String expireDate;
private String productDate;
private Integer count;
private Integer reCount;
private String orderIdFk;
private String thirdSysFk;
private Date updateTime;
}

@ -0,0 +1,21 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class ThrOrderEntity {
private Integer id;
private String billNo;
private String billdate;
private String corpId;
private String corpName;
private String billType;
private String billFlag;
private String thirdSysFk;
private Date updateTime;
private String originType;
}

@ -0,0 +1,31 @@
package com.glxp.sale.admin.entity.sync;
import lombok.Data;
import java.util.Date;
@Data
public class ThrProductsEntity {
private Integer id;
private String code;
private String name;
private String measname;
private String spec;
private String registerNo;
private String manufactory;
private String thirdSysFk;
private String cplb;
private String flbm;
private String qxlb;
private String ybbm;
private String sptm;
private String tyshxydm;
private String zczbhhzbapzbh;
private String ylqxzcrbarmc;
private String ylqxzcrbarywmc;
private String cpms;
private Date updateTime;
private String supName;
private boolean isChecked;
}

@ -1,11 +1,17 @@
package com.glxp.sale.admin.http;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity;
import com.glxp.sale.admin.entity.sync.OrderEntity;
import com.glxp.sale.admin.req.sync.BasicDataFilterRequest;
import com.glxp.sale.admin.req.sync.BasicStatusFilterRequest;
import com.glxp.sale.admin.req.sync.OrderStatusFilterRequest;
import com.glxp.sale.admin.req.sync.PostThrOrderRequest;
import com.glxp.sale.admin.res.PageSimpleResponse;
import com.glxp.sale.admin.res.sync.DlOrderResponse;
import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
import org.springframework.beans.factory.annotation.Value;
@ -70,7 +76,6 @@ public class SpGetHttp {
public BaseResponse<String> postOrder(String orderId) {
OrderStatusFilterRequest orderStatusFilterRequest = new OrderStatusFilterRequest();
orderStatusFilterRequest.setOrderId(orderId);
orderStatusFilterRequest.setStatus(2);
String result = UHttpClient.postJson(spmsUrl + "/spms/inout/order/deleteStatus", orderStatusFilterRequest, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
@ -78,4 +83,69 @@ public class SpGetHttp {
return response;
}
public BaseResponse<List<BasicExportStatusEntity>> getBasicStatus(String type) {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("type", type);
String response = UHttpClient.mipsGetHead(spmsUrl + "/udiwms/basic/udiinfo/getStatus", paramMap, getHeaders());
try {
BaseResponse<List<BasicExportStatusEntity>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<BasicExportStatusEntity>>>() {
});
return data;
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(500, "下载失败!");
}
}
//获取耗材字典
public String getBasicUdiInfo(List<String> ids) {
BasicDataFilterRequest basicDataFilterRequest = new BasicDataFilterRequest();
basicDataFilterRequest.setRelIds(ids);
String result = UHttpClient.postJson(spmsUrl + "/udiwms/basic/udiinfo/downloadByStatus", basicDataFilterRequest, getHeaders());
BaseResponse<UdiRelevanceExportJsonResponse> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<UdiRelevanceExportJsonResponse>>() {
});
UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = response.getData();
return JSON.toJSON(udiRelevanceExportJsonResponse).toString();
}
//获取往来单位
public String getBasicCorps(List<String> ids) {
BasicDataFilterRequest basicDataFilterRequest = new BasicDataFilterRequest();
basicDataFilterRequest.setIds(ids);
String result = UHttpClient.postJson(spmsUrl + "/udiwms/basic/corps/downloadByStatus", basicDataFilterRequest, getHeaders());
BaseResponse<BasicUnitMaintainExportResponse> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<BasicUnitMaintainExportResponse>>() {
});
return JSON.toJSON(response.getData()).toString();
}
//获取往来单位
public String getBasicInv(List<String> ids) {
BasicDataFilterRequest basicDataFilterRequest = new BasicDataFilterRequest();
basicDataFilterRequest.setIds(ids);
String result = UHttpClient.postJson(spmsUrl + "/spms/inv/warehouse/downloadByStatus", basicDataFilterRequest, getHeaders());
BaseResponse<InvWarehouseExportResponse> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<InvWarehouseExportResponse>>() {
});
return JSON.toJSON(response.getData()).toString();
}
public BaseResponse<String> postBasicStatus(String id) {
BasicStatusFilterRequest basicStatusFilterRequest = new BasicStatusFilterRequest();
basicStatusFilterRequest.setId(id);
basicStatusFilterRequest.setStatus(2);
String result = UHttpClient.postJson(spmsUrl + "/udiwms/basic/udiinfo/deleteByStatus", basicStatusFilterRequest, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
}

@ -0,0 +1,94 @@
package com.glxp.sale.admin.http;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.sale.admin.req.sync.OrderStatusFilterRequest;
import com.glxp.sale.admin.req.sync.PostThrCorpRequest;
import com.glxp.sale.admin.req.sync.PostThrProductsRequest;
import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.common.res.BaseResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
@Service
public class SpPostHttp {
@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 BaseResponse<String> postOrder(DlOrderResponse dlOrderResponse) {
String result = UHttpClient.postJson(spmsUrl + "/spms/inout/order/deleteStatus", dlOrderResponse, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
public BaseResponse<String> postUdiInfo(UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse) {
String result = UHttpClient.postJson(spmsUrl + "/spssync/basic/udiinfo/upload", udiRelevanceExportJsonResponse, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
public BaseResponse<String> postCorp(BasicUnitMaintainExportResponse basicUnitMaintainExportResponse) {
String result = UHttpClient.postJson(spmsUrl + "/spssync/basic/corp/upload", basicUnitMaintainExportResponse, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
public BaseResponse<String> postInv(InvWarehouseExportResponse invWarehouseExportResponse) {
String result = UHttpClient.postJson(spmsUrl + "/spssync/basic/inv/upload", invWarehouseExportResponse, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
public BaseResponse<String> postThirdProducts(PostThrProductsRequest postThrProductsRequest) {
String result = UHttpClient.postJson(spmsUrl + "/spssync/thirdsys/products/upload", postThrProductsRequest, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
public BaseResponse<String> postThirdCorps(PostThrCorpRequest postThrCorpRequest) {
String result = UHttpClient.postJson(spmsUrl + "/spssync/thirdsys/corp/upload", postThrCorpRequest, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
public BaseResponse<String> postThirdOrders(ThrOrderExportJsonResponse thrOrderExportJsonResponse) {
String result = UHttpClient.postJson(spmsUrl + "/spssync/thirdsys/order/upload", thrOrderExportJsonResponse, getHeaders());
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
return response;
}
}

@ -0,0 +1,13 @@
package com.glxp.sale.admin.req.sync;
import lombok.Data;
import java.util.List;
@Data
public class BasicDataFilterRequest {
List<String> relIds;
List<String> ids;
}

@ -0,0 +1,11 @@
package com.glxp.sale.admin.req.sync;
import com.glxp.sale.admin.req.ListPageRequest;
import lombok.Data;
@Data
public class BasicExportStatusRequest extends ListPageRequest {
private Integer id;
private Integer status;
private Integer type;
}

@ -0,0 +1,10 @@
package com.glxp.sale.admin.req.sync;
import com.glxp.sale.admin.req.ListPageRequest;
import lombok.Data;
@Data
public class BasicStatusFilterRequest extends ListPageRequest {
private String id;
private Integer status;
}

@ -0,0 +1,14 @@
package com.glxp.sale.admin.req.sync;
import com.glxp.sale.admin.entity.sync.ThrCorpEntity;
import lombok.Data;
import java.util.List;
@Data
public class PostThrCorpRequest {
private String genKey;
private String thirdSys;
private String uploadType;
private List<ThrCorpEntity> datas;
}

@ -0,0 +1,30 @@
package com.glxp.sale.admin.res.sync;
import com.glxp.sale.admin.entity.sync.BasicUnitMaintainEntity;
import com.glxp.sale.admin.entity.sync.ThrCorpEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
@Data
public class BasicUnitMaintainExportResponse {
/**
*
*/
private List<BasicUnitMaintainEntity> corpList;
/**
*
*/
private List<ThrCorpEntity> thrCorpEntities;
public BasicUnitMaintainExportResponse() {
this.corpList = new ArrayList<>();
this.thrCorpEntities = new ArrayList<>();
}
}

@ -0,0 +1,14 @@
package com.glxp.sale.admin.res.sync;
import com.glxp.sale.admin.entity.sync.InvWarehouseEntity;
import com.glxp.sale.admin.entity.sync.ThrInvWarehouseEntity;
import lombok.Data;
import java.util.List;
@Data
public class InvWarehouseExportResponse {
List<InvWarehouseEntity> invWarehouseEntities;
List<ThrInvWarehouseEntity> thrInvWarehouseEntities;
}

@ -0,0 +1,16 @@
package com.glxp.sale.admin.res.sync;
import com.glxp.sale.admin.entity.sync.ThrOrderDetailEntity;
import com.glxp.sale.admin.entity.sync.ThrOrderEntity;
import lombok.Data;
import java.util.List;
@Data
public class ThrOrderExportJsonResponse {
private List<ThrOrderEntity> thrOrderEntityList;
private List<ThrOrderDetailEntity> thrOrderDetailEntities;
}

@ -1,6 +1,7 @@
package com.glxp.sale.admin.res.sync;
import com.glxp.sale.admin.entity.info.CompanyProductRelevanceEntity;
import com.glxp.sale.admin.entity.sync.ThrProductsEntity;
import com.glxp.sale.admin.entity.sync.UdiInfoEntity;
import com.glxp.sale.admin.entity.sync.UdiRelevanceEntity;
import lombok.Data;
@ -18,11 +19,15 @@ public class UdiRelevanceExportJsonResponse {
List<UdiRelevanceEntity> udiRelevanceEntities;
List<CompanyProductRelevanceEntity> companyProductRelevanceEntities;
//第三方产品信息
List<ThrProductsEntity> thrProductsEntities;
public UdiRelevanceExportJsonResponse() {
this.udiInfoEntities = new ArrayList<>();
this.udiRelevanceEntities = new ArrayList<>();
this.companyProductRelevanceEntities = new ArrayList<>();
this.thrProductsEntities = new ArrayList<>();
}
private List<CompanyProductRelevanceEntity> companyProductRelevanceEntities;
}

@ -0,0 +1,20 @@
package com.glxp.sale.admin.service.sync;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.req.sync.BasicExportStatusRequest;
import java.util.List;
public interface BasicExportService {
List<BasicExportStatusEntity> filterExportStatus(BasicExportStatusRequest basicExportStatusRequest);
boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity);
boolean deleteById(Integer id);
boolean updateExportStatus(BasicExportStatusEntity warehouseEntity);
}

@ -0,0 +1,46 @@
package com.glxp.sale.admin.service.sync.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.sale.admin.dao.sync.BasicExportDao;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.req.sync.BasicExportStatusRequest;
import com.glxp.sale.admin.service.sync.BasicExportService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class BasicExportServiceImpl implements BasicExportService {
@Resource
BasicExportDao basicExportDao;
@Override
public List<BasicExportStatusEntity> filterExportStatus(BasicExportStatusRequest basicExportStatusRequest) {
if (basicExportStatusRequest == null) {
return Collections.emptyList();
}
if (basicExportStatusRequest.getPage() != null) {
int offset = (basicExportStatusRequest.getPage() - 1) * basicExportStatusRequest.getLimit();
PageHelper.offsetPage(offset, basicExportStatusRequest.getLimit());
}
return basicExportDao.filterExportStatus(basicExportStatusRequest);
}
@Override
public boolean insertExportStatus(BasicExportStatusEntity basicExportStatusEntity) {
return basicExportDao.insertExportStatus(basicExportStatusEntity);
}
@Override
public boolean deleteById(Integer id) {
return basicExportDao.deleteById(id);
}
@Override
public boolean updateExportStatus(BasicExportStatusEntity basicExportStatusEntity) {
return basicExportDao.updateExportStatus(basicExportStatusEntity);
}
}

@ -0,0 +1,185 @@
package com.glxp.sale.admin.thread;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.*;
import com.glxp.sale.admin.http.SpGetHttp;
import com.glxp.sale.admin.res.PageSimpleResponse;
import com.glxp.sale.admin.res.sync.DlOrderResponse;
import com.glxp.sale.admin.res.sync.UdiRelevanceExportJsonResponse;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.*;
import com.glxp.sale.admin.util.CustomUtil;
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.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class DlBasicService {
@Resource
SpGetHttp spGetHttp;
@Resource
SystemParamConfigService systemParamConfigService;
@Value("${file_path_updl_order}")
private String orderFilePath;
@Value("${file_path_updl_udiinfo}")
private String udiFilePath;
@Value("${back_file_path}")
private String backFilePath;
@Resource
private ThrImportLogService thrImportLogService;
@Resource
RedisUtil redisUtil;
@Resource
BasicExportService basicExportService;
@Async
public void dlBasicUdiInfo() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_UDI + "");
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse.getData();
if (pageSimpleResponse != null) {
List<BasicExportStatusEntity> basicExportStatusEntities = pageSimpleResponse;
if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) {
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
if (!StrUtil.isEmpty(basicExportStatusEntity.getIdDatas())) {
if (basicExportStatusEntity.getType() == BasicProcessStatus.BASIC_UDI) {
List<String> ids = JSON.parseArray(basicExportStatusEntity.getIdDatas(), String.class);
String datas = spGetHttp.getBasicUdiInfo(ids);
String key = basicExportStatusEntity.getId() + "";
if (systemParamConfigEntity.getParamValue().equals("1")) {
redisUtil.set(key, datas);
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
BeanUtils.copyProperties(basicExportStatusEntity, myEntity);
myEntity.setId(key);
basicExportService.insertExportStatus(myEntity);
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
} else {
String fileName = udiFilePath + "耗材字典" + key + ".udi";
String backFileName = backFilePath + "耗材字典" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity();
thrImportLogEntity.setGenKey(CustomUtil.getUUId());
thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_UDIINFO);
thrImportLogEntity.setUpdateTime(new Date());
thrImportLogEntity.setFilePath(fileName);
thrImportLogEntity.setBackFilePath(backFileName);
thrImportLogService.insertImportLog(thrImportLogEntity);
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
}
}
}
}
}
}
}
@Async
public void dlBasicCorp() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_CORP + "");
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse.getData();
if (pageSimpleResponse != null) {
List<BasicExportStatusEntity> basicExportStatusEntities = pageSimpleResponse;
if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) {
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
if (!StrUtil.isEmpty(basicExportStatusEntity.getIdDatas())) {
List<String> ids = JSON.parseArray(basicExportStatusEntity.getIdDatas(), String.class);
String datas = spGetHttp.getBasicCorps(ids);
String key = basicExportStatusEntity.getId() + "";
if (systemParamConfigEntity.getParamValue().equals("1")) {
redisUtil.set(key, datas);
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
BeanUtils.copyProperties(basicExportStatusEntity, myEntity);
myEntity.setId(key);
basicExportService.insertExportStatus(myEntity);
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
} else {
String fileName = udiFilePath + "往来单位" + key + ".udi";
String backFileName = backFilePath + "往来单位" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity();
thrImportLogEntity.setGenKey(CustomUtil.getUUId());
thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_CORP);
thrImportLogEntity.setUpdateTime(new Date());
thrImportLogEntity.setFilePath(fileName);
thrImportLogEntity.setBackFilePath(backFileName);
thrImportLogService.insertImportLog(thrImportLogEntity);
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
}
}
}
}
}
}
@Async
public void dlBasicInv() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_INV + "");
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse.getData();
if (pageSimpleResponse != null) {
List<BasicExportStatusEntity> basicExportStatusEntities = pageSimpleResponse;
if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) {
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
if (!StrUtil.isEmpty(basicExportStatusEntity.getIdDatas())) {
List<String> ids = JSON.parseArray(basicExportStatusEntity.getIdDatas(), String.class);
String datas = spGetHttp.getBasicInv(ids);
String key = basicExportStatusEntity.getId() + "";
if (systemParamConfigEntity.getParamValue().equals("1")) {
redisUtil.set(key, datas);
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
BeanUtils.copyProperties(basicExportStatusEntity, myEntity);
myEntity.setId(key);
basicExportService.insertExportStatus(myEntity);
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
} else {
String fileName = udiFilePath + "仓库字典" + key + ".udi";
String backFileName = backFilePath + "仓库字典" + key + ".udi";
FileUtils.makeDirectory(udiFilePath);
FileUtils.makeDirectory(backFilePath);
FileUtils.SaveFileAs(datas, fileName);
FileUtils.SaveFileAs(datas, backFileName);
ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity();
thrImportLogEntity.setGenKey(CustomUtil.getUUId());
thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_INV);
thrImportLogEntity.setUpdateTime(new Date());
thrImportLogEntity.setFilePath(fileName);
thrImportLogEntity.setBackFilePath(backFileName);
thrImportLogService.insertImportLog(thrImportLogEntity);
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
}
}
}
}
}
}
}

@ -38,7 +38,7 @@ public class DlSpOrderService {
SystemParamConfigService systemParamConfigService;
@Resource
IOOrderStatusService ioOrderStatusService;
@Value("${file_path}")
@Value("${file_path_updl_order}")
private String filePath;
@Value("${back_file_path}")
private String backFilePath;
@ -75,7 +75,10 @@ public class DlSpOrderService {
}
if (Integer.parseInt(folderConfig.getParamValue()) == 1) {
String fileName = filePath + "/" + "扫码单据" + orderEntity.getId() + ".json";
filePath = filePath + "/" + "已完成扫码单据/";
backFilePath = backFilePath + "/" + "已完成扫码单据/";
String fileName = filePath + "扫码单据" + orderEntity.getId() + ".json";
String backFileName = backFilePath + "/" + "扫码单据" + orderEntity.getId() + ".json";
List<PostOrderRequest.PostOrder> postOrders = new ArrayList<>();
PostOrderRequest postOrderRequest = new PostOrderRequest();

@ -0,0 +1,132 @@
package com.glxp.sale.admin.thread;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class DlUploadService {
@Resource
RedisUtil redisUtil;
@Resource
SystemParamConfigService systemParamConfigService;
@Resource
DlSpOrderService dlSpOrderService;
@Resource
DlBasicService dlBasicService;
final Logger logger = LoggerFactory.getLogger(DlUploadService.class);
//定时从上游下载数据----下载单据
public void dlOrder() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_order_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
//任务一,定时下载供应商平台已完成单据
Long lastTime = (Long) redisUtil.get("DL_ORDER_STATUS");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("DL_ORDER_STATUS", lastTime);
}
if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次单据下载");
redisUtil.set("DL_ORDER_STATUS", curTime);
dlSpOrderService.dlOrdedrs();
}
}
//定时从上游下载数据----下载基础信息
public void dlBasicUdiInfo() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_udiinfo_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
Long lastTime = (Long) redisUtil.get("DL_BASIC_UDIINFO_STATUS");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("DL_BASIC_UDIINFO_STATUS", lastTime);
} else if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次基础信息下载");
redisUtil.set("DL_BASIC_UDIINFO_STATUS", curTime);
dlBasicService.dlBasicUdiInfo();
dlBasicService.dlBasicCorp();
dlBasicService.dlBasicInv();
}
}
//定时扫描本地共享文件夹---上传到上游
public void scanFolderUpload() {
SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable");
if (upConnect.getParamValue().equals("1")) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_udiinfo_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
Long lastTime = (Long) redisUtil.get("DL_BASIC_UDIINFO_STATUS");
if (lastTime == null) {
redisUtil.set("DL_BASIC_UDIINFO_STATUS", System.currentTimeMillis());
} else if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次基础信息下载");
redisUtil.set("DL_BASIC_UDIINFO_STATUS", curTime);
dlBasicService.dlBasicUdiInfo();
dlBasicService.dlBasicCorp();
dlBasicService.dlBasicInv();
}
}
}
//定时扫描本地共享文件夹---上传到上游
public void scanFolderDown() {
SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable");
if (upConnect.getParamValue().equals("1")) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_udiinfo_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
Long lastTime = (Long) redisUtil.get("DL_BASIC_UDIINFO_STATUS");
if (lastTime == null) {
redisUtil.set("DL_BASIC_UDIINFO_STATUS", System.currentTimeMillis());
} else if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次基础信息下载");
redisUtil.set("DL_BASIC_UDIINFO_STATUS", curTime);
dlBasicService.dlBasicUdiInfo();
dlBasicService.dlBasicCorp();
dlBasicService.dlBasicInv();
}
}
}
public void dlBasicCorp() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_corp_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
//任务一,定时下载供应商平台已完成单据
Long lastTime = (Long) redisUtil.get("DL_BASIC_CORP_STATUS");
if (lastTime == null) {
redisUtil.set("DL_BASIC_CORP_STATUS", System.currentTimeMillis());
} else if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次单据下载");
redisUtil.set("DL_BASIC_CORP_STATUS", curTime);
dlBasicService.dlBasicCorp();
}
}
public void dlBasicInv() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_inv_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
//任务一,定时下载供应商平台已完成单据
Long lastTime = (Long) redisUtil.get("DL_BASIC_INV_STATUS");
if (lastTime == null) {
redisUtil.set("DL_BASIC_INV_STATUS", System.currentTimeMillis());
} else if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次单据下载");
redisUtil.set("DL_BASIC_INV_STATUS", curTime);
dlBasicService.dlBasicInv();
}
}
}

@ -28,11 +28,15 @@ public class HeartTask implements SchedulingConfigurer {
@Resource
protected ScheduledDao scheduledDao;
@Resource
SystemParamConfigService systemParamConfigService;
@Resource
DlUploadService dlUploadService;
@Resource
RedisUtil redisUtil;
@Resource
SystemParamConfigService systemParamConfigService;
ScanUploadService scanUploadService;
@Resource
DlSpOrderService dlSpOrderService;
ScanDownloadService scanDownloadService;
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
@ -52,21 +56,83 @@ public class HeartTask implements SchedulingConfigurer {
private void process() {
dlData();
}
//定时从上游下载数据
private void dlData() {
SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable");
if (upConnect.getParamValue().equals("1")) {
dlUploadService.dlOrder();
dlUploadService.dlBasicUdiInfo();
}
scanUpload();
scanDonwload();
}
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_order_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
//任务一,定时下载供应商平台已完成单据
Long lastTime = (Long) redisUtil.get("DL_ORDER_STATUS");
if (lastTime == null) {
redisUtil.set("DL_ORDER_STATUS", System.currentTimeMillis());
private void scanUpload() {
SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable");
if (upConnect.getParamValue().equals("1")) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sc_udiinfo_upload");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
//任务一,定时下载供应商平台已完成单据
Long lastTime = (Long) redisUtil.get("UPLOAD_UDIINFO_STATUS");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("UPLOAD_UDIINFO_STATUS", lastTime);
}
if (curTime - lastTime > timeInterval) {
redisUtil.set("UPLOAD_UDIINFO_STATUS", curTime);
scanUploadService.scanCorp();
scanUploadService.scanUdi();
scanUploadService.scanInv();
scanUploadService.scanThirdProducts();
scanUploadService.scanThirdCorp();
scanUploadService.scanThirdOrder();
}
}
if (curTime - lastTime > timeInterval) {
logger.info("每分钟执行一次单据下载");
redisUtil.set("DL_ORDER_STATUS", curTime);
dlSpOrderService.dlOrdedrs();
}
private void scanDonwload() {
SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_downstream_enable");
if (upConnect.getParamValue().equals("1")) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sc_order_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
//任务一,定时下载供应商平台已完成单据
Long lastTime = (Long) redisUtil.get("SC_ORDER_DOWNLOAD_STATUS");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("SC_ORDER_DOWNLOAD_STATUS", lastTime);
}
if (curTime - lastTime > timeInterval) {
redisUtil.set("SC_ORDER_DOWNLOAD_STATUS", curTime);
scanDownloadService.scanOrder();
}
}
if (upConnect.getParamValue().equals("1")) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sc_udiinfo_status");
long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000;
long curTime = System.currentTimeMillis();
Long lastTime = (Long) redisUtil.get("SC_UDIINFO_DOWNLOAD_STATUS");
if (lastTime == null) {
lastTime = System.currentTimeMillis();
redisUtil.set("SC_UDIINFO_DOWNLOAD_STATUS", lastTime);
}
if (curTime - lastTime > timeInterval) {
redisUtil.set("SC_UDIINFO_DOWNLOAD_STATUS", curTime);
scanDownloadService.scanUdi();
scanDownloadService.scanCorp();
scanDownloadService.scanInv();
}
}
}
}

@ -0,0 +1,121 @@
package com.glxp.sale.admin.thread;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity;
import com.glxp.sale.admin.entity.sync.WarehouseEntity;
import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.service.sync.IOOrderStatusService;
import com.glxp.sale.admin.util.FileFilterImpl;
import com.glxp.sale.admin.util.FileUtils;
import com.glxp.sale.admin.util.RedisUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.Date;
import java.util.List;
/**
* udi
*/
@Service
public class ScanDownloadService {
@Value("${file_path_wdl_order}")
private String orderFilePath;
@Value("${file_path_wdl_udiinfo}")
private String udiFilePath;
@Resource
IOOrderStatusService ioOrderStatusService;
@Resource
RedisUtil redisUtil;
@Resource
BasicExportService basicExportService;
public void scanOrder() {
File[] files = FileUtils.listAll(new File(orderFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
String data = FileUtils.readFileAll(file.getPath());
IOOrderStatusEntity orderStatusEntity = new IOOrderStatusEntity();
orderStatusEntity.setOrderId(file.getName());
orderStatusEntity.setUpdateTime(new Date());
orderStatusEntity.setStatus(1);
ioOrderStatusService.insertOrderStatus(orderStatusEntity);
redisUtil.set(file.getName(), data);
}
}
}
public void scanUdi() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("耗材字典")) {
String data = FileUtils.readFileAll(file.getPath());
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
basicExportStatusEntity.setId(file.getName());
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(1);
basicExportStatusEntity.setIdDatas(file.getPath());
basicExportStatusEntity.setType(BasicProcessStatus.BASIC_UDI);
basicExportService.insertExportStatus(basicExportStatusEntity);
redisUtil.set(file.getName(), data);
}
}
}
}
public void scanCorp() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("往来单位")) {
String data = FileUtils.readFileAll(file.getPath());
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
basicExportStatusEntity.setId(file.getName());
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(1);
basicExportStatusEntity.setIdDatas(file.getPath());
basicExportStatusEntity.setType(BasicProcessStatus.BASIC_CORP);
basicExportService.insertExportStatus(basicExportStatusEntity);
redisUtil.set(file.getName(), data);
}
}
}
}
public void scanInv() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("仓库字典")) {
String data = FileUtils.readFileAll(file.getPath());
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
basicExportStatusEntity.setId(file.getName());
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(1);
basicExportStatusEntity.setIdDatas(file.getPath());
basicExportStatusEntity.setType(BasicProcessStatus.BASIC_INV);
basicExportService.insertExportStatus(basicExportStatusEntity);
redisUtil.set(file.getName(), data);
}
}
}
}
}

@ -0,0 +1,190 @@
package com.glxp.sale.admin.thread;
import com.alibaba.fastjson.JSON;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity;
import com.glxp.sale.admin.http.SpGetHttp;
import com.glxp.sale.admin.http.SpPostHttp;
import com.glxp.sale.admin.req.sync.PostThrCorpRequest;
import com.glxp.sale.admin.req.sync.PostThrProductsRequest;
import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.service.sync.IOOrderStatusService;
import com.glxp.sale.admin.util.FileFilterImpl;
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.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.Date;
/**
* UDI
*/
@Service
public class ScanUploadService {
@Value("${file_path_wup_order}")
private String orderFilePath;
@Value("${file_path_wup_udiinfo}")
private String udiFilePath;
@Resource
SpPostHttp spPostHttp;
@Value("${back_file_path}")
private String backFilePath;
public void scanOrder() {
File[] files = FileUtils.listAll(new File(orderFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
String data = FileUtils.readFileAll(file.getPath());
DlOrderResponse dlOrderResponse = JSON.parseObject(data, DlOrderResponse.class);
BaseResponse<String> baseResponse = spPostHttp.postOrder(dlOrderResponse);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传单据/"+ file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
public void scanUdi() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("耗材字典")) {
String data = FileUtils.readFileAll(file.getPath());
UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = JSON.parseObject(data, UdiRelevanceExportJsonResponse.class);
BaseResponse<String> baseResponse = spPostHttp.postUdiInfo(udiRelevanceExportJsonResponse);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
public void scanCorp() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("往来单位")) {
String data = FileUtils.readFileAll(file.getPath());
BasicUnitMaintainExportResponse basicUnitMaintainExportResponse = JSON.parseObject(data, BasicUnitMaintainExportResponse.class);
BaseResponse<String> baseResponse = spPostHttp.postCorp(basicUnitMaintainExportResponse);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
public void scanInv() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("仓库字典")) {
String data = FileUtils.readFileAll(file.getPath());
InvWarehouseExportResponse invWarehouseExportResponse = JSON.parseObject(data, InvWarehouseExportResponse.class);
BaseResponse<String> baseResponse = spPostHttp.postInv(invWarehouseExportResponse);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
public void scanThirdProducts() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("第三方产品信息")) {
String data = FileUtils.readFileAll(file.getPath());
PostThrProductsRequest postThrProductsRequest = JSON.parseObject(data, PostThrProductsRequest.class);
BaseResponse<String> baseResponse = spPostHttp.postThirdProducts(postThrProductsRequest);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
public void scanThirdCorp() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("第三方往来单位")) {
String data = FileUtils.readFileAll(file.getPath());
PostThrCorpRequest postThrCorpRequest = JSON.parseObject(data, PostThrCorpRequest.class);
BaseResponse<String> baseResponse = spPostHttp.postThirdCorps(postThrCorpRequest);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
public void scanThirdOrder() {
File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl());
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.getName().contains("第三方业务单据")) {
String data = FileUtils.readFileAll(file.getPath());
ThrOrderExportJsonResponse thrOrderExportJsonResponse = JSON.parseObject(data, ThrOrderExportJsonResponse.class);
BaseResponse<String> baseResponse = spPostHttp.postThirdOrders(thrOrderExportJsonResponse);
if (baseResponse.getCode() == 20000) {//上传成功
try {
FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/" + file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
}

@ -0,0 +1,13 @@
package com.glxp.sale.admin.util;
import java.io.File;
import java.io.FileFilter;
//自定义文件过滤器
public class FileFilterImpl implements FileFilter {
@Override
public boolean accept(File pathname) {
return true;
}
}

@ -184,7 +184,6 @@ public class FileUtils {
}
/**
*
* false
@ -273,7 +272,7 @@ public class FileUtils {
* @since 1.0
*/
public static File[] listAll(File file,
javax.swing.filechooser.FileFilter filter) {
FileFilter filter) {
ArrayList list = new ArrayList();
File[] files;
if (!file.exists() || file.isFile()) {
@ -293,7 +292,7 @@ public class FileUtils {
* @param file
*/
private static void list(ArrayList list, File file,
javax.swing.filechooser.FileFilter filter) {
FileFilter filter) {
if (filter.accept(file)) {
list.add(file);
if (file.isFile()) {
@ -718,6 +717,9 @@ public class FileUtils {
try {
File in = new File(infile);
File out = new File(outfile);
if (!out.exists()) {
out.createNewFile();
}
return CopyFile(in, out);
} catch (IOException ie) {
ie.printStackTrace();
@ -726,6 +728,14 @@ public class FileUtils {
}
public static final boolean CutFile(String infile, String outfile) throws Exception {
if (CopyFile(infile, outfile)) {
return new File(infile).delete();
}
return false;
}
/**
* contentpath
*

@ -23,10 +23,50 @@ server.connectionTimeout=180000
# \u8F93\u51FA\u65E5\u5FD7\u5230\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u7684springboot.log\u6587\u4EF6\u4E2D // \u914D\u7F6E logback-spring.xml\u65F6 \u6B64\u65E5\u5FD7\u8F93\u51FA\u65B9\u5F0F\u4F1A\u88AB\u8986\u76D6\u3002
logging.file=D:/1s/udiwms/udiwms.log
#logging.file=/www/glxpdata/spsyc/
file_path=D:/1s/udiwms/sp/order/sync
file_path=D:/share/udisps/
#file_path=/share/order/sync
back_file_path=D:/1s/udiwms/sp/order/sync/sync_back
back_file_path=D:/share/udisps/back/
#back_file_path=/share/order/sync_back
#----------------------------------上游下载文件路径-start-----------------
#上游下载单据文件路径
file_path_updl_order=D:/share/udisps/updownload/order/
#上游下载耗材字典文件路径
file_path_updl_udiinfo=D:/share/udisps/updownload/udiinfo/
#上游下载往来单位文件路径
file_path_updl_corp=D:/share/udisps/updownload/corp/
#上游下载仓库字典文件路径
file_path_updl_inv=D:/share/udisps/updownload/inv/
#----------------------------------上游下载文件路径-end---------------------
#----------------------------------手动拷贝等待下载文件路径-start-----------------
#上游下载单据文件路径
file_path_wdl_order=D:/share/udisps/waitdownload/order/
#上游下载耗材字典文件路径
file_path_wdl_udiinfo=D:/share/udisps/waitdownload/udiinfo/
#上游下载往来单位文件路径
file_path_wdl_corp=D:/share/udisps/waitdownload/corp/
#上游下载仓库字典文件路径
file_path_wdl_inv=D:/share/udisps/waitdownload/inv/
#----------------------------------手动拷贝等待下载文件路径-end-----------------
#----------------------------------手动拷贝等待上传文件路径-start-----------------
#上游下载单据文件路径
file_path_wup_order=D:/share/udisps/waitupload/order/
#上游下载耗材字典文件路径
file_path_wup_udiinfo=D:/share/udisps/waitupload/udiinfo/
#上游下载往来单位文件路径
file_path_wup_corp=D:/share/udisps/waitupload/corp/
#上游下载仓库字典文件路径
file_path_wup_inv=D:/share/udisps/waitupload/inv/
#----------------------------------手动拷贝等待上传文件路径-end-----------------
#----------------------------------下游上传文件路径-start-----------------
#上游下载单据文件路径
file_path_dup_order=D:/share/udisps/downupload/order/
#上游下载耗材字典文件路径
file_path_dupp_udiinfo=D:/share/udisps/downupload/udiinfo/
#上游下载往来单位文件路径
file_path_dup_corp=D:/share/udisps/downupload/corp/
#上游下载仓库字典文件路径
file_path_dup_inv=D:/share/udisps/downupload/inv/
#----------------------------------下游上传文件路径-end-----------------
#UDI\u6570\u636E\u4E0B\u8F7D
UDI_SERVER_URL=https://www.udims.com/UDI_DL_Server
#UCLOD\u670D\u52A1

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.sale.admin.dao.sync.BasicExportDao">
<select id="filterExportStatus" parameterType="com.glxp.sale.admin.req.sync.BasicExportStatusRequest"
resultType="com.glxp.sale.admin.entity.sync.BasicExportStatusEntity">
select * from basic_export_status
<where>
<if test="id != '' and id!=null">
and id = #{id}
</if>
<if test="status != '' and status!=null">
and status = #{status}
</if>
<if test="type != '' and type!=null">
and type = #{type}
</if>
</where>
</select>
<insert id="insertExportStatus" keyProperty="id"
parameterType="com.glxp.sale.admin.entity.sync.BasicExportStatusEntity">
replace
INTO basic_export_status(id,idDatas,status,type,updateTime)
values(
#{id},
#{idDatas},
#{status},
#{type},
#{updateTime}
)
</insert>
<update id="updateExportStatus" parameterType="com.glxp.sale.admin.entity.sync.BasicExportStatusEntity">
UPDATE basic_export_status
<trim prefix="set" suffixOverrides=",">
<if test="idDatas != null">idDatas=#{idDatas},</if>
<if test="status != null">status=#{status},</if>
<if test="type != null">type=#{type},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
</trim>
WHERE orderId = #{orderId}
</update>
<delete id="deleteById" parameterType="Map">
DELETE
FROM basic_export_status
WHERE id = #{id}
</delete>
</mapper>
Loading…
Cancel
Save