Commit 0c96be2f by hzc

从前台获取短板单元对象(短板预警保存或预览)

parent 76fb2c53
...@@ -6,6 +6,7 @@ import java.util.Map; ...@@ -6,6 +6,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.keymobile.indicators.model.entity.shortboard.ShortBoardWarnData;
import org.apache.commons.lang.StringUtils; 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;
...@@ -135,18 +136,19 @@ public class ShortboardUnitCtrl { ...@@ -135,18 +136,19 @@ public class ShortboardUnitCtrl {
@ApiOperation(value = "根据给定的短板规则筛选短板单位(预览)", notes = "根据给定的短板规则筛选短板单位(预览)") @ApiOperation(value = "根据给定的短板规则筛选短板单位(预览)", notes = "根据给定的短板规则筛选短板单位(预览)")
@PostMapping(value = "/getObjFromShortboardRule") @PostMapping(value = "/getObjFromShortboardRule")
public List<ShortboardRecord> getObjFromShortboardRule(@RequestParam int date,@RequestParam List<String> compareObjs, public List<ShortboardRecord> getObjFromShortboardRule(@RequestBody ShortBoardWarnData shortBoardWarnData)throws Exception{
@RequestParam List<String> driveIds,@RequestParam List<Integer> shortboardRuleIds,
@RequestParam String code,@RequestParam(required=false) String user)throws Exception{ // @RequestParam int date,@RequestParam List<String> compareObjs,
return shortboardRuleService.getObjFromShortboardRule(date, compareObjs, driveIds, // @RequestParam List<String> driveIds,@RequestParam List<Integer> shortboardRuleIds,
shortboardRuleIds, code,user); // @RequestParam String code,@RequestParam(required=false) String user
return shortboardRuleService.getObjFromShortboardRule(shortBoardWarnData);
} }
@ApiOperation(value = "保存预览数据生成短板预警池数据", notes = "保存预览数据生成短板预警池数据") @ApiOperation(value = "保存预览数据生成短板预警池数据", notes = "保存预览数据生成短板预警池数据")
@PostMapping(value = "/getShortboardWarnning") @PostMapping(value = "/getShortboardWarnning")
public String getShortboardWarnning(@RequestParam Integer unitId, public String getShortboardWarnning(@RequestBody ShortBoardWarnData shortBoardWarnData)throws Exception{
@RequestParam(required=false) String user)throws Exception{ return shortboardUnitService.getShortboardObjFromUnit(shortBoardWarnData);
return shortboardUnitService.getShortboardObjFromUnit(unitId,user);
} }
@ApiOperation(value = "分页获取短板预警池数据", notes = "分页获取短板预警池数据") @ApiOperation(value = "分页获取短板预警池数据", notes = "分页获取短板预警池数据")
......
package com.keymobile.indicators.model.entity.shortboard;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("短板预警池-预览或保存")
public class ShortBoardWarnData {
@ApiModelProperty("短板单元id")
private Integer id;
@ApiModelProperty("短板对象集合")
private List<String> commpareObjs;
@ApiModelProperty("考核指标id集合")
private List<String> driveIndIds;//考核指标id,多个用分号隔开
@ApiModelProperty("短板规则id集合")
private List<Integer> shortboardIds;//短板规则id,多个用分号隔开
@ApiModelProperty("考核时间")
private Integer date;//考核时间
@ApiModelProperty("标识编码")
private String code;//标识编码
@ApiModelProperty("部门")
private String department;//部门
@ApiModelProperty("用户)保存更新者")
private String user;
}
...@@ -5,6 +5,7 @@ import java.util.HashMap; ...@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.keymobile.indicators.model.entity.shortboard.*;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -15,10 +16,6 @@ import com.google.gson.Gson; ...@@ -15,10 +16,6 @@ import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
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.shortboard.ShortboardDriveIndRel;
import com.keymobile.indicators.model.entity.shortboard.ShortboardItem;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRecord;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRule;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper; import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper; import com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper;
import com.keymobile.indicators.model.mapper.indmapper.ShortboardRuleMapper; import com.keymobile.indicators.model.mapper.indmapper.ShortboardRuleMapper;
...@@ -95,21 +92,19 @@ public class ShortboardRuleService { ...@@ -95,21 +92,19 @@ public class ShortboardRuleService {
} }
//根据给定的短板规则筛选短板单位 //根据给定的短板规则筛选短板单位
public List<ShortboardRecord> getObjFromShortboardRule(Integer date, public List<ShortboardRecord> getObjFromShortboardRule(ShortBoardWarnData shortBoardWarnData)throws Exception{
List<String> compareObjs,List<String> driveIds,
List<Integer> shortboardRuleIds,String code,String user)throws Exception{
List<ShortboardRecord> result = new ArrayList<>(); List<ShortboardRecord> result = new ArrayList<>();
Gson gson = new Gson(); Gson gson = new Gson();
int status = 0; int status = 0;
List<DriveIndCalResultDef> compareCalResults = new ArrayList<>(); List<DriveIndCalResultDef> compareCalResults = new ArrayList<>();
for(String driveId : driveIds) { for(String driveId : shortBoardWarnData.getDriveIndIds()) {
DriveIndDef driveIndDef = driveIndDefService.getById(driveId); DriveIndDef driveIndDef = driveIndDefService.getById(driveId);
if(driveIndDef!=null) { if(driveIndDef!=null) {
StringBuilder shortboardRuleIdString = new StringBuilder(""); StringBuilder shortboardRuleIdString = new StringBuilder("");
StringBuilder shortboardName = new StringBuilder(""); StringBuilder shortboardName = new StringBuilder("");
StringBuilder shortboardDesc = new StringBuilder(""); StringBuilder shortboardDesc = new StringBuilder("");
StringBuilder shortboardType = new StringBuilder(""); StringBuilder shortboardType = new StringBuilder("");
for(Integer sbRuleId : shortboardRuleIds) { for(Integer sbRuleId : shortBoardWarnData.getShortboardIds()) {
ShortboardRule shortboardRule = this.getById(sbRuleId); ShortboardRule shortboardRule = this.getById(sbRuleId);
if(shortboardRule!=null) { if(shortboardRule!=null) {
shortboardRuleIdString.append(shortboardRule.getId()).append(";");//拼接短板规则id shortboardRuleIdString.append(shortboardRule.getId()).append(";");//拼接短板规则id
...@@ -121,7 +116,7 @@ public class ShortboardRuleService { ...@@ -121,7 +116,7 @@ public class ShortboardRuleService {
for(ShortboardItem shortboardItem : shortboardItems) { for(ShortboardItem shortboardItem : shortboardItems) {
shortboardType.append(shortboardItem.getType()).append(";");//拼接短板类型 shortboardType.append(shortboardItem.getType()).append(";");//拼接短板类型
List<DriveIndCalResultDef> driveIndCalResults = this.selectShortboardObj( List<DriveIndCalResultDef> driveIndCalResults = this.selectShortboardObj(
shortboardItem, compareObjs, driveId, date, code); shortboardItem, shortBoardWarnData.getCommpareObjs(), driveId, shortBoardWarnData.getDate(), shortBoardWarnData.getCode());
if(status==0) { if(status==0) {
compareCalResults.addAll(driveIndCalResults); compareCalResults.addAll(driveIndCalResults);
status = 1; status = 1;
...@@ -139,9 +134,9 @@ public class ShortboardRuleService { ...@@ -139,9 +134,9 @@ public class ShortboardRuleService {
shortboardRecord.setDriveId(driveIndDef.getIndId()); shortboardRecord.setDriveId(driveIndDef.getIndId());
shortboardRecord.setDriveName(driveIndDef.getIndName()); shortboardRecord.setDriveName(driveIndDef.getIndName());
shortboardRecord.setValue(driveIndCalDef.getValue()); shortboardRecord.setValue(driveIndCalDef.getValue());
shortboardRecord.setDate(date); shortboardRecord.setDate(shortBoardWarnData.getDate());
shortboardRecord.setCompareCalResultJson(gson.toJson(driveIndCalDef)); shortboardRecord.setCompareCalResultJson(gson.toJson(driveIndCalDef));
shortboardRecord.setDepartment(shortBoardWarnData.getDepartment());
shortboardRecord.setShortboardRuleIds(shortboardRuleIdString.toString()); shortboardRecord.setShortboardRuleIds(shortboardRuleIdString.toString());
shortboardRecord.setShortboardName(shortboardName.toString()); shortboardRecord.setShortboardName(shortboardName.toString());
shortboardRecord.setShortboardDesc(shortboardDesc.toString()); shortboardRecord.setShortboardDesc(shortboardDesc.toString());
...@@ -152,8 +147,8 @@ public class ShortboardRuleService { ...@@ -152,8 +147,8 @@ public class ShortboardRuleService {
shortboardRecord.setUnitName(driveIndCalDef.getCompareObjDesc()); shortboardRecord.setUnitName(driveIndCalDef.getCompareObjDesc());
shortboardRecord.setIsIssue("0"); shortboardRecord.setIsIssue("0");
shortboardRecord.setCode(code); shortboardRecord.setCode(shortBoardWarnData.getCode());
shortboardRecord.setLastUpdater(user); shortboardRecord.setLastUpdater(shortBoardWarnData.getUser());
result.add(shortboardRecord); result.add(shortboardRecord);
} }
......
...@@ -7,6 +7,7 @@ import java.util.HashMap; ...@@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.keymobile.indicators.model.entity.shortboard.ShortBoardWarnData;
import com.keymobile.indicators.utils.SystemUserUtil; import com.keymobile.indicators.utils.SystemUserUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -84,44 +85,43 @@ public class ShortboardUnitService { ...@@ -84,44 +85,43 @@ public class ShortboardUnitService {
} }
//保存预览数据生成短板预警池数据 //保存预览数据生成短板预警池数据
public String getShortboardObjFromUnit(Integer id,String user) throws Exception{ public String getShortboardObjFromUnit(ShortBoardWarnData shortBoardWarnData) throws Exception{
List<ShortboardRecord> result = new ArrayList<>(); List<ShortboardRecord> result = new ArrayList<>();
ShortboardUnit shortboardUnit = this.getById(id);//根据短板单元id获取短板单元 //ShortboardUnit shortboardUnit = this.getById(id);//根据短板单元id获取短板单元
if(shortboardUnit!=null) { if(shortBoardWarnData!=null) {
List<String> compareObjList = new ArrayList<>(); List<String> compareObjList = shortBoardWarnData.getCommpareObjs();//new ArrayList<>();
List<String> driveIndIdList = new ArrayList<>(); List<String> driveIndIdList =shortBoardWarnData.getDriveIndIds();// new ArrayList<>();
List<Integer> shortboardIdList = new ArrayList<>(); List<Integer> shortboardIdList = shortBoardWarnData.getShortboardIds();// new ArrayList<>();
//转换短板对象 //转换短板对象
String compareObjsString = shortboardUnit.getCommpareObjs(); // String compareObjsString = shortBoardWarnData.getCommpareObjs();
if(StringUtils.isNotBlank(compareObjsString)) { // if(StringUtils.isNotBlank(compareObjsString)) {
String[] compareObjs = compareObjsString.split(";"); // String[] compareObjs = compareObjsString.split(";");
compareObjList = Arrays.asList(compareObjs); // compareObjList = Arrays.asList(compareObjs);
} // }
//转换考核指标id //转换考核指标id
String driveIndIdsString = shortboardUnit.getDriveIndIds(); // String driveIndIdsString = shortBoardWarnData.getDriveIndIds();
if(StringUtils.isNotBlank(driveIndIdsString)) { // if(StringUtils.isNotBlank(driveIndIdsString)) {
String[] driveIndIds = driveIndIdsString.split(";"); // String[] driveIndIds = driveIndIdsString.split(";");
driveIndIdList = Arrays.asList(driveIndIds); // driveIndIdList = Arrays.asList(driveIndIds);
} // }
//转换短板规则id //转换短板规则id
String shortboardIdsString = shortboardUnit.getShortboardIds(); // String shortboardIdsString = shortBoardWarnData.getShortboardIds();
if(StringUtils.isNotBlank(shortboardIdsString)) { // if(StringUtils.isNotBlank(shortboardIdsString)) {
String[] shortboardIds = shortboardIdsString.split(";"); // String[] shortboardIds = shortboardIdsString.split(";");
for(String shortboardId : shortboardIds) { // for(String shortboardId : shortboardIds) {
shortboardIdList.add(Integer.parseInt(shortboardId)); // shortboardIdList.add(Integer.parseInt(shortboardId));
} // }
} // }
if(!compareObjList.isEmpty() && !driveIndIdList.isEmpty() && !shortboardIdList.isEmpty()) { if(!compareObjList.isEmpty() && !driveIndIdList.isEmpty() && !shortboardIdList.isEmpty()) {
result = shortboardRuleService.getObjFromShortboardRule(shortboardUnit.getDate(), result = shortboardRuleService.getObjFromShortboardRule(shortBoardWarnData);
compareObjList, driveIndIdList, shortboardIdList,shortboardUnit.getCode(),user);
} }
if(!result.isEmpty()) { if(!result.isEmpty()) {
String currentUserId = SystemUserUtil.getCurrentUserId(); String currentUserId = SystemUserUtil.getCurrentUserId();
for(ShortboardRecord shortboardRecord : result) { for(ShortboardRecord shortboardRecord : result) {
shortboardRecord.setUserId(currentUserId); shortboardRecord.setUserId(currentUserId);
shortboardRecord.setDepartment(shortboardUnit.getDepartment()); shortboardRecord.setDepartment(shortBoardWarnData.getDepartment());
shortboardRecord.setShortboardUnitId(id); shortboardRecord.setShortboardUnitId(shortBoardWarnData.getId());
} }
//批量保存 //批量保存
shortboardRecordMapper.batchSave(result); shortboardRecordMapper.batchSave(result);
......
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