From 4f2c5503851eb6a02fedcb7ddc9f35702550810c Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期五, 06 十月 2023 11:24:47 +0800
Subject: [PATCH] 厂区介绍添加
---
ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java | 13 ++++
ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java | 37 ++++++++++++
ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java | 94 +++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+), 0 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java b/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java
new file mode 100644
index 0000000..79c72dc
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java
@@ -0,0 +1,37 @@
+package com.ruoyi.statistical.controller;
+
+import com.ruoyi.statistical.service.StatisticalService;
+import com.ruoyi.utils.result.Results;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+/**
+ * @author Administrator
+ */
+@RestController
+@RequestMapping("statistical")
+@Api(tags = "鏁版嵁缁熻")
+public class StatisticalController {
+
+ @Resource
+ private StatisticalService statisticalService;
+
+ /**
+ * 鍘傚尯浠嬬粛瀛樺偍
+ */
+ @PreAuthorize("@ss.hasPermi('minio:event:export')")
+ @ApiOperation("鏍规嵁鏉冮檺鑾峰彇璁惧鍒楄〃")
+ @PostMapping("factory/save")
+ public Results factorySave(@RequestBody Map<String,String> map){
+ return statisticalService.factorySave(map);
+ }
+
+}
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java b/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java
new file mode 100644
index 0000000..578b2c4
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java
@@ -0,0 +1,13 @@
+package com.ruoyi.statistical.service;
+
+import com.ruoyi.utils.result.Results;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * @author Administrator
+ */
+public interface StatisticalService {
+ Results factorySave(Map<String,String> map);
+}
diff --git a/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java b/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
new file mode 100644
index 0000000..7b0e13a
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
@@ -0,0 +1,94 @@
+package com.ruoyi.statistical.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
+import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper;
+import com.ruoyi.common.core.domain.entity.SysConfig;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.statistical.service.StatisticalService;
+import com.ruoyi.system.mapper.SysConfigMapper;
+import com.ruoyi.utils.result.Results;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * @author Administrator
+ */
+@Service
+public class StatisticalServiceImpl implements StatisticalService {
+
+ @Autowired
+ private SysConfigMapper sysConfigMapper;
+ @Autowired
+ private ArdAlarmpointsWellMapper wellMapper;
+
+ @Override
+ public Results factorySave(Map<String, String> map) {
+ for (Map.Entry<String, String> entry : map.entrySet()) {
+ //濡傛灉瀛樺湪淇敼
+ SysConfig sysConfigUpd = sysConfigMapper.checkConfigKeyUnique(entry.getKey());
+ if(sysConfigUpd != null){
+ sysConfigUpd.setConfigValue(entry.getValue());
+ sysConfigUpd.setUpdateBy(SecurityUtils.getUsername());
+ sysConfigMapper.updateConfig(sysConfigUpd);
+ }else {
+ //鍚﹀垯鏂板
+ SysConfig sysConfig = new SysConfig();
+ int randomNum = (int) (Math.random() * (1000 - 100 + 1)) + 100;
+ sysConfig.setConfigId((long) randomNum);
+ sysConfig.setConfigType("Y");
+ sysConfig.setCreateBy(SecurityUtils.getUsername());
+ sysConfig.setRemark("鍘傚尯浠嬬粛");
+ if ("area".equals(entry.getKey())) {
+ sysConfig.setConfigName("鍗犲湴闈㈢Н");
+ sysConfig.setConfigKey(entry.getKey());
+ sysConfig.setConfigValue(entry.getValue());
+ sysConfigMapper.insertConfig(sysConfig);
+ } else if ("store".equals(entry.getKey())) {
+ sysConfig.setConfigName("鍘熷鍦拌川鍌ㄩ噺");
+ sysConfig.setConfigKey(entry.getKey());
+ sysConfig.setConfigValue(entry.getValue());
+ sysConfigMapper.insertConfig(sysConfig);
+ }else if ("people".equals(entry.getKey())) {
+ sysConfig.setConfigName("鍛樺伐");
+ sysConfig.setConfigKey(entry.getKey());
+ sysConfig.setConfigValue(entry.getValue());
+ sysConfigMapper.insertConfig(sysConfig);
+ }else if ("depot".equals(entry.getKey())) {
+ sysConfig.setConfigName("鍚勭被绔欏簱");
+ sysConfig.setConfigKey(entry.getKey());
+ sysConfig.setConfigValue(entry.getValue());
+ sysConfigMapper.insertConfig(sysConfig);
+ }else if ("unit".equals(entry.getKey())) {
+ sysConfig.setConfigName("涓嬭鍗曚綅");
+ sysConfig.setConfigKey(entry.getKey());
+ sysConfig.setConfigValue(entry.getValue());
+ sysConfigMapper.insertConfig(sysConfig);
+ }
+ }
+ }
+ //璁板綍well琛ㄤ腑oil_production涓烘娊娌规満鐨勬暟鎹湁澶氬皯鏉�
+ QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("oil_production","鎶芥补鏈�");
+ int num = wellMapper.selectCount(queryWrapper);
+ SysConfig sysConfigUpd = sysConfigMapper.checkConfigKeyUnique("well");
+ if(sysConfigUpd!=null){
+ sysConfigUpd.setConfigValue(String.valueOf(num));
+ sysConfigUpd.setUpdateBy(SecurityUtils.getUsername());
+ sysConfigMapper.updateConfig(sysConfigUpd);
+ }else {
+ SysConfig sysConfig = new SysConfig();
+ int randomNum = (int) (Math.random() * (1000 - 1 + 1)) + 1;
+ sysConfig.setConfigId((long) randomNum);
+ sysConfig.setConfigType("Y");
+ sysConfig.setConfigName("鎶芥按浜�");
+ sysConfig.setConfigKey("well");
+ sysConfig.setConfigValue(String.valueOf(num));
+ sysConfig.setCreateBy(SecurityUtils.getUsername());
+ sysConfigMapper.insertConfig(sysConfig);
+ }
+ return Results.succeed("娣诲姞鎴愬姛锛�");
+ }
+}
--
Gitblit v1.9.3