Commit f3525e0a by zhangkb

指标报表三数据接口代码提交

parent 42b12963
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-8-21 desc:对标报表3
*/
@Data
@Table(name ="indicators_report_three")
public class IndicatorsReportThree {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String compareObj;
private String compareObjDesc;
private Integer compareDate;//对标时间
private String compareType;//对标类型
private Integer batterAverageIndCount;//优于平均水平指标个数
private Integer badAverageIndCount;//劣于平均水平指标个数
private Integer rankHeadThreeIndCount;//排名前三的指标个数
private Integer rankAfterThreeIndCount;//排名末三的指标个数
private Integer indImproveCount;//指标提升个数
private Integer indImproveHeadThreeCount;//指标提升排名前三的指标个数
private Integer indImproveAfterThreeCount;//指标提升排名末三的指标个数
private String indImproveRate;//指标提升率
}
package com.keymobile.indicators.model.mapper.report;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.report.IndicatorsReportThree;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ReportThreeMapper extends BaseMapper<IndicatorsReportThree>{
public IndicatorsReportThree getByParam(@Param("compareObj")String compareObj,
@Param("date")Integer date,@Param("type")String type);
public void batchSave(@Param("datas")List<IndicatorsReportThree> datas);
public void batchUpdate(@Param("datas")List<IndicatorsReportThree> datas);
}
......@@ -18,11 +18,13 @@ import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
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.IndicatorsReportThree;
import com.keymobile.indicators.model.entity.report.IndicatorsReportTwo;
import com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper;
import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.model.mapper.report.ReportOneMapper;
import com.keymobile.indicators.model.mapper.report.ReportThreeMapper;
import com.keymobile.indicators.model.mapper.report.ReportTwoMapper;
import com.keymobile.indicators.service.hytobacco.BaseIndDataService;
import com.keymobile.indicators.utils.CalculateUtils;
......@@ -36,6 +38,8 @@ public class IndicatorsReportService {
@Autowired
private ReportTwoMapper reportTwoMapper;
@Autowired
private ReportThreeMapper reportThreeMapper;
@Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
@Autowired
private DriveIndDefMapper driveIndDefMapper;
......@@ -54,6 +58,24 @@ public class IndicatorsReportService {
return reportTwoData.getId();
}
public void batchSaveOrUpdateReportThree(List<IndicatorsReportThree> reportThreeDatas) {
List<IndicatorsReportThree> addList = new ArrayList<>();
List<IndicatorsReportThree> updateList = new ArrayList<>();
for(IndicatorsReportThree reportThreeData : reportThreeDatas) {
if(reportThreeData.getId()==null) {
addList.add(reportThreeData);
}else {
updateList.add(reportThreeData);
}
}
if(!addList.isEmpty()) {
reportThreeMapper.batchSave(addList);
}
if(!updateList.isEmpty()) {
reportThreeMapper.batchUpdate(updateList);
}
}
public void batchSaveOrUpdateReportTwo(List<IndicatorsReportTwo> reportTwoDatas) {
List<IndicatorsReportTwo> addList = new ArrayList<>();
List<IndicatorsReportTwo> updateList = new ArrayList<>();
......@@ -100,6 +122,13 @@ public class IndicatorsReportService {
}
@Async
public void dealDriveIndReportThreeData(String compareId,List<String> indIds,Integer date) {
List<IndicatorsReportThree> dataList = new ArrayList<>();
this.batchSaveOrUpdateReportThree(dataList);
}
@Async
public void dealDriveIndReportTwoData(String compareUnitId,List<String> indIds,
List<String> compareObjs,Integer date) {
List<IndicatorsReportTwo> dataList = new ArrayList<>();
......
<?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.report.ReportThreeMapper">
<select id="getByParam" resultType="com.keymobile.indicators.model.entity.report.IndicatorsReportThree" >
select *
from indicators_report_three
where
compare_obj = #{compareObj} and
compare_date = #{date} and
compare_type = #{type}
</select>
<insert id="batchSave" parameterType="java.util.List">
insert indicators_report_three(
compare_obj, compare_obj_desc, compare_date, compare_type, batter_average_ind_count,
bad_average_ind_count, rank_head_three_ind_count, rank_after_three_ind_count,
ind_improve_count, ind_improve_head_three_count, ind_improve_after_three_count,
ind_improve_rate)
values
<foreach collection="datas" item="val" separator=",">
(
#{val.compareObj}, #{val.compareObjDesc}, #{val.compareDate}, #{val.compareType},
#{val.batterAverageIndCount}, #{val.badAverageIndCount}, #{val.rankHeadThreeIndCount},
#{val.rankAfterThreeIndCount}, #{val.indImproveCount}, #{val.indImproveHeadThreeCount},
#{val.indImproveAfterThreeCount}, #{val.indImproveRate}
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="datas" item="val" separator=";">
update indicators_report_three
<set>
<if test="val.compareObj != null">
compare_obj = #{val.compareObj},
</if>
<if test="val.compareObjDesc != null">
compare_obj_desc = #{val.compareObjDesc},
</if>
<if test="val.compareDate != null">
compare_date = #{val.compareDate},
</if>
<if test="val.compareType != null">
compare_type = #{val.compareType},
</if>
<if test="val.batterAverageIndCount != null">
batter_average_ind_count = #{val.batterAverageIndCount},
</if>
<if test="val.badAverageIndCount != null">
bad_average_ind_count = #{val.badAverageIndCount},
</if>
<if test="val.rankHeadThreeIndCount != null">
rank_head_three_ind_count = #{val.rankHeadThreeIndCount},
</if>
<if test="val.rankAfterThreeIndCount != null">
rank_after_three_ind_count = #{val.rankAfterThreeIndCount},
</if>
<if test="val.indImproveCount != null">
ind_improve_count = #{val.indImproveCount},
</if>
<if test="val.indImproveHeadThreeCount != null">
ind_improve_head_three_count = #{val.indImproveHeadThreeCount},
</if>
<if test="val.indImproveAfterThreeCount != null">
ind_improve_after_three_count = #{val.indImproveAfterThreeCount},
</if>
<if test="val.indImproveRate != null">
ind_improve_rate = #{val.indImproveRate},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</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