Browse Source

目标考评修改

wangchangsheng 1 year ago
parent
commit
b283806cc3

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationRevisionController.java

@@ -113,7 +113,7 @@ public class EvaluationRevisionController {
 	 */
 	@GetMapping(value = "/details/{deptResponsibilityId}")
 	public R details(@PathVariable String deptResponsibilityId) {
-		Map<String, List<ResponsibilityIndicatorInfoResDTO>> map = responsibilityIndicatorInfoService.selectResponsibilityIndicatorInfoList(deptResponsibilityId, null, "有效");
+		Map<Object, List<ResponsibilityIndicatorInfoResDTO>> map = responsibilityIndicatorInfoService.selectResponsibilityIndicatorInfoList(deptResponsibilityId, null, "有效");
 		return R.ok().data(map);
 	}
 

+ 25 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/ResponsibilityIndicatorInfoController.java

@@ -1,6 +1,7 @@
 package com.ims.eval.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.OrganizationEvaluationInfo;
 import com.ims.eval.entity.ResponsibilityIndicatorInfo;
@@ -220,4 +221,28 @@ public class ResponsibilityIndicatorInfoController {
 
 
 
+
+	/**
+	 * 批量修改
+	 *
+	 * @param jsonObjects
+	 * @return
+	 */
+	@PostMapping(value = "/updateResponsibilityInfo")
+	@ApiOperation(value = "批量新增(修改)", notes = "批量新增(修改)")
+	public R updateResponsibilityIndicatorInfo(@RequestBody List<JSONObject> jsonObjects) {
+
+		try {
+			boolean b = responsibilityIndicatorInfoService.updateResponsibilityIndicatorInfo(jsonObjects);
+			if (b) {
+				return R.ok().data(b);
+			} else {
+				return R.error().data("保存失败!");
+			}
+		} catch (Exception e) {
+			log.error("错误", e);
+			return R.customError(e.getMessage()).data("失败!");
+		}
+	}
+
 }

+ 7 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/dao/ResponsibilityIndicatorInfoMapper.java

@@ -31,7 +31,13 @@ public interface ResponsibilityIndicatorInfoMapper extends BaseMapper<Responsibi
 	List<ResponsibilityIndicatorInfoResDTO> selectResponsibilityIndicatorInfoList(@Param("deptResponsibilityId") String deptResponsibilityId, @Param("isQuantified") String isQuantified, @Param("dataState") String dataState);
 
 
-	List<Map> selectResponsibilityIndicatorList(@Param("responsibilityId") String organizationEvaluationId,
+	List<Map> selectResponsibilityIndicatorList(@Param("responsibilityId") String responsibilityId,
 												@Param("binSection") String binSection,
 												@Param("binStage") String binStage);
+
+	List<ResponsibilityIndicatorInfoResDTO> getResponsibilityInfoList(@Param("responsibilityId") String responsibilityId,
+																	  @Param("indicatorId") String indicatorId,
+																	  @Param("organizationShortName") String organizationShortName,
+																	  @Param("binSection") String binSection,
+																	  @Param("binStage") String binStage);
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/response/DeptResponsibilityResDTO.java

@@ -14,5 +14,5 @@ public class DeptResponsibilityResDTO extends DeptResponsibility {
 
 
 	//明细
-	Map<String, List<ResponsibilityIndicatorInfoResDTO>> map;
+	Map<Object, List<ResponsibilityIndicatorInfoResDTO>> map;
 }

+ 6 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/response/IndicatorResDTO.java

@@ -21,6 +21,12 @@ public class IndicatorResDTO {
 
 
 	/**
+	 * 指标name
+	 */
+	private String indicatorName;
+
+
+	/**
 	 * 选项编码
 	 */
 	private String optionCode;

+ 12 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/response/ResponsibilityIndicatorInfoResDTO.java

@@ -29,7 +29,12 @@ public class ResponsibilityIndicatorInfoResDTO {
 	/**
 	 * 能否量化
 	 */
-	private String isQuantified;
+	private Boolean isQuantified;
+
+	/**
+	 * 子指标code
+	 */
+	private String childCode;
 
 	/**
 	 * 业务阶段
@@ -64,6 +69,12 @@ public class ResponsibilityIndicatorInfoResDTO {
 	private String  organizationShortName;
 
 	/**
+	 * 组织编码
+	 */
+	private String  organizationId;
+
+
+	/**
 	 * 组织规则id
 	 */
 	private String organizationEvaluationRuleId;

+ 4 - 3
ims-service/ims-eval/src/main/java/com/ims/eval/service/IResponsibilityIndicatorInfoService.java

@@ -1,5 +1,6 @@
 package com.ims.eval.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.ims.eval.entity.ResponsibilityIndicatorInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ims.eval.entity.dto.request.ResponsibilityIndicatorInfoUpdateDTO;
@@ -22,11 +23,11 @@ import java.util.Map;
 public interface IResponsibilityIndicatorInfoService extends IService<ResponsibilityIndicatorInfo> {
 
 
-	Map<String  ,List<ResponsibilityIndicatorInfoResDTO>> planValueList(List<String> deptResponsibilityIds, String dept, HttpServletRequest request);
+	Map<Object  ,List<ResponsibilityIndicatorInfoResDTO>> planValueList(List<String> deptResponsibilityIds, String dept, HttpServletRequest request);
 
 
 
-	Map<String  ,List<ResponsibilityIndicatorInfoResDTO>> selectResponsibilityIndicatorInfoList(String deptResponsibilityId, String isQuantified, String dataState);
+	Map<Object  ,List<ResponsibilityIndicatorInfoResDTO>> selectResponsibilityIndicatorInfoList(String deptResponsibilityId, String isQuantified, String dataState);
 
 	boolean saveOrUpdateDto(ResponsibilityIndicatorInfoUpdateDTO infoUpdateDTO);
 
@@ -44,6 +45,6 @@ public interface IResponsibilityIndicatorInfoService extends IService<Responsibi
 
 	Map  getResponsibilityInfoList(String responsibilityId, String indicatorId,String organizationShortName,String binSection,String binStage, HttpServletRequest request);
 
-
+	boolean updateResponsibilityIndicatorInfo(List<JSONObject> jsonObjects);
 
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/DeptResponsibilityServiceImpl.java

@@ -246,7 +246,7 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 	public DeptResponsibilityResDTO getByidAndInfo(String id, String dept, HttpServletRequest request) {
 		DeptResponsibilityResDTO resDTO = baseMapper.selectById(id);
 
-		Map<String, List<ResponsibilityIndicatorInfoResDTO>> map = responsibilityIndicatorInfoService.planValueList(Arrays.asList(id), dept, request);
+		Map<Object, List<ResponsibilityIndicatorInfoResDTO>> map = responsibilityIndicatorInfoService.planValueList(Arrays.asList(id), dept, request);
 		if (null != resDTO) {
 			resDTO.setMap(map);
 		}

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java

@@ -493,7 +493,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 				//是否量化
 				indicatormap.put("IS_LH_" +d.getChildCode() + "_" + d.getOptionCode(),resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getIsQuantified2()?"1":"2");
 
-				//设置状态
+
 
 			}
 

+ 162 - 16
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/ResponsibilityIndicatorInfoServiceImpl.java

@@ -1,27 +1,30 @@
 package com.ims.eval.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ims.common.utils.Constant;
+import com.ims.eval.cache.CacheContext;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.dao.ResponsibilityIndicatorInfoMapper;
 import com.ims.eval.entity.Indicator;
+import com.ims.eval.entity.OrganizationEvaluationInfo;
 import com.ims.eval.entity.ResponsibilityIndicatorInfo;
 import com.ims.eval.entity.dto.request.ResponsibilityIndicatorInfoUpdateDTO;
+import com.ims.eval.entity.dto.response.IndicatorResDTO;
 import com.ims.eval.entity.dto.response.MyuserResDTO;
+import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
 import com.ims.eval.entity.dto.response.ResponsibilityIndicatorInfoResDTO;
 import com.ims.eval.service.IIndicatorService;
 import com.ims.eval.service.IResponsibilityIndicatorInfoService;
 import com.ims.eval.service.IUserService;
+import com.ims.eval.util.MathCalculatorUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -45,24 +48,24 @@ public class ResponsibilityIndicatorInfoServiceImpl extends ServiceImpl<Responsi
 	private IIndicatorService indicatorService;
 
 	@Override
-	public Map<String, List<ResponsibilityIndicatorInfoResDTO>> planValueList(List<String> deptResponsibilityIds, String dept, HttpServletRequest request) {
+	public Map<Object, List<ResponsibilityIndicatorInfoResDTO>> planValueList(List<String> deptResponsibilityIds, String dept, HttpServletRequest request) {
 
 		List<ResponsibilityIndicatorInfoResDTO> list = baseMapper.listByresponsibilityId(deptResponsibilityIds, dept, "ZRMB", "");//默认获取指定的怎目标
 
-		Map<String, List<ResponsibilityIndicatorInfoResDTO>> map = list.stream().collect(Collectors.groupingBy(ResponsibilityIndicatorInfoResDTO::getIsQuantified));
-		map.put("quantifiedList", map.remove("是"));
-		map.put("nonQuantifiedList", map.remove("否"));
+		Map<Object, List<ResponsibilityIndicatorInfoResDTO>> map = list.stream().collect(Collectors.groupingBy(ResponsibilityIndicatorInfoResDTO::getIsQuantified));
+		map.put("quantifiedList", map.remove(true));
+		map.put("nonQuantifiedList", map.remove(false));
 		return map;
 
 	}
 
 
 	@Override
-	public Map<String, List<ResponsibilityIndicatorInfoResDTO>> selectResponsibilityIndicatorInfoList(String deptResponsibilityId, String isQuantified, String dataState) {
+	public Map<Object, List<ResponsibilityIndicatorInfoResDTO>> selectResponsibilityIndicatorInfoList(String deptResponsibilityId, String isQuantified, String dataState) {
 		List<ResponsibilityIndicatorInfoResDTO> list = baseMapper.selectResponsibilityIndicatorInfoList(deptResponsibilityId, isQuantified, dataState);
-		Map<String, List<ResponsibilityIndicatorInfoResDTO>> map = list.stream().collect(Collectors.groupingBy(ResponsibilityIndicatorInfoResDTO::getIsQuantified));
-		map.put("quantifiedList", map.remove("是"));
-		map.put("nonQuantifiedList", map.remove("否"));
+		Map<Object, List<ResponsibilityIndicatorInfoResDTO>> map = list.stream().collect(Collectors.groupingBy(ResponsibilityIndicatorInfoResDTO::getIsQuantified));
+		map.put("quantifiedList", map.remove(true));
+		map.put("nonQuantifiedList", map.remove(false));
 		return map;
 	}
 
@@ -176,16 +179,159 @@ public class ResponsibilityIndicatorInfoServiceImpl extends ServiceImpl<Responsi
 
 	@Override
 	public List<Map> getResponsibilityIndicatorList(String responsibilityId, String binSection, String binStage, HttpServletRequest request) {
-		List<Map> list = baseMapper.selectResponsibilityIndicatorList(responsibilityId, binSection, binStage);
-		return list;
+
+		//判断是否是(重点专项和管理事项)
+		List<Map> indicatorMap = new ArrayList<>();
+		if("ZDZX".equals(CacheContext.bseIdObject.get(binStage).getStageCode()) || "GLSX".equals(CacheContext.bseIdObject.get(binStage).getStageCode())){
+
+			List<Indicator> indicatorList = indicatorService.listAll("","","",binSection,binStage,"","");
+			if(null != indicatorList && indicatorList.size()>0){
+				for (Indicator i : indicatorList){
+					Map map = new HashMap();
+					map.put("id",i.getId());
+					map.put("indicator_name",i.getIndicatorName());
+					indicatorMap.add(map);
+				}
+			}
+
+		}else{
+			indicatorMap = baseMapper.selectResponsibilityIndicatorList(responsibilityId, binSection, binStage);
+		}
+
+		return indicatorMap;
 	}
 
 	@Override
 	public Map getResponsibilityInfoList(String responsibilityId, String indicatorId, String organizationShortName, String binSection, String binStage, HttpServletRequest request) {
+		Map data = new HashMap();
+		//设置数据头
+		//获取指标名称
+
+		boolean titlemark = true;//标记生成标题
+
+		List<Map> indicatorMap  = getResponsibilityIndicatorList(responsibilityId, binSection, binStage,request);
+
+		List<String> idList = indicatorMap.stream()
+			.map(map -> String.valueOf(map.get("id"))) // 提取每个Map中key为"id"的值,并转换成String
+			.collect(Collectors.toList()); // 将提取的值收集到List中
+		if(null == idList || idList.size()<=0){
+				throw  new CustomException("未查询导数据");
+		}
+		List<IndicatorResDTO> indicatorResDTOS = indicatorService.getGroupChildCodeByIds(idList);
+
+		//根据指标id和指标名分组
+		Map<String, List<IndicatorResDTO>> groupedMap = indicatorResDTOS.stream()
+			.collect(Collectors.groupingBy(dto -> dto.getIndicatorId() + "," + dto.getIndicatorName())); // 根据indicatorId和indicatorName进行分组
+
+		if (titlemark) {
+			// 遍历分组后的Map
+			Map title = new LinkedHashMap();//保存所有的指标名
+			for (Map.Entry<String, List<IndicatorResDTO>> entry : groupedMap.entrySet()) {
+
+				List<IndicatorResDTO> groupedList = entry.getValue(); // 获取分组后的List
+				if(null == groupedList || groupedList.size()<=0){
+					continue;
+				}
+				// 进一步处理每个分组
+				List<Map> titleArray = new ArrayList<>();
+				for (IndicatorResDTO dto : groupedList) {
+					// 处理每个分组中的元素
+					Map titlemap = new LinkedHashMap();
+					titlemap.put("childName",dto.getChildName());//子指标名
+					titlemap.put("key", dto.getOptionName());//名称
+					titlemap.put("code",dto.getChildCode()+"_"+dto.getOptionCode());//名称
+					titlemap.put("flag", dto.getIsQuantified());//是否量化
+					titleArray.add(titlemap);
+				}
+				title.put(entry.getKey().split(",")[1], titleArray);
+			}
+
+			data.put("title",title);
+			titlemark = false;
+		}
+
+
 		//获取数据
-		//
+		List<Map> datamapList = new ArrayList<>();
+		List<ResponsibilityIndicatorInfoResDTO> dataList = baseMapper.getResponsibilityInfoList(responsibilityId, indicatorId,organizationShortName, binSection, binStage);
+
+		Map<String, List<ResponsibilityIndicatorInfoResDTO>> groupeddataMap = dataList.stream().collect(Collectors.groupingBy(ResponsibilityIndicatorInfoResDTO::getOrganizationId)); // 根据organizationId进行分组
 
-		return null;
+		// 遍历分组后的Map
+		for (Map.Entry<String, List<ResponsibilityIndicatorInfoResDTO>> entry : groupeddataMap.entrySet()) {
+			List<ResponsibilityIndicatorInfoResDTO> groupedList = entry.getValue(); // 获取分组后的List
+
+
+			Map<String, ResponsibilityIndicatorInfoResDTO> resultMap = groupedList.stream()
+				.collect(Collectors.toMap(
+					dto -> dto.getChildCode() + "_" + dto.getOptionCode(),
+					dto -> dto,
+					(oldValue, newValue) -> oldValue)); // 解决键重复的情况
+
+
+			Map indicatormap = new HashMap();
+			// 进一步处理每个分组
+			for (IndicatorResDTO d : indicatorResDTOS) {
+				boolean mark = true;//标记给公司名赋值
+				if (mark) {
+					indicatormap.put("organizationShortName", resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getOrganizationShortName());//公司名
+					indicatormap.put("organizationId", resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getOrganizationId());//公司id
+					indicatormap.put("state",resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getState());
+					indicatormap.put("IS_LH_state","3");
+					mark = false;
+				}
+				//指标属性
+				indicatormap.put(d.getChildCode() + "_" + d.getOptionCode(), null == resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getNonQuantifiedValue() ? "" : resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getNonQuantifiedValue());
+				//指标id
+				indicatormap.put("ID_" + d.getChildCode() + "_" + d.getOptionCode(), resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getId());
+				//是否量化
+				indicatormap.put("IS_LH_" +d.getChildCode() + "_" + d.getOptionCode(),resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getIsQuantified()?"1":"2");
+			}
+			datamapList.add(indicatormap);
+		}
+
+		data.put("value", datamapList);
+		return data;
 	}
 
+
+	@Override
+	public boolean updateResponsibilityIndicatorInfo(List<JSONObject> jsonObjects) {
+
+		for (JSONObject json :jsonObjects){
+
+			Map<String,Object > idMap = new HashMap();
+			Map valueMap =  new HashMap();
+			for (String key : json.keySet()) {
+				Object value = json.get(key);
+				if(key.startsWith("ID_")){
+					idMap.put(key,value);
+				}else {
+					valueMap.put(key,value);
+				}
+			}
+
+			List<ResponsibilityIndicatorInfo> responsibilityInfos =new ArrayList<>();
+			for (Map.Entry<String,Object > entry : idMap.entrySet()) {
+				ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+				info.setId(entry.getValue().toString());
+				String quantified = valueMap.get(entry.getKey().replace("ID_","IS_LH_")).toString();
+				if ("1".equals(quantified)) {
+
+					if (MathCalculatorUtil.isNumber(String.valueOf(valueMap.get(entry.getKey().replace("ID_", "")).toString()))) {
+						info.setQuantifiedValue(Double.valueOf(valueMap.get(entry.getKey().replace("ID_", "")).toString()));
+					} else {
+						info.setQuantifiedValue(0);
+					}
+				}
+
+				info.setNonQuantifiedValue(valueMap.get(entry.getKey().replace("ID_","")).toString());
+				info.setState(valueMap.get("state").toString());//
+				responsibilityInfos.add(info);
+			}
+			return  this.saveOrUpdateBatch(responsibilityInfos);
+		}
+
+		return false;
+	}
 }

+ 2 - 1
ims-service/ims-eval/src/main/resources/mappers/IndicatorMapper.xml

@@ -176,6 +176,7 @@
         SELECT
         d.id,
         d.indicator_id,
+        i.indicator_name,
         d.option_code,
         d.option_name,
         d.is_quantified,
@@ -190,7 +191,7 @@
                 AND i.id in
                 <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
             </if>
-            and d.option_code in ('JHZ','WCZ','MBZ')
+            and d.option_code in ('JHZ','DBZ','MBZ')
         </where>
     </select>
 

+ 60 - 1
ims-service/ims-eval/src/main/resources/mappers/ResponsibilityIndicatorInfoMapper.xml

@@ -140,7 +140,7 @@
         <where>
 
             <if test="responsibilityId !=null and responsibilityId !=''">
-                and  ri.responsibilityId = #{responsibilityId}
+                and  ri.dept_responsibility_id = #{responsibilityId}
             </if>
 
             <if test="binSection !=null and binSection !=''">
@@ -153,5 +153,64 @@
         </where>
 
     </select>
+    <select id="getResponsibilityInfoList"
+            resultType="com.ims.eval.entity.dto.response.ResponsibilityIndicatorInfoResDTO">
+
+        select
+        ri.id,
+        ri.dept_responsibility_id,
+        ri.option_code,
+        d.option_name,
+        ri.indicator_id,
+        ri.is_quantified,
+        ri.child_code,
+        d.child_name,
+        be.stage_name,
+        be.id binStage,
+        bn.id binSection,
+        bn.section_name,
+        oer.id organizationEvaluationRuleId,
+        oer.organization_name,
+        oer.organization_short_name,
+        oer.organization_id,
+        dd.key_name deptName,
+        it.type_name,
+        i.indicator_name,
+        ri.quantified_value,
+        ri.non_quantified_value,
+        i.unit,
+        ri.state
+        from
+        responsibility_indicator_info ri
+        inner join dept_responsibility dr on dr.id = ri.dept_responsibility_id
+        inner join organization_evaluation_rule oer on oer.id = ri.organization_evaluation_rule_id
+        left join indicator i on ri.indicator_id = i.id
+        left join indicator_dictionary d on ri.indicator_dictionary_id = d.id
+        left join bin_stage be on i.bin_stage = be.id
+        left join bin_section bn on i.bin_section = bn.id
+        left join indicator_type it on i.indicator_type_id = it.id
+        inner join data_dictionary dd on dd.data_key = i.dept_id
+        <where>
+
+            <if test="responsibilityId !=null and responsibilityId !=''">
+                ri.dept_responsibility_id = #{responsibilityId}
+            </if>
+
+            <if test="organizationShortName !=null and organizationShortName !=''">
+                and oer.organization_short_name like #{organizationShortName}
+            </if>
+
+            <if test="binSection !=null and binSection !=''">
+                and bn.id = #{binSection}
+            </if>
+
+            <if test="binStage !=null and binStage !=''">
+                and be.id = #{binStage}
+            </if>
+
+        </where>
+
+        order by oer.organization_id,dd.data_key,i.id desc
+    </select>
 
 </mapper>