Commit 7bcd537d by zhangkb

提交考核指标curd接口和考核指标计分信息curd接口

parent 589d6ffc
package com.keymobile.indicators.api.cmbkpi; package com.keymobile.indicators.api.cmbkpi;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.keymobile.indicators.model.entity.GeneralParm;
import com.keymobile.indicators.model.entity.IndAcsDef; import com.keymobile.indicators.model.entity.IndAcsDef;
import com.keymobile.indicators.service.cmbkpi.GeneralParmService;
import com.keymobile.indicators.service.cmbkpi.IndAcsDefService; import com.keymobile.indicators.service.cmbkpi.IndAcsDefService;
import com.keymobile.indicators.utils.DateUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -22,8 +25,6 @@ import io.swagger.annotations.ApiOperation; ...@@ -22,8 +25,6 @@ import io.swagger.annotations.ApiOperation;
public class IndAcsDefCtrl { public class IndAcsDefCtrl {
@Autowired @Autowired
private IndAcsDefService indAcsDefService; private IndAcsDefService indAcsDefService;
@Autowired
private GeneralParmService generalParmService;
@ApiOperation(value = "获取所有考核指标定义", notes = "获取所有考核指标定义") @ApiOperation(value = "获取所有考核指标定义", notes = "获取所有考核指标定义")
@PostMapping(value = "/getAll") @PostMapping(value = "/getAll")
...@@ -31,15 +32,40 @@ public class IndAcsDefCtrl { ...@@ -31,15 +32,40 @@ public class IndAcsDefCtrl {
return indAcsDefService.getAll(); return indAcsDefService.getAll();
} }
@ApiOperation(value = "获取所有参数", notes = "获取所有参数")
@PostMapping(value = "/getAllParm")
public List<GeneralParm> getAllParm()throws Exception{
return generalParmService.getAll();
}
@ApiOperation(value = "根据指标id(编码)获取分析指标", notes = "根据指标id(编码)获取分析指标") @ApiOperation(value = "根据指标id(编码)获取分析指标", notes = "根据指标id(编码)获取分析指标")
@PostMapping(value = "/getById") @PostMapping(value = "/getById")
public IndAcsDef getById(@RequestParam("id")String id){ public IndAcsDef getById(@RequestParam("id")String id){
return indAcsDefService.getById(id); return indAcsDefService.getById(id);
} }
@ApiOperation(value = "保存或修改分析指标", notes = "保存或修改分析指标")
@PostMapping(value = "/saveOrUpdate")
public String saveOrUpdate(@RequestBody IndAcsDef indAcsDef,
@RequestParam(required=false) String defTime,
@RequestParam(required=false) String updTime) throws Exception{
if(StringUtils.isNotBlank(defTime)) {
Date defDate = DateUtils.getDate(defTime, "yyyy-MM-dd HH:mm:ss");
indAcsDef.setDefTime(defDate);
}
if(StringUtils.isNotBlank(updTime)) {
Date updDate = DateUtils.getDate(updTime, "yyyy-MM-dd HH:mm:ss");
indAcsDef.setUpdTime(updDate);
}
return indAcsDefService.saveOrUpdate(indAcsDef);
}
@ApiOperation(value = "删除考核指标", notes = "删除考核指标")
@PostMapping(value = "/delete")
public void delete(@RequestParam String indId) throws Exception{
indAcsDefService.delete(indId);
}
@ApiOperation(value = "根据关键字分页获取考核指标列表(page:0 开始)", notes = "根据关键字分页获取考核指标列表(page:0 开始)")
@PostMapping(value = "/getPageListByKeyword")
public Map<String,Object> getPageListByKeyword(
@RequestParam(required=false) String keyword,
@RequestParam int page,
@RequestParam int rows) throws Exception{
return indAcsDefService.getByPageAndKeyword(keyword, page, rows);
}
} }
package com.keymobile.indicators.api.cmbkpi;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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 com.keymobile.indicators.model.entity.IndAcsScoreInfo;
import com.keymobile.indicators.service.cmbkpi.IndAcsScoreInfoService;
import com.keymobile.indicators.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Api(tags={"考核指标计分信息接口"})
@RestController
@RequestMapping(value = "/indAcsScore")
public class IndAcsScoreInfoCtrl {
@Autowired
private IndAcsScoreInfoService indAscScoreService;
@ApiOperation(value = "保存考核指标计分信息", notes = "保存考核指标计分信息")
@PostMapping(value = "/save")
public String save(@RequestBody IndAcsScoreInfo indAcsScoreInfo,
@RequestParam String updTime) throws Exception{
if(StringUtils.isNotBlank(updTime)) {
Date updDate = DateUtils.getDate(updTime, "yyyy-MM-dd HH:mm:ss");
indAcsScoreInfo.setUpdateTime(updDate);
}
return indAscScoreService.save(indAcsScoreInfo);
}
@ApiOperation(value = "删除考核指标计分信息", notes = "删除考核指标计分信息")
@PostMapping(value = "/delete")
public void delete(@RequestParam String orgId,
@RequestParam String indId,@RequestParam String indAttrId) throws Exception{
indAscScoreService.delete(orgId, indId, indAttrId);
}
@ApiOperation(value = "根据考核指标编号获取计分信息", notes = "根据考核指标编号获取计分信息")
@PostMapping(value = "/getListByIndId")
public List<IndAcsScoreInfo> getListByIndId(@RequestParam String indId) throws Exception{
return indAscScoreService.getListByIndId(indId);
}
@ApiOperation(value = "根据组织机构,指标id和指标类型获取考核指标计分信息", notes = "根据组织机构,指标id和指标类型获取考核指标计分信息")
@PostMapping(value = "/selectOne")
public IndAcsScoreInfo selectOne(@RequestParam String orgId,
@RequestParam String indId,@RequestParam String indAttrId) throws Exception{
return indAscScoreService.selectOneByOrgIdAndIndidAndIndtype(orgId, indId, indAttrId);
}
@ApiOperation(value = "根据关键字和类型获取考核指标或者分析指标(type:0 分析指标;1 考核指标)",
notes = "根据关键字和类型获取考核指标或者分析指标(type:0 分析指标;1 考核指标)")
@PostMapping(value = "/getIndByKeywordAndType")
public List<Map<String,Object>> getIndByKeywordAndType(
@RequestParam(required=false) String keyword,
@RequestParam(required=false) String type) throws Exception{
return indAscScoreService.getIndByKeywordAndType(keyword, type);
}
}
...@@ -16,5 +16,5 @@ public class IndAcsData { ...@@ -16,5 +16,5 @@ public class IndAcsData {
private String indId;//指标编号 private String indId;//指标编号
private String indName;//指标名称 private String indName;//指标名称
private String indType;//指标类型 private String indType;//指标类型
private double statVal;//统计值 private Double statVal;//统计值
} }
...@@ -27,7 +27,7 @@ public class IndAcsDef { ...@@ -27,7 +27,7 @@ public class IndAcsDef {
private String markType;//计分类型 private String markType;//计分类型
private String freqCd;//频率代码 private String freqCd;//频率代码
private String freqName;//频率名称 private String freqName;//频率名称
private double weight;//权重 private Double weight;//权重
private String cltCmt;//口径说明(汉字描述) private String cltCmt;//口径说明(汉字描述)
private String markRule;//计分规则(汉字描述) private String markRule;//计分规则(汉字描述)
private String dataSrc;//数据来源 private String dataSrc;//数据来源
......
...@@ -19,7 +19,7 @@ public class IndAcsScoreInfo { ...@@ -19,7 +19,7 @@ public class IndAcsScoreInfo {
private String indexAttrId;//指标属性编号001 目标002 市场003 实际值004 参考值… private String indexAttrId;//指标属性编号001 目标002 市场003 实际值004 参考值…
private String scoreMode;//计分方式 private String scoreMode;//计分方式
private String scoreFormula;//计分公式 private String scoreFormula;//计分公式
private double weight;// double comment "权重" private Double weight;// double comment "权重"
private String isValid;//是否有效Y N private String isValid;//是否有效Y N
private String updateUserId;//更新人id private String updateUserId;//更新人id
private String updateUserName;//更新人姓名 private String updateUserName;//更新人姓名
......
...@@ -18,5 +18,5 @@ public class IndAnaData { ...@@ -18,5 +18,5 @@ public class IndAnaData {
private String indType;//指标类型 private String indType;//指标类型
private String indName;//指标名称 private String indName;//指标名称
private String orgId;//机构编号 private String orgId;//机构编号
private double statVal;//统计值 private Double statVal;//统计值
} }
package com.keymobile.indicators.model.mapper; package com.keymobile.indicators.model.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -9,5 +10,11 @@ import tk.mybatis.mapper.common.BaseMapper; ...@@ -9,5 +10,11 @@ import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface IndAcsDefMapper extends BaseMapper<IndAcsDef> { public interface IndAcsDefMapper extends BaseMapper<IndAcsDef> {
List<IndAcsDef> getAll(); public List<IndAcsDef> getAll();
public List<IndAcsDef> getPageByKeyword(Map<String,Object> param);
public int getByKeywordCount(Map<String,Object> param);
public List<IndAcsDef> getByKeyword(Map<String,Object> param);
} }
...@@ -2,7 +2,11 @@ package com.keymobile.indicators.model.mapper; ...@@ -2,7 +2,11 @@ package com.keymobile.indicators.model.mapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.IndAcsScoreInfo;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface IndAcsScoreInfoMapper { public interface IndAcsScoreInfoMapper extends BaseMapper<IndAcsScoreInfo>{
} }
...@@ -14,4 +14,6 @@ public interface IndAnaDefMapper extends BaseMapper<IndAnaDef>{ ...@@ -14,4 +14,6 @@ public interface IndAnaDefMapper extends BaseMapper<IndAnaDef>{
public List<IndAnaDef> getPageByKeyword(Map<String,Object> param); public List<IndAnaDef> getPageByKeyword(Map<String,Object> param);
public int getByKeywordCount(Map<String,Object> param); public int getByKeywordCount(Map<String,Object> param);
public List<IndAnaDef> getByKeyword(Map<String,Object> param);
} }
package com.keymobile.indicators.service.cmbkpi; package com.keymobile.indicators.service.cmbkpi;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.IndAcsDef; import com.keymobile.indicators.model.entity.IndAcsDef;
import com.keymobile.indicators.model.entity.IndAcsScoreInfo;
import com.keymobile.indicators.model.mapper.IndAcsDefMapper; import com.keymobile.indicators.model.mapper.IndAcsDefMapper;
@Service @Service
public class IndAcsDefService { public class IndAcsDefService {
@Autowired @Autowired
private IndAcsDefMapper indAcsDefMapper; private IndAcsDefMapper indAcsDefMapper;
@Autowired
private IndAcsScoreInfoService indAcsScoreService;
public List<IndAcsDef> getAll(){ public List<IndAcsDef> getAll(){
return indAcsDefMapper.getAll(); return indAcsDefMapper.getAll();
...@@ -22,4 +28,51 @@ public class IndAcsDefService { ...@@ -22,4 +28,51 @@ public class IndAcsDefService {
def.setIndId(id); def.setIndId(id);
return indAcsDefMapper.selectOne(def); return indAcsDefMapper.selectOne(def);
} }
public String saveOrUpdate(IndAcsDef indAcsDef) throws Exception{
if(StringUtils.isBlank(indAcsDef.getIndId())) {
return "indId is not be null";
}
//根据考核指标编号判断是否已存在
IndAcsDef dbIndAcsDef = this.getById(indAcsDef.getIndId());
if(dbIndAcsDef==null) {
indAcsDefMapper.insert(indAcsDef);
}else {
indAcsDefMapper.updateByPrimaryKey(indAcsDef);
}
return indAcsDef.getIndId();
}
public Map<String,Object> getByPageAndKeyword(String keyword,int page,int rows)throws Exception{
Map<String,Object> paramMap = new HashMap<>();
Map<String,Object> resultMap = new HashMap<>();
if(StringUtils.isBlank(keyword)) {
paramMap.put("keyword", null);
}else {
paramMap.put("keyword", "%"+keyword+"%");
}
//计算总数
int count = indAcsDefMapper.getByKeywordCount(paramMap);
//计算start
int start = page*rows;
paramMap.put("start", start);
paramMap.put("end", rows);
List<IndAcsDef> resultList = indAcsDefMapper.getPageByKeyword(paramMap);
resultMap.put("resultList", resultList);
resultMap.put("total", count);
return resultMap;
}
public void delete(String indId) throws Exception{
indAcsDefMapper.deleteByPrimaryKey(indId);
//删除考核指标关联的公式
List<IndAcsScoreInfo> indAcsScoreInfos = indAcsScoreService.getListByIndId(indId);
if(!indAcsScoreInfos.isEmpty()) {
for(IndAcsScoreInfo acsScore : indAcsScoreInfos) {
indAcsScoreService.delete(acsScore.getOrgId(), acsScore.getIndexId(), acsScore.getIndexAttrId());
}
}
}
} }
package com.keymobile.indicators.service.cmbkpi; package com.keymobile.indicators.service.cmbkpi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.IndAcsDef;
import com.keymobile.indicators.model.entity.IndAcsScoreInfo;
import com.keymobile.indicators.model.entity.IndAnaDef;
import com.keymobile.indicators.model.mapper.IndAcsDefMapper;
import com.keymobile.indicators.model.mapper.IndAcsScoreInfoMapper; import com.keymobile.indicators.model.mapper.IndAcsScoreInfoMapper;
import com.keymobile.indicators.model.mapper.IndAnaDefMapper;
@Service @Service
public class IndAcsScoreInfoService { public class IndAcsScoreInfoService {
@Autowired @Autowired
private IndAcsScoreInfoMapper indAcsScoreInfoMapper; private IndAcsScoreInfoMapper indAcsScoreInfoMapper;
@Autowired
private IndAnaDefMapper indAnaDefMapper;
@Autowired
private IndAcsDefMapper indAcsDefMapper;
public String save(IndAcsScoreInfo indAcsScoreInfo) throws Exception{
if(StringUtils.isBlank(indAcsScoreInfo.getOrgId())||
StringUtils.isBlank(indAcsScoreInfo.getIndexId())||
StringUtils.isBlank(indAcsScoreInfo.getIndexAttrId())) {
return "orgId,indexId,indexAttrId can not be null";
}else {
//根据组织机构id,指标编号和指标类型判断是否有公式存在
IndAcsScoreInfo dbIndAcsScoreInfo = this.selectOneByOrgIdAndIndidAndIndtype(
indAcsScoreInfo.getOrgId(),indAcsScoreInfo.getIndexId(),indAcsScoreInfo.getIndexAttrId());
if(dbIndAcsScoreInfo!=null) {
return "the indicators have exist,can not save to the database";
}else {
indAcsScoreInfoMapper.insert(indAcsScoreInfo);
}
}
return "save success";
}
public void delete(String orgId,String indId,String indAttrId) throws Exception{
IndAcsScoreInfo indAcsScoreInfo = this.selectOneByOrgIdAndIndidAndIndtype(orgId, indId, indAttrId);
if(indAcsScoreInfo!=null) {
indAcsScoreInfoMapper.delete(indAcsScoreInfo);
}
}
public List<IndAcsScoreInfo> getListByIndId(String indId)throws Exception{
IndAcsScoreInfo indAcsScoreInfo = new IndAcsScoreInfo();
indAcsScoreInfo.setIndexId(indId);
return indAcsScoreInfoMapper.select(indAcsScoreInfo);
}
public IndAcsScoreInfo selectOneByOrgIdAndIndidAndIndtype(
String orgId,String indId,String indAttrId) throws Exception{
IndAcsScoreInfo indAcsScoreInfo = new IndAcsScoreInfo();
indAcsScoreInfo.setOrgId(orgId);
indAcsScoreInfo.setIndexId(indId);
indAcsScoreInfo.setIndexAttrId(indAttrId);
return indAcsScoreInfoMapper.selectOne(indAcsScoreInfo);
}
//type:0 分析指标 ;1 考核指标
public List<Map<String,Object>> getIndByKeywordAndType(String keyword,String type) throws Exception{
List<Map<String,Object>> resultList = new ArrayList<>();
Map<String,Object> paramMap = new HashMap<>();
if(StringUtils.isBlank(keyword)) {
paramMap.put("keyword", null);
}else {
paramMap.put("keyword", "%"+keyword+"%");
}
if(StringUtils.isNotBlank(type)) {
if("0".equals(type)) {
List<IndAnaDef> indAnaDefs = indAnaDefMapper.getByKeyword(paramMap);
if(!indAnaDefs.isEmpty()) {
for(IndAnaDef indAnaDef : indAnaDefs) {
Map<String,Object> map = new HashMap<>();
map.put("indId",indAnaDef.getIndId());
map.put("indName", indAnaDef.getIndName());
map.put("type", "0");
resultList.add(map);
}
}
}else {
List<IndAcsDef> indAcsDefs = indAcsDefMapper.getByKeyword(paramMap);
if(!indAcsDefs.isEmpty()) {
for(IndAcsDef indAcsDef : indAcsDefs) {
Map<String,Object> map = new HashMap<>();
map.put("indId",indAcsDef.getIndId());
map.put("indName", indAcsDef.getIndName());
map.put("type", "1");
resultList.add(map);
}
}
}
}else {
List<IndAnaDef> indAnaDefs = indAnaDefMapper.getByKeyword(paramMap);
List<IndAcsDef> indAcsDefs = indAcsDefMapper.getByKeyword(paramMap);
if(!indAnaDefs.isEmpty()) {
for(IndAnaDef indAnaDef : indAnaDefs) {
Map<String,Object> map = new HashMap<>();
map.put("indId",indAnaDef.getIndId());
map.put("indName", indAnaDef.getIndName());
map.put("type", "0");
resultList.add(map);
}
}
if(!indAcsDefs.isEmpty()) {
for(IndAcsDef indAcsDef : indAcsDefs) {
Map<String,Object> map = new HashMap<>();
map.put("indId",indAcsDef.getIndId());
map.put("indName", indAcsDef.getIndName());
map.put("type", "1");
resultList.add(map);
}
}
}
return resultList;
}
} }
...@@ -4,4 +4,26 @@ ...@@ -4,4 +4,26 @@
<select id="getAll" resultType="com.keymobile.indicators.model.entity.IndAcsDef"> <select id="getAll" resultType="com.keymobile.indicators.model.entity.IndAcsDef">
select * from ind_acs_ind_def_inf select * from ind_acs_ind_def_inf
</select> </select>
<select id="getPageByKeyword" parameterType="map" resultType="com.keymobile.indicators.model.entity.IndAcsDef" >
select * from ind_acs_ind_def_inf
<if test="keyword!=null">
where ind_name like #{keyword} or ind_id like #{keyword}
</if>
limit #{start},#{end}
</select>
<select id="getByKeywordCount" parameterType="map" resultType="java.lang.Integer">
select count(1) from ind_acs_ind_def_inf
<if test="keyword!=null">
where ind_name like #{keyword} or ind_id like #{keyword}
</if>
</select>
<select id="getByKeyword" parameterType="map" resultType="com.keymobile.indicators.model.entity.IndAcsDef" >
select * from ind_acs_ind_def_inf
<if test="keyword!=null">
where ind_name like #{keyword} or ind_id like #{keyword}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -15,4 +15,11 @@ ...@@ -15,4 +15,11 @@
where ind_name like #{keyword} or ind_id like #{keyword} where ind_name like #{keyword} or ind_id like #{keyword}
</if> </if>
</select> </select>
<select id="getByKeyword" parameterType="map" resultType="com.keymobile.indicators.model.entity.IndAnaDef" >
select * from ind_ana_ind_def_inf
<if test="keyword!=null">
where ind_name like #{keyword} or ind_id like #{keyword}
</if>
</select>
</mapper> </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