Commit fe345cd8 by dengwei

权重配置管理功能新增

parent c422a57c
package com.keymobile.indicators.api.hytobacco;
import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg;
import com.keymobile.indicators.result.Result;
import com.keymobile.indicators.service.ObjScoreIndWeightCfgService;
import com.keymobile.indicators.utils.LogManager;
import com.keymobile.indicators.utils.SystemUserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
/**
* @author DW
* @date 2023-02-10-0010 9:59
* @description
*/
@Api(tags={"数据填报-权重配置"})
@RestController
@RequestMapping(value = "/weightCfg")
@Slf4j
public class ObjScoreIndWeightCfgCtrl {
@Autowired
private ObjScoreIndWeightCfgService weightCfgService;
@ApiOperation("分页查询权重配置信息")
@GetMapping("/findByPage")
public Page<ObjScoreIndWeightCfg> findByPage(@ApiParam("搜索关键字(名字)")@RequestParam(value = "keyword", required=false) String keyword,
@ApiParam("页码,从1开始") @RequestParam(value ="page",defaultValue = "1") int page,
@ApiParam("每页条数") @RequestParam(value ="pageSize", defaultValue = "10") int pageSize,
@ApiParam("机构编号") @RequestParam(value = "orgNo",required=false) String orgNo) {
LogManager.logInfo(Constants.LOG_INDICATOR_WEIGHTCFG_API, "根据参数分页查询权重配置信息{}", keyword);
return weightCfgService.findByPage(page, pageSize, keyword, orgNo);
}
@ApiOperation(value = "新增/修改", notes = "新增/修改")
@PostMapping(value = "/saveOrUpdate")
public Result saveOrUpdate(@RequestBody ObjScoreIndWeightCfg weightCfg){
String message;
Date now = new Date();
String currentUserId = SystemUserUtil.getCurrentUserId();
weightCfg.setUpdater(currentUserId);
weightCfg.setUpdateTime(now);
if (weightCfg.getId() == null || weightCfg.getId() == 0) {
message = "新增权重配置信息:{}";
weightCfg.setCreator(currentUserId);
weightCfg.setCreateTime(now);
weightCfgService.createWeight(weightCfg);
}else {
message = "修改权重配置信息:{}";
ObjScoreIndWeightCfg cfg = weightCfgService.getById(weightCfg.getId());
weightCfg.setCreator(cfg.getCreator());
weightCfg.setCreateTime(cfg.getCreateTime());
weightCfgService.updateWeight(weightCfg);
}
LogManager.logInfo(Constants.LOG_INDICATOR_WEIGHTCFG_API, message, weightCfg.getName());
return Result.genOkResult(weightCfg);
}
@ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = "/delete")
public Result delete(@RequestParam List<Integer> ids) {
StringBuilder message = new StringBuilder();
List<ObjScoreIndWeightCfg> weightCfgs = weightCfgService.findByIdList(ids);
for(ObjScoreIndWeightCfg weightCfg : weightCfgs) {
message.append(weightCfg.getName()).append(";");
}
weightCfgService.delete(ids);
LogManager.logInfo(Constants.LOG_INDICATOR_WEIGHTCFG_API, "删除权重配置信息:{}", message.toString());
return Result.genOkResult();
}
}
...@@ -56,6 +56,11 @@ public class Constants { ...@@ -56,6 +56,11 @@ public class Constants {
public static final String LOG_INDICATOR_SHORTBOARD_AUDIT_API = "indicator.shortboardaudit"; public static final String LOG_INDICATOR_SHORTBOARD_AUDIT_API = "indicator.shortboardaudit";
/** /**
* 权重配置
*/
public static final String LOG_INDICATOR_WEIGHTCFG_API = "indicator.weightcfg";
/**
*短板管理结果汇总 *短板管理结果汇总
**/ **/
public static final String LOG_INDICATOR_SHORTBOARD_RESULT_API = "indicator.shortboardresult"; public static final String LOG_INDICATOR_SHORTBOARD_RESULT_API = "indicator.shortboardresult";
......
package com.keymobile.indicators.model.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
/**
* @author DW
* @date 2023-02-09-0009 9:57
* @description 权重配置实体类
*/
@Data
@Table(name = "obj_score_ind_weight_cfg")
@ApiModel("权重配置")
public class ObjScoreIndWeightCfg extends BaseModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id; // 主键
@ApiModelProperty(value = "配置名称")
private String name; // 配置名称
@ApiModelProperty(value = "配置级别")
private String levelName; // 配置级别
@ApiModelProperty(value = "配置周期")
private String dateValue; // 配置周期
@ApiModelProperty(value = "对标主体分组ID")
private String orgGroupId; // 对标主体分组ID
@ApiModelProperty(value = "对标主体分组名称")
private String orgGroupName;// 对标主体分组名称
@ApiModelProperty(value = "指标ID")
private String indIds; // 指标ID
@ApiModelProperty(value = "指标名称")
private String indNames; // 指标名称
@ApiModelProperty(value = "两烟区大类权重")
private BigDecimal weightTwo; // 两烟区大类权重
@ApiModelProperty(value = "两烟区单位")
private String weightTwoUnit; // 两烟区单位
@ApiModelProperty(value = "纯销区大类权重")
private BigDecimal weightOne; // 纯销区大类权重
@ApiModelProperty(value = "纯销区单位")
private String weightOneUnit; // 纯销区单位
@ApiModelProperty(value = "租户组织CODE,区分不同单位")
private String code; // 租户组织CODE,区分不同单位
@ApiModelProperty(value = "所属组织机构")
private String orgNo; // 所属组织机构
@ApiModelProperty(value = "备注")
private String remark; // 备注
}
package com.keymobile.indicators.model.mapper.indicators;
import com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.BaseMapper;
import java.util.List;
@Mapper
public interface ObjScoreIndWeightCfgMapper extends BaseMapper<ObjScoreIndWeightCfg> {
/**
* 根据id获取权重配置
* @param id 主键ID
* @return 权重配置内容
*/
ObjScoreIndWeightCfg getById(Integer id);
/**
* 根据id删除权重配置
* @param id 主键id
*/
void deleteById(Integer id);
/**
* 批量删除权重配置
* @param ids
*/
void deleteByIdIn(@Param("ids") List<Integer> ids);
/**
* 分页查询
* @param keyword
* @param start
* @param pageSize
* @param orgNo
* @return
*/
List<ObjScoreIndWeightCfg> findByPage(@Param("keyword") String keyword,
@Param("start") long start,
@Param("pageSize") int pageSize,
@Param("orgNo") String orgNo);
/**
* 查询权重配置记录数
* @param keyword
* @param orgNo
* @return
*/
long findCount(@Param("keyword") String keyword,
@Param("orgNo") String orgNo);
/**
* 根据id集合查询权重配置
* @param ids
* @return
*/
List<ObjScoreIndWeightCfg> findByIdList(List<Integer> ids);
}
package com.keymobile.indicators.service;
import com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg;
import org.springframework.data.domain.Page;
import java.util.List;
/**
* 权重管理
*/
public interface ObjScoreIndWeightCfgService {
/**
* 根据id删除权重配置
* @param id 主键ID
*/
void deleteById(Integer id);
/**
* 根据id获取权重配置
* @param id 主键ID
*/
ObjScoreIndWeightCfg getById(Integer id);
/**
* 分页查询
* @param page
* @param pageSize
* @param keyword
* @param orgNo
* @return
*/
Page<ObjScoreIndWeightCfg> findByPage(Integer page, Integer pageSize, String keyword, String orgNo);
/**
* 新增权重配置
* @param weightCfg
*/
void createWeight(ObjScoreIndWeightCfg weightCfg);
/**
* 更新权重配置
* @param weightCfg
*/
void updateWeight(ObjScoreIndWeightCfg weightCfg);
/**
* 批量删除
* @param ids
* @return
*/
void delete(List<Integer> ids);
/**
* 根据id集合查询权重配置
* @param ids
* @return
*/
List<ObjScoreIndWeightCfg> findByIdList(List<Integer> ids);
}
...@@ -680,6 +680,7 @@ public class IndScorecardService { ...@@ -680,6 +680,7 @@ public class IndScorecardService {
if("2".equals(section[7])){ if("2".equals(section[7])){
//不按比例。满才加分 去掉小数点取整 //不按比例。满才加分 去掉小数点取整
// TODO: 2023-02-09-0009 目前为小数向下取整,可能需要改成向上取整 -- 向上取整方法Math.ceil
scopeValue= Math.floor(scopeValue); scopeValue= Math.floor(scopeValue);
} }
//判断是加还是减 //判断是加还是减
......
package com.keymobile.indicators.service.impl;
import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg;
import com.keymobile.indicators.model.mapper.indicators.ObjScoreIndWeightCfgMapper;
import com.keymobile.indicators.service.ObjScoreIndWeightCfgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* @author DW
* @date 2023-02-09-0009 14:59
* @description
*/
@Service
public class ObjScoreIndWeightCfgServiceImpl implements ObjScoreIndWeightCfgService {
@Autowired
private ObjScoreIndWeightCfgMapper weightCfgMapper;
@Override
public void deleteById(Integer id) {
weightCfgMapper.deleteById(id);
}
@Override
public ObjScoreIndWeightCfg getById(Integer id) {
return weightCfgMapper.getById(id);
}
@Override
public Page<ObjScoreIndWeightCfg> findByPage(Integer page, Integer pageSize, String keyword, String orgNo) {
long total = weightCfgMapper.findCount(keyword, orgNo);
PageRequest request = PageRequest.of(page - 1, pageSize);
List<ObjScoreIndWeightCfg> list = new ArrayList<>();
if (total > 0) {
list = weightCfgMapper.findByPage(keyword, request.getOffset(), pageSize, orgNo);
}
return new PageImpl<ObjScoreIndWeightCfg>(list, request, total);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createWeight(ObjScoreIndWeightCfg weightCfg) {
weightCfg.setState(Constants.DATA_STATE_A);
weightCfgMapper.insert(weightCfg);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateWeight(ObjScoreIndWeightCfg weightCfg) {
weightCfg.setState(Constants.DATA_STATE_A);
weightCfgMapper.updateByPrimaryKey(weightCfg);
}
@Override
public void delete(List<Integer> ids) {
weightCfgMapper.deleteByIdIn(ids);
}
@Override
public List<ObjScoreIndWeightCfg> findByIdList(List<Integer> ids) {
return weightCfgMapper.findByIdList(ids);
}
}
...@@ -24,7 +24,9 @@ public enum ModelPathEnum { ...@@ -24,7 +24,9 @@ public enum ModelPathEnum {
LOG_INDICATOR_CONFIG_INFO("indicator.config.info","系统管理/配置项管理"), LOG_INDICATOR_CONFIG_INFO("indicator.config.info","系统管理/配置项管理"),
LOG_INDICATOR_LOG("indicator.log","系统管理/操作日志"), LOG_INDICATOR_LOG("indicator.log","系统管理/操作日志"),
LOG_INDICATOR_AUDIT_ROLE_API("indicator.audit.role","系统管理/填报审核角色配置管理 "); LOG_INDICATOR_AUDIT_ROLE_API("indicator.audit.role","系统管理/填报审核角色配置管理 "),
LOG_INDICATOR_WEIGHTCFG_API("indicator.weightcfg", "数据填报/权重配置");
private String modelName; private String modelName;
private String modelPath; private String modelPath;
......
<?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.keymobile.indicators.model.mapper.indicators.ObjScoreIndWeightCfgMapper">
<select id="getById" parameterType="java.lang.Integer" resultType="com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg">
select * from obj_score_ind_weight_cfg weight
where weight.id = #{id}
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
update obj_score_ind_weight_cfg weight
set weight.state = 3
where weight.id = #{id}
</delete>
<select id="findByPage" resultType="com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg">
select * from obj_score_ind_weight_cfg weight
<include refid="findWhereSql" />
order by weight.update_time desc, weight.name asc
limit #{start}, #{pageSize}
</select>
<sql id="findWhereSql">
where weight.state = 1
<if test="keyword != null and keyword != ''">
and weight.name like concat('%', #{keyword}, '%')
</if>
<if test="orgNo != null and orgNo != ''">
and weight.org_no = #{orgNo}
</if>
</sql>
<select id="findCount" resultType="long">
select count(1) from obj_score_ind_weight_cfg as weight
<include refid="findWhereSql" />
</select>
<select id="findByIdList" resultType="com.keymobile.indicators.model.entity.ObjScoreIndWeightCfg" >
select *
from obj_score_ind_weight_cfg as weight
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<delete id="deleteByIdIn" parameterType="java.util.List">
update obj_score_ind_weight_cfg weight
set weight.state = 3
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment