|
@@ -0,0 +1,129 @@
|
|
|
|
+package com.shkpr.service.aimodelpower.controllerapi;
|
|
|
|
+
|
|
|
|
+import com.global.base.log.LogLevelFlag;
|
|
|
|
+import com.global.base.log.LogPrintMgr;
|
|
|
|
+import com.global.base.tools.FastJsonUtil;
|
|
|
|
+import com.shkpr.service.aimodelpower.bizmgr.KprAimWaterCollecationBizFun;
|
|
|
|
+import com.shkpr.service.aimodelpower.commtools.CommTool;
|
|
|
|
+import com.shkpr.service.aimodelpower.commtools.HttpTool;
|
|
|
|
+import com.shkpr.service.aimodelpower.constants.ApiURI;
|
|
|
|
+import com.shkpr.service.aimodelpower.constants.LogFlagBusiType;
|
|
|
|
+import com.shkpr.service.aimodelpower.controllerfilter.TokenAuthenticationService;
|
|
|
|
+import com.shkpr.service.aimodelpower.dto.MsgNotifyBean;
|
|
|
|
+import com.shkpr.service.aimodelpower.dto.ResponseCode;
|
|
|
|
+import com.shkpr.service.aimodelpower.dto.ResponseRes;
|
|
|
|
+import com.shkpr.service.aimodelpower.exception.SelfException;
|
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.zilaishui.JPTbMHourWater;
|
|
|
|
+import com.shkpr.service.aimodelpower.jsonbean.zilaishui.JPTbMWater;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @ClassName WaterCollecationController
|
|
|
|
+ * @Description: TODO 水量预测相关接口
|
|
|
|
+ * @Author LX
|
|
|
|
+ * @Date 2024/5/27
|
|
|
|
+ * @Version V1.0
|
|
|
|
+ **/
|
|
|
|
+@RequestMapping(ApiURI.URI_WATER_ZILAISHUI_H)
|
|
|
|
+@RestController
|
|
|
|
+public class WaterCollecationController {
|
|
|
|
+ final String MSG_SUCCESS = "success.";
|
|
|
|
+ final String MSG_FAILED = "failed.";
|
|
|
|
+ private String mStrClassName;
|
|
|
|
+ private AtomicInteger mSeqNotify = null;
|
|
|
|
+
|
|
|
|
+ public WaterCollecationController() {
|
|
|
|
+ mStrClassName = "WaterCollecationController";
|
|
|
|
+ mSeqNotify = new AtomicInteger(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping(value = ApiURI.URI_WATER_ZILAISHUI_DAY)
|
|
|
|
+ public ResponseRes dayData(HttpServletRequest request
|
|
|
|
+ , @RequestHeader(value= ApiURI.HEADER_CLIENT_TYPE, required=false) String strClientType
|
|
|
|
+ , @RequestHeader(value= ApiURI.HEADER_USER_AGENT, required=false) String strUserAgent) throws Exception{
|
|
|
|
+ final String URI_PATH = request.getRequestURI();
|
|
|
|
+ final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
|
|
|
|
+ final String strUserId = (String)request.getAttribute(TokenAuthenticationService.HEADER_USERID);
|
|
|
|
+ JPTbMWater oJsonParam = FastJsonUtil.fromJSONByGson(HttpTool.getJsonBodyStr(request), JPTbMWater.class);
|
|
|
|
+ if (oJsonParam == null
|
|
|
|
+ || !oJsonParam.checkValid()){
|
|
|
|
+ throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrCode()
|
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
|
+ , strPlatform
|
|
|
|
+ , URI_PATH
|
|
|
|
+ , ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrMsg()));
|
|
|
|
+ }
|
|
|
|
+ long llReqBefore = System.currentTimeMillis();
|
|
|
|
+ String strRunSeq = String.format("%d-%d", llReqBefore, mSeqNotify.incrementAndGet());
|
|
|
|
+
|
|
|
|
+ ResponseRes<String> resResult = new ResponseRes<String>();
|
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
|
+ resResult.setResmsg(MSG_SUCCESS);
|
|
|
|
+ resResult.setResdata("");
|
|
|
|
+
|
|
|
|
+// resResult.setResdata(waterZILAISHUIDao.getCount("WHERE TAG_CODE = 'SPB.SSWD.total_flow1' and QCQUISITION_TIME >= to_date('2023-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')").toString());
|
|
|
|
+ ResponseRes oRes = KprAimWaterCollecationBizFun.selectTbWaterList(oJsonParam);
|
|
|
|
+ if(oRes!=null&&ResponseCode.RESULT_NORMAL.toStrCode().equals(oRes.getRescode())) {
|
|
|
|
+ resResult.setResdata(FastJsonUtil.toJSON(oRes.getResdata()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ resResult.setTimestamp(System.currentTimeMillis());
|
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_INTERNAL.toStrValue(), mStrClassName, strUserId
|
|
|
|
+ ,String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
|
|
|
|
+ ,strPlatform
|
|
|
|
+ ,URI_PATH
|
|
|
|
+ ,strRunSeq
|
|
|
|
+ ,resResult.getRescode()
|
|
|
|
+ ,resResult.getResmsg()
|
|
|
|
+ ,resResult.getTimestamp()-llReqBefore));
|
|
|
|
+ return resResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping(value = ApiURI.URI_WATER_ZILAISHUI_HOUR)
|
|
|
|
+ public ResponseRes hourData(HttpServletRequest request
|
|
|
|
+ , @RequestHeader(value= ApiURI.HEADER_CLIENT_TYPE, required=false) String strClientType
|
|
|
|
+ , @RequestHeader(value= ApiURI.HEADER_USER_AGENT, required=false) String strUserAgent) throws Exception{
|
|
|
|
+ final String URI_PATH = request.getRequestURI();
|
|
|
|
+ final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
|
|
|
|
+ final String strUserId = (String)request.getAttribute(TokenAuthenticationService.HEADER_USERID);
|
|
|
|
+ JPTbMHourWater oJsonParam = FastJsonUtil.fromJSONByGson(HttpTool.getJsonBodyStr(request), JPTbMHourWater.class);
|
|
|
|
+ if (oJsonParam == null
|
|
|
|
+ || !oJsonParam.checkValid()){
|
|
|
|
+ throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrCode()
|
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
|
+ , strPlatform
|
|
|
|
+ , URI_PATH
|
|
|
|
+ , ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrMsg()));
|
|
|
|
+ }
|
|
|
|
+ long llReqBefore = System.currentTimeMillis();
|
|
|
|
+ String strRunSeq = String.format("%d-%d", llReqBefore, mSeqNotify.incrementAndGet());
|
|
|
|
+
|
|
|
|
+ ResponseRes<String> resResult = new ResponseRes<String>();
|
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
|
+ resResult.setResmsg(MSG_SUCCESS);
|
|
|
|
+ resResult.setResdata("");
|
|
|
|
+
|
|
|
|
+// resResult.setResdata(waterZILAISHUIDao.getCount("WHERE TAG_CODE = 'SPB.SSWD.total_flow1' and QCQUISITION_TIME >= to_date('2023-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')").toString());
|
|
|
|
+ ResponseRes oRes = KprAimWaterCollecationBizFun.selectTbHourWaterList(oJsonParam);
|
|
|
|
+ if(oRes!=null&&ResponseCode.RESULT_NORMAL.toStrCode().equals(oRes.getRescode())) {
|
|
|
|
+ resResult.setResdata(FastJsonUtil.toJSON(oRes.getResdata()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ resResult.setTimestamp(System.currentTimeMillis());
|
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_INTERNAL.toStrValue(), mStrClassName, strUserId
|
|
|
|
+ ,String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
|
|
|
|
+ ,strPlatform
|
|
|
|
+ ,URI_PATH
|
|
|
|
+ ,strRunSeq
|
|
|
|
+ ,resResult.getRescode()
|
|
|
|
+ ,resResult.getResmsg()
|
|
|
|
+ ,resResult.getTimestamp()-llReqBefore));
|
|
|
|
+ return resResult;
|
|
|
|
+ }
|
|
|
|
+}
|