获取类名调整

master
wj 2 years ago
parent 7e22e0190f
commit e9082b8e1c

@ -12,6 +12,11 @@ public enum BasicExportTypeEnum {
* *
*/ */
BASIC_DATA("basic_data", "基础数据"), BASIC_DATA("basic_data", "基础数据"),
/**
* DI
*/
COUNTRY_DI_DATA("country_di_data", "国家库DI数据"),
; ;
@EnumValue @EnumValue
private String key; private String key;

@ -181,16 +181,16 @@ public class SpsSyncDownloadController {
Dict map = JsonUtils.parseMap(str.toString()); Dict map = JsonUtils.parseMap(str.toString());
// 组装返回数据 // 组装返回数据
spsSyncBasicDataResponse.setTaskId(one.getId()); spsSyncBasicDataResponse.setTaskId(one.getId());
spsSyncBasicDataResponse.setHospTypeList((List<BasicHospTypeEntity>) map.get(BasicHospTypeEntity.class.getName())); spsSyncBasicDataResponse.setHospTypeList((List<BasicHospTypeEntity>) map.get(BasicHospTypeEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setUdiRelevanceList((List<UdiRelevanceEntity>) map.get(UdiRelevanceEntity.class.getName())); spsSyncBasicDataResponse.setUdiRelevanceList((List<UdiRelevanceEntity>) map.get(UdiRelevanceEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setProductsList((List<BasicProductsEntity>) map.get(BasicProductsEntity.class.getName())); spsSyncBasicDataResponse.setProductsList((List<BasicProductsEntity>) map.get(BasicProductsEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setRelevanceList((List<CompanyProductRelevanceEntity>) map.get(CompanyProductRelevanceEntity.class.getName())); spsSyncBasicDataResponse.setRelevanceList((List<CompanyProductRelevanceEntity>) map.get(CompanyProductRelevanceEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setCorpList((List<BasicCorpEntity>) map.get(BasicCorpEntity.class.getName())); spsSyncBasicDataResponse.setCorpList((List<BasicCorpEntity>) map.get(BasicCorpEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupCertList((List<SupCertEntity>) map.get(SupCertEntity.class.getName())); spsSyncBasicDataResponse.setSupCertList((List<SupCertEntity>) map.get(SupCertEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupCertSetList((List<SupCertSetEntity>) map.get(SupCertSetEntity.class.getName())); spsSyncBasicDataResponse.setSupCertSetList((List<SupCertSetEntity>) map.get(SupCertSetEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupCompanyList((List<SupCompanyEntity>) map.get(SupCompanyEntity.class.getName())); spsSyncBasicDataResponse.setSupCompanyList((List<SupCompanyEntity>) map.get(SupCompanyEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupManufacturerList((List<SupManufacturerEntity>) map.get(SupManufacturerEntity.class.getName())); spsSyncBasicDataResponse.setSupManufacturerList((List<SupManufacturerEntity>) map.get(SupManufacturerEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupProductList((List<SupProductEntity>) map.get(SupProductEntity.class.getName())); spsSyncBasicDataResponse.setSupProductList((List<SupProductEntity>) map.get(SupProductEntity.class.getSimpleName()));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new RuntimeException("系统异常,未找到对应数据文件"); throw new RuntimeException("系统异常,未找到对应数据文件");
} catch (IOException e) { } catch (IOException e) {

@ -2,11 +2,14 @@ package com.glxp.api.controller.sync;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.annotation.Log; import com.glxp.api.annotation.Log;
import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicExportStatusEnum;
import com.glxp.api.constant.BasicExportStatusTimeEnum;
import com.glxp.api.constant.BusinessType; import com.glxp.api.constant.BusinessType;
import com.glxp.api.entity.sync.BasicExportStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity; import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
@ -23,6 +26,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -59,6 +67,9 @@ public class SpsSyncExportStatusController {
@Log(title = "定时任务", businessType = BusinessType.DELETE) @Log(title = "定时任务", businessType = BusinessType.DELETE)
public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) { public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) {
if (StrUtil.isBlank(deleteRequest.getId())) {
return ResultVOUtils.error(500, "缺少唯一标识");
}
boolean b = basicExportService.deleteById(deleteRequest.getId()); boolean b = basicExportService.deleteById(deleteRequest.getId());
redisUtil.del(deleteRequest.getId()); redisUtil.del(deleteRequest.getId());
if (b) if (b)
@ -67,10 +78,66 @@ public class SpsSyncExportStatusController {
return ResultVOUtils.error(500, "删除失败!"); return ResultVOUtils.error(500, "删除失败!");
} }
@AuthRuleAnnotation("")
@PostMapping("/spssync/basic/udiinfo/infoByStatus")
public void infoByStatus(HttpServletResponse response, @RequestBody DeleteRequest deleteRequest) throws IOException {
if (StrUtil.isBlank(deleteRequest.getId())) {
throw new RuntimeException("缺少唯一标识");
}
BasicExportStatusEntity info = basicExportService.getById(deleteRequest.getId());
if (info == null) {
throw new RuntimeException("数据不存在");
}
if (StrUtil.isBlank(info.getCacheFilePath())) {
throw new RuntimeException("文件未生成");
}
File file = new File(info.getCacheFilePath());
if (!file.exists()) {
throw new RuntimeException("文件丢失");
}
String[] split = info.getCacheFilePath().split("/");
String enFileName = URLEncoder.encode(split[split.length - 1], StandardCharsets.UTF_8);
// 设值返回文件属性,浏览器会根据属性调用下载文件方法
response.addHeader("Content-Disposition", "attachment;filename=" + enFileName);
// 前端获取文件名,需要解码
response.addHeader("downLoadName", enFileName);
// 定义输出流
ServletOutputStream outputStream = null;
FileInputStream fileInputStream = null;
try {
outputStream = response.getOutputStream();
// 定义输出类型为二进制流输出
response.setContentType("application/octet-stream");
fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes);
// 把流写入response
outputStream.write(bytes);
// flush落盘
outputStream.flush();
// 关闭输出流
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (outputStream != null) {
outputStream.close();
}
if (fileInputStream != null) {
fileInputStream.close();
}
}
}
@AuthRuleAnnotation("") @AuthRuleAnnotation("")
@PostMapping("/spssync/basic/udiinfo/updateStatus") @PostMapping("/spssync/basic/udiinfo/updateStatus")
@Log(title = "定时任务", businessType = BusinessType.UPDATE) @Log(title = "定时任务", businessType = BusinessType.UPDATE)
public BaseResponse updateStatus(@RequestBody BasicExportStatusEntity basicExportStatusEntity) { public BaseResponse updateStatus(@RequestBody BasicExportStatusEntity basicExportStatusEntity) {
if (StrUtil.isBlank(basicExportStatusEntity.getId())) {
return ResultVOUtils.error(500, "缺少唯一标识!");
}
if (StrUtil.isEmpty(basicExportStatusEntity.getReceiveStatus())) { if (StrUtil.isEmpty(basicExportStatusEntity.getReceiveStatus())) {
basicExportStatusEntity.setEndTime(new Date()); basicExportStatusEntity.setEndTime(new Date());
} }
@ -82,6 +149,33 @@ public class SpsSyncExportStatusController {
return ResultVOUtils.error(500, "更新成功!"); return ResultVOUtils.error(500, "更新成功!");
} }
@AuthRuleAnnotation("")
@PostMapping("/spssync/basic/udiinfo/finishTask")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
public BaseResponse finishTask(@RequestBody BasicExportStatusEntity basicExportStatusEntity) {
if (StrUtil.isBlank(basicExportStatusEntity.getId())) {
return ResultVOUtils.error(500, "缺少唯一标识!");
}
if (StrUtil.isEmpty(basicExportStatusEntity.getReceiveStatus())) {
basicExportStatusEntity.setEndTime(new Date());
}
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(BasicExportStatusEnum.COMPLETED.getCode());
boolean b = basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.COMPLETED.getCode())
.set(BasicExportStatusEntity::getEndTime, new Date())
.set(BasicExportStatusEntity::getUpdateTime, new Date())
.set(BasicExportStatusEntity::getReceiveStatus, 1)
.eq(BasicExportStatusEntity::getId, basicExportStatusEntity.getId())
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode())
);
if (b)
return ResultVOUtils.success("更新成功!");
else
return ResultVOUtils.error(500, "更新成功!");
}
@AuthRuleAnnotation("") @AuthRuleAnnotation("")
@GetMapping("/spssync/basic/schedule/lastTime") @GetMapping("/spssync/basic/schedule/lastTime")

@ -115,10 +115,10 @@ public class SpsSyncDownloadService {
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity(); BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
basicExportStatusEntity.setId(CustomUtil.getId()); basicExportStatusEntity.setId(CustomUtil.getId());
basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS); basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_DI); basicExportStatusEntity.setType(BasicExportTypeEnum.COUNTRY_DI_DATA.getRemark());
basicExportStatusEntity.setUpdateTime(new Date()); basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(0);
basicExportStatusEntity.setStartTime(new Date()); basicExportStatusEntity.setStartTime(new Date());
basicExportStatusEntity.setStatus(BasicExportStatusEnum.WAIT_TRIGGERED.getCode());
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportService.insertExportStatus(basicExportStatusEntity); basicExportService.insertExportStatus(basicExportStatusEntity);
} }
@ -242,7 +242,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(hospTypeList)) { if (CollectionUtil.isNotEmpty(hospTypeList)) {
jsonMap.put(BasicExportStatusTimeEntity.class.getName(), hospTypeList); jsonMap.put(BasicExportStatusTimeEntity.class.getSimpleName(), hospTypeList);
} }
List<UdiRelevanceEntity> udiRelevanceList = udiRelevanceService.list(Wrappers.lambdaQuery(UdiRelevanceEntity.class) List<UdiRelevanceEntity> udiRelevanceList = udiRelevanceService.list(Wrappers.lambdaQuery(UdiRelevanceEntity.class)
.le((boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime, now)
@ -250,7 +250,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(udiRelevanceList)) { if (CollectionUtil.isNotEmpty(udiRelevanceList)) {
jsonMap.put(UdiRelevanceEntity.class.getName(), udiRelevanceList); jsonMap.put(UdiRelevanceEntity.class.getSimpleName(), udiRelevanceList);
} }
List<BasicProductsEntity> productsList = basicProductsDao.selectList(Wrappers.lambdaQuery(BasicProductsEntity.class) List<BasicProductsEntity> productsList = basicProductsDao.selectList(Wrappers.lambdaQuery(BasicProductsEntity.class)
.le((boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime, now)
@ -258,7 +258,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(productsList)) { if (CollectionUtil.isNotEmpty(productsList)) {
jsonMap.put(BasicProductsEntity.class.getName(), productsList); jsonMap.put(BasicProductsEntity.class.getSimpleName(), productsList);
} }
List<CompanyProductRelevanceEntity> relevanceList = relevanceService.list(Wrappers.lambdaQuery(CompanyProductRelevanceEntity.class) List<CompanyProductRelevanceEntity> relevanceList = relevanceService.list(Wrappers.lambdaQuery(CompanyProductRelevanceEntity.class)
.le((boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime, now)
@ -266,7 +266,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(relevanceList)) { if (CollectionUtil.isNotEmpty(relevanceList)) {
jsonMap.put(CompanyProductRelevanceEntity.class.getName(), relevanceList); jsonMap.put(CompanyProductRelevanceEntity.class.getSimpleName(), relevanceList);
} }
} }
//确认有开启往来单位字典同步 //确认有开启往来单位字典同步
@ -279,7 +279,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(corpList)) { if (CollectionUtil.isNotEmpty(corpList)) {
jsonMap.put(BasicCorpEntity.class.getName(), corpList); jsonMap.put(BasicCorpEntity.class.getSimpleName(), corpList);
} }
} }
@ -293,7 +293,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(supCertList)) { if (CollectionUtil.isNotEmpty(supCertList)) {
jsonMap.put(SupCertEntity.class.getName(), supCertList); jsonMap.put(SupCertEntity.class.getSimpleName(), supCertList);
} }
List<SupCertSetEntity> supCertSetList = supCertSetService.list(Wrappers.lambdaQuery(SupCertSetEntity.class) List<SupCertSetEntity> supCertSetList = supCertSetService.list(Wrappers.lambdaQuery(SupCertSetEntity.class)
.le((boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime, now)
@ -301,7 +301,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(supCertSetList)) { if (CollectionUtil.isNotEmpty(supCertSetList)) {
jsonMap.put(SupCertSetEntity.class.getName(), supCertSetList); jsonMap.put(SupCertSetEntity.class.getSimpleName(), supCertSetList);
} }
List<SupCompanyEntity> supCompanyList = supCompanyService.list(Wrappers.lambdaQuery(SupCompanyEntity.class) List<SupCompanyEntity> supCompanyList = supCompanyService.list(Wrappers.lambdaQuery(SupCompanyEntity.class)
.le((boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime, now)
@ -309,7 +309,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(supCompanyList)) { if (CollectionUtil.isNotEmpty(supCompanyList)) {
jsonMap.put(SupCompanyEntity.class.getName(), supCompanyList); jsonMap.put(SupCompanyEntity.class.getSimpleName(), supCompanyList);
} }
List<SupManufacturerEntity> supManufacturerList = supManufacturerService.list(Wrappers.lambdaQuery(SupManufacturerEntity.class) List<SupManufacturerEntity> supManufacturerList = supManufacturerService.list(Wrappers.lambdaQuery(SupManufacturerEntity.class)
.le((boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime, now)
@ -317,7 +317,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(supManufacturerList)) { if (CollectionUtil.isNotEmpty(supManufacturerList)) {
jsonMap.put(SupManufacturerEntity.class.getName(), supManufacturerList); jsonMap.put(SupManufacturerEntity.class.getSimpleName(), supManufacturerList);
} }
List<SupProductEntity> supProductList = supProductService.list(Wrappers.lambdaQuery(SupProductEntity.class) List<SupProductEntity> supProductList = supProductService.list(Wrappers.lambdaQuery(SupProductEntity.class)
.le((boolean) map.get("isNew"), SupProductEntity::getUpdateTime, now) .le((boolean) map.get("isNew"), SupProductEntity::getUpdateTime, now)
@ -325,7 +325,7 @@ public class SpsSyncDownloadService {
, map.get("oldDate"), now) , map.get("oldDate"), now)
); );
if (CollectionUtil.isNotEmpty(supProductList)) { if (CollectionUtil.isNotEmpty(supProductList)) {
jsonMap.put(SupProductEntity.class.getName(), supProductList); jsonMap.put(SupProductEntity.class.getSimpleName(), supProductList);
} }
} }

Loading…
Cancel
Save