|
@@ -19,7 +19,7 @@ import com.shkpr.service.aimodelpower.dto.*;
|
|
|
import com.shkpr.service.aimodelpower.dto.woDispatchPlanModel.*;
|
|
|
import com.shkpr.service.aimodelpower.globalmgr.AsyncTaskQueueMgr;
|
|
|
import com.shkpr.service.aimodelpower.jsonbean.woDispatchPlan.*;
|
|
|
-import javafx.beans.binding.ObjectExpression;
|
|
|
+import com.shkpr.service.aimodelpower.services.ServiceMgrProxy;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@@ -68,11 +68,118 @@ public class WODispatchPlanTmDoBizFun {
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
+ //TODO 判断差值是否小于等于五分钟
|
|
|
+ private static boolean isWithinFiveMinutes(long timestamp1, long timestamp2) {
|
|
|
+ return Math.abs(timestamp1 - timestamp2) <= 5 * 60 * 1000;
|
|
|
+ }
|
|
|
+
|
|
|
private static ResponseCode handleProduceCmd(String planId, long checkTm){
|
|
|
ResponseCode code = ResponseCode.RESULT_BAD;
|
|
|
//通过planId在计划视图中查询指定计划基本信息,进行如下比对:
|
|
|
//若:status==1 && checkTm == next_task_time && batch_total > 0
|
|
|
//则对排班调用接口生成指令工单,否则直接返回
|
|
|
+ Map<String,Object> mapSel = getThisDBService().getOne(planId);
|
|
|
+ if(mapSel!=null&&mapSel.size()>0){
|
|
|
+ DispatchPlanInfoSSModel model = FastJsonUtil.map2Obj(mapSel,DispatchPlanInfoSSModel.class,true);
|
|
|
+ Map<String, Object> andWheres = new HashMap<>();
|
|
|
+ andWheres.put("plan_id", planId);
|
|
|
+ List<DispatchCmdBatchItemModel> itemModels = getItemDBService()
|
|
|
+ .listAllWithsExByDispoal("", "", andWheres, new HashMap<>(), "handle_start_time", "");
|
|
|
+ if(model.getNextTakeTime()!=null&&model.getNextTakeTime()>0L
|
|
|
+ &&model.getPlanStatus()==1
|
|
|
+ &&(checkTm <=model.getNextTakeTime()&&isWithinFiveMinutes(checkTm,model.getNextTakeTime()))
|
|
|
+ &&!CollectionUtils.isEmpty(itemModels)){
|
|
|
+ //TODO 满足以上条件就派发调用远程接口生成指令工单
|
|
|
+ for (DispatchCmdBatchItemModel item:itemModels) {
|
|
|
+ Map<String, Object> planCommandParam = new HashMap<>();
|
|
|
+ planCommandParam.put("type", 1);
|
|
|
+ planCommandParam.put("title", model.getTitle());
|
|
|
+ planCommandParam.put("zoneId", model.getZoneId());
|
|
|
+ planCommandParam.put("zoneType", model.getZoneType());
|
|
|
+ planCommandParam.put("zone", model.getZone());
|
|
|
+ planCommandParam.put("sender", model.getCreatorId());
|
|
|
+ planCommandParam.put("receiver", item.getHeadUserId());
|
|
|
+
|
|
|
+ Long sugBeginTime = 0L;
|
|
|
+
|
|
|
+ if(model.getDispatchLeadTime()<0){
|
|
|
+ sugBeginTime = Instant.ofEpochMilli(model.getNextTakeTime())
|
|
|
+ .plus(Math.abs(model.getDispatchLeadTime()),ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }else if(model.getDispatchLeadTime()==0){
|
|
|
+ sugBeginTime = model.getNextTakeTime();
|
|
|
+ }else if(model.getDispatchLeadTime()>0){
|
|
|
+ sugBeginTime = Instant.ofEpochMilli(model.getNextTakeTime())
|
|
|
+ .minus(Math.abs(model.getDispatchLeadTime()),ChronoUnit.MINUTES).toEpochMilli();
|
|
|
+ }
|
|
|
+ if (sugBeginTime<=0L){
|
|
|
+ //TODO 说明时间错误,将错误拦截在此处不再进行派单动作
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ planCommandParam.put("sugBeginTime",sugBeginTime);
|
|
|
+ String endTimeStr = item.getHandleEndTime();
|
|
|
+ planCommandParam.put("sugEndTime", LocalDateTime.now()
|
|
|
+ .withHour(Integer.valueOf(endTimeStr.split(":")[0]))
|
|
|
+ .withMinute(Integer.valueOf(endTimeStr.split(":")[1]))
|
|
|
+ .withSecond(Integer.valueOf(endTimeStr.split(":")[2])));
|
|
|
+ List<Map<String,Object>> suggestions = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(item.getDispoalModels())){
|
|
|
+ for(DispatchCmdBatchDispoalModel dispoalModel:item.getDispoalModels()) {
|
|
|
+ Map<String, Object> sug = new HashMap<>();
|
|
|
+ sug.put("key", dispoalModel.getKey());
|
|
|
+ sug.put("data", dispoalModel.getData());
|
|
|
+ sug.put("ordering", dispoalModel.getOrdering());
|
|
|
+ sug.put("did", dispoalModel.getDid());
|
|
|
+ sug.put("dname", dispoalModel.getDname());
|
|
|
+ suggestions.add(sug);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ planCommandParam.put("suggestions",FastJsonUtil.toJSON(suggestions));
|
|
|
+ planCommandParam.put("fromSource",planId);
|
|
|
+ planCommandParam.put("level",model.getUrgentLevel());
|
|
|
+ planCommandParam.put("sendway",model.getSendway());
|
|
|
+ planCommandParam.put("remark",model.getDispatchRemark());
|
|
|
+ planCommandParam.put("gis",item.getGis());
|
|
|
+ planCommandParam.put("address",item.getHandleAddress());
|
|
|
+
|
|
|
+ //TODO 调用数据接口
|
|
|
+ try {
|
|
|
+ ResponseRes res = ServiceMgrProxy.getInstance().applyTaskServiceApi().postPlanCommand(planCommandParam);
|
|
|
+ if(ResponseCode.RESULT_NORMAL.equals(res.getRescode())){
|
|
|
+ //TODO 再计算下一次的时间,并且更新至调度计划的数据库
|
|
|
+ Map<String,Object> upPlanUpWhere = new HashMap<>();//修改计划的条件
|
|
|
+ upPlanUpWhere.put("plan_id",model.getPlanId());
|
|
|
+ Map<String,Object> upPlan = new HashMap<>();//要修改的计划
|
|
|
+ DispatchPlanInfoNextTimeModel nextTimeModel = new DispatchPlanInfoNextTimeModel();
|
|
|
+ List<DispatchCmdBatchItemNextTimeModel> itemModelNextTimes = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(itemModels)){
|
|
|
+ for(DispatchCmdBatchItemModel jpItem:itemModels){
|
|
|
+ DispatchCmdBatchItemNextTimeModel dispatchCmdBatchItemNextTimeModel =new DispatchCmdBatchItemNextTimeModel();
|
|
|
+ dispatchCmdBatchItemNextTimeModel.setHandleStartTime(jpItem.getHandleStartTime());
|
|
|
+ itemModelNextTimes.add(dispatchCmdBatchItemNextTimeModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ nextTimeModel.setItemsList(itemModelNextTimes);
|
|
|
+ nextTimeModel.setPlanType(model.getPlanType());
|
|
|
+ nextTimeModel.setDispatchLeadTime(model.getDispatchLeadTime());
|
|
|
+ nextTimeModel.setCycles(model.getCycles());
|
|
|
+ if(model.getPlanType()==0){
|
|
|
+ upPlan.put("next_take_time",0L);
|
|
|
+ }else {
|
|
|
+ upPlan.put("next_take_time", returnNextTakeTime(nextTimeModel));
|
|
|
+ upPlan.put("last_take_time", model.getNextTakeTime());
|
|
|
+ }
|
|
|
+ getThisDBService().updateWiths(upPlan, upPlanUpWhere);
|
|
|
+
|
|
|
+ code = ResponseCode.RESULT_NORMAL;
|
|
|
+ }
|
|
|
+ }catch(Exception ex){
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mStrClassName, mStrClassName
|
|
|
+ ,String.format("check planInfo errorMsg:%s end<====",
|
|
|
+ ex.getLocalizedMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@@ -201,7 +308,7 @@ public class WODispatchPlanTmDoBizFun {
|
|
|
}
|
|
|
try{
|
|
|
Map<String,Object> map = getThisDBService().getOne(oJsonParam.getPlanId());
|
|
|
- if(map!=null||map.keySet().size()>0){
|
|
|
+ if(map!=null||map.size()>0){
|
|
|
DispatchPlanInfoDetailsModel model = FastJsonUtil.map2Obj(map,DispatchPlanInfoDetailsModel.class,true);
|
|
|
if (model!=null) {
|
|
|
//TODO 查询相关联规则和标签
|