|
|
|
@ -4,12 +4,14 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Dict;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.*;
|
|
|
|
|
import com.glxp.api.controller.purchase.PurOrderController;
|
|
|
|
|
import com.glxp.api.constant.BasicProcessStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.dao.BaseMapperPlus;
|
|
|
|
|
import com.glxp.api.dao.auth.*;
|
|
|
|
|
import com.glxp.api.dao.basic.BasicBusTypeChangeDao;
|
|
|
|
|
import com.glxp.api.dao.basic.BasicBusTypePreDao;
|
|
|
|
@ -148,6 +150,107 @@ public class SpsSyncDownloadController {
|
|
|
|
|
return baseResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下发基础数据 ,供给中继服务,UDI管理系统下载
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
|
@GetMapping("sps/sync/data")
|
|
|
|
|
public BaseResponse data(BasicExportTypeEnum exportType) {
|
|
|
|
|
BaseResponse<Object> baseResponse = new BaseResponse<>();
|
|
|
|
|
BasicExportStatusEntity one = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class)
|
|
|
|
|
.eq(BasicExportStatusEntity::getType, exportType.getRemark())
|
|
|
|
|
.orderByDesc(BasicExportStatusEntity::getStartTime)
|
|
|
|
|
.last("limit 1")
|
|
|
|
|
);
|
|
|
|
|
Object result = null;
|
|
|
|
|
if (one != null) {
|
|
|
|
|
if (BasicExportStatusEnum.WAIT_TRIGGERED.getCode().equals(one.getStatus())) {
|
|
|
|
|
basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
|
|
|
|
|
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode())
|
|
|
|
|
.set(BasicExportStatusEntity::getUpdateTime, new Date())
|
|
|
|
|
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_TRIGGERED.getCode())
|
|
|
|
|
.eq(BasicExportStatusEntity::getId, one.getId())
|
|
|
|
|
);
|
|
|
|
|
} else if (BasicExportStatusEnum.WAIT_SYNC.getCode().equals(one.getStatus())) {
|
|
|
|
|
switch (exportType) {
|
|
|
|
|
case BASIC_DATA:
|
|
|
|
|
result = this.readBasicDataFile(one);
|
|
|
|
|
break;
|
|
|
|
|
case OTHER_DATA:
|
|
|
|
|
result = this.readOtherDataFile(one);
|
|
|
|
|
break;
|
|
|
|
|
case COUNTRY_DI_DATA:
|
|
|
|
|
}
|
|
|
|
|
// 修改任务状态
|
|
|
|
|
// basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
|
|
|
|
|
// .set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.COMPLETED.getCode())
|
|
|
|
|
// .set(BasicExportStatusEntity::getUpdateTime, new Date())
|
|
|
|
|
// .set(BasicExportStatusEntity::getEndTime, new Date())
|
|
|
|
|
// .eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode())
|
|
|
|
|
// .eq(BasicExportStatusEntity::getId, one.getId())
|
|
|
|
|
// );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
baseResponse.setCode(ResultEnum.SUCCESS.getCode());
|
|
|
|
|
baseResponse.setData(result);
|
|
|
|
|
return baseResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SpsSyncBasicDataResponse readBasicDataFile(BasicExportStatusEntity one) {
|
|
|
|
|
|
|
|
|
|
// 读取文件数据
|
|
|
|
|
try {
|
|
|
|
|
FileReader reader = new FileReader(one.getCacheFilePath());
|
|
|
|
|
StringBuilder str = new StringBuilder();
|
|
|
|
|
int data;
|
|
|
|
|
while ((data = reader.read()) != -1) {
|
|
|
|
|
str.append((char) data);
|
|
|
|
|
}
|
|
|
|
|
reader.close();
|
|
|
|
|
Dict map = JsonUtils.parseMap(str.toString());
|
|
|
|
|
|
|
|
|
|
SpsSyncBasicDataResponse spsSyncBasicDataResponse = new SpsSyncBasicDataResponse();
|
|
|
|
|
// 组装返回数据
|
|
|
|
|
spsSyncBasicDataResponse.setTaskId(one.getId());
|
|
|
|
|
spsSyncBasicDataResponse.setHospTypeList((List<BasicHospTypeEntity>) map.get(BasicHospTypeEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setUdiRelevanceList((List<UdiRelevanceEntity>) map.get(UdiRelevanceEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setProductsList((List<BasicProductsEntity>) map.get(BasicProductsEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setRelevanceList((List<CompanyProductRelevanceEntity>) map.get(CompanyProductRelevanceEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setCorpList((List<BasicCorpEntity>) map.get(BasicCorpEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setSupCertList((List<SupCertEntity>) map.get(SupCertEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setSupCertSetList((List<SupCertSetEntity>) map.get(SupCertSetEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setSupCompanyList((List<SupCompanyEntity>) map.get(SupCompanyEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setSupManufacturerList((List<SupManufacturerEntity>) map.get(SupManufacturerEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncBasicDataResponse.setSupProductList((List<SupProductEntity>) map.get(SupProductEntity.class.getSimpleName()));
|
|
|
|
|
return spsSyncBasicDataResponse;
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
throw new RuntimeException("系统异常,未找到对应数据文件");
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SpsSyncOtherDataResponse readOtherDataFile(BasicExportStatusEntity one) {
|
|
|
|
|
// 读取文件数据
|
|
|
|
|
try {
|
|
|
|
|
FileReader reader = new FileReader(one.getCacheFilePath());
|
|
|
|
|
StringBuilder str = new StringBuilder();
|
|
|
|
|
int data;
|
|
|
|
|
while ((data = reader.read()) != -1) {
|
|
|
|
|
str.append((char) data);
|
|
|
|
|
}
|
|
|
|
|
reader.close();
|
|
|
|
|
Dict map = JsonUtils.parseMap(str.toString());
|
|
|
|
|
SpsSyncOtherDataResponse spsSyncOtherDataResponse = new SpsSyncOtherDataResponse();
|
|
|
|
|
// 组装返回数据
|
|
|
|
|
spsSyncOtherDataResponse.setTaskId(one.getId());
|
|
|
|
|
spsSyncOtherDataResponse.setIoCodeLostList((List<IoCodeLostEntity>) map.get(IoCodeLostEntity.class.getSimpleName()));
|
|
|
|
|
spsSyncOtherDataResponse.setIoCodeRelList((List<IoCodeRelEntity>) map.get(IoCodeRelEntity.class.getSimpleName()));
|
|
|
|
|
return spsSyncOtherDataResponse;
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
throw new RuntimeException("系统异常,未找到对应数据文件");
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下发基础数据 ,供给中继服务,UDI管理系统下载
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
|