|
|
@@ -0,0 +1,218 @@
|
|
|
+package com.trs.ggzyexchange.schedul;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.trs.ggzyexchange.entity.*;
|
|
|
+import com.trs.ggzyexchange.enums.ClassIfy;
|
|
|
+import com.trs.ggzyexchange.enums.JobLock;
|
|
|
+import com.trs.ggzyexchange.service.*;
|
|
|
+import com.trs.ggzyexchange.utils.TenderDetailsVoUtils;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.quartz.Job;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.quartz.JobExecutionException;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class GcTenderbidfilepublicitySchedul implements Job {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ScheduledTashService scheduledTashService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TRegionService tRegionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AreaPlatformService areaPlatformService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GcTenderbidfilepublicityService gcTenderbidfilepublicityService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GcNoticeandfileService gcNoticeandfileService;
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(ZfcgGongao.class);
|
|
|
+
|
|
|
+ public void queryPageListUpdateEs() throws JsonProcessingException {
|
|
|
+ /**
|
|
|
+ * 查询当前在定时任务表当中的最新时间
|
|
|
+ */
|
|
|
+ QueryWrapper<ScheduledTash> scheduledTashQueryWrapper = new QueryWrapper<ScheduledTash>();
|
|
|
+ scheduledTashQueryWrapper.eq("table_name_value","gc_tenderbidfilepublicity");
|
|
|
+ Page<ScheduledTash> pageScheduledTash = new Page<ScheduledTash>(1, 1);
|
|
|
+ Page<ScheduledTash> page = scheduledTashService.page(pageScheduledTash, scheduledTashQueryWrapper);
|
|
|
+ List<ScheduledTash> records = page.getRecords();
|
|
|
+ ScheduledTash scheduledTash = null;
|
|
|
+ if(records.size() > 0){
|
|
|
+ scheduledTash = records.get(0);
|
|
|
+ }
|
|
|
+ Long time = null;
|
|
|
+ if(ObjectUtils.isEmpty(scheduledTash)){
|
|
|
+ try {
|
|
|
+ /**
|
|
|
+ * 如果scheduledTash为空,证明没有当前定时任务,设置当前的定时任务的时间为0 查询表gcNoticeandfile表当中的最新时间
|
|
|
+ */
|
|
|
+ time = gcTenderbidfilepublicityService.maxDataTimeStamp();
|
|
|
+ ScheduledTash scheduledTashTash = new ScheduledTash();
|
|
|
+ scheduledTashTash.setTime(0L);
|
|
|
+ time = 0L;
|
|
|
+ scheduledTashTash.setTableNameValue("gc_tenderbidfilepublicity");
|
|
|
+ scheduledTashTash.setUpdateTime(new Date());
|
|
|
+ scheduledTashTash.setCreateTime(new Date());
|
|
|
+ scheduledTashService.saveOrUpdate(scheduledTashTash,scheduledTashQueryWrapper);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ /**
|
|
|
+ * 如果scheduledTash为空,证明没有当前定时任务,设置当前的定时任务的时间为0 查询表gcNoticeandfile表当中的最新时间
|
|
|
+ */
|
|
|
+ time = scheduledTash.getTime();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ //查询表gcNoticeandfile表当中的最新时间
|
|
|
+ Long newTime = gcTenderbidfilepublicityService.maxDataTimeStamp();
|
|
|
+ ScheduledTash scheduledTashTash = new ScheduledTash();
|
|
|
+ scheduledTashTash.setTime(newTime);
|
|
|
+ scheduledTashTash.setTableNameValue("gc_tenderbidfilepublicity");
|
|
|
+ scheduledTashTash.setUpdateTime(new Date());
|
|
|
+ scheduledTashService.saveOrUpdate(scheduledTashTash,scheduledTashQueryWrapper);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!ObjectUtils.isEmpty(time)){
|
|
|
+ try {
|
|
|
+ QueryWrapper<GcTenderbidfilepublicity> gcTenderbidfilepublicityQueryWrapper = new QueryWrapper<GcTenderbidfilepublicity>();
|
|
|
+ gcTenderbidfilepublicityQueryWrapper.gt("DATA_TIMESTAMP",time);
|
|
|
+ int count = gcTenderbidfilepublicityService.count(gcTenderbidfilepublicityQueryWrapper);
|
|
|
+ Integer pageSize = 1000;
|
|
|
+ Integer pageNum = (int)Math.ceil((double)count/pageSize);
|
|
|
+ for(int i = 1; i <= pageNum;i++){
|
|
|
+ try {
|
|
|
+ List<TenderDetailsVo> tenderDetailsVoListAll = getTenderDetailsVoListAll(i, pageSize,time);
|
|
|
+ Boolean aBoolean = gcNoticeandfileService.parseTenderDetailsVo(tenderDetailsVoListAll);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<TenderDetailsVo> getTenderDetailsVoListAll(Integer pageNo,Integer pageSize,Long time){
|
|
|
+ Page<GcTenderbidfilepublicity> page = new Page<GcTenderbidfilepublicity>(pageNo, pageSize);
|
|
|
+ IPage<TenderDetailsVo> tenderDetailsVoIPage = gcTenderbidfilepublicityService.queryGcTenderbidfilepublicityListByTime(page,time);
|
|
|
+ List<TenderDetailsVo> tenderDetailsVos = new ArrayList<TenderDetailsVo>();
|
|
|
+ for (TenderDetailsVo record : tenderDetailsVoIPage.getRecords()) {
|
|
|
+ record.setTransactionTypeCode(ClassIfy.ENGINEERING_CONSTRUCTION.getCode());
|
|
|
+ record.setTransactionTypeName(ClassIfy.ENGINEERING_CONSTRUCTION.getName());
|
|
|
+
|
|
|
+ record.setNoticeTypeCode(ClassIfy.TENDER_TENDERBIDFILEPUBLICITY.getCode());
|
|
|
+ record.setNoticeTypeName(ClassIfy.TENDER_TENDERBIDFILEPUBLICITY.getName());
|
|
|
+
|
|
|
+ /*record.setPlatformName("内蒙古公共资源交易平台");*/
|
|
|
+ //获取国标区域名称
|
|
|
+ QueryWrapper<TRegion> tRegionQueryWrapper = new QueryWrapper<TRegion>();
|
|
|
+ String TregionCode = record.getRegionCode();
|
|
|
+ if(TregionCode.equals("150001")){
|
|
|
+ record.setRegionName("内蒙古自治区本级");
|
|
|
+ record.setRegionCode("150000");
|
|
|
+ TregionCode = "150000";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150101")){
|
|
|
+ record.setRegionName("呼和浩特市");record.setRegionCode("150100");TregionCode = "150100";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150201")){
|
|
|
+ record.setRegionName("包头市");record.setRegionCode("150200");TregionCode = "150200";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150301")){
|
|
|
+ record.setRegionName("乌海市");record.setRegionCode("150300");TregionCode = "150300";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150401")){
|
|
|
+ record.setRegionName("赤峰市");record.setRegionCode("150400");TregionCode = "150400";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150501")){
|
|
|
+ record.setRegionName("通辽市");record.setRegionCode("150500");TregionCode = "150500";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150601")){
|
|
|
+ record.setRegionName("鄂尔多斯市");record.setRegionCode("150600");TregionCode = "150600";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150701")){
|
|
|
+ record.setRegionName("呼伦贝尔市");record.setRegionCode("150700");TregionCode = "150700";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150801")){
|
|
|
+ record.setRegionName("巴彦淖尔市");record.setRegionCode("150800");TregionCode = "150800";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("150901")){
|
|
|
+ record.setRegionName("乌兰察布市");record.setRegionCode("150900");TregionCode = "150900";
|
|
|
+ }
|
|
|
+ if(TregionCode.equals("152901")){
|
|
|
+ record.setRegionName("阿拉善盟");record.setRegionCode("152900");TregionCode = "152900";
|
|
|
+ }
|
|
|
+ Page<TRegion> pageTRegion = new Page<TRegion>(1, 1);
|
|
|
+ if(!ObjectUtils.isEmpty(TregionCode)){
|
|
|
+ tRegionQueryWrapper.eq("code",TregionCode+"000000");
|
|
|
+ List<TRegion> records = tRegionService.page(pageTRegion, tRegionQueryWrapper).getRecords();
|
|
|
+ if(records.size() >= 1){
|
|
|
+ try {
|
|
|
+ String name = records.get(0).getName();
|
|
|
+ if(!ObjectUtils.isEmpty(name)){
|
|
|
+ record.setRegionName(name);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String regionCode = TregionCode;
|
|
|
+ AreaPlatform areaPlatformByRegionCode = areaPlatformService.getAreaPlatformByRegionCode(regionCode);
|
|
|
+ if(!ObjectUtils.isEmpty(areaPlatformByRegionCode)){
|
|
|
+ record.setPlatformCode(areaPlatformByRegionCode.getPlatformCode());
|
|
|
+ record.setPlatformName(areaPlatformByRegionCode.getRegionName());
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ TenderDetailsVo aNull = TenderDetailsVoUtils.isNull(record);
|
|
|
+ tenderDetailsVos.add(aNull);
|
|
|
+ }
|
|
|
+ return tenderDetailsVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
+ try {
|
|
|
+ if(JobLock.GcTenderbidfilepublicityFlag){
|
|
|
+ JobLock.GcTenderbidfilepublicityFlag = false;
|
|
|
+ logger.info("GcTenderbidfilepublicity", new SimpleDateFormat().format(new Date()));
|
|
|
+ try {
|
|
|
+ queryPageListUpdateEs();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ JobLock.GcTenderbidfilepublicityFlag = true;
|
|
|
+ }else{
|
|
|
+ logger.info("GcTenderbidfilepublicity", new SimpleDateFormat().format(new Date()));
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ JobLock.GcTenderbidfilepublicityFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|