From e705cbecdbc12498deea50bdcbf86eb5635fbeb5 Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Fri, 18 Mar 2022 09:34:52 +0800 Subject: [PATCH] =?UTF-8?q?UDI=E5=90=8C=E6=AD=A5=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC=E8=AE=B0=E5=BD=95=E6=9C=89?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/thread/DownloadProductInfoTask.java | 30 ++++++++++------- .../udidl/admin/thread/UdiCompanyTask.java | 32 ++++++++++++------- .../main/resources/application-pro.properties | 4 +-- .../mybatis/mapper/udi/ProductInfoDao.xml | 1 - 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/thread/DownloadProductInfoTask.java b/api-admin/src/main/java/com/glxp/udidl/admin/thread/DownloadProductInfoTask.java index bb4ff67..03bcd9a 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/thread/DownloadProductInfoTask.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/thread/DownloadProductInfoTask.java @@ -27,18 +27,22 @@ import java.util.Date; @EnableScheduling public class DownloadProductInfoTask implements SchedulingConfigurer { final Logger logger = LoggerFactory.getLogger(DownloadProductInfoTask.class); - /* @Autowired - GlobalConfig globalConfig; - @Autowired - ProductInfoService productInfoService; - @Autowired - FileInfoService fileInfoService;*/ + /* @Autowired + GlobalConfig globalConfig; + @Autowired + ProductInfoService productInfoService; + @Autowired + FileInfoService fileInfoService;*/ @Autowired ProductInfoDlService productInfoDlService; @Resource private ScheduledDao scheduledDao; @Autowired - JobLogService jobLogService; //日志 + JobLogService jobLogService; + @Resource + UdiCompanyTask udiCompanyTask; + + //日志 /* public void SaveToFile() throws IOException { String updateTime = DateUtil.getLastDay(-7); String fromDate = DateUtil.getDate("yyyyMMdd",-7,5); @@ -76,19 +80,23 @@ public class DownloadProductInfoTask implements SchedulingConfigurer { return new CronTrigger(cron).nextExecutionTime(triggerContext); }); } + private void process() { Date endDate = DateUtil.parseDate((DateUtil.formatDate(new Date()))); - Date startDate=DateUtil.addDays(endDate,-7); - BaseResponse res = productInfoDlService.ExportToFile(startDate,endDate,"auto"); - if(res.getCode() != 20000){ + Date startDate = DateUtil.addDays(endDate, -7); + BaseResponse res = productInfoDlService.ExportToFile(startDate, endDate, "auto"); + if (res.getCode() != 20000) { JobLog jobLog = new JobLog(); jobLog.setType("error"); jobLog.setDownloadType("auto"); - jobLog.setMsg("下载文件失败:"+res.getMessage()); + jobLog.setMsg("下载文件失败:" + res.getMessage()); jobLog.setCreateTime(new Date()); jobLogService.insert(jobLog); } + //更新一下企业信息 + udiCompanyTask.transAll(); + /*try{ SaveToFile(); }catch (Exception e){ diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/thread/UdiCompanyTask.java b/api-admin/src/main/java/com/glxp/udidl/admin/thread/UdiCompanyTask.java index e97e848..37e4e12 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/thread/UdiCompanyTask.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/thread/UdiCompanyTask.java @@ -39,9 +39,9 @@ public class UdiCompanyTask { udiCompanyEntity.setQylxrcz(contactlist.getQylxrcz()); udiCompanyEntity.setQylxrdh(contactlist.getQylxrdh()); udiCompanyEntity.setQylxryx(contactlist.getQylxryx()); - udiCompanyService.insertUdiCompany(udiCompanyEntity); } } + udiCompanyService.insertUdiCompany(udiCompanyEntity); } } } @@ -58,19 +58,24 @@ public class UdiCompanyTask { productInfoFilterRequest.setDiType("1"); List productInfoEntities = productInfoDao.filterUdiByCreditNo(productInfoFilterRequest); for (ProductInfoEntity productInfoEntity : productInfoEntities) { + + //将该记录所有产品初始化 ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest(); filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey()); List temps = productInfoDao.filterProductInfo(filterRequest); if (temps != null && temps.size() > 0) { + ProductInfoEntity maxProduct = temps.get(0); for (ProductInfoEntity change : temps) { change.setIsNewest(false); + if (change.getVersionNumber() > maxProduct.getVersionNumber()) { + maxProduct = change; + } productInfoDao.updateProductInfo(change); } - } - List updates = productInfoDao.selectByUuid(productInfoEntity.getUuid()); - for (ProductInfoEntity update : updates) { - update.setIsNewest(true); - productInfoDao.updateProductInfo(update); + ProductInfoEntity updateEntity = new ProductInfoEntity(); + updateEntity.setIsNewest(true); + updateEntity.setUuid(maxProduct.getUuid()); + productInfoDao.updateProductByUuid(updateEntity); } logger.info("更新 = " + productInfoEntity.getNameCode() + "--" + index); index++; @@ -89,18 +94,23 @@ public class UdiCompanyTask { ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest(); filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey()); List temps = productInfoDao.filterProductInfo(filterRequest); + if (temps != null && temps.size() > 0) { + ProductInfoEntity maxProduct = temps.get(0); for (ProductInfoEntity change : temps) { change.setIsNewest(false); + if (change.getVersionNumber() > maxProduct.getVersionNumber()) { + maxProduct = change; + } productInfoDao.updateProductInfo(change); } + ProductInfoEntity updateEntity = new ProductInfoEntity(); + updateEntity.setIsNewest(true); + updateEntity.setUuid(maxProduct.getUuid()); + productInfoDao.updateProductByUuid(updateEntity); } - List updates = productInfoDao.selectByUuid(productInfoEntity.getUuid()); - for (ProductInfoEntity update : updates) { - update.setIsNewest(true); - productInfoDao.updateProductInfo(update); - } + logger.info("更新 = " + productInfoEntity.getNameCode()); } diff --git a/api-admin/src/main/resources/application-pro.properties b/api-admin/src/main/resources/application-pro.properties index 559e2ac..f1a7054 100644 --- a/api-admin/src/main/resources/application-pro.properties +++ b/api-admin/src/main/resources/application-pro.properties @@ -5,8 +5,8 @@ server.port=9994 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://127.0.0.1:3306/udidl?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false spring.datasource.username=root -#spring.datasource.password=mysql@2020 -spring.datasource.password=123456 +spring.datasource.password=mysql@2020 +#spring.datasource.password=123456 server.servlet.context-path= # 跨域设置 diff --git a/api-admin/src/main/resources/mybatis/mapper/udi/ProductInfoDao.xml b/api-admin/src/main/resources/mybatis/mapper/udi/ProductInfoDao.xml index 5a92985..b2686c4 100644 --- a/api-admin/src/main/resources/mybatis/mapper/udi/ProductInfoDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/udi/ProductInfoDao.xml @@ -408,7 +408,6 @@ diType=#{diType}, isNewest=#{isNewest}, updateTime=#{updateTime}, - WHERE id = #{id}