15 changed files with 289 additions and 22 deletions
			
			
		@ -0,0 +1,32 @@
					 | 
				
			||||
package com.mh.web.controller.policy; | 
				
			||||
 | 
				
			||||
import com.mh.common.core.controller.BaseController; | 
				
			||||
import com.mh.common.core.page.TableDataInfo; | 
				
			||||
import com.mh.system.service.policy.IPolicyManageService; | 
				
			||||
import org.springframework.web.bind.annotation.GetMapping; | 
				
			||||
import org.springframework.web.bind.annotation.RequestMapping; | 
				
			||||
import org.springframework.web.bind.annotation.RequestParam; | 
				
			||||
import org.springframework.web.bind.annotation.RestController; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author LJF | 
				
			||||
 * @version 1.0 | 
				
			||||
 * @project EEMCS | 
				
			||||
 * @description 策略管理 | 
				
			||||
 * @date 2025-04-01 14:51:48 | 
				
			||||
 */ | 
				
			||||
@RestController | 
				
			||||
@RequestMapping("/policy") | 
				
			||||
public class PolicyManageController extends BaseController { | 
				
			||||
 | 
				
			||||
    private final IPolicyManageService policyManageService; | 
				
			||||
 | 
				
			||||
    public PolicyManageController(IPolicyManageService policyManageService) { | 
				
			||||
        this.policyManageService = policyManageService; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @GetMapping("/list") | 
				
			||||
    public TableDataInfo getPolicyList(@RequestParam(required = false) String systemType, @RequestParam(required = false) String funPolicyType){ | 
				
			||||
        return getDataTable(policyManageService.selectPolicyList(systemType,funPolicyType)); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,92 @@
					 | 
				
			||||
package com.mh.common.core.domain.entity; | 
				
			||||
 | 
				
			||||
import com.baomidou.mybatisplus.annotation.IdType; | 
				
			||||
import com.baomidou.mybatisplus.annotation.TableId; | 
				
			||||
import com.baomidou.mybatisplus.annotation.TableName; | 
				
			||||
import lombok.Getter; | 
				
			||||
import lombok.Setter; | 
				
			||||
import org.apache.commons.lang3.builder.ToStringBuilder; | 
				
			||||
 | 
				
			||||
import java.math.BigDecimal; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author LJF | 
				
			||||
 * @version 1.0 | 
				
			||||
 * @project EEMCS | 
				
			||||
 * @description 策略管理 | 
				
			||||
 * @date 2025-04-01 14:26:31 | 
				
			||||
 */ | 
				
			||||
@Setter | 
				
			||||
@Getter | 
				
			||||
@TableName("policy_manage") | 
				
			||||
public class PolicyManage { | 
				
			||||
 | 
				
			||||
    @TableId(value = "id", type = IdType.ASSIGN_UUID) | 
				
			||||
    private String id; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 策略类型 | 
				
			||||
     */ | 
				
			||||
    private String policyType; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 策略名称 | 
				
			||||
     */ | 
				
			||||
    private String policyName; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 点位名称 | 
				
			||||
     */ | 
				
			||||
    private String pointName; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 输入类型 | 
				
			||||
     */ | 
				
			||||
    private String inputType; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 输入值 | 
				
			||||
     */ | 
				
			||||
    private BigDecimal curValue; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 单位 | 
				
			||||
     */ | 
				
			||||
    private String unit; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 采集点位名称 | 
				
			||||
     */ | 
				
			||||
    private String cpmId; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 系统类型 | 
				
			||||
     */ | 
				
			||||
    private String systemType; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 功能策略类型 | 
				
			||||
     */ | 
				
			||||
    private String funPolicyType; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * 排序 | 
				
			||||
     */ | 
				
			||||
    private int orderNum; | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    public String toString() { | 
				
			||||
        return new ToStringBuilder(this) | 
				
			||||
                .append("id", id) | 
				
			||||
                .append("policyType", policyType) | 
				
			||||
                .append("policyName", policyName) | 
				
			||||
                .append("pointName", pointName) | 
				
			||||
                .append("inputType", inputType) | 
				
			||||
                .append("unit", unit) | 
				
			||||
                .append("cpmId", cpmId) | 
				
			||||
                .append("systemType", systemType) | 
				
			||||
                .append("funPolicyType", funPolicyType) | 
				
			||||
                .toString(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -0,0 +1,26 @@
					 | 
				
			||||
package com.mh.system.mapper.policy; | 
				
			||||
 | 
				
			||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
				
			||||
import com.mh.common.core.domain.entity.PolicyManage; | 
				
			||||
import org.apache.ibatis.annotations.Mapper; | 
				
			||||
import org.apache.ibatis.annotations.Param; | 
				
			||||
import org.apache.ibatis.annotations.Select; | 
				
			||||
 | 
				
			||||
import java.util.List; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author LJF | 
				
			||||
 * @version 1.0 | 
				
			||||
 * @project EEMCS | 
				
			||||
 * @description 策略管理 | 
				
			||||
 * @date 2025-04-01 15:11:28 | 
				
			||||
 */ | 
				
			||||
@Mapper | 
				
			||||
public interface PolicyManageMapper extends BaseMapper<PolicyManage> { | 
				
			||||
 | 
				
			||||
    @Select("select pm.*,cpm.cur_value from policy_manage pm " + | 
				
			||||
            " left join collection_params_manage cpm on pm.cpm_id = cpm.id " + | 
				
			||||
            " where pm.system_type = #{systemType} and pm.fun_policy_type = #{funPolicyType} order by pm.policy_type, pm.order_num ") | 
				
			||||
    List<PolicyManage> selectPolicyList(@Param("systemType") String systemType, | 
				
			||||
                                        @Param("funPolicyType") String funPolicyType); | 
				
			||||
} | 
				
			||||
@ -0,0 +1,14 @@
					 | 
				
			||||
package com.mh.system.service.policy; | 
				
			||||
 | 
				
			||||
import java.util.List; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author LJF | 
				
			||||
 * @version 1.0 | 
				
			||||
 * @project EEMCS | 
				
			||||
 * @description 策略管理 | 
				
			||||
 * @date 2025-04-01 15:04:53 | 
				
			||||
 */ | 
				
			||||
public interface IPolicyManageService { | 
				
			||||
    List<?> selectPolicyList(String systemType, String funPolicyType); | 
				
			||||
} | 
				
			||||
@ -0,0 +1,55 @@
					 | 
				
			||||
package com.mh.system.service.policy.impl; | 
				
			||||
 | 
				
			||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
				
			||||
import com.mh.common.core.domain.dto.DeviceMonitorDTO; | 
				
			||||
import com.mh.common.core.domain.entity.PolicyManage; | 
				
			||||
import com.mh.system.mapper.policy.PolicyManageMapper; | 
				
			||||
import com.mh.system.service.policy.IPolicyManageService; | 
				
			||||
import org.springframework.stereotype.Service; | 
				
			||||
 | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.Comparator; | 
				
			||||
import java.util.List; | 
				
			||||
import java.util.Map; | 
				
			||||
import java.util.stream.Collectors; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author LJF | 
				
			||||
 * @version 1.0 | 
				
			||||
 * @project EEMCS | 
				
			||||
 * @description 策略管理服务实现类 | 
				
			||||
 * @date 2025-04-01 15:05:43 | 
				
			||||
 */ | 
				
			||||
@Service | 
				
			||||
public class PolicyManageServiceImpl implements IPolicyManageService { | 
				
			||||
 | 
				
			||||
    private final PolicyManageMapper policyManageMapper; | 
				
			||||
 | 
				
			||||
    public PolicyManageServiceImpl(PolicyManageMapper policyManageMapper) { | 
				
			||||
        this.policyManageMapper = policyManageMapper; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    public List<?> selectPolicyList(String systemType, String funPolicyType) { | 
				
			||||
//        QueryWrapper<PolicyManage> queryWrapper = new QueryWrapper<>();
 | 
				
			||||
//        queryWrapper.eq("system_type", systemType);
 | 
				
			||||
//        queryWrapper.eq("fun_policy_type", funPolicyType);
 | 
				
			||||
//        queryWrapper.orderByAsc("order_num");
 | 
				
			||||
        List<PolicyManage> policyManages = policyManageMapper.selectPolicyList(systemType, funPolicyType); | 
				
			||||
        // policyManages使用stream流,根据policyType进行数据分组,
 | 
				
			||||
        Map<String, List<PolicyManage>> listMap = policyManages.stream() | 
				
			||||
                // 先按PolicyType排序
 | 
				
			||||
                .sorted(Comparator.comparing(PolicyManage::getPolicyType)) | 
				
			||||
                // 再按PolicyName分组
 | 
				
			||||
                .collect(Collectors.groupingBy(PolicyManage::getPolicyName, Collectors.toList())); | 
				
			||||
        // 在遍历赋值给DeviceMonitorDTO,key给name,value给list
 | 
				
			||||
        List<DeviceMonitorDTO> list = new ArrayList<>(); | 
				
			||||
        listMap.keySet().forEach(k -> { | 
				
			||||
            DeviceMonitorDTO deviceMonitorDTO = new DeviceMonitorDTO(); | 
				
			||||
            deviceMonitorDTO.setName(k); | 
				
			||||
            deviceMonitorDTO.setValues(listMap.get(k)); | 
				
			||||
            list.add(deviceMonitorDTO); | 
				
			||||
        }); | 
				
			||||
        return list; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue