Commit 0c96be2f by hzc

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

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