123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- 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.api.vo.Result;
- import com.trs.ggzyexchange.controller.AreaDataName;
- import com.trs.ggzyexchange.controller.BaseController;
- 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 org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpServletRequest;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- /**
- * <p>
- * 中标结果公示 定时任务
- * </p>
- *
- * @author trs
- * @since 2023-02-16
- */
- @Component
- public class GcBidpublicitySchedul implements Job {
- private Logger logger = LoggerFactory.getLogger(GcBidpublicitySchedul.class);
- @Autowired
- private GcNoticeandfileService gcNoticeandfileService;
- @Autowired
- private AreaDataName areaDataName;
- @Autowired
- private GcBidpublicityService gcBidpublicityService;
- @Autowired
- private TenderDetailsVoService tenderDetailsVoService;
- @Autowired
- private ScheduledTashService scheduledTashService;
- @Autowired
- private GcAttachmentService gcAttachmentService;
- public void queryPageListUpdateEs() throws JsonProcessingException {
- /**
- * 查询当前在定时任务表当中的最新时间
- */
- QueryWrapper<ScheduledTash> scheduledTashQueryWrapper = new QueryWrapper<ScheduledTash>();
- scheduledTashQueryWrapper.eq("table_name_value","gc_bidpublicity");
- 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 = gcBidpublicityService.maxDataTimeStamp();
- ScheduledTash scheduledTashTash = new ScheduledTash();
- scheduledTashTash.setTime(0L);
- time = 0L;
- scheduledTashTash.setTableNameValue("gc_bidpublicity");
- 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 = gcBidpublicityService.maxDataTimeStamp();
- ScheduledTash scheduledTashTash = new ScheduledTash();
- scheduledTashTash.setTime(newTime);
- scheduledTashTash.setTableNameValue("gc_bidpublicity");
- scheduledTashTash.setUpdateTime(new Date());
- scheduledTashService.saveOrUpdate(scheduledTashTash,scheduledTashQueryWrapper);
- }catch (Exception e){
- e.printStackTrace();
- }
- if(!ObjectUtils.isEmpty(time)){
- try {
- QueryWrapper<GcBidpublicity> GcBidpublicityQueryWrapper = new QueryWrapper<GcBidpublicity>();
- GcBidpublicityQueryWrapper.gt("DATA_TIMESTAMP",time);
- int count = gcBidpublicityService.count(GcBidpublicityQueryWrapper);
- 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);
- gcNoticeandfileService.parseTenderDetailsVo(tenderDetailsVoListAll);
- }catch (Exception e){
- e.printStackTrace();
- }
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- }
- }
- public List<TenderDetailsVo> getTenderDetailsVoListAll(Integer pageNo,Integer pageSize,Long time){
- Page<GcBidpublicity> page = new Page<GcBidpublicity>(pageNo, pageSize);
- IPage<TenderDetailsVo> pageList = gcBidpublicityService.queryGcBidpublicityAllListByTime(page,time);
- for (TenderDetailsVo record : pageList.getRecords()) {
- try {
- record.setNoticeTypeCode(ClassIfy.ANNOUNCEMENT_OF_BID_WINNING_RESULTS.getCode());
- record.setNoticeTypeName(ClassIfy.ANNOUNCEMENT_OF_BID_WINNING_RESULTS.getName());
- record.setTransactionTypeCode(ClassIfy.ENGINEERING_CONSTRUCTION.getCode());
- record.setTransactionTypeName(ClassIfy.ENGINEERING_CONSTRUCTION.getName());
- record = tenderDetailsVoService.getTenderDetailsVoAllOrther(record);
- String bidSectionCodes = record.getBidSectionCodes();
- if(!ObjectUtils.isEmpty(bidSectionCodes)) {
- int i1 = bidSectionCodes.indexOf(",");
- int i2 = bidSectionCodes.indexOf(";");
- int i3 = bidSectionCodes.indexOf("<br>");
- int i4 = bidSectionCodes.indexOf("ltbrgt");
- String splitBidSectionCode = null;
- String[] split = null;
- boolean flag = false;
- if (i1 > 0) {
- splitBidSectionCode = bidSectionCodes.split(",")[0];
- split = bidSectionCodes.split(",");
- flag = true;
- }
- if (i2 > 0) {
- splitBidSectionCode = bidSectionCodes.split(";")[0];
- split = bidSectionCodes.split(";");
- flag = true;
- }
- if (i3 > 0) {
- splitBidSectionCode = bidSectionCodes.split("<br>")[0];
- split = bidSectionCodes.split("<br>");
- flag = true;
- }
- if (i4 > 0) {
- splitBidSectionCode = bidSectionCodes.split("ltbrgt")[0];
- split = bidSectionCodes.split("ltbrgt");
- flag = true;
- }
- if (!flag) {
- splitBidSectionCode = bidSectionCodes;
- split = bidSectionCodes.split(",");
- }
- List<GcAttachment> attachmentList = new ArrayList<GcAttachment>();
- if (!ObjectUtils.isEmpty(split)) {
- if (split.length >= 1) {
- for (String bidSectionCode : split) {
- try {
- String bidSectionCodeClean = bidSectionCode.replaceAll(">", "").replaceAll("<", "");
- String bidSectionCodeClean2 = bidSectionCodeClean.replaceAll("gt", "").replaceAll("lt", "");
- //通过标包编号查询对应的附件信息
- QueryWrapper<GcAttachment> gcAttachmentQueryWrapper = new QueryWrapper<GcAttachment>();
- gcAttachmentQueryWrapper.eq("ATTACHMENT_SET_CODE", "WIN_BID_NOTICE");//add
- gcAttachmentQueryWrapper.eq("isshow", "0");//add
- //gcAttachmentQueryWrapper.eq("BID_SECTION_CODE",bidSectionCode);
- gcAttachmentQueryWrapper.like("BID_SECTION_CODE", bidSectionCodeClean2);
- List<GcAttachment> list = gcAttachmentService.list(gcAttachmentQueryWrapper);
- if (attachmentList.size() > 0) {
- break;
- }
- if (!ObjectUtils.isEmpty(list)) {
- attachmentList.addAll(list);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
- String noticeContent = record.getNoticeContent();
- String file = "";
- if (!ObjectUtils.isEmpty(attachmentList)) {
- if (attachmentList.size() > 0) {
- file = "<br>附件:<br>";
- }
- }
- for (GcAttachment gcAttachment : attachmentList) {
- try {
- String attachmentName = gcAttachment.getAttachmentName();
- String url = gcAttachment.getUrl();
- file += "<a target='_blank' style='color: blue' href='" + url + "'>" + attachmentName + "</a><br/>";
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- //招标文件拼接地址
- if (!ObjectUtils.isEmpty(noticeContent) && noticeContent != "") {
- file = noticeContent + file;
- }
- record.setNoticeContent(file);
- }
- TenderDetailsVoUtils.isNull(record);
- }catch (Exception e){
- e.printStackTrace();
- }
- }
- return pageList.getRecords();
- }
- @Override
- public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
- try {
- if(JobLock.GcBidpublicityFlag){
- JobLock.GcBidpublicityFlag = false;
- logger.info("执行GcBidpublicity", new SimpleDateFormat().format(new Date()));
- try {
- queryPageListUpdateEs();
- } catch (Exception e) {
- e.printStackTrace();
- }
- JobLock.GcBidpublicityFlag = true;
- }else{
- logger.info("不执行GcBidpublicity", new SimpleDateFormat().format(new Date()));
- }
- }catch (Exception e){
- e.printStackTrace();
- JobLock.GcBidpublicityFlag = true;
- }
- }
- }
|