diff --git a/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java b/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java index 08959cb..35a8988 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java @@ -46,4 +46,7 @@ public class BasicProcessStatus { public static final int SCHEDULE_TRANSFER = 2; //需要传递任务 + public static final int INTERFACE_TYPE = 1; //接口方式 + public static final int FILE_TYPE = 2; //文件方式 + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/constant/ConstantStatus.java b/api-admin/src/main/java/com/glxp/sale/admin/constant/ConstantStatus.java new file mode 100644 index 0000000..33a5e87 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/constant/ConstantStatus.java @@ -0,0 +1,10 @@ +package com.glxp.sale.admin.constant; + +public class ConstantStatus { + + public static final String SYNC_BASIC_DATA = "AutoDownloadAllData"; + public static final String SYNC_BUS_TYPE = "AutoDownloadBusType"; + public static final String SYNC_SCAN_ORDER = "AutoDownloadOrder"; + public static final String SYNC_DI_PRODUCTS = "AutoDownloadDiProducts"; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDataSyncStatusController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDataSyncStatusController.java new file mode 100644 index 0000000..2f617fa --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDataSyncStatusController.java @@ -0,0 +1,104 @@ +package com.glxp.sale.admin.controller.sync; + +import cn.hutool.core.util.StrUtil; +import com.github.pagehelper.PageInfo; +import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.req.sync.BasicUploadRequest; +import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; +import com.glxp.sale.admin.res.PageSimpleResponse; +import com.glxp.sale.admin.service.sync.BasicUploadService; +import com.glxp.sale.admin.service.sync.BasicExportService; +import com.glxp.sale.common.enums.ResultEnum; +import com.glxp.sale.common.res.BaseResponse; +import com.glxp.sale.common.util.ResultVOUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 数据同步日志查询接口 + */ +@Slf4j +@RestController +public class BasicDataSyncStatusController { + + @Resource + private BasicUploadService basicUploadService; + @Resource + private BasicExportService basicExportService; + + //--------------------------------------------------下载任务接口----------------------------------------------------------------- + + /** + * 下载任务日志查询 + * + * @param basicExportStatusRequest + * @return + */ + @GetMapping("/spssync/basic/download/status/filter") + public BaseResponse filterDownloadStatus(BasicExportStatusRequest basicExportStatusRequest) { + List basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest); + PageInfo pageInfo = new PageInfo<>(basicExportStatusEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(basicExportStatusEntities); + return ResultVOUtils.success(pageSimpleResponse); + } + + /** + * 删除下载任务日志 + * + * @param id + * @return + */ + @GetMapping("/spssync/basic/download/status/delete") + public BaseResponse deleteDownloadStatus(String id) { + if (StrUtil.isBlank(id)) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + if (basicExportService.deleteById(id)) { + return ResultVOUtils.success(); + } + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + + //---------------------------------------------------上传任务接口---------------------------------------------------------------- + + /** + * 查询下载任务日志 + * + * @param basicDownloadRequest + * @return + */ + @GetMapping("/spssync/basic/upload/status/filter") + public BaseResponse filterUploadStatus(BasicUploadRequest basicDownloadRequest) { + List basicDownloadStatusEntities = basicUploadService.filterDownloadStatus(basicDownloadRequest); + PageInfo pageInfo = new PageInfo<>(basicDownloadStatusEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setList(basicDownloadStatusEntities); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + return ResultVOUtils.success(pageSimpleResponse); + } + + /** + * 删除下载任务日志 + * + * @param id + * @return + */ + @GetMapping("/spssync/basic/upload/status/delete") + public BaseResponse deleteUploadStatus(String id) { + if (StrUtil.isBlank(id)) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + if (basicUploadService.deleteById(id)) { + return ResultVOUtils.success(); + } + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java similarity index 75% rename from api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java rename to api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java index a1add34..5d0f460 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java @@ -1,30 +1,23 @@ package com.glxp.sale.admin.controller.sync; -import cn.hutool.core.collection.CollUtil; -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.*; 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 { +public class BasicDownloadController { @Resource @@ -32,20 +25,6 @@ public class BasicDowmloadController { @Resource RedisUtil redisUtil; - - @GetMapping("/spssync/basic/udiinfo/getStatus") - public BaseResponse getStatus(BasicExportStatusRequest basicExportStatusRequest) { - List basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest); - - if (CollUtil.isNotEmpty(basicExportStatusEntities)) { - for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) { - basicExportStatusEntity.setFromType(1); - } - } - return ResultVOUtils.success(basicExportStatusEntities); - } - - @PostMapping("/spssync/basic/udiinfo/downloadByStatus") public BaseResponse downloadByStatus(@RequestBody BasicExportStatusRequest basicExportStatusRequest) { @@ -53,30 +32,37 @@ public class BasicDowmloadController { String data = (String) redisUtil.get(basicExportStatusRequest.getId() + ""); UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = JSONObject.parseObject(data, new TypeReference() { }); + basicExportService.finished(basicExportStatusRequest.getId()); 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() { }); + basicExportService.finished(basicExportStatusRequest.getId()); 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() { }); + basicExportService.finished(basicExportStatusRequest.getId()); return ResultVOUtils.success(invWarehouseExportResponse); } else if (basicExportStatusRequest.getType() == BasicProcessStatus.NEW_ALL_DATA) {//基础信息下载 SpsSyncDataResponse spsSyncDataResponse = (SpsSyncDataResponse) redisUtil.get(basicExportStatusRequest.getId() + ""); + basicExportService.finished(basicExportStatusRequest.getId()); return ResultVOUtils.success(spsSyncDataResponse); } else if (basicExportStatusRequest.getType() == BasicProcessStatus.NEW_ALL_BUS) {//单据类型 SpsSyncBusResponse spsSyncDataResponse = (SpsSyncBusResponse) redisUtil.get(basicExportStatusRequest.getId() + ""); + basicExportService.finished(basicExportStatusRequest.getId()); return ResultVOUtils.success(spsSyncDataResponse); } else if (basicExportStatusRequest.getType() == BasicProcessStatus.NEW_ALL_ORDER) {//单据 SpsSyncOrderResponse spsSyncDataResponse = (SpsSyncOrderResponse) redisUtil.get(basicExportStatusRequest.getId() + ""); + basicExportService.finished(basicExportStatusRequest.getId()); return ResultVOUtils.success(spsSyncDataResponse); } else if (basicExportStatusRequest.getType() == BasicProcessStatus.NEW_ALL_UDIS) {//单据 String data = (String) redisUtil.get(basicExportStatusRequest.getId() + ""); SpSyncUdiResponse spSyncUdiResponse = JSONObject.parseObject(data, new TypeReference() { }); + basicExportService.finished(basicExportStatusRequest.getId()); return ResultVOUtils.success(spSyncUdiResponse); } return ResultVOUtils.error(500, "数据不存在!"); @@ -84,18 +70,6 @@ public class BasicDowmloadController { } - @PostMapping("/spssync/basic/udiinfo/deleteByStatus") - public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) { - - boolean b = basicExportService.deleteById(deleteRequest.getId()); - redisUtil.del(deleteRequest.getId()); - if (b) - return ResultVOUtils.success("删除成功!"); - else - return ResultVOUtils.error(500, "删除失败!"); - } - - @PostMapping("/spssync/basic/udiinfo/updateStatus") public BaseResponse updateStatus(@RequestBody BasicExportStatusEntity basicExportStatusEntity) { diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java index 602b41f..feba471 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java @@ -1,13 +1,16 @@ package com.glxp.sale.admin.controller.sync; import com.alibaba.fastjson.JSON; +import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.constant.ConstantStatus; import com.glxp.sale.admin.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; -import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; import com.glxp.sale.admin.http.SpPostHttp; import com.glxp.sale.admin.req.sync.SpsSyncDataRequest; import com.glxp.sale.admin.res.sync.*; import com.glxp.sale.admin.service.param.SystemParamConfigService; +import com.glxp.sale.admin.service.sync.BasicUploadService; import com.glxp.sale.admin.util.CustomUtil; import com.glxp.sale.admin.util.DateUtil; import com.glxp.sale.admin.util.FileUtils; @@ -34,6 +37,9 @@ public class SpsSyncDataController { SystemParamConfigService systemParamConfigService; @Resource SpPostHttp spPostHttp; + @Resource + private BasicUploadService basicUploadService; + private static final Logger logger = LoggerFactory.getLogger(SpsSyncDataController.class); public String getPath() { @@ -83,16 +89,41 @@ public class SpsSyncDataController { if (bindingResult.hasErrors()) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + + BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity(); + basicUploadStatusEntity.setId(CustomUtil.getId()); + basicUploadStatusEntity.setTaskId(syncDataResponse.getTaskId()); + basicUploadStatusEntity.setStartTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_BASIC_DATA); + basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA); + basicUploadStatusEntity.setRemark(syncDataResponse.toString()); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 String path = getPath(); String fileName = path + FileConstant.lowerWaitCopy_products + "BaseData_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn"; String datas = JSON.toJSONString(syncDataResponse); FileUtils.SaveFileAs(datas, fileName); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE); + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setStatus(1); + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); } else { //上游通 - return spPostHttp.postAllDatas(syncDataResponse); + BaseResponse response = spPostHttp.postAllDatas(syncDataResponse); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setUpdateTime(new Date()); + if (response.getCode() == 20000) { + basicUploadStatusEntity.setStatus(1); + } else { + basicUploadStatusEntity.setStatus(0); + } + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); + return response; } } @@ -104,15 +135,40 @@ public class SpsSyncDataController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + + BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity(); + basicUploadStatusEntity.setId(CustomUtil.getId()); + basicUploadStatusEntity.setTaskId(spsSyncOrderResponse.getTaskId()); + basicUploadStatusEntity.setStartTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER); + basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER); + basicUploadStatusEntity.setRemark(spsSyncOrderResponse.toString()); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 String path = getPath(); String fileName = path + FileConstant.lowerWaitCopy_products + "order_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn"; String datas = JSON.toJSONString(spsSyncOrderResponse); FileUtils.SaveFileAs(datas, fileName); + + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE); + basicUploadStatusEntity.setStatus(1); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); } else { //上游通 - return spPostHttp.postAllOrders(spsSyncOrderResponse); + BaseResponse response = spPostHttp.postAllOrders(spsSyncOrderResponse); + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + if (response.getCode() == 20000) { + basicUploadStatusEntity.setStatus(1); + } else { + basicUploadStatusEntity.setStatus(0); + } + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); + return response; } } @@ -125,33 +181,81 @@ public class SpsSyncDataController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + + BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity(); + basicUploadStatusEntity.setId(CustomUtil.getId()); + basicUploadStatusEntity.setTaskId(spsSyncBusResponse.getTaskId()); + basicUploadStatusEntity.setStartTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE); + basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_BUS); + basicUploadStatusEntity.setRemark(spsSyncBusResponse.toString()); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 String path = getPath(); String fileName = path + FileConstant.lowerWaitCopy_products + "BusType_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn"; String datas = JSON.toJSONString(spsSyncBusResponse); FileUtils.SaveFileAs(datas, fileName); + + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE); + basicUploadStatusEntity.setStatus(1); + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); } else { //上游通 - return spPostHttp.postAllBus(spsSyncBusResponse); + BaseResponse response = spPostHttp.postAllBus(spsSyncBusResponse); + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + if (response.getCode() == 20000) { + basicUploadStatusEntity.setStatus(0); + } else { + basicUploadStatusEntity.setStatus(1); + } + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); + return response; } } @PostMapping("sps/sync/schedule/upload") public BaseResponse postSchedule(@RequestBody SpsSyncScheduleResponse spsSyncScheduleResponse) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity(); + basicUploadStatusEntity.setId(CustomUtil.getId()); + basicUploadStatusEntity.setStartTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setRemark(spsSyncScheduleResponse.toString()); - SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 String path = getPath(); String fileName = path + FileConstant.lowerWaitCopy_products + "ScheduleList_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn"; String datas = JSON.toJSONString(spsSyncScheduleResponse); FileUtils.SaveFileAs(datas, fileName); + + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setStatus(1); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE); + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); } else { //上游通 - return spPostHttp.postAllSchedule(spsSyncScheduleResponse); + BaseResponse response = spPostHttp.postAllSchedule(spsSyncScheduleResponse); + basicUploadStatusEntity.setUpdateTime(new Date()); + basicUploadStatusEntity.setEndTime(DateUtil.getDateTime()); + basicUploadStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + + if (response.getCode() == 20000) { + basicUploadStatusEntity.setStatus(1); + } else { + basicUploadStatusEntity.setStatus(0); + } + basicUploadService.insertDownloadStatus(basicUploadStatusEntity); + return response; } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java index 20b45df..319294d 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java @@ -19,4 +19,5 @@ public interface BasicExportDao { boolean updateExportStatus(BasicExportStatusEntity warehouseEntity); + BasicExportStatusEntity selectById(@Param("id") String id); } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicUploadDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicUploadDao.java new file mode 100644 index 0000000..66666ad --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicUploadDao.java @@ -0,0 +1,21 @@ +package com.glxp.sale.admin.dao.sync; + +import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; +import com.glxp.sale.admin.req.sync.BasicUploadRequest; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface BasicUploadDao { + + List filterUploadStatus(BasicUploadRequest basicDownloadRequest); + + boolean insertUploadStatus(BasicUploadStatusEntity basicDownloadStatusEntity); + + boolean deleteById(@Param("id") String id); + + boolean updateUploadStatus(BasicUploadStatusEntity basicDownloadStatusEntity); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java index 6a08851..9df5803 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java @@ -7,10 +7,20 @@ import java.util.Date; @Data public class BasicExportStatusEntity { private String id; + private String taskId; private String idDatas; private Integer status; private Integer type; + /** + * 传输状态 1.接口 2.文件 + */ + private Integer transportType; private Date updateTime; private Integer scheduleType; private int fromType; + private String startTime; + private String endTime; + private String remark; + private String superiorService; //上游服务 + private String subordinateService; //下游服务 } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java new file mode 100644 index 0000000..e694a03 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java @@ -0,0 +1,28 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +/** + * 数据下载记录 + */ +@Data +public class BasicUploadStatusEntity { + private String id; + private String taskId; + private String idDatas; + private Integer status; + private Integer type; + /** + * 传输状态 1.接口 2.文件 + */ + private Integer transportType; + private Date updateTime; + private Integer scheduleType; + private String startTime; + private String endTime; + private String remark; + private String superiorService; //上游服务 + private String subordinateService; //下游服务 +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicUploadRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicUploadRequest.java new file mode 100644 index 0000000..f638679 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicUploadRequest.java @@ -0,0 +1,16 @@ +package com.glxp.sale.admin.req.sync; + +import com.glxp.sale.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class BasicUploadRequest extends ListPageRequest { + private String id; + private String taskId; //任务ID + private Integer status; + private Integer type; + private String idDatas; + private Integer scheduleType; + public Integer createType; + private String syncTime; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncBusResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncBusResponse.java index 961c9ca..c64afda 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncBusResponse.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncBusResponse.java @@ -1,5 +1,6 @@ package com.glxp.sale.admin.res.sync; +import cn.hutool.core.collection.CollUtil; import com.glxp.sale.admin.entity.sync.*; import lombok.Data; @@ -10,9 +11,30 @@ public class SpsSyncBusResponse { //同步任务ID private String taskId; - private List bussinessTypeEntities; - private List bussinessOriginTypeEntities; - private List bussinessLocalTypeEntities; - private List bussinessChangeTypeEntities; - private List entrustReceEntities; + private List bussinessTypeEntities; //扫码单据类型 + private List bussinessOriginTypeEntities; //第三方单据类型 + private List bussinessLocalTypeEntities; //业务单据类型 + private List bussinessChangeTypeEntities; //缺量补单单据类型 + private List entrustReceEntities; //委托验收单据类型 + + @Override + public String toString() { + StringBuffer remark = new StringBuffer(); + if (CollUtil.isNotEmpty(bussinessTypeEntities)) { + remark.append("扫码单据类型:").append(bussinessTypeEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(bussinessLocalTypeEntities)) { + remark.append("业务单据类型:").append(bussinessTypeEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(bussinessOriginTypeEntities)) { + remark.append("第三方单据类型:").append(bussinessOriginTypeEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(bussinessChangeTypeEntities)) { + remark.append("缺量补单单据类型:").append(bussinessChangeTypeEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(entrustReceEntities)) { + remark.append("委托验收单据类型:").append(entrustReceEntities.size()).append(" 条\n"); + } + return remark.toString(); + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncDataResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncDataResponse.java index 309b5f5..568c9a1 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncDataResponse.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncDataResponse.java @@ -1,5 +1,6 @@ package com.glxp.sale.admin.res.sync; +import cn.hutool.core.collection.CollUtil; import com.glxp.sale.admin.entity.auth.AuthAdmin; import com.glxp.sale.admin.entity.info.CompanyProductRelevanceEntity; import com.glxp.sale.admin.entity.info.WarehouseBussinessTypeEntity; @@ -29,4 +30,49 @@ public class SpsSyncDataResponse { List warehouseBussinessTypeEntities; List warehouseUserEntities; List authAdminList; + + @Override + public String toString() { + StringBuffer remark = new StringBuffer(); + if (CollUtil.isNotEmpty(invWarehouseEntities)) { + remark.append("仓库信息:").append(invWarehouseEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(warehouseBussinessTypeEntities)) { + remark.append("仓库用户信息:").append(warehouseBussinessTypeEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(warehouseBussinessTypeEntities)) { + remark.append("仓库单据类型:").append(warehouseBussinessTypeEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(udiInfoEntities)) { + remark.append("产品信息:").append(udiInfoEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(basicUnitMaintainEntities)) { + remark.append("往来单位:").append(basicUnitMaintainEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(thrInvWarehouseEntities)) { + remark.append("第三方仓库信息:").append(thrInvWarehouseEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(thrCorpEntities)) { + remark.append("第三方往来单位:").append(thrCorpEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(thrProductsEntities)) { + remark.append("第三方产品信息:").append(thrProductsEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(thrOrderEntities)) { + remark.append("第三方单据:").append(thrOrderEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(thrOrderDetailEntities)) { + remark.append("第三方单据详情:").append(thrOrderDetailEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(companyProductRelevanceEntities)) { + remark.append("公司产品信息:").append(companyProductRelevanceEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(udiRelevanceEntities)) { + remark.append("耗材字典:").append(udiRelevanceEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(authAdminList)) { + remark.append("用户信息:").append(authAdminList.size()).append(" 条\n"); + } + return remark.toString(); + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java index 55ae015..daa826d 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java @@ -1,5 +1,6 @@ package com.glxp.sale.admin.res.sync; +import cn.hutool.core.collection.CollUtil; import com.glxp.sale.admin.entity.sync.ErpOrderEntity; import com.glxp.sale.admin.entity.sync.OrderEntity; import com.glxp.sale.admin.entity.sync.WarehouseEntity; @@ -15,4 +16,19 @@ public class SpsSyncOrderResponse { List orderEntities; List orderDetailEntityList; List warehouseEntityList; + + @Override + public String toString() { + StringBuffer remark = new StringBuffer(); + if (CollUtil.isNotEmpty(orderEntities)) { + remark.append("单据:").append(orderEntities.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(orderDetailEntityList)) { + remark.append("单据详情:").append(orderDetailEntityList.size()).append(" 条\n"); + } + if (CollUtil.isNotEmpty(warehouseEntityList)) { + remark.append("库存信息:").append(warehouseEntityList.size()).append(" 条\n"); + } + return remark.toString(); + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncScheduleResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncScheduleResponse.java index ec4d9ee..58bd5d5 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncScheduleResponse.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncScheduleResponse.java @@ -1,5 +1,6 @@ package com.glxp.sale.admin.res.sync; +import cn.hutool.core.collection.CollUtil; import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; import lombok.Data; @@ -9,4 +10,12 @@ import java.util.List; public class SpsSyncScheduleResponse { List basicExportStatusEntities; + @Override + public String toString() { + StringBuffer remark = new StringBuffer(); + if (CollUtil.isNotEmpty(basicExportStatusEntities)) { + remark.append("任务:").append(basicExportStatusEntities.size()).append(" 条\n"); + } + return remark.toString(); + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java index c25712f..ad02ba6 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java @@ -1,7 +1,6 @@ package com.glxp.sale.admin.service.sync; - import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; @@ -14,7 +13,15 @@ public interface BasicExportService { boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity); - boolean deleteById(String id); + boolean deleteById(String id); boolean updateExportStatus(BasicExportStatusEntity warehouseEntity); + + /** + * 数据被拉走,结束任务 + * + * @param id + * @return + */ + boolean finished(String id); } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicUploadService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicUploadService.java new file mode 100644 index 0000000..b5397ee --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicUploadService.java @@ -0,0 +1,20 @@ +package com.glxp.sale.admin.service.sync; + +import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; +import com.glxp.sale.admin.req.sync.BasicUploadRequest; + +import java.util.List; + +public interface BasicUploadService { + + BasicUploadStatusEntity findByData(String idDatas, Integer status); + + List filterDownloadStatus(BasicUploadRequest basicDownloadRequest); + + boolean insertDownloadStatus(BasicUploadStatusEntity basicDownloadStatusEntity); + + boolean deleteById(String id); + + boolean updateDownloadStatus(BasicUploadStatusEntity basicDownloadStatusEntity); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java index 4aea725..10064ff 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java @@ -1,11 +1,14 @@ package com.glxp.sale.admin.service.sync.impl; +import cn.hutool.core.util.StrUtil; 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 com.glxp.sale.admin.util.DateUtil; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Collections; @@ -43,4 +46,18 @@ public class BasicExportServiceImpl implements BasicExportService { public boolean updateExportStatus(BasicExportStatusEntity basicExportStatusEntity) { return basicExportDao.updateExportStatus(basicExportStatusEntity); } + + @Transactional(rollbackFor = Exception.class) + @Override + public boolean finished(String id) { + if (StrUtil.isNotBlank(id)) { + BasicExportStatusEntity basicExportStatusEntity = basicExportDao.selectById(id); + if (null != basicExportStatusEntity) { + basicExportStatusEntity.setEndTime(DateUtil.getDateTime()); + basicExportStatusEntity.setStatus(1); + basicExportDao.updateExportStatus(basicExportStatusEntity); + } + } + return false; + } } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicUploadServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicUploadServiceImpl.java new file mode 100644 index 0000000..43b67f6 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicUploadServiceImpl.java @@ -0,0 +1,61 @@ +package com.glxp.sale.admin.service.sync.impl; + +import cn.hutool.core.collection.CollUtil; +import com.github.pagehelper.PageHelper; +import com.glxp.sale.admin.dao.sync.BasicUploadDao; +import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; +import com.glxp.sale.admin.req.sync.BasicUploadRequest; +import com.glxp.sale.admin.service.sync.BasicUploadService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Slf4j +@Service +public class BasicUploadServiceImpl implements BasicUploadService { + + @Resource + private BasicUploadDao basicUploadDao; + + @Override + public BasicUploadStatusEntity findByData(String idDatas, Integer status) { + BasicUploadRequest basicUploadRequest = new BasicUploadRequest(); + basicUploadRequest.setStatus(status); + basicUploadRequest.setIdDatas(idDatas); + List basicDownloadStatusEntities = basicUploadDao.filterUploadStatus(basicUploadRequest); + if (CollUtil.isNotEmpty(basicDownloadStatusEntities)) { + return basicDownloadStatusEntities.get(0); + } + return null; + } + + @Override + public List filterDownloadStatus(BasicUploadRequest basicUploadRequest) { + if (basicUploadRequest == null) { + return Collections.emptyList(); + } + if (basicUploadRequest.getPage() != null) { + int offset = (basicUploadRequest.getPage() - 1) * basicUploadRequest.getLimit(); + PageHelper.offsetPage(offset, basicUploadRequest.getLimit()); + } + return basicUploadDao.filterUploadStatus(basicUploadRequest); + } + + @Override + public boolean insertDownloadStatus(BasicUploadStatusEntity basicDownloadStatusEntity) { + return basicUploadDao.insertUploadStatus(basicDownloadStatusEntity); + } + + @Override + public boolean deleteById(String id) { + return basicUploadDao.deleteById(id); + } + + @Override + public boolean updateDownloadStatus(BasicUploadStatusEntity basicDownloadStatusEntity) { + return basicUploadDao.updateUploadStatus(basicDownloadStatusEntity); + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java index 8933180..2fbf1c1 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java @@ -3,11 +3,11 @@ package com.glxp.sale.admin.thread; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.constant.ConstantStatus; import com.glxp.sale.admin.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; import com.glxp.sale.admin.entity.sync.ProductInfoEntity; -import com.glxp.sale.admin.entity.sync.ThrImportLogEntity; import com.glxp.sale.admin.entity.sync.UdiCompanyEntity; import com.glxp.sale.admin.http.SpGetHttp; import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; @@ -15,20 +15,15 @@ import com.glxp.sale.admin.req.sync.SpsSyncDataRequest; import com.glxp.sale.admin.res.sync.*; import com.glxp.sale.admin.service.param.SystemParamConfigService; import com.glxp.sale.admin.service.sync.BasicExportService; -import com.glxp.sale.admin.service.sync.ThrImportLogService; import com.glxp.sale.admin.thread.didl.AsyncDiDlHelper; -import com.glxp.sale.admin.util.CustomUtil; import com.glxp.sale.admin.util.DateUtil; import com.glxp.sale.admin.util.FileUtils; import com.glxp.sale.admin.util.RedisUtil; import com.glxp.sale.common.res.BaseResponse; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -95,6 +90,11 @@ public class DlAllDataService { myEntity.setStatus(0); myEntity.setUpdateTime(new Date()); myEntity.setType(BasicProcessStatus.NEW_ALL_DATA); + myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + myEntity.setIdDatas(basicExportStatusRequest.getIdDatas()); + myEntity.setStartTime(DateUtil.getDateTime()); + myEntity.setTaskId(syncOrderResponse.getTaskId()); + myEntity.setRemark(syncOrderResponse.toString()); basicExportService.insertExportStatus(myEntity); } else { String path = getPath(); @@ -161,9 +161,13 @@ public class DlAllDataService { redisUtil.set(key, baseResponse.getData()); BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); myEntity.setId(key); + myEntity.setTaskId(syncOrderResponse.getTaskId()); myEntity.setStatus(0); myEntity.setUpdateTime(new Date()); + myEntity.setStartTime(DateUtil.getDateTime()); + myEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER); myEntity.setType(BasicProcessStatus.NEW_ALL_ORDER); + myEntity.setRemark(syncOrderResponse.toString()); basicExportService.insertExportStatus(myEntity); } else { String path = getPath(); @@ -229,9 +233,14 @@ public class DlAllDataService { redisUtil.set(key, baseResponse.getData()); BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); myEntity.setId(key); + myEntity.setTaskId(syncOrderResponse.getTaskId()); myEntity.setStatus(0); myEntity.setUpdateTime(new Date()); + myEntity.setStartTime(DateUtil.getDateTime()); + myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); myEntity.setType(BasicProcessStatus.NEW_ALL_BUS); + myEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE); + myEntity.setRemark(syncOrderResponse.toString()); basicExportService.insertExportStatus(myEntity); } else { String path = getPath(); @@ -293,7 +302,7 @@ public class DlAllDataService { public void dlAllDi() { log.info("下载所有国家库DI信息--"); BasicExportStatusRequest basicExportStatusRequest = new BasicExportStatusRequest(); - basicExportStatusRequest.setIdDatas("AutoDownloadDiProducts"); + basicExportStatusRequest.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS); basicExportStatusRequest.setStatus(0); basicExportStatusRequest.setType(BasicProcessStatus.NEW_ALL_UDIS); basicExportStatusRequest.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); @@ -303,6 +312,7 @@ public class DlAllDataService { SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable"); for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) { if (basicExportStatusEntity.getFromType() == 0) { + BaseResponse response = spGetHttp.getLastUpdateTime("AutoDownloadDiProducts"); String lastUpdateTime = response.getData(); if (lastUpdateTime.equals("1949-01-01 00:00:00")) { @@ -321,11 +331,17 @@ public class DlAllDataService { if (downstream.getParamValue().equals("1")) { String datas = JSON.toJSON(spSyncUdiResponse).toString(); redisUtil.set(key, datas); + //记录下载日志 BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); myEntity.setId(key); + myEntity.setTaskId(spSyncUdiResponse.getTaskId()); myEntity.setStatus(0); + myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS); myEntity.setUpdateTime(new Date()); myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS); + myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + myEntity.setStartTime(DateUtil.getDateTime()); + myEntity.setRemark("国家库DI信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条"); basicExportService.insertExportStatus(myEntity); } else { String path = getPath(); @@ -361,9 +377,15 @@ public class DlAllDataService { redisUtil.set(key, datas); BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); myEntity.setId(key); + myEntity.setTaskId(spSyncUdiResponse.getTaskId()); myEntity.setStatus(0); myEntity.setUpdateTime(new Date()); myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS); + myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); + myEntity.setStartTime(DateUtil.getDateTime()); + myEntity.setUpdateTime(new Date()); + myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS); + myEntity.setRemark("公司信息:{} " + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条"); basicExportService.insertExportStatus(myEntity); } else { String path = getPath(); @@ -395,14 +417,21 @@ public class DlAllDataService { spsSyncDataRequest.setId(basicExportStatusEntity.getId()); BaseResponse baseResponse = spGetHttp.getAllDi(spsSyncDataRequest); + SpSyncUdiResponse spSyncUdiResponse = baseResponse.getData(); if (downstream.getParamValue().equals("1")) { String key = "UdiPrdoucts" + System.currentTimeMillis(); redisUtil.set(key, baseResponse.getData()); BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); myEntity.setId(key); + myEntity.setTaskId(spSyncUdiResponse.getTaskId()); myEntity.setStatus(0); myEntity.setUpdateTime(new Date()); + myEntity.setStartTime(DateUtil.getDateTime()); + myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS); + myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE); myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS); + myEntity.setRemark("国家库DI信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条\n" + + "公司信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + "条\n"); basicExportService.insertExportStatus(myEntity); } else { String path = getPath(); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java index 4f90a8e..d3da4b1 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java @@ -1,35 +1,30 @@ package com.glxp.sale.admin.thread; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.constant.ConstantStatus; import com.glxp.sale.admin.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; -import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; -import com.glxp.sale.admin.entity.sync.UdiCompanyEntity; -import com.glxp.sale.admin.entity.sync.WarehouseEntity; import com.glxp.sale.admin.res.sync.SpsSyncBusResponse; import com.glxp.sale.admin.res.sync.SpsSyncDataResponse; import com.glxp.sale.admin.res.sync.SpsSyncOrderResponse; import com.glxp.sale.admin.res.sync.SpsSyncScheduleResponse; import com.glxp.sale.admin.service.param.SystemParamConfigService; import com.glxp.sale.admin.service.sync.BasicExportService; -import com.glxp.sale.admin.service.sync.IOOrderStatusService; +import com.glxp.sale.admin.util.DateUtil; 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.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.File; import java.util.Date; -import java.util.List; /** * 扫面文件路径,形成状态表等待udi管理系统下载 @@ -66,10 +61,15 @@ public class ScanDownloadService { String fileName = file.getName(); basicExportStatusEntity.setId(fileName); basicExportStatusEntity.setUpdateTime(new Date()); + basicExportStatusEntity.setStartTime(DateUtil.getDateTime()); basicExportStatusEntity.setStatus(1); basicExportStatusEntity.setIdDatas(file.getPath()); + basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_BASIC_DATA); basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA); basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); + basicExportStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE); + SpsSyncDataResponse spsSyncDataResponse = JSONUtil.toBean(data, SpsSyncDataResponse.class); + basicExportStatusEntity.setRemark(spsSyncDataResponse.toString()); basicExportService.insertExportStatus(basicExportStatusEntity); SpsSyncDataResponse baseResponse = JSONObject.parseObject(data, new TypeReference() { diff --git a/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml b/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml index 3d433b1..7e7ea76 100644 --- a/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml @@ -27,14 +27,21 @@ replace - INTO basic_export_status(id,idDatas,status,`type`,updateTime,scheduleType) + INTO basic_export_status(id,taskId,idDatas,status,`type`,transportType,updateTime,scheduleType,startTime,endTime,remark,superiorService,subordinateService) values( #{id}, + #{taskId}, #{idDatas}, #{status}, #{type}, + #{transportType}, #{updateTime}, - #{scheduleType} + #{scheduleType}, + #{startTime}, + #{endTime}, + #{remark}, + #{superiorService}, + #{subordinateService} ) @@ -42,11 +49,17 @@ UPDATE basic_export_status idDatas=#{idDatas}, + taskId=#{taskId}, status=#{status}, `type`=#{type}, + transportType=#{transportType}, updateTime=#{updateTime}, scheduleType=#{scheduleType}, - + startTime=#{startTime}, + endTime=#{endTime}, + remark=#{remark}, + superiorService=#{superiorService}, + subordinateService=#{subordinateService}, WHERE id = #{id} @@ -56,4 +69,10 @@ WHERE id = #{id} + + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml b/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml new file mode 100644 index 0000000..8ddb8aa --- /dev/null +++ b/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml @@ -0,0 +1,78 @@ + + + + + + + + + + replace + INTO basic_upload_status(id,taskId,idDatas,status,type,transportType,updateTime,scheduleType,startTime,endTime,remark,superiorService,subordinateService) + values( + #{id}, + #{taskId}, + #{idDatas}, + #{status}, + #{type}, + #{transportType}, + #{updateTime}, + #{scheduleType}, + #{startTime}, + #{endTime}, + #{remark}, + #{superiorService}, + #{subordinateService} + ) + + + + UPDATE basic_upload_status + + idDatas=#{idDatas}, + status=#{status}, + type=#{type}, + transportType=#{transportType}, + updateTime=#{updateTime}, + scheduleType=#{scheduleType}, + startTime=#{startTime}, + endTime=#{endTime}, + remark=#{remark}, + subordinateService=#{subordinateService}, + superiorService=#{superiorService}, + + WHERE id = #{id} + + + DELETE + FROM basic_upload_status + WHERE id = #{id} + + + \ No newline at end of file