GcTenderbidfileSchedul.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. package com.trs.ggzyexchange.schedul;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.fasterxml.jackson.core.JsonProcessingException;
  6. import com.trs.ggzyexchange.api.vo.Result;
  7. import com.trs.ggzyexchange.controller.AreaDataName;
  8. import com.trs.ggzyexchange.controller.BaseController;
  9. import com.trs.ggzyexchange.entity.*;
  10. import com.trs.ggzyexchange.enums.ClassIfy;
  11. import com.trs.ggzyexchange.enums.JobLock;
  12. import com.trs.ggzyexchange.service.*;
  13. import com.trs.ggzyexchange.utils.TenderDetailsVoUtils;
  14. import org.apache.commons.lang3.ObjectUtils;
  15. import org.quartz.Job;
  16. import org.quartz.JobExecutionContext;
  17. import org.quartz.JobExecutionException;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Component;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestParam;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import javax.servlet.http.HttpServletRequest;
  27. import java.text.SimpleDateFormat;
  28. import java.util.ArrayList;
  29. import java.util.Date;
  30. import java.util.List;
  31. /**
  32. * <p>
  33. * 招标文件/招标文件澄清与修改 定时任务
  34. * </p>
  35. *
  36. * @author trs
  37. * @since 2023-02-16
  38. */
  39. @Component
  40. public class GcTenderbidfileSchedul implements Job {
  41. private Logger logger = LoggerFactory.getLogger(GcTenderbidfileSchedul.class);
  42. @Autowired
  43. private GcTenderbidfileService gcTenderbidfileService;
  44. @Autowired
  45. private AreaDataName areaDataName;
  46. @Autowired
  47. private GcNoticeandfileService gcNoticeandfileService;
  48. @Autowired
  49. private TenderDetailsVoService tenderDetailsVoService;
  50. @Autowired
  51. private GcAttachmentService gcAttachmentService;
  52. @Autowired
  53. private ScheduledTashService scheduledTashService;
  54. public void queryPageListUpdateEs() throws JsonProcessingException {
  55. /**
  56. * 查询当前在定时任务表当中的最新时间
  57. */
  58. QueryWrapper<ScheduledTash> scheduledTashQueryWrapper = new QueryWrapper<ScheduledTash>();
  59. scheduledTashQueryWrapper.eq("table_name_value","gc_tenderbidfile");
  60. Page<ScheduledTash> pageScheduledTash = new Page<ScheduledTash>(1, 1);
  61. Page<ScheduledTash> page = scheduledTashService.page(pageScheduledTash, scheduledTashQueryWrapper);
  62. List<ScheduledTash> records = page.getRecords();
  63. ScheduledTash scheduledTash = null;
  64. if(records.size() > 0){
  65. scheduledTash = records.get(0);
  66. }
  67. Long time = null;
  68. if(ObjectUtils.isEmpty(scheduledTash)){
  69. try {
  70. /**
  71. * 如果scheduledTash为空,证明没有当前定时任务,设置当前的定时任务的时间为0 查询表gcNoticeandfile表当中的最新时间
  72. */
  73. time = gcTenderbidfileService.maxDataTimeStamp();
  74. ScheduledTash scheduledTashTash = new ScheduledTash();
  75. scheduledTashTash.setTime(0L);
  76. time = 0L;
  77. scheduledTashTash.setTableNameValue("gc_tenderbidfile");
  78. scheduledTashTash.setUpdateTime(new Date());
  79. scheduledTashTash.setCreateTime(new Date());
  80. scheduledTashService.saveOrUpdate(scheduledTashTash,scheduledTashQueryWrapper);
  81. }catch (Exception e){
  82. e.printStackTrace();
  83. }
  84. }else {
  85. /**
  86. * 如果scheduledTash为空,证明没有当前定时任务,设置当前的定时任务的时间为0 查询表gcNoticeandfile表当中的最新时间
  87. */
  88. time = scheduledTash.getTime();
  89. }
  90. try {
  91. //查询表gcNoticeandfile表当中的最新时间
  92. Long newTime = gcTenderbidfileService.maxDataTimeStamp();
  93. ScheduledTash scheduledTashTash = new ScheduledTash();
  94. scheduledTashTash.setTime(newTime);
  95. scheduledTashTash.setTableNameValue("gc_tenderbidfile");
  96. scheduledTashTash.setUpdateTime(new Date());
  97. scheduledTashService.saveOrUpdate(scheduledTashTash,scheduledTashQueryWrapper);
  98. }catch (Exception e){
  99. e.printStackTrace();
  100. }
  101. if(!ObjectUtils.isEmpty(time)){
  102. try {
  103. QueryWrapper<GcTenderbidfile> gcPerformanceQueryWrapper = new QueryWrapper<GcTenderbidfile>();
  104. gcPerformanceQueryWrapper.gt("DATA_TIMESTAMP",time);
  105. int count = gcTenderbidfileService.count(gcPerformanceQueryWrapper);
  106. Integer pageSize = 1000;
  107. Integer pageNum = (int)Math.ceil((double)count/pageSize);
  108. for(int i = 1; i <= pageNum;i++){
  109. try {
  110. List<TenderDetailsVo> tenderDetailsVoListAll = getTenderDetailsVoListAll(i, pageSize,time);
  111. Boolean aBoolean = gcNoticeandfileService.parseTenderDetailsVo(tenderDetailsVoListAll);
  112. }catch (Exception e){
  113. e.printStackTrace();
  114. }
  115. }
  116. }catch (Exception e){
  117. e.printStackTrace();
  118. }
  119. }
  120. }
  121. public List<TenderDetailsVo> getTenderDetailsVoListAll(Integer pageNo,Integer pageSize,Long time){
  122. Page<GcTenderbidfile> page = new Page<GcTenderbidfile>(pageNo, pageSize);
  123. IPage<TenderDetailsVo> tenderDetailsVoIPage = gcTenderbidfileService.queryGcTenderbidfileAllListByTime(page,time);
  124. for (TenderDetailsVo record : tenderDetailsVoIPage.getRecords()) {
  125. String noticeName = record.getNoticeName();
  126. if(!ObjectUtils.isEmpty(noticeName)){
  127. record.setNoticeName(noticeName);
  128. }
  129. record.setNoticeTypeCode(ClassIfy.BIDDING_DOCUMENTS.getCode());
  130. record.setNoticeTypeName(ClassIfy.BIDDING_DOCUMENTS.getName());
  131. //电力交易
  132. if(!ObjectUtils.isEmpty(record.getSourceDataCode()) && "7089bc24".equals(record.getSourceDataCode())) {
  133. record.setTransactionTypeCode(ClassIfy.ELECTRICITY.getCode());
  134. record.setTransactionTypeName(ClassIfy.ELECTRICITY.getName());
  135. }else if(!ObjectUtils.isEmpty(record.getSourceDataCode()) && "d844782a".equals(record.getSourceDataCode())) {
  136. record.setTransactionTypeCode(ClassIfy.WEITUO.getCode());
  137. record.setTransactionTypeName(ClassIfy.WEITUO.getName());
  138. }else {
  139. record.setTransactionTypeCode(ClassIfy.ENGINEERING_CONSTRUCTION.getCode());
  140. record.setTransactionTypeName(ClassIfy.ENGINEERING_CONSTRUCTION.getName());
  141. }
  142. record = tenderDetailsVoService.getTenderDetailsVoAllOrther(record);
  143. try {
  144. String bidSectionCodes = record.getBidSectionCodes();
  145. int i1 = bidSectionCodes.indexOf(",");
  146. int i2 = bidSectionCodes.indexOf(";");
  147. int i3 = bidSectionCodes.indexOf("<br>");
  148. int i4 = bidSectionCodes.indexOf("ltbrgt");
  149. String splitBidSectionCode = null;
  150. boolean flag = false;
  151. String[] split = null;
  152. if(i1 > 0){
  153. split = bidSectionCodes.split(",");
  154. flag = true;
  155. }
  156. if(i2 > 0){
  157. split = bidSectionCodes.split(";");
  158. flag = true;
  159. }
  160. if(i3 > 0){
  161. split = bidSectionCodes.split("<br>");
  162. flag = true;
  163. }
  164. if(i4 > 0){
  165. split = bidSectionCodes.split("ltbrgt");
  166. flag = true;
  167. }
  168. if(!flag){
  169. split = new String[]{bidSectionCodes};
  170. }
  171. List<GcAttachment> attachmentList = new ArrayList<GcAttachment>();
  172. if(record.getDataTimestamp()>20250324000000L){
  173. //通过标包编号查询对应的附件信息
  174. QueryWrapper<GcAttachment> gcAttachmentQueryWrapper3 = new QueryWrapper<GcAttachment>();
  175. // gcAttachmentQueryWrapper3.eq("ATTACHMENT_SET_CODE","TENDER_FILE");//add
  176. gcAttachmentQueryWrapper3.eq("ASSOCIATION_CODE", record.getSourceDataKey());
  177. gcAttachmentQueryWrapper3.notLike("ATTACHMENT_NAME","%xml");
  178. gcAttachmentQueryWrapper3.notLike("ATTACHMENT_NAME","%nmgzf");
  179. List<GcAttachment> list3 = gcAttachmentService.list(gcAttachmentQueryWrapper3);
  180. /* //通过标包编号查询对应的附件信息
  181. QueryWrapper<GcAttachment> gcAttachmentQueryWrapper = new QueryWrapper<GcAttachment>();
  182. // gcAttachmentQueryWrapper.eq("ATTACHMENT_SET_CODE","TENDER_FILE_FILE");//add
  183. gcAttachmentQueryWrapper.eq("ASSOCIATION_CODE", record.getSourceDataKey());
  184. gcAttachmentQueryWrapper.notLike("ATTACHMENT_NAME","%xml");
  185. gcAttachmentQueryWrapper.notLike("ATTACHMENT_NAME","%nmgzf");
  186. List<GcAttachment> list = gcAttachmentService.list(gcAttachmentQueryWrapper);
  187. //通过标包编号查询对应的附件信息
  188. QueryWrapper<GcAttachment> gcAttachmentQueryWrapper2 = new QueryWrapper<GcAttachment>();
  189. // gcAttachmentQueryWrapper2.eq("ATTACHMENT_SET_CODE","FILE_EX_TDOC");//add
  190. gcAttachmentQueryWrapper2.eq("ASSOCIATION_CODE", record.getSourceDataKey());
  191. gcAttachmentQueryWrapper2.notLike("ATTACHMENT_NAME","%xml");
  192. gcAttachmentQueryWrapper2.notLike("ATTACHMENT_NAME","%nmgzf");
  193. List<GcAttachment> list2 = gcAttachmentService.list(gcAttachmentQueryWrapper2);*/
  194. if(!ObjectUtils.isEmpty(list3)){
  195. attachmentList.addAll(list3);
  196. }
  197. /* if(!ObjectUtils.isEmpty(list2)){
  198. attachmentList.addAll(list2);
  199. }
  200. if(!ObjectUtils.isEmpty(list)){
  201. attachmentList.addAll(list);
  202. }*/
  203. }else{
  204. if(!ObjectUtils.isEmpty(split)){
  205. if(split.length >=1){
  206. for (String bidSectionCode : split) {
  207. try {
  208. //通过标包编号查询对应的附件信息
  209. QueryWrapper<GcAttachment> gcAttachmentQueryWrapper = new QueryWrapper<GcAttachment>();
  210. gcAttachmentQueryWrapper.eq("ATTACHMENT_SET_CODE","TENDER_FILE_FILE");//add
  211. gcAttachmentQueryWrapper.eq("BID_SECTION_CODE",bidSectionCode);
  212. gcAttachmentQueryWrapper.notLike("ATTACHMENT_NAME","%xml");
  213. gcAttachmentQueryWrapper.notLike("ATTACHMENT_NAME","%nmgzf");
  214. List<GcAttachment> list = gcAttachmentService.list(gcAttachmentQueryWrapper);
  215. //通过标包编号查询对应的附件信息
  216. QueryWrapper<GcAttachment> gcAttachmentQueryWrapper2 = new QueryWrapper<GcAttachment>();
  217. gcAttachmentQueryWrapper2.eq("ATTACHMENT_SET_CODE","FILE_EX_TDOC");//add
  218. gcAttachmentQueryWrapper2.eq("BID_SECTION_CODE",bidSectionCode);
  219. gcAttachmentQueryWrapper2.notLike("ATTACHMENT_NAME","%xml");
  220. gcAttachmentQueryWrapper2.notLike("ATTACHMENT_NAME","%nmgzf");
  221. List<GcAttachment> list2 = gcAttachmentService.list(gcAttachmentQueryWrapper2);
  222. if(!ObjectUtils.isEmpty(list2)){
  223. attachmentList.addAll(list2);
  224. }
  225. if(!ObjectUtils.isEmpty(list)){
  226. attachmentList.addAll(list);
  227. }
  228. }catch (Exception e){
  229. e.printStackTrace();
  230. }
  231. }
  232. }
  233. }
  234. }
  235. String noticeContent = record.getNoticeContent();
  236. String file = "";
  237. if(!ObjectUtils.isEmpty(attachmentList)){
  238. if(attachmentList.size() > 0){
  239. file = "<br>附件:<br>";
  240. }
  241. }
  242. for (GcAttachment gcAttachment : attachmentList) {
  243. try{
  244. String attachmentName = gcAttachment.getAttachmentName();
  245. String url = gcAttachment.getUrl();
  246. file += "<a target='_blank' style='color: blue' href='"+ url +"'>"+ attachmentName +"</a><br/>";
  247. }catch (Exception e){
  248. e.printStackTrace();
  249. }
  250. }
  251. //招标文件拼接地址
  252. if(!ObjectUtils.isEmpty(noticeContent) && noticeContent != ""){
  253. file = noticeContent + file;
  254. }
  255. record.setNoticeContent(file);
  256. }catch (Exception e){
  257. e.printStackTrace();
  258. }
  259. TenderDetailsVoUtils.isNull(record);
  260. }
  261. return tenderDetailsVoIPage.getRecords();
  262. }
  263. @Override
  264. public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
  265. try {
  266. if(JobLock.GcTenderbidfileFlag){
  267. JobLock.GcTenderbidfileFlag = false;
  268. logger.info("执行GcTenderbidfile", new SimpleDateFormat().format(new Date()));
  269. try {
  270. queryPageListUpdateEs();
  271. } catch (Exception e) {
  272. e.printStackTrace();
  273. }
  274. JobLock.GcTenderbidfileFlag = true;
  275. }else{
  276. logger.info("不执行GcTenderbidfile", new SimpleDateFormat().format(new Date()));
  277. }
  278. }catch (Exception e){
  279. e.printStackTrace();
  280. JobLock.GcTenderbidfileFlag = true;
  281. }
  282. }
  283. }