aijinhui
2023-10-06 4f2c5503851eb6a02fedcb7ddc9f35702550810c
厂区介绍添加
已添加3个文件
144 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/statistical/controller/StatisticalController.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/statistical/service/StatisticalService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    }
}
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);
}
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("添加成功!");
    }
}