Merge remote-tracking branch 'origin/master'

# Conflicts:
#	api-admin/src/main/java/com/glxp/sale/admin/constant/BasicExportTypeEnum.java
master
anthonywj 2 years ago
commit fd0e4f3d8b

@ -1,10 +1,13 @@
package com.glxp.sale.admin.controller.sync; package com.glxp.sale.admin.controller.sync;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glxp.sale.admin.constant.BasicProcessStatus; import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.constant.ConstantStatus; import com.glxp.sale.admin.constant.ConstantStatus;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity;
import com.glxp.sale.admin.idc.utils.UriUtils; import com.glxp.sale.admin.idc.utils.UriUtils;
@ -12,14 +15,17 @@ import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService; import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.service.sync.BasicUploadService; import com.glxp.sale.admin.service.sync.BasicUploadService;
import com.glxp.sale.admin.util.*; import com.glxp.sale.admin.util.*;
import com.glxp.sale.common.enums.ResultEnum;
import com.glxp.sale.common.res.BaseResponse; import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils; import com.glxp.sale.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -60,9 +66,27 @@ public class SyncController {
* *
* @return * @return
*/ */
@PostMapping("/udispsync/sync/testConnection") @GetMapping("/udispsync/sync/testConnection")
public BaseResponse testConnection() { public BaseResponse testConnection(HttpServletRequest request) {
return ResultVOUtils.success("连接成功"); String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
if (StrUtil.isNotEmpty(upperServerHost)) {
upperServerHost = upperServerHost + "/udispsync/sync/testConnection";
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getLocalAddr() + "服务缺少上级服务IP");
}
String str = null;
try {
str = HttpUtil.get(upperServerHost);
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getLocalAddr() + "服务访问上级服务" + upperServerHost + "异常");
}
BaseResponse response = JSONUtil.toBean(str, BaseResponse.class);
if (response.getCode().equals(20000)) {
return ResultVOUtils.success("连接成功");
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), response.getMessage());
}
} }
//单据接口直连--扫码单据 //单据接口直连--扫码单据

@ -210,6 +210,7 @@ public class DlAllDataService {
myEntity.setRemark(remark); myEntity.setRemark(remark);
myEntity.setIdDatas(SYNC_SCAN_ORDER); myEntity.setIdDatas(SYNC_SCAN_ORDER);
myEntity.setType(BasicProcessStatus.NEW_ALL_ORDER); myEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
myEntity.setScheduleType(1);
basicExportService.insertExportStatus(myEntity); basicExportService.insertExportStatus(myEntity);
myEntity.setStatus(Constant.SYNC_STATUS_WAIT); myEntity.setStatus(Constant.SYNC_STATUS_WAIT);
if (downstream.getParamValue().equals("1")) { if (downstream.getParamValue().equals("1")) {
@ -233,15 +234,18 @@ public class DlAllDataService {
} }
} }
} }
if (basicExportStatusEntity.getFromType() == 0) { // if (basicExportStatusEntity.getFromType() == 0) {
BasicExportStatusEntity basicExportStatusEntity1 = basicExportStatusEntities.get(0); //
basicExportStatusEntity1.setStatus(4); // } else {
spGetHttp.postUpdateBasicStatus(basicExportStatusEntity1); // spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId());
spGetHttp.finishTask(basicExportStatusEntity1.getId()); // }
spGetHttp.updateLastTime(SYNC_SCAN_ORDER, DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
} else {
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId()); BasicExportStatusEntity basicExportStatusEntity1 = basicExportStatusEntities.get(0);
} basicExportStatusEntity1.setStatus(4);
spGetHttp.postUpdateBasicStatus(basicExportStatusEntity1);
spGetHttp.finishTask(basicExportStatusEntity1.getId());
spGetHttp.updateLastTime(SYNC_SCAN_ORDER, DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
} }
} }
@ -256,6 +260,11 @@ public class DlAllDataService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void pullData(BasicExportTypeEnum exportType) { public void pullData(BasicExportTypeEnum exportType) {
switch (exportType){
case IO_ORDER:
case COUNTRY_DI_DATA:
return;
}
String data = spGetHttp.pullData(exportType); String data = spGetHttp.pullData(exportType);
cn.hutool.json.JSONObject obj = JSONUtil.parseObj(data); cn.hutool.json.JSONObject obj = JSONUtil.parseObj(data);
@ -280,7 +289,6 @@ public class DlAllDataService {
if (StrUtil.isNotBlank(bean.getTaskId())) { if (StrUtil.isNotBlank(bean.getTaskId())) {
// 将数据写入文件 // 将数据写入文件
// try { // try {
FileUtils.makeDirectory(filePath + "sync/"); FileUtils.makeDirectory(filePath + "sync/");
String fileName = filePath + "sync/" + exportType.getRemark() + "-" + bean.getTaskId() + ".udi"; String fileName = filePath + "sync/" + exportType.getRemark() + "-" + bean.getTaskId() + ".udi";
FileUtils.SaveFileAs(bean.getFileContent(), fileName); FileUtils.SaveFileAs(bean.getFileContent(), fileName);
@ -288,14 +296,13 @@ public class DlAllDataService {
// log.error("从UDI自助平台拉取基础数据 文件[{}]写入异常----{}",bean.getFilePath(), e.getMessage()); // log.error("从UDI自助平台拉取基础数据 文件[{}]写入异常----{}",bean.getFilePath(), e.getMessage());
// throw new RuntimeException(e); // throw new RuntimeException(e);
// } // }
BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder() BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder()
.id(bean.getTaskId()) .id(bean.getTaskId())
.taskId(bean.getTaskId()) .taskId(bean.getTaskId())
.status(BasicExportStatusEnum.WAIT_SYNC.getCode()) .status(BasicExportStatusEnum.WAIT_SYNC.getCode())
.type(exportType.getRemark()) .type(exportType.getRemark())
.transportType(1) .transportType(1)
.scheduleType(0) .scheduleType(1)
.fromType(1).remark(remark) .fromType(1).remark(remark)
.startTime(DateUtil.getDateTime()) .startTime(DateUtil.getDateTime())
.updateTime(new Date()) .updateTime(new Date())
@ -390,6 +397,7 @@ public class DlAllDataService {
myEntity.setUpdateTime(new Date()); myEntity.setUpdateTime(new Date());
myEntity.setType(NEW_ALL_UDIS); myEntity.setType(NEW_ALL_UDIS);
myEntity.setStartTime(DateUtil.getDateTime()); myEntity.setStartTime(DateUtil.getDateTime());
myEntity.setScheduleType(1);
myEntity.setRemark("国家库DI信息" + spSyncUdiResponse.getProductInfoEntityList().size() + " 条"); myEntity.setRemark("国家库DI信息" + spSyncUdiResponse.getProductInfoEntityList().size() + " 条");
basicExportService.insertExportStatus(myEntity); basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) { if (downstream.getParamValue().equals("1")) {
@ -449,6 +457,7 @@ public class DlAllDataService {
myEntity.setStartTime(DateUtil.getDateTime()); myEntity.setStartTime(DateUtil.getDateTime());
myEntity.setUpdateTime(new Date()); myEntity.setUpdateTime(new Date());
myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS); myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
myEntity.setScheduleType(1);
myEntity.setRemark("医疗器械注册人信息:{} " + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条"); myEntity.setRemark("医疗器械注册人信息:{} " + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条");
basicExportService.insertExportStatus(myEntity); basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) { if (downstream.getParamValue().equals("1")) {
@ -522,8 +531,9 @@ public class DlAllDataService {
myEntity.setCacheFilePath(fileName); myEntity.setCacheFilePath(fileName);
basicExportService.updateExportStatus(myEntity); basicExportService.updateExportStatus(myEntity);
} }
// BasicExportStatusEntity basicExportStatusEntity1 = basicExportStatusEntities.get(0);
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId()); basicExportStatusEntity.setStatus(4);
spGetHttp.postUpdateBasicStatus(basicExportStatusEntity);
} }
} }

Loading…
Cancel
Save