UDI同步时,最新版本记录有错

master
anthonyywj2 3 years ago
parent e61cdcf69c
commit e705cbecdb

@ -27,18 +27,22 @@ import java.util.Date;
@EnableScheduling @EnableScheduling
public class DownloadProductInfoTask implements SchedulingConfigurer { public class DownloadProductInfoTask implements SchedulingConfigurer {
final Logger logger = LoggerFactory.getLogger(DownloadProductInfoTask.class); final Logger logger = LoggerFactory.getLogger(DownloadProductInfoTask.class);
/* @Autowired /* @Autowired
GlobalConfig globalConfig; GlobalConfig globalConfig;
@Autowired @Autowired
ProductInfoService productInfoService; ProductInfoService productInfoService;
@Autowired @Autowired
FileInfoService fileInfoService;*/ FileInfoService fileInfoService;*/
@Autowired @Autowired
ProductInfoDlService productInfoDlService; ProductInfoDlService productInfoDlService;
@Resource @Resource
private ScheduledDao scheduledDao; private ScheduledDao scheduledDao;
@Autowired @Autowired
JobLogService jobLogService; //日志 JobLogService jobLogService;
@Resource
UdiCompanyTask udiCompanyTask;
//日志
/* public void SaveToFile() throws IOException { /* public void SaveToFile() throws IOException {
String updateTime = DateUtil.getLastDay(-7); String updateTime = DateUtil.getLastDay(-7);
String fromDate = DateUtil.getDate("yyyyMMdd",-7,5); String fromDate = DateUtil.getDate("yyyyMMdd",-7,5);
@ -76,19 +80,23 @@ public class DownloadProductInfoTask implements SchedulingConfigurer {
return new CronTrigger(cron).nextExecutionTime(triggerContext); return new CronTrigger(cron).nextExecutionTime(triggerContext);
}); });
} }
private void process() { private void process() {
Date endDate = DateUtil.parseDate((DateUtil.formatDate(new Date()))); Date endDate = DateUtil.parseDate((DateUtil.formatDate(new Date())));
Date startDate=DateUtil.addDays(endDate,-7); Date startDate = DateUtil.addDays(endDate, -7);
BaseResponse res = productInfoDlService.ExportToFile(startDate,endDate,"auto"); BaseResponse res = productInfoDlService.ExportToFile(startDate, endDate, "auto");
if(res.getCode() != 20000){ if (res.getCode() != 20000) {
JobLog jobLog = new JobLog(); JobLog jobLog = new JobLog();
jobLog.setType("error"); jobLog.setType("error");
jobLog.setDownloadType("auto"); jobLog.setDownloadType("auto");
jobLog.setMsg("下载文件失败:"+res.getMessage()); jobLog.setMsg("下载文件失败:" + res.getMessage());
jobLog.setCreateTime(new Date()); jobLog.setCreateTime(new Date());
jobLogService.insert(jobLog); jobLogService.insert(jobLog);
} }
//更新一下企业信息
udiCompanyTask.transAll();
/*try{ /*try{
SaveToFile(); SaveToFile();
}catch (Exception e){ }catch (Exception e){

@ -39,9 +39,9 @@ public class UdiCompanyTask {
udiCompanyEntity.setQylxrcz(contactlist.getQylxrcz()); udiCompanyEntity.setQylxrcz(contactlist.getQylxrcz());
udiCompanyEntity.setQylxrdh(contactlist.getQylxrdh()); udiCompanyEntity.setQylxrdh(contactlist.getQylxrdh());
udiCompanyEntity.setQylxryx(contactlist.getQylxryx()); udiCompanyEntity.setQylxryx(contactlist.getQylxryx());
udiCompanyService.insertUdiCompany(udiCompanyEntity);
} }
} }
udiCompanyService.insertUdiCompany(udiCompanyEntity);
} }
} }
} }
@ -58,19 +58,24 @@ public class UdiCompanyTask {
productInfoFilterRequest.setDiType("1"); productInfoFilterRequest.setDiType("1");
List<ProductInfoEntity> productInfoEntities = productInfoDao.filterUdiByCreditNo(productInfoFilterRequest); List<ProductInfoEntity> productInfoEntities = productInfoDao.filterUdiByCreditNo(productInfoFilterRequest);
for (ProductInfoEntity productInfoEntity : productInfoEntities) { for (ProductInfoEntity productInfoEntity : productInfoEntities) {
//将该记录所有产品初始化
ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest(); ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest();
filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey()); filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey());
List<ProductInfoEntity> temps = productInfoDao.filterProductInfo(filterRequest); List<ProductInfoEntity> temps = productInfoDao.filterProductInfo(filterRequest);
if (temps != null && temps.size() > 0) { if (temps != null && temps.size() > 0) {
ProductInfoEntity maxProduct = temps.get(0);
for (ProductInfoEntity change : temps) { for (ProductInfoEntity change : temps) {
change.setIsNewest(false); change.setIsNewest(false);
if (change.getVersionNumber() > maxProduct.getVersionNumber()) {
maxProduct = change;
}
productInfoDao.updateProductInfo(change); productInfoDao.updateProductInfo(change);
} }
} ProductInfoEntity updateEntity = new ProductInfoEntity();
List<ProductInfoEntity> updates = productInfoDao.selectByUuid(productInfoEntity.getUuid()); updateEntity.setIsNewest(true);
for (ProductInfoEntity update : updates) { updateEntity.setUuid(maxProduct.getUuid());
update.setIsNewest(true); productInfoDao.updateProductByUuid(updateEntity);
productInfoDao.updateProductInfo(update);
} }
logger.info("更新 = " + productInfoEntity.getNameCode() + "--" + index); logger.info("更新 = " + productInfoEntity.getNameCode() + "--" + index);
index++; index++;
@ -89,18 +94,23 @@ public class UdiCompanyTask {
ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest(); ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest();
filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey()); filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey());
List<ProductInfoEntity> temps = productInfoDao.filterProductInfo(filterRequest); List<ProductInfoEntity> temps = productInfoDao.filterProductInfo(filterRequest);
if (temps != null && temps.size() > 0) { if (temps != null && temps.size() > 0) {
ProductInfoEntity maxProduct = temps.get(0);
for (ProductInfoEntity change : temps) { for (ProductInfoEntity change : temps) {
change.setIsNewest(false); change.setIsNewest(false);
if (change.getVersionNumber() > maxProduct.getVersionNumber()) {
maxProduct = change;
}
productInfoDao.updateProductInfo(change); productInfoDao.updateProductInfo(change);
} }
ProductInfoEntity updateEntity = new ProductInfoEntity();
updateEntity.setIsNewest(true);
updateEntity.setUuid(maxProduct.getUuid());
productInfoDao.updateProductByUuid(updateEntity);
} }
List<ProductInfoEntity> updates = productInfoDao.selectByUuid(productInfoEntity.getUuid());
for (ProductInfoEntity update : updates) {
update.setIsNewest(true);
productInfoDao.updateProductInfo(update);
}
logger.info("更新 = " + productInfoEntity.getNameCode()); logger.info("更新 = " + productInfoEntity.getNameCode());
} }

@ -5,8 +5,8 @@ server.port=9994
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 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.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.username=root
#spring.datasource.password=mysql@2020 spring.datasource.password=mysql@2020
spring.datasource.password=123456 #spring.datasource.password=123456
server.servlet.context-path= server.servlet.context-path=
# 跨域设置 # 跨域设置

@ -408,7 +408,6 @@
<if test="diType != null">diType=#{diType},</if> <if test="diType != null">diType=#{diType},</if>
<if test="isNewest != null">isNewest=#{isNewest},</if> <if test="isNewest != null">isNewest=#{isNewest},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if> <if test="updateTime != null">updateTime=#{updateTime},</if>
</set> </set>
WHERE id = #{id} WHERE id = #{id}
</update> </update>

Loading…
Cancel
Save