Commit db434e16 by zhangkb

优化程序,将逐条新增或修改的代码改成批量新增或者修改,提高sql执行效率

parent 67c791f7
......@@ -124,6 +124,7 @@ public class DriveIndIdCalActor extends AbstractActor{
calIndAverageAndRankMsg.getDate());
//算组内排名
Map<String,Integer> rankValue = CalculateUtils.rankValue(valueMap, indType);
List<DriveIndCalResultDef> dataList = new ArrayList<>();
//填充平均数和排名到考核结果中
for(Entry<String,Integer> entry : rankValue.entrySet()) {
//根据id获取指标值结果
......@@ -133,9 +134,13 @@ public class DriveIndIdCalActor extends AbstractActor{
driveIndCalResult.setAverage(average);
driveIndCalResult.setRank(entry.getValue());
driveIndCalResult.setActualAverage(actualAverage);
driveIndCalResultService.saveOrUpdate(driveIndCalResult);
dataList.add(driveIndCalResult);
}
}
//批量保存修改
driveIndCalResultService.batchSaveOrUpdate(dataList);
//清空list
dataList.clear();
//根据评分卡算指标分数
for(Entry<String,Integer> entry : rankValue.entrySet()) {
//根据id获取指标值结果
......@@ -149,11 +154,16 @@ public class DriveIndIdCalActor extends AbstractActor{
driveIndCalResult.getCompareId(),compareObjs);
driveIndCalResult.setScore(scoreMap.get("score"));
driveIndCalResult.setImproveScore(scoreMap.get("improveScore"));
driveIndCalResultService.saveOrUpdate(driveIndCalResult);
//整合本期同期报表数据
indiReportService.dealSingleReportOneData(driveIndCalResult);
dataList.add(driveIndCalResult);
}
}
//批量保存修改
driveIndCalResultService.batchSaveOrUpdate(dataList);
//整合本期同期报表数据
indiReportService.dealReportOneDatas(dataList);
//清空list
dataList.clear();
//发送确认信息给父actor
FirstExeConfirmMsg firstExeConfirmMsg = new FirstExeConfirmMsg(1,"",compCalLogId);
compareUnitCalActor.tell(firstExeConfirmMsg, ActorRef.noSender());
......
......@@ -27,6 +27,12 @@ public class DriveIndCalResultCtrl {
@Autowired
private CompareUnitCalLogService compUnitCalLogService;
@ApiOperation(value = "对标结果批量新增,修改", notes = "对标结果批量新增,修改")
@PostMapping(value = "/batchSaveOrUpdate")
public void batchSaveOrUpdate(@RequestBody List<DriveIndCalResultDef> calResults) {
driveIndCalResultService.batchSaveOrUpdate(calResults);
}
@ApiOperation(value = "对标单元综合计算", notes = "对标单元综合计算")
@PostMapping(value = "/compareUnitListCal")
public void compareUnitListCal(@RequestBody List<CompareUnitDef> compareUnitList) {
......
......@@ -108,7 +108,7 @@ public class ShortboardUnitCtrl {
@ApiOperation(value = "保存预览数据生成短板预警池数据", notes = "保存预览数据生成短板预警池数据")
@PostMapping(value = "/getShortboardWarnning")
public List<ShortboardRecord> getShortboardWarnning(@RequestParam Integer unitId,
public String getShortboardWarnning(@RequestParam Integer unitId,
@RequestParam(required=false) String user)throws Exception{
return shortboardUnitService.getShortboardObjFromUnit(unitId,user);
}
......
......@@ -21,20 +21,20 @@ public class IndicatorsReportTwo {
private String indName;//指标名称
private String compareUnitId;//对标单元id
private String compareUnitName;//对标单元名称
private String compareDate;//对标时间
private Integer compareDate;//对标时间
private String compareType;//对标类型
private String unit;//单位
private Double currentAverage;//本期全省平均值
private Double sameAverage;//同期全省平均值
private Double averageRate;//全省平均分同比
private String currentActualAverage;//本期全省平均值
private String sameActualAverage;//同期全省平均值
private String averageRate;//全省平均分同比
private String trend;//全省平均分变化趋势 0:趋好 1:趋坏
private Double currentActualAverage;//本期实际平均值
private String currentAverage;//本期实际平均值
private String bestUnit;//标杆单位
private Double bestUnitValue;//标杆值
private String bestUnitValue;//标杆值
private Integer bestAverageUnits;//优于平均单位数
private Integer sameImproveUnits;//同比提升单位数
private Integer rankHeadThree;//排名前三
private Integer rankAfterThree;//排名末三
private Integer sameImproveHeadThree;//同比提升前三
private Integer sameImproveAfterThree;//同比提升末三
private String rankHeadThree;//排名前三
private String rankAfterThree;//排名末三
private String sameImproveHeadThree;//同比提升前三
private String sameImproveAfterThree;//同比提升末三
}
......@@ -22,4 +22,6 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{
public List<BaseIndDef> getByIndFormatLike(@Param("indId")String indId);
public List<BaseIndDef> getByIdIn(@Param("indIds") List<String> indIds);
public void deleteByIdIn(@Param("indIds") List<String> indIds);
}
......@@ -24,4 +24,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
public List<DriveIndDef> getByScorecardId(@Param("scorecardId")Integer scorecardId);
public List<DriveIndDef> getByIndFormatLike(@Param("indId")String indId);
public void deleteByIdIn(@Param("ids")List<String> ids);
}
......@@ -14,4 +14,7 @@ public interface BaseIndDefVersionDataMapper extends BaseMapper<BaseIndDefVersio
public List<BaseIndDefVersionData> getVersionDataByIndId(@Param("indId") String indId);
public void updateIsDeleteStatus(@Param("indId") String indId,@Param("status") String status);
public void updateIsDeleteStatusByIndIdIn(@Param("indIds") List<String> indIds,
@Param("status") String status);
}
......@@ -54,4 +54,9 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult
@Param("date")Integer date);
public List<DriveIndCalResultDef> findReportData(@Param("code")String code);
//批量保存
public void batchSave(@Param("datas")List<DriveIndCalResultDef> datas);
//批量修改
public void batchUpdate(@Param("datas")List<DriveIndCalResultDef> datas);
}
......@@ -14,4 +14,7 @@ public interface DriveIndDefVersionDataMapper extends BaseMapper<DriveIndDefVers
public List<DriveIndDefVersionData> getVersionDataByIndId(@Param("indId")String indId);
public void updateIsDeleteStatus(@Param("indId") String indId,@Param("status") String status);
public void updateIsDeleteStatusByIndIdIn(@Param("indIds") List<String> indIds,
@Param("status") String status);
}
......@@ -20,4 +20,6 @@ public interface IndScorecardMapper extends BaseMapper<IndScorecard>{
public List<IndScorecard> findByIdList(@Param("ids")List<Integer> ids);
public List<IndScorecard> findByCode(@Param("code") String code);
public void deleteByIdIn(@Param("ids")List<Integer> ids);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -11,4 +13,8 @@ import tk.mybatis.mapper.common.BaseMapper;
public interface ObjScoreCalResultMapper extends BaseMapper<ObjScoreCalResult>{
public ObjScoreCalResult getObjScoreCalResultByParam(@Param("compareId")String compareId,
@Param("compareObj")String compareObj,@Param("date")Integer date);
public void batchSave(@Param("datas")List<ObjScoreCalResult> datas);
public void batchUpdate(@Param("datas")List<ObjScoreCalResult> datas);
}
......@@ -20,4 +20,6 @@ public interface ScoreRuleMapper extends BaseMapper<ScoreRule>{
public int countByCatalogId(@Param("catalogId")Integer catalogId,@Param("keyword")String keyword);
public List<ScoreRule> findByIdList(@Param("ids")List<Integer> ids);
public void deleteByIdIn(@Param("ids")List<Integer> ids);
}
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRecord;
......@@ -14,4 +15,6 @@ public interface ShortboardRecordMapper extends BaseMapper<ShortboardRecord>{
public List<ShortboardRecord> getPageByCodeIn(Map<String,Object> param);
public int countByCodeIn(Map<String,Object> param);
public void batchSave(@Param("datas")List<ShortboardRecord> datas);
}
......@@ -16,4 +16,6 @@ public interface ShortboardRuleMapper extends BaseMapper<ShortboardRule>{
@Param("keyword")String keyword,@Param("start") int start,@Param("end") int end);
public int countByCatalogId(@Param("catalogId")Integer catalogId,@Param("keyword")String keyword);
public void deleteByIdIn(@Param("ids")List<Integer> ids);
}
package com.keymobile.indicators.model.mapper.report;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -12,4 +14,8 @@ public interface ReportOneMapper extends BaseMapper<IndicatorsReportOne>{
public IndicatorsReportOne getByParam(@Param("indId")String indId,
@Param("compareObj")String compareObj,@Param("date")Integer date,
@Param("type")String type);
public void batchSave(@Param("datas")List<IndicatorsReportOne> datas);
public void batchUpdate(@Param("datas")List<IndicatorsReportOne> datas);
}
package com.keymobile.indicators.model.mapper.report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.report.IndicatorsReportTwo;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ReportTwoMapper extends BaseMapper<IndicatorsReportTwo>{
public IndicatorsReportTwo getDataByParam(@Param("indId")String indId,@Param("compareUnitId")String compareUnitId,
@Param("date")Integer date,@Param("type")String type);
}
package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -79,11 +80,11 @@ public class BaseIndDefService {
public String delete(List<String> indIds) throws Exception{
StringBuilder message = new StringBuilder("");
List<String> canDeleteList = new ArrayList<>();
for(String indId : indIds) {
if(driveIndDefService.getByIndFormatLike(indId).isEmpty()&&
this.getByIndFormatLike(indId).isEmpty()) {//基础项都没有关联指标才能删除
baseIndDefMapper.deleteByPrimaryKey(indId);
baseIndDefVersionService.updateIsDeleteStatus(indId, "1");//标识已删除
canDeleteList.add(indId);
}else {
BaseIndDef baseIndDef = this.getById(indId);
if(baseIndDef!=null) {
......@@ -92,6 +93,10 @@ public class BaseIndDefService {
}
}
}
if(!canDeleteList.isEmpty()) {
baseIndDefMapper.deleteByIdIn(canDeleteList);
baseIndDefVersionService.updateIsDeleteStatusByIndIdIn(canDeleteList, "1");//标识已删除
}
if(StringUtils.isBlank(message.toString())) {
message.append("删除成功");
}
......
......@@ -41,4 +41,8 @@ public class BaseIndDefVersionService {
public void updateIsDeleteStatus(String indId,String status) {
baseIndDefVersionDataMapper.updateIsDeleteStatus(indId, status);
}
public void updateIsDeleteStatusByIndIdIn(List<String> indIds,String status) {
baseIndDefVersionDataMapper.updateIsDeleteStatusByIndIdIn(indIds, status);
}
}
package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
......@@ -33,6 +34,25 @@ public class DriveIndCalResultService {
return driveIndCalResult.getId();
}
//批量新增或者修改
public void batchSaveOrUpdate(List<DriveIndCalResultDef> driveIndCalResults) {
List<DriveIndCalResultDef> addList = new ArrayList<>();
List<DriveIndCalResultDef> updateList = new ArrayList<>();
for(DriveIndCalResultDef driveIndCalResult : driveIndCalResults) {
if(driveIndCalResult.getId()==null) {
addList.add(driveIndCalResult);//新增list
}else {
updateList.add(driveIndCalResult);//修改list
}
}
if(!addList.isEmpty()) {//批量新增
driveIndCalResultDefMapper.batchSave(addList);
}
if(!updateList.isEmpty()) {//批量修改
driveIndCalResultDefMapper.batchUpdate(updateList);
}
}
public DriveIndCalResultDef findById(Integer id) {
return driveIndCalResultDefMapper.selectByPrimaryKey(id);
}
......
......@@ -67,8 +67,11 @@ public class DriveIndCatalogService {
//递归删除
public void recursionDelete(List<Integer> ids) {
List<Integer> result = new ArrayList<>();
for(Integer id : ids) {
List<Integer> result = this.getDeleteCatalogId(id);
result.addAll(this.getDeleteCatalogId(id));
}
if(!result.isEmpty()) {
this.delete(result);
//删除目录关联的指标
driveIndDefMapper.deleteByCatalogIdIn(result);
......
......@@ -136,10 +136,8 @@ public class DriveIndDefService {
}
public void delete(List<String> indIds) throws Exception{
for(String indId : indIds) {
driveIndDefMapper.deleteByPrimaryKey(indId);
driveIndDefVersionService.updateIsDeleteStatus(indId, "1");//标识已删除
}
driveIndDefMapper.deleteByIdIn(indIds);
driveIndDefVersionService.updateIsDeleteStatusByIndIdIn(indIds, "1");//标识已删除
}
public Map<String,Object> getByPageAndKeyword(Integer catalogId,String keyword,
......
......@@ -41,4 +41,8 @@ public class DriveIndDefVersionService {
public void updateIsDeleteStatus(String indId,String status) {
driveIndDefVersionDataMapper.updateIsDeleteStatus(indId, status);
}
public void updateIsDeleteStatusByIndIdIn(List<String> indIds,String status) {
driveIndDefVersionDataMapper.updateIsDeleteStatusByIndIdIn(indIds, status);
}
}
......@@ -66,8 +66,11 @@ public class IndCatalogService {
//递归删除
public void recursionDelete(List<Integer> ids) {
List<Integer> result = new ArrayList<>();
for(Integer id : ids) {
List<Integer> result = this.getDeleteCatalogId(id);
result.addAll(this.getDeleteCatalogId(id));
}
if(!result.isEmpty()) {
this.delete(result);
//删除目录关联的指标
baseIndDefMapper.deleteByCatalogIdIn(result);
......
......@@ -73,6 +73,7 @@ public class IndScorecardService {
public String delete(List<Integer> ids) {
StringBuilder message = new StringBuilder("");
List<Integer> canDeleteIds = new ArrayList<>();
for(Integer id : ids) {
if(!driveIndDefService.getByScorecardId(id).isEmpty()) {
IndScorecard scorecard = this.findById(id);
......@@ -81,9 +82,12 @@ public class IndScorecardService {
.append("'").append("关联了考核指标,无法删除;");
}
}else {
indScorecardMapper.deleteByPrimaryKey(id);
canDeleteIds.add(id);
}
}
if(!canDeleteIds.isEmpty()) {
indScorecardMapper.deleteByIdIn(canDeleteIds);
}
if(StringUtils.isBlank(message.toString())) {
message.append("删除成功");
}
......@@ -92,11 +96,6 @@ public class IndScorecardService {
public List<IndScorecard> getAll(String code){
List<IndScorecard> scorecards = indScorecardMapper.findByCode(code);
// List<IndScorecard> result = new ArrayList<>();
// for(IndScorecard scorecard : scorecards) {
// IndScorecard scorecard1 = this.changeJson(scorecard);
// result.add(scorecard1);
// }
return scorecards;
}
......
......@@ -66,8 +66,11 @@ public class ScoreRuleCatalogService {
//递归删除
public void recursionDelete(List<Integer> ids) {
List<Integer> result = new ArrayList<>();
for(Integer id : ids) {
List<Integer> result = this.getDeleteCatalogId(id);
result.addAll(this.getDeleteCatalogId(id));
}
if(!result.isEmpty()) {
this.delete(result);
//删除目录关联的单位评分规则
scoreRuleMapper.deleteByCatalogIdIn(result);
......
......@@ -61,9 +61,7 @@ public class ScoreRuleService {
}
public void delete(List<Integer> ids) {
for(Integer id : ids) {
scoreRuleMapper.deleteByPrimaryKey(id);
}
scoreRuleMapper.deleteByIdIn(ids);
}
public List<ScoreRule> getAll(String code){
......@@ -104,6 +102,24 @@ public class ScoreRuleService {
return scoreRuleMapper.findByIdList(ids);
}
public void batchSaveOrUpdateObjScoreCalResult(List<ObjScoreCalResult> calDatas) {
List<ObjScoreCalResult> addList = new ArrayList<>();//新增list
List<ObjScoreCalResult> updateList = new ArrayList<>();//修改list
for(ObjScoreCalResult calData : calDatas) {
if(calData.getId()==null) {
addList.add(calData);
}else {
updateList.add(calData);
}
}
if(!addList.isEmpty()) {
objScoreCalResultMapper.batchSave(addList);
}
if(!updateList.isEmpty()) {
objScoreCalResultMapper.batchUpdate(updateList);
}
}
//计算组内考核指标平均值
private ObjScoreCalResult calGroupIndAverage(ObjScoreCalResult objResult,ScoreRule scoreRule,List<String> indIds,
String compareObj,int date){
......@@ -341,6 +357,7 @@ public class ScoreRuleService {
List<String> compareObjs,int date,Integer scoreRuleId) {
//根据单位得分评分卡id获取评分卡详情
ScoreRule scoreRule = this.getById(scoreRuleId);
List<ObjScoreCalResult> datas = new ArrayList<>();
if(scoreRule!=null) {
for(String compareObj : compareObjs) {
//判断库表是否已存在改结果数据
......@@ -361,12 +378,11 @@ public class ScoreRuleService {
compareObj, date);
}
objScoreCalResult.setCompareId(compareId);
if(objScoreCalResult.getId()==null) {
objScoreCalResultMapper.insert(objScoreCalResult);
}else {
objScoreCalResultMapper.updateByPrimaryKey(objScoreCalResult);
}
datas.add(objScoreCalResult);
}
//批量新增或修改
this.batchSaveOrUpdateObjScoreCalResult(datas);
}else {
logger.info("单位评分卡id:"+scoreRuleId+" 不存在");
}
......
......@@ -66,8 +66,11 @@ public class ScorecardCatalogService {
//递归删除
public void recursionDelete(List<Integer> ids) {
List<Integer> result = new ArrayList<>();
for(Integer id : ids) {
List<Integer> result = this.getDeleteCatalogId(id);
result.addAll(this.getDeleteCatalogId(id));
}
if(!result.isEmpty()) {
this.delete(result);
//删除目录关联的评分卡
indScorecardMapper.deleteByCatalogIdIn(result);
......
......@@ -65,8 +65,11 @@ public class ShortboardCatalogService {
//递归删除
public void recursionDelete(List<Integer> ids) {
List<Integer> result = new ArrayList<>();
for(Integer id : ids) {
List<Integer> result = this.getDeleteCatalogId(id);
result.addAll(this.getDeleteCatalogId(id));
}
if(!result.isEmpty()) {
this.delete(result);
//删除目录关联的短板筛选规则
shortboardRuleMapper.deleteByCatalogIdIn(result);
......
......@@ -57,9 +57,7 @@ public class ShortboardRuleService {
}
public void delete(List<Integer> ids) {
for(Integer id : ids) {
shortboardRuleMapper.deleteByPrimaryKey(id);
}
shortboardRuleMapper.deleteByIdIn(ids);
}
public Map<String,Object> getByCatalogId(Integer catalogId,String keyword,int page,int rows){
......
......@@ -66,8 +66,11 @@ public class ShortboardUnitCatalogService {
//递归删除
public void recursionDelete(List<Integer> ids) {
List<Integer> result = new ArrayList<>();
for(Integer id : ids) {
List<Integer> result = this.getDeleteCatalogId(id);
result.addAll(this.getDeleteCatalogId(id));
}
if(!result.isEmpty()) {
this.delete(result);
//删除目录关联的短板筛选规则
shortboardUnitMapper.deleteByCatalogIdIn(result);
......
......@@ -79,7 +79,7 @@ public class ShortboardUnitService {
}
//保存预览数据生成短板预警池数据
public List<ShortboardRecord> getShortboardObjFromUnit(Integer id,String user) throws Exception{
public String getShortboardObjFromUnit(Integer id,String user) throws Exception{
List<ShortboardRecord> result = new ArrayList<>();
ShortboardUnit shortboardUnit = this.getById(id);//根据短板单元id获取短板单元
if(shortboardUnit!=null) {
......@@ -113,11 +113,12 @@ public class ShortboardUnitService {
if(!result.isEmpty()) {
for(ShortboardRecord shortboardRecord : result) {
shortboardRecord.setShortboardUnitId(id);
shortboardRecordMapper.insert(shortboardRecord);
}
//批量保存
shortboardRecordMapper.batchSave(result);
}
}
return result;
return "保存成功";
}
//根据标识编码分页获取预警池短板数据
......
package com.keymobile.indicators.service.report;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
......@@ -13,10 +14,12 @@ 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.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.ReportTwoMapper;
import com.keymobile.indicators.service.hytobacco.BaseIndDataService;
import com.keymobile.indicators.utils.CalculateUtils;
......@@ -27,6 +30,8 @@ public class IndicatorsReportService {
@Autowired
private ReportOneMapper reportOneMapper;
@Autowired
private ReportTwoMapper reportTwoMapper;
@Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
@Autowired
private DriveIndDefMapper driveIndDefMapper;
......@@ -35,6 +40,16 @@ public class IndicatorsReportService {
@Autowired
private BaseIndDataService baseIndDataService;
//保存指标本期同期结果
public Integer saveOrUpdateReportTwo(IndicatorsReportTwo reportTwoData) {
if(reportTwoData.getId()==null) {
reportTwoMapper.insert(reportTwoData);
}else {
reportTwoMapper.updateByPrimaryKey(reportTwoData);
}
return reportTwoData.getId();
}
public Integer saveOrUpdate(IndicatorsReportOne reportData) {
if(reportData.getId()==null) {
reportOneMapper.insert(reportData);
......@@ -44,13 +59,50 @@ public class IndicatorsReportService {
return reportData.getId();
}
public void batchSaveOrUpdate(List<IndicatorsReportOne> reportDatas) {
List<IndicatorsReportOne> addList = new ArrayList<>();
List<IndicatorsReportOne> updateList = new ArrayList<>();
for(IndicatorsReportOne reportData : reportDatas) {
if(reportData.getId()==null) {
addList.add(reportData);
}else {
updateList.add(reportData);
}
}
if(!addList.isEmpty()) {//批量新增
reportOneMapper.batchSave(addList);
}
if(!updateList.isEmpty()) {//批量修改
reportOneMapper.batchUpdate(updateList);
}
}
public void dealDriveIndReportTwoData(String compareUnitId,Integer date) {
String type = this.getCompareType(date);
List<DriveIndCalResultDef> calDatas = driveIndCalResultDefMapper.findByCompareIdAndDate(
compareUnitId, date);
for(DriveIndCalResultDef calData : calDatas) {
//判断是否存在
IndicatorsReportTwo indReportData = reportTwoMapper.getDataByParam(calData.getIndId(),
compareUnitId, date, type);
if(indReportData!=null) {
indReportData = new IndicatorsReportTwo();
}
indReportData.setCompareType(type);
indReportData.setUnit(calData.getUnit());
//TODO:
this.saveOrUpdateReportTwo(indReportData);
}
}
//异步执行基础项数据整合
@Async
public void dealBaseIndReportOneData(Integer date,List<String> compareObjs) {
String type = this.getCompareType(date);
//根据条件获取基础项数据
List<IndicatorsData> indiDatas = baseIndDataService.getIndDataByParam(date, compareObjs);
List<IndicatorsReportOne> datas = new ArrayList<>();
for(IndicatorsData indiData : indiDatas) {
String type = this.getCompareType(indiData.getDim2());
//判断是否存在
IndicatorsReportOne indReportData = reportOneMapper.getByParam(
indiData.getIndId(), indiData.getDim1(), indiData.getDim2(), type);
......@@ -60,25 +112,32 @@ public class IndicatorsReportService {
indReportData.setCompareType(type);
indReportData.setUnit(indiData.getUnit());
indReportData = fillBaseIndiReportOneData(indiData,indReportData);
this.saveOrUpdate(indReportData);
datas.add(indReportData);
}
//批量新增或修改
this.batchSaveOrUpdate(datas);
logger.info("完成基础项本期同期整合");
}
//处理单挑指标结果报表数据
public void dealSingleReportOneData(DriveIndCalResultDef calData) {
String type = this.getCompareType(calData.getDate());
//判断是否存在
IndicatorsReportOne indReportData = reportOneMapper.getByParam(
calData.getIndId(), calData.getCompareObj(), calData.getDate(), type);
if(indReportData==null) {
indReportData = new IndicatorsReportOne();
public void dealReportOneDatas(List<DriveIndCalResultDef> calDatas) {
List<IndicatorsReportOne> datas = new ArrayList<>();
for(DriveIndCalResultDef calData : calDatas) {
String type = this.getCompareType(calData.getDate());
//判断是否存在
IndicatorsReportOne indReportData = reportOneMapper.getByParam(
calData.getIndId(), calData.getCompareObj(), calData.getDate(), type);
if(indReportData==null) {
indReportData = new IndicatorsReportOne();
}
indReportData.setCode(calData.getCode());
indReportData.setCompareType(type);
indReportData.setUnit(calData.getUnit());
indReportData = this.fillReportOneData(calData, indReportData);
datas.add(indReportData);
}
indReportData.setCode(calData.getCode());
indReportData.setCompareType(type);
indReportData.setUnit(calData.getUnit());
indReportData = this.fillReportOneData(calData, indReportData);
this.saveOrUpdate(indReportData);
//批量新增或修改
this.batchSaveOrUpdate(datas);
}
//整合指标本期同期指标报表数据
......@@ -86,6 +145,7 @@ public class IndicatorsReportService {
public String dealReportOne(String code) {
//获取所有考核指标结果
List<DriveIndCalResultDef> calDatas = driveIndCalResultDefMapper.findReportData(code);
List<IndicatorsReportOne> datas = new ArrayList<>();
for(DriveIndCalResultDef calData : calDatas) {
//判断是否存在
String type = this.getCompareType(calData.getDate());
......@@ -98,8 +158,9 @@ public class IndicatorsReportService {
indReportData.setCompareType(type);
indReportData.setUnit(calData.getUnit());
indReportData = this.fillReportOneData(calData, indReportData);
this.saveOrUpdate(indReportData);
datas.add(indReportData);
}
this.batchSaveOrUpdate(datas);//批量新增或修改
return "deal indicators report one success";
}
......
......@@ -5,7 +5,7 @@ spring:
hibernate:
ddl-auto: update
datasource:
url: jdbc:mysql://139.198.127.54:9306/hyindicators?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://139.198.127.54:9306/hyindicators?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
username: test
password: test
hikari:
......
......@@ -55,4 +55,13 @@
#{id}
</foreach>
</select>
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from base_ind_def
where ind_id in
<foreach item="id" collection="indIds" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -10,4 +10,13 @@
<update id="updateIsDeleteStatus">
update base_ind_def_version_data set is_delete=#{status} where ind_id=#{indId}
</update>
<update id="updateIsDeleteStatusByIndIdIn">
update base_ind_def_version_data
set is_delete=#{status}
where ind_id in
<foreach item="id" collection="indIds" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -146,4 +146,79 @@
code = #{code}
order by date desc
</select>
<insert id="batchSave" parameterType="java.util.List">
insert into drive_ind_cal_result_def(
compare_id, ind_id, compare_obj, compare_obj_desc, date, value, unit, type,
is_right, last_update_time, last_updater, average, rank, score, improve_score,
actual_average, code)
values
<foreach collection="datas" item="val" separator=",">
(
#{val.compareId}, #{val.indId}, #{val.compareObj}, #{val.compareObjDesc}, #{val.date},
#{val.value},#{val.unit},#{val.type},#{val.isRight},#{val.lastUpdateTime},#{val.lastUpdater},
#{val.average},#{val.rank},#{val.score},#{val.improveScore},#{val.actualAverage},#{val.code}
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="datas" item="val" index="index" separator=";">
update drive_ind_cal_result_def
<set>
<if test="val.compareId != null">
compare_id = #{val.compareId},
</if>
<if test="val.indId != null">
ind_id = #{val.indId},
</if>
<if test="val.compareObj != null">
compare_obj = #{val.compareObj},
</if>
<if test="val.compareObjDesc != null">
compare_obj_desc = #{val.compareObjDesc},
</if>
<if test="val.date != null">
date = #{val.date},
</if>
<if test="val.value != null">
value = #{val.value},
</if>
<if test="val.unit != null">
unit = #{val.unit},
</if>
<if test="val.type != null">
type = #{val.type},
</if>
<if test="val.isRight != null">
is_right = #{val.isRight},
</if>
<if test="val.lastUpdateTime != null">
last_update_time = #{val.lastUpdateTime},
</if>
<if test="val.lastUpdater != null">
last_updater = #{val.lastUpdater},
</if>
<if test="val.average != null">
average = #{val.average},
</if>
<if test="val.rank != null">
rank = #{val.rank},
</if>
<if test="val.score != null">
score = #{val.score},
</if>
<if test="val.improveScore != null">
improve_score = #{val.improveScore},
</if>
<if test="val.actualAverage != null">
actual_average = #{val.actualAverage},
</if>
<if test="val.code != null">
code = #{val.code},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -61,4 +61,13 @@
from drive_ind_def
where ind_format like #{indId}
</select>
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from drive_ind_def
where ind_id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -10,4 +10,13 @@
<update id="updateIsDeleteStatus">
update drive_ind_def_version_data set is_delete=#{status} where ind_id=#{indId}
</update>
<update id="updateIsDeleteStatusByIndIdIn">
update drive_ind_def_version_data
set is_delete=#{status}
where ind_id in
<foreach item="id" collection="indIds" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -43,4 +43,13 @@
from drive_ind_score_card
where code = #{code}
</select>
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from drive_ind_score_card
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -8,4 +8,45 @@
compare_obj=#{compareObj} and
date=#{date}
</select>
<insert id="batchSave" parameterType="java.util.List">
insert into obj_score_cal_result(
compare_id, compare_obj, compare_obj_desc, ind_ids, date, score_value, improve_value)
values
<foreach collection="datas" item="val" separator=",">
(
#{val.compareId}, #{val.compareObj}, #{val.compareObjDesc}, #{val.indIds}, #{val.date},
#{val.scoreValue},#{val.improveValue})
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="datas" item="val" separator=";">
update obj_score_cal_result
<set>
<if test="val.compareId != null">
compare_id = #{val.compareId},
</if>
<if test="val.compareObj != null">
compare_obj = #{val.compareObj},
</if>
<if test="val.compareObjDesc != null">
compare_obj_desc = #{val.compareObjDesc},
</if>
<if test="val.indIds != null">
ind_ids = #{val.indIds},
</if>
<if test="val.date != null">
date = #{val.date},
</if>
<if test="val.scoreValue != null">
score_value = #{val.scoreValue},
</if>
<if test="val.improveValue != null">
improve_value = #{val.improveValue},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -10,4 +10,87 @@
compare_date = #{date} and
compare_type = #{type}
</select>
<insert id="batchSave" parameterType="java.util.List">
insert into indicators_report_one(
ind_id, ind_name, compare_obj, compare_obj_desc, compare_date, compare_type, unit, depart,
catalog_type, current_value, last_same_value, value_rate, current_rank, last_same_rank,
current_score, current_improve, last_same_score, last_same_improve, code)
values
<foreach collection="datas" item="val" separator=",">
(
#{val.indId}, #{val.indName}, #{val.compareObj}, #{val.compareObjDesc}, #{val.compareDate},
#{val.compareType},#{val.unit},#{val.depart},#{val.catalogType},#{val.currentValue},
#{val.lastSameValue},#{val.valueRate},#{val.currentRank},#{val.lastSameRank},
#{val.currentScore},#{val.currentImprove},#{val.lastSameScore},#{val.lastSameImprove},
#{val.code}
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="datas" item="val" separator=";">
update indicators_report_one
<set>
<if test="val.indId != null">
ind_id = #{val.indId},
</if>
<if test="val.indName != null">
ind_name = #{val.indName},
</if>
<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.unit != null">
unit = #{val.unit},
</if>
<if test="val.depart != null">
depart = #{val.depart},
</if>
<if test="val.catalogType != null">
catalog_type = #{val.catalogType},
</if>
<if test="val.currentValue != null">
current_value = #{val.currentValue},
</if>
<if test="val.lastSameValue != null">
last_same_value = #{val.lastSameValue},
</if>
<if test="val.valueRate != null">
value_rate = #{val.valueRate},
</if>
<if test="val.currentRank != null">
current_rank = #{val.currentRank},
</if>
<if test="val.lastSameRank != null">
last_same_rank = #{val.lastSameRank},
</if>
<if test="val.currentScore != null">
current_score = #{val.currentScore},
</if>
<if test="val.currentImprove != null">
current_improve = #{val.currentImprove},
</if>
<if test="val.lastSameScore != null">
last_same_score = #{val.lastSameScore},
</if>
<if test="val.lastSameImprove != null">
last_same_improve = #{val.lastSameImprove},
</if>
<if test="val.code != null">
code = #{val.code},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</mapper>
\ No newline at end of file
<?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.ReportTwoMapper">
<select id="getDataByParam" resultType="com.keymobile.indicators.model.entity.report.IndicatorsReportTwo" >
select *
from indicators_report_two
where
ind_id = #{indId} and
compare_unit_id = #{compareUnitId} and
compare_date = #{date} and
compare_type = #{type}
</select>
</mapper>
\ No newline at end of file
......@@ -43,4 +43,13 @@
#{id}
</foreach>
</select>
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from obj_score_rule
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -20,4 +20,20 @@
#{id}
</foreach>
</select>
<insert id="batchSave" parameterType="java.util.List">
insert into short_board_record(
shortboard_unit_id, compare_obj, drive_id, drive_name, value, date, compare_cal_result_json,
shortboard_rule_ids, shortboard_name, shortboard_desc, shortboard_type, is_issue, code,
last_updater, last_update_time)
values
<foreach collection="datas" item="val" separator=",">
(
#{val.shortboardUnitId}, #{val.compareObj}, #{val.driveId}, #{val.driveName}, #{val.value},
#{val.date},#{val.compareCalResultJson},#{val.shortboardRuleIds},#{val.shortboardName},
#{val.shortboardDesc},#{val.shortboardType},#{val.isIssue},#{val.code},#{val.lastUpdater},
#{val.lastUpdateTime}
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -28,4 +28,13 @@
#{id}
</foreach>
</delete>
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from short_board_rule
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