Browse Source

目标责任书功能开发

wangchangsheng 2 years ago
parent
commit
db91330f85

+ 2 - 3
ims-service/ims-eval/src/main/java/com/ims/eval/controller/DeptResponsibilityController.java

@@ -53,12 +53,11 @@ public class DeptResponsibilityController {
 				  @RequestParam(value = "checkCycle", required = false) String checkCycle,
 				  @RequestParam(value = "beginDate", required = false) String beginDate,
 				  @RequestParam(value = "endDate", required = false) String endDate,
-				  @RequestParam(value = "binStage", required = false) String binStage,
 				  @RequestParam(value = "stage", required = false) String stage,
 				  @RequestParam(value = "createBy", required = false) String createBy,
 				  @RequestParam(value = "year", required = false) String year,
 				  @RequestParam(value = "month", required = false) String month) {
-		IPage<DeptResponsibility> list = deptResponsibilityService.list(pageNum, pageSize, id, cycleUnit, checkCycle, beginDate, endDate, binStage, stage, createBy, year, month);
+		IPage<DeptResponsibility> list = deptResponsibilityService.list(pageNum, pageSize, id, cycleUnit, checkCycle, beginDate, endDate, stage, createBy, year, month);
 		return R.ok().data(null);
 	}
 
@@ -102,7 +101,7 @@ public class DeptResponsibilityController {
 									@RequestParam(value = "date", required = false) String date) {
 
 		try {
-			boolean b = false;//  deptResponsibilityService.saveOrUpdate();
+			boolean b = deptResponsibilityService.generateResponsibility(orgEvalRuleId,date);
 			if (b) {
 				return R.ok().data(b);
 			} else {

+ 6 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/IndicatorMapper.java

@@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ims.eval.entity.Indicator;
 import com.ims.eval.entity.OrganizationEvaluationRule;
+import com.ims.eval.entity.dto.response.IndicatorResDTO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  *  Mapper 接口
@@ -28,4 +31,7 @@ public interface IndicatorMapper extends BaseMapper<Indicator> {
 							@Param("company") String company);
 
 
+	List<IndicatorResDTO> selectListByIds(@Param("indicatorIds")List<String> indicatorIds);
+
+
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/DeptResponsibility.java

@@ -56,7 +56,7 @@ public class DeptResponsibility extends Model {
 	private String month;
 
 	/**
-	 * 考评单位规则id
+	 * 考评单位配置id
 	 */
 	private  String organizationEvaluationRuleId;
 

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/Indicator.java

@@ -59,7 +59,7 @@ public class Indicator extends Model {
 	/**
 	 * 是否主子指标
 	 */
-	private boolean isChild;
+	private Boolean isChild;
 
 
 

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/IndicatorType.java

@@ -37,7 +37,7 @@ public class IndicatorType extends Model {
 	/**
 	 * 删除标记
 	 */
-	private boolean delFlag;
+	private Boolean delFlag;
 
     /**
      * 排序

+ 2 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/entity/OrganizationEvaluationRule.java

@@ -103,12 +103,12 @@ public class OrganizationEvaluationRule extends Model {
 	 * 删除标记(false 为未删除,true 为已删除)
 
 	 */
-	private boolean delFlag;
+	private Boolean delFlag;
 
 	/**
 	 * 是否考核(false;未考核;true:以考核)
 	 */
-	private boolean isCheck;
+	private Boolean isCheck;
 
 	/**
 	 * 生产经营权重

+ 49 - 51
ims-service/ims-eval/src/main/java/com/ims/eval/entity/ResponsibilityIndicatorInfo.java

@@ -1,8 +1,6 @@
 package com.ims.eval.entity;
 
-import java.math.BigDecimal;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDateTime;
 import java.util.Date;
 
 import lombok.Data;
@@ -16,73 +14,73 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author wang
- * @since 2023-03-08
+ * @since 2023-03-11
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
 public class ResponsibilityIndicatorInfo extends Model {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    /**
-     * 主键id
-     */
-    private String id;
+	/**
+	 * 主键id
+	 */
+	private String id;
 
-    /**
-     * 责任书id
-     */
-    private String deptResponsibilityId;
+	/**
+	 * 责任书id
+	 */
+	private String deptResponsibilityId;
 
-    /**
-     * 指标名称
-     */
-    private String indicatorName;
+	/**
+	 * 指标ID
+	 */
+	private String indicatorId;
 
-    /**
-     * 指标编码
-     */
-    private String indicatorCode;
+	/**
+	 * 指标编码
+	 */
+	private String indicatorDictionaryId;
 
-    /**
-     * 选项编码
-     */
-    private String optionCode;
+	/**
+	 * 选项编码
+	 */
+	private String optionCode;
 
-    /**
-     * 选项名称
-     */
-    private String optionName;
+	/**
+	 * 能否量化
+	 */
+	private String isQuantified;
 
 	/**
-	 * 量化指标
+	 * 量化值
 	 */
 	private double quantifiedValue;
 
 	/**
-	 * 非量化指标值
+	 * 非量化值
+	 */
+	private String nonQuantifiedValue;
+
+	/**
+	 * 创建时间
+	 */
+	private Date createTime;
+
+	/**
+	 * 创建者
+	 */
+	private String createBy;
+
+	/**
+	 * 更新时间
+	 */
+	private Date updateTime;
+
+	/**
+	 * 更新者
 	 */
-    private String nonQuantifiedValue;
-
-    /**
-     * 创建时间
-     */
-    private Date createTime;
-
-    /**
-     * 创建者
-     */
-    private String createBy;
-
-    /**
-     * 更新时间
-     */
-    private Date updateTime;
-
-    /**
-     * 更新者
-     */
-    private String updateBy;
+	private String updateBy;
 
 	/**
 	 * 备注

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

@@ -0,0 +1,40 @@
+package com.ims.eval.entity.dto.response;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+@Data
+@ApiModel(value="指标关联明细响应类", description="指标关联明细响应类")
+public class IndicatorResDTO {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 指标id
+	 */
+	private String id;
+
+	/**
+	 * 指标id
+	 */
+	private String indicatorDictionaryID;
+
+	/**
+	 * 选项编码
+	 */
+	private String optionCode;
+
+	/**
+	 * 能否量化
+	 */
+	private String isQuantified;
+
+	/**
+	 * 选项名称
+	 */
+	private String optionName;
+
+
+
+
+}

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

@@ -16,7 +16,7 @@ import java.util.List;
  */
 public interface IDeptResponsibilityService extends IService<DeptResponsibility> {
 
-	IPage<DeptResponsibility> list(Integer pageNum, Integer pageSize, String id, String cycleUnit, String checkCycle, String beginDate, String endDate, String binStage, String stage, String createBy, String year, String month);
+	IPage<DeptResponsibility> list(Integer pageNum, Integer pageSize, String id, String cycleUnit, String checkCycle, String beginDate, String endDate, String stage, String createBy, String year, String month);
 
 	List<DeptResponsibility> list( String organizationId, String checkCycle,  String year, String month);
 

+ 4 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IIndicatorService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ims.eval.entity.Indicator;
 import com.ims.eval.entity.IndicatorDictionary;
+import com.ims.eval.entity.dto.response.IndicatorResDTO;
 
 import java.util.List;
 import java.util.Map;
@@ -26,4 +27,7 @@ public interface IIndicatorService extends IService<Indicator> {
 	List<Indicator> listAll(String id, String indicatorName, String indicatorCode, String binSection, String binStage, String dept, String company);
 
 	Indicator selectByCode(String indicatorCode);
+
+	List<IndicatorResDTO> listByIds(List<String> indicatorIds);
+
 }

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

@@ -2,19 +2,21 @@ package com.ims.eval.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ims.common.utils.DateUtils;
 import com.ims.common.utils.StringUtils;
 import com.ims.eval.config.CustomException;
-import com.ims.eval.entity.DeptResponsibility;
+import com.ims.eval.dao.ResponsibilityIndicatorInfoMapper;
+import com.ims.eval.entity.*;
 import com.ims.eval.dao.DeptResponsibilityMapper;
-import com.ims.eval.entity.EvaluateRule;
-import com.ims.eval.entity.EvaluateRuleInfo;
-import com.ims.eval.entity.OrganizationEvaluationRule;
+import com.ims.eval.entity.dto.response.IndicatorResDTO;
 import com.ims.eval.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -36,41 +38,101 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 	/**
 	 * 指标主业务类
 	 */
+	@Autowired
 	private IIndicatorService iIndicatorService;
 
 	/**
 	 * 指标子业务类
 	 */
+	@Autowired
 	private IIndicatorDictionaryService indicatorDictionaryService;
 
 
 	/**
 	 * 单位/部门考评配置业务类
 	 */
-
+	@Autowired
 	private IOrganizationEvaluationRuleService organizationEvaluationRuleService;
 
 	/**
 	 * 考评规则业务类
 	 */
+	@Autowired
 	private IEvaluateRuleService evaluateRuleService;
 
 	/**
 	 * 考评规则明细业务类
 	 */
+	@Autowired
 	private IEvaluateRuleInfoService evaluateRuleInfoService;
 
 
+	@Resource
+	private ResponsibilityIndicatorInfoMapper responsibilityIndicatorInfoMapper;
+
+	@Resource
+	private IResponsibilityIndicatorInfoService responsibilityIndicatorInfoService;
+
 	@Override
-	public IPage<DeptResponsibility> list(Integer pageNum, Integer pageSize, String id, String cycleUnit, String checkCycle, String beginDate, String endDate, String binStage, String stage, String createBy, String year, String month) {
+	public IPage<DeptResponsibility> list(Integer pageNum, Integer pageSize, String id, String cycleUnit, String checkCycle, String beginDate, String endDate,  String stage, String createBy, String year, String month) {
+
+		QueryWrapper<DeptResponsibility>  qw = new QueryWrapper<>();
+		if (null == pageNum || null == pageSize) {
+			throw new CustomException("分页参数为空");
+		}
+		//构造分页构造器
+		Page<DeptResponsibility> page = new Page<>(pageNum, pageSize);
+
+		if (StringUtils.isNotEmpty(id)) {
+			qw.lambda().eq(DeptResponsibility::getId, id);
+		}
+
+		if (StringUtils.isNotEmpty(cycleUnit)) {
+			qw.lambda().like(DeptResponsibility::getCycleUnit, cycleUnit);
+		}
+
+		if (StringUtils.isNotEmpty(checkCycle)) {
+			qw.lambda().like(DeptResponsibility::getCheckCycle, checkCycle);
+		}
+
+		if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate)) {
+			qw.lambda().ge(DeptResponsibility::getBeginDate, beginDate);
+			qw.lambda().le(DeptResponsibility::getEndDate, endDate);
+		}
+
+		if (StringUtils.isNotEmpty(stage)) {
+			qw.lambda().eq(DeptResponsibility::getStage, stage);
+		}
+
+		if (StringUtils.isNotEmpty(createBy)) {
+			qw.lambda().eq(DeptResponsibility::getCreateBy, createBy);
+		}
 
-		return null;
+		if (StringUtils.isNotEmpty(createBy)) {
+			qw.lambda().eq(DeptResponsibility::getCreateBy, createBy);
+		}
+		if (StringUtils.isNotEmpty(year)) {
+			qw.lambda().eq(DeptResponsibility::getYear, year);
+		}
+		if (StringUtils.isNotEmpty(month)) {
+			qw.lambda().eq(DeptResponsibility::getMonth, month);
+		}
+
+		qw.lambda().orderByDesc(DeptResponsibility::getCreateTime);
+
+		IPage<DeptResponsibility> list = baseMapper.selectPage(page, qw);
+		return list;
 	}
 
 
 	@Override
 	public boolean generateResponsibility(String orgEvalRuleId, String date) {
 
+		//单位目标责任书
+		DeptResponsibility responsibility = new DeptResponsibility();
+		//责任书指标详情记录集合
+		//List<ResponsibilityIndicatorInfo> indicatorInfolist = new ArrayList<>();
+
 		Date newDate;
 		//获取当前时间
 		if (StringUtils.isEmpty(date)) {
@@ -79,42 +141,85 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 			newDate = DateUtils.toDate(date);
 		}
 
+		String year = String.valueOf(DateUtils.getYear(newDate));//获取年份
+		String season = String.valueOf(DateUtils.getSeason(newDate));//获取季度
+		String month = String.valueOf(DateUtils.getMonth(newDate));//获取月份
 
 		//获取指定部门的规则
 		OrganizationEvaluationRule evaluationRule = organizationEvaluationRuleService.getById(orgEvalRuleId);
 		if (null == evaluationRule) {
 			throw new CustomException("不存在此单位权重配置");
 		}
+
 		//判断该是否存在目标责任书
 		List<DeptResponsibility> oriList = new ArrayList<>();
 		if ("NDKP".equals(evaluationRule.getEvaluationCycle())) {
-			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), "");
+			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, "");
 		}
 		if ("JDKP".equals(evaluationRule.getEvaluationCycle())) {
-			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), String.valueOf(DateUtils.getSeason(newDate)));
+			month = String.valueOf(Integer.valueOf(month) * Integer.valueOf(season));//季度考评将
+			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, month);
 		}
 		if ("YDKP".equals(evaluationRule.getEvaluationCycle())) {
-			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), String.valueOf(DateUtils.getYear(newDate)));
+			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, month);
 		}
-		if(oriList.size()>0){
+		if (oriList.size() > 0) {
 			throw new CustomException("已存在该单位目标责任书");
 		}
 
+		//保存目标责任书
+		responsibility.setOrganizationId(evaluationRule.getOrganizationId());//考评组织ID
+		responsibility.setOrganizationName(evaluationRule.getOrganizationName());//考评组织名称
+		responsibility.setCheckCycle(evaluationRule.getEvaluationCycle());//考评周期
+		responsibility.setYear(year);//年份
+		responsibility.setMonth(month);//月份
+		responsibility.setOrganizationEvaluationRuleId(evaluationRule.getId());//考评规则id
+		//responsibility.setBeginDate(null);
+		//responsibility.setEndDate(null);
+		responsibility.setStage("流程未启动");
+		responsibility.setCreateTime(new Date());
+		//responsibility.setCreateBy("");
+
+		boolean b = super.saveOrUpdate(responsibility);
+		if (!b) {
+			throw new CustomException("保存目标责任书失败");
+		}
+
 		//获取对应的考评规(至少存在一条)
 		List<String> evaluateRuleIds = Arrays.asList(evaluationRule.getEvaluateRuleId().split(","));
 		List<EvaluateRule> evaluateRuleList = evaluateRuleService.listAll(evaluateRuleIds);
-		if(null == evaluateRuleList || evaluateRuleList.size()<=0){
+		if (null == evaluateRuleList || evaluateRuleList.size() <= 0) {
 			throw new CustomException("未获取到配置的规则");
 		}
-
 		//获取考评规则的id
-		List<String> ruleIds =  evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
+		List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
 		//通过规则id获取对应的规则明细
-		List<EvaluateRuleInfo>  ruleInfos = evaluateRuleInfoService.list(ruleIds);
-
+		List<EvaluateRuleInfo> ruleInfos = evaluateRuleInfoService.list(ruleIds);
+		if (null == ruleInfos || ruleInfos.size() <= 0) {
+			throw new CustomException("规则明细配置为空");
+		}
+		//获取考评规则中的指标id
+		List<String> indicatorIds = ruleInfos.stream().map(EvaluateRuleInfo::getIndicatorId).collect(Collectors.toList());
+		//通过指标id获取指标明细项
+		List<IndicatorResDTO> resDTOS = iIndicatorService.listByIds(indicatorIds);
+		if (null == resDTOS || resDTOS.size() <= 0) {
+			throw new CustomException("指标规则明细项为空");
+		}
 
 
-		return false;
+		resDTOS.stream().forEach(r -> {
+			ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+			info.setDeptResponsibilityId(responsibility.getId());
+			info.setIndicatorId(r.getId());
+			info.setIndicatorDictionaryId(r.getIndicatorDictionaryID());
+			info.setOptionCode(r.getOptionCode());
+			info.setIsQuantified(r.getIsQuantified());
+			boolean b2 = responsibilityIndicatorInfoService.saveOrUpdate(info);
+			if (!b2) {
+				throw new CustomException("初始化目标责任书明细失败");
+			}
+		});
+		return true;
 	}
 
 	@Transactional

+ 7 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/IndicatorServiceImpl.java

@@ -11,6 +11,7 @@ import com.ims.eval.dao.IndicatorMapper;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.Indicator;
 import com.ims.eval.entity.IndicatorDictionary;
+import com.ims.eval.entity.dto.response.IndicatorResDTO;
 import com.ims.eval.service.IIndicatorService;
 import io.swagger.models.auth.In;
 import org.springframework.stereotype.Service;
@@ -146,6 +147,12 @@ public class IndicatorServiceImpl extends ServiceImpl<IndicatorMapper, Indicator
 	}
 
 	@Override
+	public List<IndicatorResDTO> listByIds(List<String> indicatorIds) {
+		List<IndicatorResDTO> list = baseMapper.selectListByIds(indicatorIds);
+		return list;
+	}
+
+	@Override
 	public boolean saveOrUpdate(Indicator entity) {
 
 		if (null != entity && (null == entity.getId() || "".equals(entity.getId().trim()))) {

+ 18 - 0
ims-service/ims-eval/src/main/resources/mappers/IndicatorMapper.xml

@@ -82,4 +82,22 @@
 
     </select>
 
+
+    <select id="selectListByIds" resultType="com.ims.eval.entity.dto.response.IndicatorResDTO">
+
+        SELECT
+        i.id id,
+        i.is_quantified isQuantified,
+        d.id indicatorDictionaryID,
+        d.option_code optionCode,
+        d.option_name optionName
+        FROM
+        INDICATOR i
+        LEFT JOIN indicator_dictionary d ON i.ID = d.indicator_id
+        <where>
+            AND i.id in
+            <foreach item="item" collection="indicatorIds" separator="," open="(" close=")" index="">'${item}'</foreach>
+        </where>
+    </select>
+
 </mapper>

+ 27 - 0
ims-service/ims-eval/src/main/resources/mappers/ResponsibilityIndicatorInfoMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ims.eval.dao.ResponsibilityIndicatorInfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.ims.eval.entity.ResponsibilityIndicatorInfo">
+        <id column="id" property="id" />
+        <result column="dept_responsibility_id" property="deptResponsibilityId" />
+        <result column="indicator_id" property="indicatorId" />
+        <result column="indicator_dictionary_id" property="indicatorDictionaryId" />
+        <result column="option_code" property="optionCode" />
+        <result column="is_quantified" property="isQuantified" />
+        <result column="quantified_value" property="quantifiedValue" />
+        <result column="non_quantified_value" property="nonQuantifiedValue" />
+        <result column="create_time" property="createTime" />
+        <result column="create_by" property="createBy" />
+        <result column="update_time" property="updateTime" />
+        <result column="update_by" property="updateBy" />
+        <result column="remark" property="remark" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, dept_responsibility_id, indicator_id, indicator_dictionary_id, option_code, is_quantified, quantified_value, non_quantified_value, create_time, create_by, update_time, update_by, remark
+    </sql>
+
+</mapper>