|
@@ -0,0 +1,171 @@
|
|
|
|
|
+package com.lc.ibps.platform.plan.job;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.lc.ibps.base.core.util.AppUtil;
|
|
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
|
|
+import com.lc.ibps.components.quartz.BaseJob2;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.DayOfWeek;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.Month;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+public class QualityIndicatorJob extends AbstractJob {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
|
|
+// String sql = "SELECT id_,di_dian_,cha_xun_yu_ju_ FROM t_zlzbpzb WHERE shi_fou_ji_huo_ = 'Y'";
|
|
|
|
|
+ List<Map<String, Object>> list = fetchRecords("zlzb1");
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(list)) {
|
|
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
|
|
+ String canshu = (String)map.get("cha_xun_yu_ju_");
|
|
|
|
|
+ String id = (String)map.get("id_");
|
|
|
|
|
+ String diDian = (String)map.get("di_dian_");
|
|
|
|
|
+ QualityIndicatorJobParameter parameter = JSON.parseObject(canshu, QualityIndicatorJobParameter.class);
|
|
|
|
|
+ createRecords(diDian,id,"每月",parameter.checkMonth());
|
|
|
|
|
+ createRecords(diDian,id,"每季度",parameter.checkQuarter());
|
|
|
|
|
+ createRecords(diDian,id,"每半年",parameter.checkHalfYear());
|
|
|
|
|
+ createRecords(diDian,id,"每年",parameter.checkYear());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void createRecords(String diDian,String id,String rate, String periodNum) {
|
|
|
|
|
+ if(StringUtils.isBlank(periodNum) ||
|
|
|
|
|
+ fetchRecords("zlzb2", new String[]{diDian, rate, periodNum}) != null){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> list = fetchRecords("zlzb3", new String[]{periodNum,rate,id});
|
|
|
|
|
+ if(list == null) return ;
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<String> ids = generateRecords(list, "t_zlzbpjb");
|
|
|
|
|
+ String parentId = ids.get(0);
|
|
|
|
|
+ List<Map<String, Object>> list1 = fetchRecords("zlzb4", new String[]{parentId,id,rate,periodNum});
|
|
|
|
|
+ generateRecords(list1, "t_zlzbpjzb");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ //ignore it.
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class QualityIndicatorJobParameter{
|
|
|
|
|
+ //{"month":[0,1],"quarter":[1,2],"halfYear":[1,3],"year":[1,4]}
|
|
|
|
|
+ int[] month;
|
|
|
|
|
+ int[] quarter;
|
|
|
|
|
+ int[] halfYear;
|
|
|
|
|
+ int[] year;
|
|
|
|
|
+
|
|
|
|
|
+ public String checkMonth(){
|
|
|
|
|
+ LocalDate nowDate = LocalDate.now();
|
|
|
|
|
+ if(nowDate.getDayOfMonth()>= month[1]){
|
|
|
|
|
+ nowDate = nowDate.minusMonths(1);
|
|
|
|
|
+ return nowDate.format(DateTimeFormatter.ofPattern("yyyy年M月份"));
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String checkQuarter(){
|
|
|
|
|
+ LocalDate nowDate = LocalDate.now();
|
|
|
|
|
+ int monthNum = nowDate.getMonthValue();
|
|
|
|
|
+ LocalDate firstDayOfQuarter;
|
|
|
|
|
+ if (monthNum <= 3) {
|
|
|
|
|
+ firstDayOfQuarter = LocalDate.of(nowDate.getYear(), Month.JANUARY, 1);
|
|
|
|
|
+ } else if (monthNum <= 6) {
|
|
|
|
|
+ firstDayOfQuarter = LocalDate.of(nowDate.getYear(), Month.APRIL, 1);
|
|
|
|
|
+ } else if (monthNum <= 9) {
|
|
|
|
|
+ firstDayOfQuarter = LocalDate.of(nowDate.getYear(), Month.JULY, 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ firstDayOfQuarter = LocalDate.of(nowDate.getYear(), Month.OCTOBER, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(quarter[0]>1) {
|
|
|
|
|
+ firstDayOfQuarter = firstDayOfQuarter.plusMonths(quarter[0]-1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(quarter[1]>1){
|
|
|
|
|
+ firstDayOfQuarter = firstDayOfQuarter.plusDays(quarter[1]-1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(nowDate.compareTo(firstDayOfQuarter)>=0){
|
|
|
|
|
+ nowDate = nowDate.minusMonths(3);
|
|
|
|
|
+ return nowDate.format(DateTimeFormatter.ofPattern("yyyy第Q季度"));
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String checkHalfYear(){
|
|
|
|
|
+ LocalDate nowDate = LocalDate.now();
|
|
|
|
|
+ int monthNum = nowDate.getMonthValue();
|
|
|
|
|
+ LocalDate firstDayOfHalfYear;
|
|
|
|
|
+ if (monthNum <= 6) {
|
|
|
|
|
+ firstDayOfHalfYear = LocalDate.of(nowDate.getYear(), Month.JANUARY, 1);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ firstDayOfHalfYear = LocalDate.of(nowDate.getYear(), Month.JULY, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(halfYear[0]>1) {
|
|
|
|
|
+ firstDayOfHalfYear = firstDayOfHalfYear.plusMonths(halfYear[0]-1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(halfYear[1]>1){
|
|
|
|
|
+ firstDayOfHalfYear = firstDayOfHalfYear.plusDays(halfYear[1]-1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(nowDate.compareTo(firstDayOfHalfYear)>=0){
|
|
|
|
|
+ nowDate = nowDate.minusMonths(6);
|
|
|
|
|
+ return nowDate.format(DateTimeFormatter.ofPattern(
|
|
|
|
|
+ String.format("yyyy%s半年",nowDate.getMonthValue()<=6?"上":"下")));
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ public String checkYear(){
|
|
|
|
|
+ LocalDate nowDate = LocalDate.now();
|
|
|
|
|
+ LocalDate firstDayOfHalfYear = LocalDate.of(nowDate.getYear(), Month.JANUARY, 1);
|
|
|
|
|
+ if(year[0]>1) {
|
|
|
|
|
+ firstDayOfHalfYear = firstDayOfHalfYear.plusMonths(year[0]-1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(year[1]>1){
|
|
|
|
|
+ firstDayOfHalfYear = firstDayOfHalfYear.plusDays(year[1]-1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(nowDate.compareTo(firstDayOfHalfYear)>=0){
|
|
|
|
|
+ nowDate = nowDate.minusYears(1);
|
|
|
|
|
+ return nowDate.format(DateTimeFormatter.ofPattern("yyyy年度"));
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int[] getMonth() {
|
|
|
|
|
+ return month;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setMonth(int[] month) {
|
|
|
|
|
+ this.month = month;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int[] getQuarter() {
|
|
|
|
|
+ return quarter;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setQuarter(int[] quarter) {
|
|
|
|
|
+ this.quarter = quarter;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int[] getHalfYear() {
|
|
|
|
|
+ return halfYear;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setHalfYear(int[] halfYear) {
|
|
|
|
|
+ this.halfYear = halfYear;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int[] getYear() {
|
|
|
|
|
+ return year;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setYear(int[] year) {
|
|
|
|
|
+ this.year = year;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|