From a737f0b6a91f286b85071b4ca9d14935b7aeb7cd Mon Sep 17 00:00:00 2001 From: pengjie <17373303529@163.com> Date: Fri, 17 May 2024 16:53:29 +0800 Subject: [PATCH] 1231 --- ...zSpecialOperationFireSafetyController.java | 8 +- .../XzTemporaryElectricitySafeController.java | 96 +++++++++++++++++++ 2 files changed, 100 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzSpecialOperationFireSafetyController.java b/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzSpecialOperationFireSafetyController.java index 22006e3f7..804451be1 100644 --- a/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzSpecialOperationFireSafetyController.java +++ b/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzSpecialOperationFireSafetyController.java @@ -116,10 +116,10 @@ public class XzSpecialOperationFireSafetyController { // if (safetyInformant != null) { // paramMap.put("safetyInformant", safetyInformant.get(0)); // } -// JSONArray assignmentPersonInCharge = paramMap.getJSONArray("assignmentPersonInCharge"); -// if (assignmentPersonInCharge != null) { -// paramMap.put("assignmentPersonInCharge", assignmentPersonInCharge.get(0)); -// } + JSONArray assignmentPersonInCharge = paramMap.getJSONArray("assignmentPersonInCharge"); + if (assignmentPersonInCharge != null) { + paramMap.put("assignmentPersonInCharge", assignmentPersonInCharge.get(0)); + } JSONArray jobApplicationUnit = paramMap.getJSONArray("jobApplicationUnit"); if (jobApplicationUnit != null) { paramMap.put("jobApplicationUnit", jobApplicationUnit.get(0)); diff --git a/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzTemporaryElectricitySafeController.java b/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzTemporaryElectricitySafeController.java index 9ebb7ed6f..62a0de588 100644 --- a/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzTemporaryElectricitySafeController.java +++ b/src/main/java/com/zhgd/xmgl/modules/xz/special/controller/XzTemporaryElectricitySafeController.java @@ -1,5 +1,12 @@ package com.zhgd.xmgl.modules.xz.special.controller; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.zhgd.xmgl.modules.xz.special.entity.XzGasAnalyze; +import com.zhgd.xmgl.modules.xz.special.entity.XzSpecialOperationFireSafety; import com.zhgd.xmgl.modules.xz.special.entity.XzTemporaryElectricitySafe; import com.zhgd.xmgl.modules.xz.special.service.IXzTemporaryElectricitySafeService; import io.swagger.annotations.Api; @@ -7,6 +14,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiImplicitParams; +import java.util.ArrayList; import java.util.HashMap; import springfox.documentation.annotations.ApiIgnore; @@ -78,6 +86,94 @@ public class XzTemporaryElectricitySafeController { return Result.ok(); } + /** + * 添加 + * + * @param paramMap + * @return + */ + @ApiOperation(value = "添加星纵-临时用电安全作业票信息", notes = "添加星纵-临时用电安全作业票信息", httpMethod = "POST") + @PostMapping(value = "/save") + public Result save(@RequestBody @Validate JSONObject paramMap) { + log.info("临时用电安全作业票信息同步" + paramMap); + JSONArray workExecutionBeginTime = paramMap.getJSONArray("workExecutionBeginTime"); + if (workExecutionBeginTime != null) { + String begin = workExecutionBeginTime.getString(0); + String end = workExecutionBeginTime.getString(0); + paramMap.put("workExecutionBeginTime", DateUtil.parse(begin + ":00", DatePattern.NORM_DATETIME_FORMAT)); + paramMap.put("workExecutionEndTime", DateUtil.parse(end + ":00", DatePattern.NORM_DATETIME_FORMAT)); + } + JSONArray jobApplicationUnit = paramMap.getJSONArray("jobApplicationUnit"); + if (jobApplicationUnit != null) { + paramMap.put("jobApplicationUnit", jobApplicationUnit.get(0)); + } + String [] param = {"combustibleGasAnalysis", "analysePlace", "analysePerson"}; + JSONArray analyseInfo = paramMap.getJSONArray("analysePlace"); + if (analyseInfo != null) { + for (int i = 0; i < analyseInfo.size(); i++) { + JSONObject j = analyseInfo.getJSONObject(i); + int k = 0; + for (String s : j.keySet()) { + paramMap.put(param[k], j.get(s)); + k++; + } + } + } + + String [] param1 = {"result", "time"}; + JSONArray analyse = JSONArray.parseArray(JSON.toJSONString(paramMap.get("combustibleGasAnalysis"))); + JSONArray combustibleGasAnalysis = new JSONArray(); + if (analyse != null) { + for (int i = 0; i < analyse.size(); i++) { + JSONObject detailObj = new JSONObject(); + JSONObject j = analyse.getJSONObject(i); + int k = 0; + for (String s : j.keySet()) { + detailObj.put(param1[k], j.get(s)); + k++; + } + combustibleGasAnalysis.add(detailObj); + } + } + paramMap.put("combustibleGasAnalysis", JSON.toJSONString(combustibleGasAnalysis)); + + String [] param2 = {"name", "flag"}; + JSONArray safeMeasures = paramMap.getJSONArray("safeMeasure"); + JSONArray safeMeasure = new JSONArray(); + if (safeMeasures != null) { + for (int i = 0; i < safeMeasures.size(); i++) { + JSONObject detailObj = new JSONObject(); + JSONObject j = safeMeasures.getJSONObject(i); + int k = 0; + for (String s : j.keySet()) { + detailObj.put(param2[k], j.get(s)); + k++; + } + safeMeasure.add(detailObj); + } + } + paramMap.put("safeMeasure", JSON.toJSONString(safeMeasure)); + String [] param3 = {"content", "person"}; + JSONArray otherSafeMeasures = paramMap.getJSONArray("otherSafeMeasure"); + JSONArray otherSafeMeasure = new JSONArray(); + if (otherSafeMeasures != null) { + for (int i = 0; i < otherSafeMeasures.size(); i++) { + JSONObject detailObj = new JSONObject(); + JSONObject j = otherSafeMeasures.getJSONObject(i); + int k = 0; + for (String s : j.keySet()) { + detailObj.put(param3[k], j.get(s)); + k++; + } + otherSafeMeasure.add(detailObj); + } + } + paramMap.put("otherSafeMeasure", JSON.toJSONString(otherSafeMeasure)); + XzTemporaryElectricitySafe xzTemporaryElectricitySafe = JSONObject.parseObject(JSON.toJSONString(paramMap), XzTemporaryElectricitySafe.class); + xzTemporaryElectricitySafeService.add(xzTemporaryElectricitySafe); + return Result.ok(); + } + /** * 编辑 *