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

master
anthonyywj2 3 years ago
parent e61cdcf69c
commit e705cbecdb

@ -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){

@ -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<ProductInfoEntity> productInfoEntities = productInfoDao.filterUdiByCreditNo(productInfoFilterRequest);
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
//将该记录所有产品初始化
ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest();
filterRequest.setDeviceRecordKey(productInfoEntity.getDeviceRecordKey());
List<ProductInfoEntity> 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<ProductInfoEntity> 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<ProductInfoEntity> 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<ProductInfoEntity> updates = productInfoDao.selectByUuid(productInfoEntity.getUuid());
for (ProductInfoEntity update : updates) {
update.setIsNewest(true);
productInfoDao.updateProductInfo(update);
}
logger.info("更新 = " + productInfoEntity.getNameCode());
}

@ -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=
# 跨域设置

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

Loading…
Cancel
Save