|
@@ -7,12 +7,15 @@ import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.slibra.business.domain.*;
|
|
|
import com.slibra.business.mapper.*;
|
|
|
import com.slibra.business.req.ChatReq;
|
|
|
+import com.slibra.business.req.WorkOrderReq;
|
|
|
+import com.slibra.business.res.WorkOrderRes;
|
|
|
import com.slibra.business.res.XinyiDailyFeeSimple;
|
|
|
import com.slibra.business.res.XinyiIndustrySimple;
|
|
|
import com.slibra.business.service.IFrontService;
|
|
|
import com.slibra.common.exception.ServiceException;
|
|
|
import com.slibra.common.utils.DateUtils;
|
|
|
import com.slibra.common.utils.SecurityUtils;
|
|
|
+import com.slibra.common.utils.StringUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +24,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -28,6 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import static com.slibra.common.constant.MyConstants.FORECAST_WARNING_TEMPLATE;
|
|
|
import static com.slibra.common.constant.MyConstants.WARNING_TEMPLATE;
|
|
|
+import static com.slibra.common.utils.DateUtils.getAllDatesBetween;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -102,7 +107,7 @@ public class FrontServiceImpl implements IFrontService {
|
|
|
@Override
|
|
|
public TXinyiChatRecord qaDetailByWarningId(String warningId) {
|
|
|
//2024年5月28日19:10:21 只获取决策的 因为决策和仿真预测是一个接口,所以通过类型区分
|
|
|
- List<TXinyiChatRecord> tXinyiChatRecords = this.xinyiChatRecordMapper.selectTXinyiChatRecordList(TXinyiChatRecord.builder().warningId(warningId).type(1).build());
|
|
|
+ List<TXinyiChatRecord> tXinyiChatRecords = this.xinyiChatRecordMapper.selectTXinyiChatRecordList(TXinyiChatRecord.builder().warningId(warningId).build());
|
|
|
return CollectionUtils.isEmpty(tXinyiChatRecords) ? null : tXinyiChatRecords.get(0);
|
|
|
}
|
|
|
|
|
@@ -157,6 +162,126 @@ public class FrontServiceImpl implements IFrontService {
|
|
|
return xinyiDailyFeeSimple;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义工单接口 获取数据接口
|
|
|
+ * @param workOrderReq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<WorkOrderRes> customWorkOrder(WorkOrderReq workOrderReq) {
|
|
|
+ checkCustomWorkOrder(workOrderReq);
|
|
|
+ //两个日期之间所有的时间-天
|
|
|
+ List<String> allDatesBetween = getAllDatesBetween(LocalDate.parse(workOrderReq.getTimeBegin()), LocalDate.parse(workOrderReq.getTimeEnd()));
|
|
|
+ //返回结果
|
|
|
+ List<WorkOrderRes> result = new ArrayList<>(allDatesBetween.size());
|
|
|
+ for (String date : allDatesBetween) {
|
|
|
+ //查询机器人数据
|
|
|
+ WorkOrderRes workOrderRes = new WorkOrderRes();
|
|
|
+ workOrderRes.setTime(date);
|
|
|
+ TXinyiRobot xinyiRobot = this.xinyiRobotMapper.selectRebotAvgByDate(date);
|
|
|
+ if(!Objects.isNull(xinyiRobot))
|
|
|
+ this.buildRobotData(xinyiRobot, workOrderRes, workOrderReq);
|
|
|
+ //判断数据来源(进出水情况)
|
|
|
+ if(workOrderReq.getType() == 0){// 0:日报 1:工业库(在线仪表)
|
|
|
+ List<TXinyiDaily> tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(date).build());
|
|
|
+ if(!CollectionUtils.isEmpty(tXinyiDailies)){
|
|
|
+ TXinyiDaily tXinyiDaily = tXinyiDailies.get(0);
|
|
|
+ this.buildDailyData(tXinyiDaily, workOrderRes, workOrderReq);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ TXinyiIndustry industry = this.xinyiIndustryMapper.selectIndustryAvgByDate(date);
|
|
|
+ if(!Objects.isNull(industry))
|
|
|
+ this.buildIndustryData(industry, workOrderRes, workOrderReq);
|
|
|
+ }
|
|
|
+ result.add(workOrderRes);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildIndustryData(TXinyiIndustry industry, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
|
|
|
+ if(workOrderReq.getJsSlq())
|
|
|
+ workOrderRes.setJsSlq(industry.getJsSlq());
|
|
|
+ if(workOrderReq.getJsCod())
|
|
|
+ workOrderRes.setJsCod(industry.getJsCod());
|
|
|
+ if(workOrderReq.getJsTn())
|
|
|
+ workOrderRes.setJsTn(industry.getJsTn());
|
|
|
+ if(workOrderReq.getJsTp())
|
|
|
+ workOrderRes.setJsTp(industry.getJsTp());
|
|
|
+ if(workOrderReq.getJsNh3())
|
|
|
+ workOrderRes.setJsNh3(industry.getJsNh3());
|
|
|
+ if(workOrderReq.getJsSs())
|
|
|
+ workOrderRes.setJsSs(industry.getJsSs());
|
|
|
+ if(workOrderReq.getCsSlqc())
|
|
|
+ workOrderRes.setCsSlqc(industry.getCsSlqc());
|
|
|
+ if(workOrderReq.getCsCod())
|
|
|
+ workOrderRes.setCsCod(industry.getCsCod());
|
|
|
+ if(workOrderReq.getCsTn())
|
|
|
+ workOrderRes.setCsTn(industry.getCsTn());
|
|
|
+ if(workOrderReq.getCsTp())
|
|
|
+ workOrderRes.setCsTp(industry.getCsTp());
|
|
|
+ if(workOrderReq.getCsNh3())
|
|
|
+ workOrderRes.setCsNh3(industry.getCsNh3());
|
|
|
+ if(workOrderReq.getCsSs())
|
|
|
+ workOrderRes.setCsSs(industry.getCsSs());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildDailyData(TXinyiDaily tXinyiDaily, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
|
|
|
+ if(workOrderReq.getJsSlq())
|
|
|
+ workOrderRes.setJsSlq(tXinyiDaily.getJSL());
|
|
|
+ if(workOrderReq.getJsCod())
|
|
|
+ workOrderRes.setJsCod(tXinyiDaily.getJsCod());
|
|
|
+ if(workOrderReq.getJsTn())
|
|
|
+ workOrderRes.setJsTn(tXinyiDaily.getJsTn());
|
|
|
+ if(workOrderReq.getJsTp())
|
|
|
+ workOrderRes.setJsTp(tXinyiDaily.getJsTp());
|
|
|
+ if(workOrderReq.getJsNh3())
|
|
|
+ workOrderRes.setJsNh3(tXinyiDaily.getJsNh3());
|
|
|
+ if(workOrderReq.getJsSs())
|
|
|
+ workOrderRes.setJsSs(tXinyiDaily.getJsSs());
|
|
|
+ if(workOrderReq.getCsSlqc())
|
|
|
+ workOrderRes.setCsSlqc(tXinyiDaily.getCSL());
|
|
|
+ if(workOrderReq.getCsCod())
|
|
|
+ workOrderRes.setCsCod(tXinyiDaily.getCsCod());
|
|
|
+ if(workOrderReq.getCsTn())
|
|
|
+ workOrderRes.setCsTn(tXinyiDaily.getCsTn());
|
|
|
+ if(workOrderReq.getCsTp())
|
|
|
+ workOrderRes.setCsTp(tXinyiDaily.getCsTp());
|
|
|
+ if(workOrderReq.getCsNh3())
|
|
|
+ workOrderRes.setCsNh3(tXinyiDaily.getCsNh3());
|
|
|
+ if(workOrderReq.getCsSs())
|
|
|
+ workOrderRes.setCsSs(tXinyiDaily.getCsSs());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildRobotData(TXinyiRobot xinyiRobot, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
|
|
|
+ if(workOrderReq.getNo3Hlj1Jqr())
|
|
|
+ workOrderRes.setNo3Hlj1Jqr(xinyiRobot.getNo3Hlj1Jqr());
|
|
|
+ if(workOrderReq.getNo3Hlj2Jqr())
|
|
|
+ workOrderRes.setNo3Hlj2Jqr(xinyiRobot.getNo3Hlj2Jqr());
|
|
|
+ if(workOrderReq.getNh31Jqr())
|
|
|
+ workOrderRes.setNh31Jqr(xinyiRobot.getNh31Jqr());
|
|
|
+ if(workOrderReq.getNh32Jqr())
|
|
|
+ workOrderRes.setNh32Jqr(xinyiRobot.getNh32Jqr());
|
|
|
+ if(workOrderReq.getNo3Qyc1Jqr())
|
|
|
+ workOrderRes.setNo3Qyc1Jqr(xinyiRobot.getNo3Qyc1Jqr());
|
|
|
+ if(workOrderReq.getNo3Qyc2Jqr())
|
|
|
+ workOrderRes.setNo3Qyc2Jqr(xinyiRobot.getNo3Qyc2Jqr());
|
|
|
+ if(workOrderReq.getTpRccJqr())
|
|
|
+ workOrderRes.setTpRccJqr(xinyiRobot.getTpRccJqr());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkCustomWorkOrder(WorkOrderReq workOrderReq) {
|
|
|
+ if(StringUtils.isBlank(workOrderReq.getTimeBegin()) || StringUtils.isBlank(workOrderReq.getTimeEnd()))
|
|
|
+ throw new ServiceException("输入的参数不合法");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 将工业库数据计算出结果
|
|
|
+ * @param xinyiIndustrySimple
|
|
|
+ * @param nowTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private XinyiIndustrySimple calculateData(XinyiIndustrySimple xinyiIndustrySimple, LocalDateTime nowTime) {
|
|
|
LocalDateTime yesterdaySameTime = nowTime.plusDays(-1);
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYYMMDDHH_TS);
|
|
@@ -397,5 +522,9 @@ public class FrontServiceImpl implements IFrontService {
|
|
|
LocalDateTime begin = endTime.plusMinutes(-1);
|
|
|
System.out.println(formatter.format(endTime));
|
|
|
System.out.println(formatter.format(begin));
|
|
|
+
|
|
|
+ LocalDate parse = LocalDate.parse("2024-02-26");
|
|
|
+ System.out.println("parse = " + parse);
|
|
|
+
|
|
|
}
|
|
|
}
|