Commit bbf353e0 by zhangkb

添加基础项报表数据整合

parent 6c72fe48
...@@ -80,8 +80,8 @@ public class IndScorecardCtrl { ...@@ -80,8 +80,8 @@ public class IndScorecardCtrl {
@ApiOperation(value = "获取所有评分卡", notes = "获取所有评分卡") @ApiOperation(value = "获取所有评分卡", notes = "获取所有评分卡")
@PostMapping(value = "/getAll") @PostMapping(value = "/getAll")
public List<IndScorecard> getAll(){ public List<IndScorecard> getAll(@RequestParam String code){
return indScorecardService.getAll(); return indScorecardService.getAll(code);
} }
@ApiOperation(value = "根据评分卡目录获取评分卡", notes = "根据评分卡目录获取评分卡") @ApiOperation(value = "根据评分卡目录获取评分卡", notes = "根据评分卡目录获取评分卡")
......
package com.keymobile.indicators.api.report; package com.keymobile.indicators.api.report;
import java.util.List;
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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
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.service.report.IndicatorsReportService; import com.keymobile.indicators.service.report.IndicatorsReportService;
...@@ -19,7 +22,13 @@ public class IndicatorReportCtrl { ...@@ -19,7 +22,13 @@ public class IndicatorReportCtrl {
@ApiOperation(value = "整合指标本期同期报表数据", notes = "整合指标本期同期报表数据") @ApiOperation(value = "整合指标本期同期报表数据", notes = "整合指标本期同期报表数据")
@PostMapping(value = "/dealReportOne") @PostMapping(value = "/dealReportOne")
public String dealReportOne() { public String dealReportOne(@RequestParam String code) {
return indicatorsReportService.dealReportOne(); return indicatorsReportService.dealReportOne(code);
}
@ApiOperation(value = "整合基础项本期同期报表数据", notes = "整合基础项本期同期报表数据")
@PostMapping(value = "/dealBaseReportOne")
public String dealBaseReportOne(@RequestParam Integer date,@RequestParam List<String> compareObjs) {
return indicatorsReportService.dealBaseIndReportOneData(date, compareObjs);
} }
} }
...@@ -24,6 +24,8 @@ public class IndicatorsReportOne { ...@@ -24,6 +24,8 @@ public class IndicatorsReportOne {
private Integer compareDate;//对标日期 private Integer compareDate;//对标日期
private String compareType;//对标类型: 1:日 2:月 3:季 4:年 private String compareType;//对标类型: 1:日 2:月 3:季 4:年
private String unit;//指标单位 private String unit;//指标单位
private String depart;//指标归属部门
private String catalogType;//指标归属类别
private String currentValue;//本期值 private String currentValue;//本期值
private String lastSameValue;// 同期值 private String lastSameValue;// 同期值
private String valueRate;//同比 private String valueRate;//同比
......
package com.keymobile.indicators.model.entity.report;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
*author:zhangkb time:2020-7-13 desc:对标报表2
*/
@Data
@Table(name ="indicators_report_two")
public class IndicatorsReportTwo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String indId;//指标编号
private String indName;//指标名称
private String compareDate;//对标时间
private String compareType;//对标类型
private String unit;//单位
private String average;//平均值
private String bestUnit;//标杆单位
private String bestUnitValue;//标杆值
private String bestAverageUnits;//优于平均单位数
private String sameImproveUnits;//同比提升单位数
private String rankHeadThree;//排名前三
private String rankAfterThree;//排名末三
private String sameImproveHeadThree;//同比提升前三
private String sameImproveAfterThree;//同比提升末三
}
...@@ -53,5 +53,5 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult ...@@ -53,5 +53,5 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult
public List<DriveIndCalResultDef> findByCompareIdAndDate(@Param("compareId")String compareId, public List<DriveIndCalResultDef> findByCompareIdAndDate(@Param("compareId")String compareId,
@Param("date")Integer date); @Param("date")Integer date);
public List<DriveIndCalResultDef> findReportData(); public List<DriveIndCalResultDef> findReportData(@Param("code")String code);
} }
...@@ -18,4 +18,6 @@ public interface IndScorecardMapper extends BaseMapper<IndScorecard>{ ...@@ -18,4 +18,6 @@ public interface IndScorecardMapper extends BaseMapper<IndScorecard>{
public int countByCatalogId(@Param("catalogId")Integer catalogId,@Param("keyword")String keyword); public int countByCatalogId(@Param("catalogId")Integer catalogId,@Param("keyword")String keyword);
public List<IndScorecard> findByIdList(@Param("ids")List<Integer> ids); public List<IndScorecard> findByIdList(@Param("ids")List<Integer> ids);
public List<IndScorecard> findByCode(@Param("code") String code);
} }
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.indicators.IndicatorsData; import com.keymobile.indicators.model.entity.indicators.IndicatorsData;
...@@ -18,5 +19,6 @@ public interface IndicatorsDataMapper extends BaseMapper<IndicatorsData>{ ...@@ -18,5 +19,6 @@ public interface IndicatorsDataMapper extends BaseMapper<IndicatorsData>{
void batchCreateIndData(List<IndicatorsData> datas); void batchCreateIndData(List<IndicatorsData> datas);
public IndicatorsData getIndData(@Param("indId")String indId,
@Param("date")Integer date,@Param("compareObj")String compareObj);
} }
...@@ -6,8 +6,6 @@ import java.util.List; ...@@ -6,8 +6,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -22,6 +20,10 @@ public class BaseIndDataService { ...@@ -22,6 +20,10 @@ public class BaseIndDataService {
@Autowired @Autowired
private IndicatorsDataMapper indicatorsDataMapper; private IndicatorsDataMapper indicatorsDataMapper;
public IndicatorsData getSingleIndData(String indId,int date,String compareObj) {
return indicatorsDataMapper.getIndData(indId, date, compareObj);
}
public List<String> getIndData(String indId,int date,List<String> compareObjs){ public List<String> getIndData(String indId,int date,List<String> compareObjs){
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
...@@ -36,6 +38,18 @@ public class BaseIndDataService { ...@@ -36,6 +38,18 @@ public class BaseIndDataService {
} }
return result; return result;
} }
public List<IndicatorsData> getIndDataByParam(Integer date,List<String> compareObjs){
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("indId", null);
paramMap.put("date", date);
if(compareObjs.isEmpty()) {
paramMap.put("compareObjs", null);
}else {
paramMap.put("compareObjs", compareObjs);
}
return indicatorsDataMapper.getIndDataByParam(paramMap);
}
/** /**
* 一步批量插入数据 * 一步批量插入数据
......
...@@ -90,8 +90,8 @@ public class IndScorecardService { ...@@ -90,8 +90,8 @@ public class IndScorecardService {
return message.toString(); return message.toString();
} }
public List<IndScorecard> getAll(){ public List<IndScorecard> getAll(String code){
List<IndScorecard> scorecards = indScorecardMapper.selectAll(); List<IndScorecard> scorecards = indScorecardMapper.findByCode(code);
// List<IndScorecard> result = new ArrayList<>(); // List<IndScorecard> result = new ArrayList<>();
// for(IndScorecard scorecard : scorecards) { // for(IndScorecard scorecard : scorecards) {
// IndScorecard scorecard1 = this.changeJson(scorecard); // IndScorecard scorecard1 = this.changeJson(scorecard);
......
...@@ -5,12 +5,16 @@ import java.util.List; ...@@ -5,12 +5,16 @@ import java.util.List;
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.indicators.BaseIndDef;
import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef; import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
import com.keymobile.indicators.model.entity.indicators.DriveIndDef; import com.keymobile.indicators.model.entity.indicators.DriveIndDef;
import com.keymobile.indicators.model.entity.indicators.IndicatorsData;
import com.keymobile.indicators.model.entity.report.IndicatorsReportOne; import com.keymobile.indicators.model.entity.report.IndicatorsReportOne;
import com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper;
import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper; import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper; import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.model.mapper.report.ReportOneMapper; import com.keymobile.indicators.model.mapper.report.ReportOneMapper;
import com.keymobile.indicators.service.hytobacco.BaseIndDataService;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
@Service @Service
...@@ -21,6 +25,10 @@ public class IndicatorsReportService { ...@@ -21,6 +25,10 @@ public class IndicatorsReportService {
private DriveIndCalResultDefMapper driveIndCalResultDefMapper; private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
@Autowired @Autowired
private DriveIndDefMapper driveIndDefMapper; private DriveIndDefMapper driveIndDefMapper;
@Autowired
private BaseIndDefMapper baseIndDefMapper;
@Autowired
private BaseIndDataService baseIndDataService;
public Integer saveOrUpdate(IndicatorsReportOne reportData) { public Integer saveOrUpdate(IndicatorsReportOne reportData) {
if(reportData.getId()==null) { if(reportData.getId()==null) {
...@@ -31,10 +39,29 @@ public class IndicatorsReportService { ...@@ -31,10 +39,29 @@ public class IndicatorsReportService {
return reportData.getId(); return reportData.getId();
} }
public String dealBaseIndReportOneData(Integer date,List<String> compareObjs) {
//根据条件获取基础项数据
List<IndicatorsData> indiDatas = baseIndDataService.getIndDataByParam(date, compareObjs);
for(IndicatorsData indiData : indiDatas) {
String type = this.getCompareType(indiData.getDim2());
//判断是否存在
IndicatorsReportOne indReportData = reportOneMapper.getByParam(
indiData.getIndId(), indiData.getDim1(), indiData.getDim2(), type);
if(indReportData==null) {
indReportData = new IndicatorsReportOne();
}
indReportData.setCompareType(type);
indReportData.setUnit(indiData.getUnit());
indReportData = fillBaseIndiReportOneData(indiData,indReportData);
this.saveOrUpdate(indReportData);
}
return "整合基础项报表数据完成";
}
//处理单挑指标结果报表数据 //处理单挑指标结果报表数据
public void dealSingleReportOneData(DriveIndCalResultDef calData) { public void dealSingleReportOneData(DriveIndCalResultDef calData) {
//判断是否存在
String type = this.getCompareType(calData.getDate()); String type = this.getCompareType(calData.getDate());
//判断是否存在
IndicatorsReportOne indReportData = reportOneMapper.getByParam( IndicatorsReportOne indReportData = reportOneMapper.getByParam(
calData.getIndId(), calData.getCompareObj(), calData.getDate(), type); calData.getIndId(), calData.getCompareObj(), calData.getDate(), type);
if(indReportData==null) { if(indReportData==null) {
...@@ -47,10 +74,10 @@ public class IndicatorsReportService { ...@@ -47,10 +74,10 @@ public class IndicatorsReportService {
this.saveOrUpdate(indReportData); this.saveOrUpdate(indReportData);
} }
//整合指标本期同期报表数据 //整合指标本期同期指标报表数据
public String dealReportOne() { public String dealReportOne(String code) {
//获取所有考核指标结果 //获取所有考核指标结果
List<DriveIndCalResultDef> calDatas = driveIndCalResultDefMapper.findReportData(); List<DriveIndCalResultDef> calDatas = driveIndCalResultDefMapper.findReportData(code);
for(DriveIndCalResultDef calData : calDatas) { for(DriveIndCalResultDef calData : calDatas) {
//判断是否存在 //判断是否存在
String type = this.getCompareType(calData.getDate()); String type = this.getCompareType(calData.getDate());
...@@ -68,6 +95,29 @@ public class IndicatorsReportService { ...@@ -68,6 +95,29 @@ public class IndicatorsReportService {
return "deal indicators report one success"; return "deal indicators report one success";
} }
public IndicatorsReportOne fillBaseIndiReportOneData(IndicatorsData indiData,
IndicatorsReportOne indReportData) {
indReportData.setIndId(indiData.getIndId());
//根据基础项id获取基础项信息
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indiData.getIndId());
if(baseIndDef!=null) {
indReportData.setIndName(baseIndDef.getIndName());
indReportData.setDepart(baseIndDef.getIndDept());
//indReportData.setCatalogType(baseIndDef.getCatalogId()==null? "":baseIndDef.getCatalogId().toString());
}
indReportData.setCompareObj(indiData.getDim1());//对标对象
indReportData.setCompareObjDesc(indiData.getDim1Desc());//对标对象描述
indReportData.setCompareDate(indiData.getDim2());
indReportData.setCurrentValue(indiData.getValue());
//查找同期基础项
IndicatorsData sameIndData = baseIndDataService.getSingleIndData(indiData.getIndId(),
(indiData.getDim2()-100), indiData.getDim1());
if(sameIndData!=null) {
indReportData.setLastSameValue(sameIndData.getValue());
}
return indReportData;
}
public IndicatorsReportOne fillReportOneData(DriveIndCalResultDef calData, public IndicatorsReportOne fillReportOneData(DriveIndCalResultDef calData,
IndicatorsReportOne indReportData) { IndicatorsReportOne indReportData) {
indReportData.setIndId(calData.getIndId()); indReportData.setIndId(calData.getIndId());
...@@ -75,6 +125,8 @@ public class IndicatorsReportService { ...@@ -75,6 +125,8 @@ public class IndicatorsReportService {
DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(calData.getIndId()); DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(calData.getIndId());
if(driveIndDef!=null) { if(driveIndDef!=null) {
indReportData.setIndName(driveIndDef.getIndName()); indReportData.setIndName(driveIndDef.getIndName());
indReportData.setDepart(driveIndDef.getIndDept());
indReportData.setCatalogType(driveIndDef.getCatalogId()==null? "":driveIndDef.getCatalogId().toString());
} }
indReportData.setCompareObj(calData.getCompareObj());//对标对象 indReportData.setCompareObj(calData.getCompareObj());//对标对象
indReportData.setCompareObjDesc(calData.getCompareObj());//对标对象描述 indReportData.setCompareObjDesc(calData.getCompareObj());//对标对象描述
......
...@@ -142,7 +142,8 @@ ...@@ -142,7 +142,8 @@
select * select *
from drive_ind_cal_result_def from drive_ind_cal_result_def
where where
score is not null score is not null and
code = #{code}
order by date desc order by date desc
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -37,4 +37,10 @@ ...@@ -37,4 +37,10 @@
#{id} #{id}
</foreach> </foreach>
</select> </select>
<select id="findByCode" parameterType="java.util.List" resultType="com.keymobile.indicators.model.entity.scorecard.IndScorecard">
select *
from drive_ind_score_card
where code = #{code}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -14,12 +14,25 @@ ...@@ -14,12 +14,25 @@
select * select *
from indi_data_def from indi_data_def
where where
ind_id=#{indId} and dim2= #{date}
dim2= #{date} and <if test="indId!=null">
dim1 in and ind_id=#{indId}
<foreach item="obj" collection="compareObjs" open="(" close=")" separator=","> </if>
#{obj} <if test="compareObjs!=null">
</foreach> and dim1 in
<foreach item="obj" collection="compareObjs" open="(" close=")" separator=",">
#{obj}
</foreach>
</if>
</select>
<select id="getIndData" parameterType="map" resultType="com.keymobile.indicators.model.entity.indicators.IndicatorsData" >
select *
from indi_data_def
where
dim2 = #{date}
and ind_id = #{indId}
and dim1 = #{compareObj}
</select> </select>
<insert id="batchCreateIndData" parameterType="list"> <insert id="batchCreateIndData" parameterType="list">
......
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