|
@@ -1,7 +1,12 @@
|
|
|
package com.shkpr.service.aimodelpower.bizmgr;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.global.base.log.LogLevelFlag;
|
|
|
+import com.global.base.log.LogPrintMgr;
|
|
|
import com.global.base.tools.FastJsonUtil;
|
|
|
import com.shkpr.service.aimodelpower.commtools.CommTool;
|
|
|
+import com.shkpr.service.aimodelpower.commtools.TimeTool;
|
|
|
import com.shkpr.service.aimodelpower.components.locks.CountDownLatchEx;
|
|
|
import com.shkpr.service.aimodelpower.components.locks.WODispatchPlanLockMgr;
|
|
|
import com.shkpr.service.aimodelpower.constants.CommFieldStatus;
|
|
@@ -9,17 +14,35 @@ import com.shkpr.service.aimodelpower.constants.TaskQueueDataTypeEx;
|
|
|
import com.shkpr.service.aimodelpower.dbdao.DBMgrProxy;
|
|
|
import com.shkpr.service.aimodelpower.dbdao.services.intef.WODispatchPlanDBService;
|
|
|
import com.shkpr.service.aimodelpower.dbdao.tables.WODispatchPlanInfoTable;
|
|
|
-import com.shkpr.service.aimodelpower.dto.CommUTMBean;
|
|
|
-import com.shkpr.service.aimodelpower.dto.ResponseCode;
|
|
|
-import com.shkpr.service.aimodelpower.dto.WODispatchCheckBean;
|
|
|
-import com.shkpr.service.aimodelpower.dto.WODispatchCheckTotal;
|
|
|
+import com.shkpr.service.aimodelpower.dto.*;
|
|
|
+import com.shkpr.service.aimodelpower.dto.woDispatchPlanModel.DispatchPlanInfoDetailsModel;
|
|
|
+import com.shkpr.service.aimodelpower.dto.woDispatchPlanModel.DispatchPlanInfoModel;
|
|
|
+import com.shkpr.service.aimodelpower.dto.woDispatchPlanModel.DispatchPlanInfoSSModel;
|
|
|
import com.shkpr.service.aimodelpower.globalmgr.AsyncTaskQueueMgr;
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.woDispatchPlan.JPDispatchCmdBatchItem;
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.woDispatchPlan.JPDispatchPlanInfoDetailsSS;
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.woDispatchPlan.JPDispatchPlanInfoSS;
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.woDispatchPlan.JPDispatchPlanInfoSave;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.DayOfWeek;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class WODispatchPlanTmDoBizFun {
|
|
|
+ private final static String mStrClassName = "WODispatchPlanTmDoBizFun";
|
|
|
+ private final static String EMPTY_NULL = "NULL";
|
|
|
+ private final static String MSG_FAILED = "failed.";
|
|
|
+ private final static String MSG_SUCCESS = "success.";
|
|
|
+
|
|
|
private static WODispatchPlanDBService getThisDBService(){ return DBMgrProxy.getInstance().applyWODispatchPlanApi();}
|
|
|
|
|
|
public static ResponseCode produceCmd(String planId, long checkTm){
|
|
@@ -120,4 +143,316 @@ public class WODispatchPlanTmDoBizFun {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //TODO 分页查询计划
|
|
|
+ //查询·分页
|
|
|
+ public static PageRecordRes<DispatchPlanInfoSSModel> queryPageList(JPDispatchPlanInfoSS jsonParam){
|
|
|
+ PageRecordRes<DispatchPlanInfoSSModel> oRes = new PageRecordRes<>();
|
|
|
+ if (jsonParam == null)
|
|
|
+ return oRes;
|
|
|
+ final String lilterExtend = jsonParam.genQueryExtend();
|
|
|
+ Map<String,Object> andWheres = new HashMap<>();
|
|
|
+ if(jsonParam.getPlanType()!=null){
|
|
|
+ andWheres.put("plan_type", jsonParam.getPlanType());
|
|
|
+ }
|
|
|
+ if(jsonParam.getPlanStatus()!=null){
|
|
|
+ andWheres.put("plan_status", jsonParam.getPlanStatus());
|
|
|
+ }
|
|
|
+ String sql = "";
|
|
|
+ if(jsonParam.getDownFlag()!=null) {
|
|
|
+ if(jsonParam.getDownFlag()==0) {
|
|
|
+ sql += " AND " + WODispatchPlanInfoTable.R_INFO.LAST_TAKE_TIME + " !=0 AND "
|
|
|
+ + WODispatchPlanInfoTable.R_INFO.LAST_TAKE_TIME + " IS NOT NULL";
|
|
|
+ }else{
|
|
|
+ sql += " AND (" + WODispatchPlanInfoTable.R_INFO.LAST_TAKE_TIME + " = 0 OR "
|
|
|
+ + WODispatchPlanInfoTable.R_INFO.LAST_TAKE_TIME + " IS NULL )";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int nTotals = getThisDBService().totalCountsEx("", andWheres, null, lilterExtend+sql);
|
|
|
+ if (nTotals > 0){
|
|
|
+ List<Map<String,Object>> dataList = getThisDBService().listAllWithsEx("","",
|
|
|
+ jsonParam.getLimit(),
|
|
|
+ jsonParam.getOffset(),
|
|
|
+ andWheres,
|
|
|
+ null,
|
|
|
+ WODispatchPlanInfoTable.R_INFO.ID,
|
|
|
+ lilterExtend+sql);
|
|
|
+ if(dataList==null){
|
|
|
+ oRes.setCode(ResponseCode.RESULT_BAD.toInt());
|
|
|
+ }else{
|
|
|
+ List<DispatchPlanInfoSSModel> ssInfoModels = dataList.isEmpty()?new ArrayList<>():
|
|
|
+ FastJsonUtil.batchMap2Obj(dataList,DispatchPlanInfoSSModel.class,true);
|
|
|
+ oRes.setCode(ResponseCode.RESULT_NORMAL.toInt());
|
|
|
+ oRes.setTotal(nTotals);
|
|
|
+ oRes.setData(ssInfoModels);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return oRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 查询详情信息
|
|
|
+ public static ResponseRes selectPlanInfoView(JPDispatchPlanInfoDetailsSS oJsonParam){
|
|
|
+ ResponseRes oRes = new ResponseRes();
|
|
|
+ oRes.setRescode(ResponseCode.RESULT_BAD.toStrCode());
|
|
|
+ oRes.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
|
|
|
+ if(StringUtils.isEmpty(oJsonParam)||StringUtils.isEmpty(oJsonParam.getPlanId())){
|
|
|
+ oRes.setRescode(ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrCode());
|
|
|
+ oRes.setResmsg(ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrMsg());
|
|
|
+ return oRes;
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ Map<String,Object> map = getThisDBService().viewInfo("","",oJsonParam.getPlanId());
|
|
|
+ if(map!=null){
|
|
|
+ oRes.setResdata(FastJsonUtil.toJSON(map,true));
|
|
|
+ }
|
|
|
+ oRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
+ oRes.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
+ return oRes;
|
|
|
+ }catch (Exception ex){
|
|
|
+ return oRes;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 新增计划
|
|
|
+ public static ResponseCode savePlan(JPDispatchPlanInfoSave oJsonParam){
|
|
|
+ try{
|
|
|
+ //TODO 根据计划类型计算计划的下次生效时间
|
|
|
+ DispatchPlanInfoModel model = new DispatchPlanInfoModel();
|
|
|
+ model.setPlanId("PL"+ UUID.randomUUID());
|
|
|
+ model.setPlanType(oJsonParam.getPlanType());
|
|
|
+ model.setPlanStatus(oJsonParam.getPlanStatus());
|
|
|
+ model.setTitle(oJsonParam.getTitle());
|
|
|
+ model.setUrgentLevel(oJsonParam.getUrgentLevel());
|
|
|
+ model.setDispatchRemark(oJsonParam.getDispatchRemark());
|
|
|
+ model.setDispatchLeadTime(oJsonParam.getDispatchLeadTime());
|
|
|
+ model.setCreatorId(oJsonParam.getCreatorId());
|
|
|
+ model.setCreateTime(TimeTool.getCurMsUTC());
|
|
|
+ model.setCycles(oJsonParam.getCycles());
|
|
|
+ model.setZoneId(oJsonParam.getZoneId());
|
|
|
+ //TODO 开始计算时间字段并设置
|
|
|
+ Long lastTakeTime = 0L;
|
|
|
+ Long nextTakeTime = 0L;//下一次生效时间
|
|
|
+ //TODO 分是否排班
|
|
|
+ if(!CollectionUtils.isEmpty(oJsonParam.getItemsList())){
|
|
|
+ List<JPDispatchCmdBatchItem> newList = oJsonParam.getItemsList().stream()
|
|
|
+ .sorted(Comparator.comparing(JPDispatchCmdBatchItem::getHandleStartTime))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(model.getPlanType()==0) {
|
|
|
+ //TODO 临时计划
|
|
|
+ Instant nowTime = Instant.ofEpochMilli(
|
|
|
+ TimeTool.convertDateStr2UTC
|
|
|
+ (
|
|
|
+ JSONArray.parseArray(model.getCycles()).getString(0)
|
|
|
+ +" "+
|
|
|
+ newList.get(0).getHandleStartTime()));
|
|
|
+ if(model.getDispatchLeadTime()==0) {
|
|
|
+ nextTakeTime = nowTime.toEpochMilli();
|
|
|
+ }else if(model.getDispatchLeadTime()>0){
|
|
|
+ nextTakeTime = nowTime.minus(-model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }else if(model.getDispatchLeadTime()<0){
|
|
|
+ nextTakeTime = nowTime.minus(model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }
|
|
|
+ }else if(model.getPlanType()==1){
|
|
|
+ //TODO 日计划
|
|
|
+ Instant nowTime = Instant.ofEpochMilli(
|
|
|
+ TimeTool.convertDateStr2UTC
|
|
|
+ (JSONArray.parseArray(
|
|
|
+ model.getCycles()+" "+newList.get(0).getHandleStartTime()).get(0).toString()));
|
|
|
+ if(model.getDispatchLeadTime()==0) {
|
|
|
+ nextTakeTime = nowTime.toEpochMilli();
|
|
|
+ }else if(model.getDispatchLeadTime()>0){
|
|
|
+ nextTakeTime = nowTime.minus(-model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }else if(model.getDispatchLeadTime()<0){
|
|
|
+ nextTakeTime = nowTime.minus(model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }
|
|
|
+ }else if(model.getPlanType()==2){
|
|
|
+ //TODO 周计划
|
|
|
+ //TODO 先取周期值里最小的数,新集合里最小的值就是最早的周几数
|
|
|
+ JSONArray newJSONArray = JSONArray.parseArray(model.getCycles()).stream().sorted(
|
|
|
+ // 根据
|
|
|
+ Comparator.comparingLong(
|
|
|
+ e -> Long.valueOf(e.toString())
|
|
|
+ )
|
|
|
+ // 放开下面的注释,使用reversed()方法,就是降序 大到小
|
|
|
+ // .reversed()
|
|
|
+ ).collect(Collectors.toCollection(JSONArray::new));
|
|
|
+
|
|
|
+ //TODO dayOfWeekInt 为当前时间的星期几
|
|
|
+ DayOfWeek dayOfWeek = LocalDateTime.now().getDayOfWeek();
|
|
|
+ Integer dayOfWeekInt = dayOfWeek.getValue();
|
|
|
+
|
|
|
+ if(newJSONArray!=null&&!newJSONArray.isEmpty()) {
|
|
|
+ //TODO 三种情况,小于等于最小值取最小(大于最大值也取最小),大于区间最小值和小于等于区间最大值(取区间最大值),大于最大值,则取下周的最小值日期
|
|
|
+ for (int i = 0; i < newJSONArray.size(); i++) {
|
|
|
+ LocalDate newResult = null;
|
|
|
+ if (dayOfWeekInt <= newJSONArray.getInteger(0)
|
|
|
+ ||
|
|
|
+ dayOfWeekInt>newJSONArray.getInteger(newJSONArray.size()-1)) {
|
|
|
+ //TODO 那么下次生效时间为本周期最小值的日期
|
|
|
+ LocalDate result = LocalDate.now().with(DayOfWeek.of(newJSONArray.getInteger(0)));
|
|
|
+ newResult = result; // 返回指定的星期几的日期
|
|
|
+ } else if (dayOfWeekInt > newJSONArray.getInteger(i) && dayOfWeekInt <= newJSONArray.getInteger(i + 1)) {
|
|
|
+ //TODO 循环到此处不会报错, 因为如果为7的话 ,循环的i+1只会增加到6,不会到7
|
|
|
+ //TODO 那么下次生效时间为该区间的最大值
|
|
|
+ LocalDate result = LocalDate.now().with(DayOfWeek.of(newJSONArray.getInteger(i + 1))); // 将日期调整到本周的周一
|
|
|
+ newResult = result; // 返回指定的星期几的日期
|
|
|
+ }else if(dayOfWeekInt > newJSONArray.getInteger(newJSONArray.size()-1)){
|
|
|
+ //TODO 说明当前天已不再设置范围内,则取下一周的最小星期数日期
|
|
|
+ LocalDate result = LocalDate.now().minusWeeks(-1).with(DayOfWeek.of(newJSONArray.getInteger(0))); // 将日期调整到下周的指定星期几
|
|
|
+ newResult = result;
|
|
|
+ }
|
|
|
+ if (newResult!=null) {
|
|
|
+ Instant nowTime = Instant.ofEpochMilli(
|
|
|
+ TimeTool.convertDateStr2UTC
|
|
|
+ (JSONArray.parseArray(
|
|
|
+ newResult.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
|
|
+ + " " +
|
|
|
+ newList.get(0).getHandleStartTime()).get(0).toString()));
|
|
|
+ if (model.getDispatchLeadTime() == 0) {
|
|
|
+ nextTakeTime = nowTime.toEpochMilli();
|
|
|
+ } else if (model.getDispatchLeadTime() > 0) {
|
|
|
+ nextTakeTime = nowTime.minus(-model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ } else if (model.getDispatchLeadTime() < 0) {
|
|
|
+ nextTakeTime = nowTime.minus(model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(model.getPlanType()==3){
|
|
|
+ //TODO 月计划
|
|
|
+ JSONArray newJSONArray = JSONArray.parseArray(model.getCycles()).stream().sorted(
|
|
|
+ // 根据
|
|
|
+ Comparator.comparingLong(
|
|
|
+ e -> Long.valueOf(e.toString())
|
|
|
+ )
|
|
|
+ // 放开下面的注释,使用reversed()方法,就是降序 大到小
|
|
|
+ // .reversed()
|
|
|
+ ).collect(Collectors.toCollection(JSONArray::new));
|
|
|
+
|
|
|
+ Integer dayOfMonth = LocalDate.now().getDayOfMonth();//当前天号数
|
|
|
+ //TODO 三种情况,小于等于最小值取最小(大于最大值也取最小),大于区间最小值和小于等于区间最大值(取区间最大值),大于最大值则取下个月的最小日期
|
|
|
+ for (int i = 0; i < newJSONArray.size(); i++) {
|
|
|
+ LocalDate newResult = null;
|
|
|
+ if (dayOfMonth <= newJSONArray.getInteger(0)){
|
|
|
+ //TODO 如果设置的值大于当前月的最后一天
|
|
|
+ if(newJSONArray.getInteger(0)>LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth()){
|
|
|
+ //TODO 说明是想设置最后一天,因此特殊处理一下,避免日期设置报错
|
|
|
+ newResult = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }else{
|
|
|
+ newResult = LocalDate.now().withDayOfMonth(newJSONArray.getInteger(0));
|
|
|
+ }
|
|
|
+ }else if (dayOfMonth > newJSONArray.getInteger(i) && dayOfMonth <= newJSONArray.getInteger(i + 1)) {
|
|
|
+ if(newJSONArray.getInteger(i + 1)>LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth()) {
|
|
|
+ //TODO 说明是想设置最后一天,因此特殊处理一下,避免日期设置报错
|
|
|
+ newResult = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }else{
|
|
|
+ newResult = LocalDate.now().withDayOfMonth(newJSONArray.getInteger(i+1));
|
|
|
+ }
|
|
|
+ }else if(dayOfMonth > newJSONArray.getInteger(newJSONArray.size()-1)){
|
|
|
+ if(newJSONArray.getInteger(0)>LocalDate.now().minusMonths(-1).with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth()) {
|
|
|
+ //TODO 说明是想设置最后一天,因此特殊处理一下,避免日期设置报错
|
|
|
+ newResult = LocalDate.now().minusMonths(-1).with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }else{
|
|
|
+ newResult = LocalDate.now().minusMonths(-1).withDayOfMonth(newJSONArray.getInteger(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(newResult!=null){
|
|
|
+ Instant nowTime = Instant.ofEpochMilli(
|
|
|
+ TimeTool.convertDateStr2UTC
|
|
|
+ (JSONArray.parseArray(
|
|
|
+ newResult.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
|
|
+ + " " +
|
|
|
+ newList.get(0).getHandleStartTime()).get(0).toString()));
|
|
|
+ if (model.getDispatchLeadTime() == 0) {
|
|
|
+ nextTakeTime = nowTime.toEpochMilli();
|
|
|
+ } else if (model.getDispatchLeadTime() > 0) {
|
|
|
+ nextTakeTime = nowTime.minus(-model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ } else if (model.getDispatchLeadTime() < 0) {
|
|
|
+ nextTakeTime = nowTime.minus(model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(model.getPlanType()==4){
|
|
|
+ //TODO 年计划
|
|
|
+ JSONArray newJSONArray = JSONArray.parseArray(model.getCycles()).stream().sorted(
|
|
|
+ // 根据
|
|
|
+ Comparator.comparing(
|
|
|
+ e -> e.toString()
|
|
|
+ )
|
|
|
+ // 放开下面的注释,使用reversed()方法,就是降序 大到小
|
|
|
+ // .reversed()
|
|
|
+ ).collect(Collectors.toCollection(JSONArray::new));
|
|
|
+
|
|
|
+ LocalDate dateNow = LocalDate.now();//当前日期
|
|
|
+ //TODO 三种情况,小于等于最小值取最小(大于最大值也取最小),大于区间最小值和小于等于区间最大值(取区间最大值),大于最大值则取下个月的最小日期
|
|
|
+ for (int i = 0; i < newJSONArray.size(); i++) {
|
|
|
+ LocalDate newResult = null;
|
|
|
+ //TODO 转换时默认为当前年
|
|
|
+ LocalDate firstDate = LocalDate.parse(LocalDate.now().getYear()+"-"+newJSONArray.getString(0),DateTimeFormatter.ofPattern("MM-dd"));
|
|
|
+ LocalDate nowDate = LocalDate.parse(LocalDate.now().getYear()+"-"+newJSONArray.getString(i),DateTimeFormatter.ofPattern("MM-dd"));
|
|
|
+ LocalDate nowLastDate = LocalDate.parse(LocalDate.now().getYear()+"-"+newJSONArray.getString(i+1),DateTimeFormatter.ofPattern("MM-dd"));
|
|
|
+ LocalDate lastDate = LocalDate.parse(LocalDate.now().getYear()+"-"+newJSONArray.getString(newJSONArray.size()-1),DateTimeFormatter.ofPattern("MM-dd"));
|
|
|
+ if (dateNow.isBefore(firstDate)||dateNow.isEqual(firstDate)){
|
|
|
+ newResult = firstDate;
|
|
|
+ }else if (dateNow.isAfter(nowDate) && (dateNow.isBefore(nowLastDate) || dateNow.isEqual(nowLastDate) )) {
|
|
|
+ newResult = nowLastDate;
|
|
|
+ }else if(dateNow.isAfter(lastDate)){
|
|
|
+ //TODO 说明值已为当前时间的过去时,那么设置下一年的时间为生效时间
|
|
|
+ newResult = lastDate.minusYears(-1);
|
|
|
+ }
|
|
|
+ if(newResult!=null){
|
|
|
+ Instant nowTime = Instant.ofEpochMilli(
|
|
|
+ TimeTool.convertDateStr2UTC
|
|
|
+ (JSONArray.parseArray(
|
|
|
+ newResult.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
|
|
+ + " " +
|
|
|
+ newList.get(0).getHandleStartTime()).get(0).toString()));
|
|
|
+ if (model.getDispatchLeadTime() == 0) {
|
|
|
+ nextTakeTime = nowTime.toEpochMilli();
|
|
|
+ } else if (model.getDispatchLeadTime() > 0) {
|
|
|
+ nextTakeTime = nowTime.minus(-model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ } else if (model.getDispatchLeadTime() < 0) {
|
|
|
+ nextTakeTime = nowTime.minus(model.getDispatchLeadTime(), ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 如果当前时间与下次生效时间是同一天,但是时刻已经是过去时,那么则返回失败信息
|
|
|
+ Long nowTimeLong = TimeTool.getCurMsUTC();
|
|
|
+ if(nowTimeLong>nextTakeTime&&isSameDay(nowTimeLong,nextTakeTime)){
|
|
|
+ return ResponseCode.STATUS_ERROR_JSON_FORMAT;
|
|
|
+ }
|
|
|
+
|
|
|
+ model.setLastTakeTime(lastTakeTime);
|
|
|
+ model.setNextTakeTime(nextTakeTime);
|
|
|
+ model.setTakes(0);
|
|
|
+ model.setErrors("");
|
|
|
+ model.setSendway(oJsonParam.getSendway());
|
|
|
+ model.setChufaRulsFlag(oJsonParam.getChufaRulsFlag());
|
|
|
+
|
|
|
+ ResponseCode insertRes = getThisDBService().insertPlanInfoByCount(model,oJsonParam.getRulesList(),
|
|
|
+ oJsonParam.getTagsList(),oJsonParam.getItemsList());
|
|
|
+ return insertRes;
|
|
|
+ }catch(Exception ex){
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mStrClassName, mStrClassName
|
|
|
+ ,String.format("insert planInfo errorMsg:%s end<====",
|
|
|
+ ex.getLocalizedMessage()));
|
|
|
+ return ResponseCode.RESULT_BAD;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean isSameDay(long timestamp1, long timestamp2) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // 确保时区设置正确,以避免因夏令时导致的问题
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
|
+
|
|
|
+ return sdf.format(new Date(timestamp1)).equals(sdf.format(new Date(timestamp2)));
|
|
|
+ }
|
|
|
}
|