同步服务完结,代码备份
							parent
							
								
									3f6be920d0
								
							
						
					
					
						commit
						fe39577398
					
				@ -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);
 | 
				
			||||
        }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
}
 | 
				
			||||
@ -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;
 | 
				
			||||
 | 
				
			||||
}
 | 
				
			||||
@ -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;
 | 
				
			||||
 | 
				
			||||
}
 | 
				
			||||
@ -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());
 | 
				
			||||
                        }
 | 
				
			||||
 | 
				
			||||
                    }
 | 
				
			||||
                }
 | 
				
			||||
            }
 | 
				
			||||
        }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
}
 | 
				
			||||
@ -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();
 | 
				
			||||
        }
 | 
				
			||||
    }
 | 
				
			||||
 | 
				
			||||
}
 | 
				
			||||
@ -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;
 | 
				
			||||
    }
 | 
				
			||||
}
 | 
				
			||||
@ -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…
					
					
				
		Reference in New Issue