Commit a50d2545 by hzc

增加数据运算里的试运算、计算、短板里的运算日志

parent 31fe167b
...@@ -60,6 +60,8 @@ public class BeforeCompareUnitCalActor extends AbstractActor{ ...@@ -60,6 +60,8 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
StartCompareUnitCalMsg startCompareUnitCalMsg = new StartCompareUnitCalMsg( StartCompareUnitCalMsg startCompareUnitCalMsg = new StartCompareUnitCalMsg(
compareUnitDefs,beforeCompareUnitCalMsg.getCode(), compareUnitDefs,beforeCompareUnitCalMsg.getCode(),
beforeCompareUnitCalMsg.getIsTest()); beforeCompareUnitCalMsg.getIsTest());
//加入点击运算的用户
startCompareUnitCalMsg.setUser(beforeCompareUnitCalMsg.getUser());
ActorRef startCompareUnitCalActor = this.getContext().actorOf(Props.create( ActorRef startCompareUnitCalActor = this.getContext().actorOf(Props.create(
StartCompareUnitCalActor.class,()-> new StartCompareUnitCalActor(getSelf()))); StartCompareUnitCalActor.class,()-> new StartCompareUnitCalActor(getSelf())));
startCompareUnitCalActor.tell(startCompareUnitCalMsg, getSelf()); startCompareUnitCalActor.tell(startCompareUnitCalMsg, getSelf());
......
...@@ -78,6 +78,10 @@ public class CompareUnitCalActor extends AbstractActor{ ...@@ -78,6 +78,10 @@ public class CompareUnitCalActor extends AbstractActor{
//新增运行日志记录 //新增运行日志记录
CompareUnitCalLog compCalLog = new CompareUnitCalLog(compareId,date, CompareUnitCalLog compCalLog = new CompareUnitCalLog(compareId,date,
System.currentTimeMillis()+"","0"); System.currentTimeMillis()+"","0");
compCalLog.setCreater(compareUnitCalMsg.getUser());
//1成功
compCalLog.setStatus(1);
compCalLog.setType(isTest);
//保存 //保存
Integer compCalLogId = compareUnitCalLogService.saveOrUndate(compCalLog); Integer compCalLogId = compareUnitCalLogService.saveOrUndate(compCalLog);
......
...@@ -149,6 +149,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -149,6 +149,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{
} }
if(baseIndValueMsg.getIsFinish()==0) { if(baseIndValueMsg.getIsFinish()==0) {
//日志填充 //日志填充
compCalLog.setStatus(0);
if(compCalLog!=null) { if(compCalLog!=null) {
String logInfo = compCalLog.getLogInfo(); String logInfo = compCalLog.getLogInfo();
if(StringUtils.isNotBlank(logInfo)) { if(StringUtils.isNotBlank(logInfo)) {
...@@ -179,6 +180,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -179,6 +180,8 @@ public class DriveIndIdObjCalActor extends AbstractActor{
"formula:"+driveIndFormula+";"+ "formula:"+driveIndFormula+";"+
"errorValue:"+indValue+";"+"paramEnv:"+env); "errorValue:"+indValue+";"+"paramEnv:"+env);
//日志记录 //日志记录
//运算失败
compCalLog.setStatus(0);
String logInfo = compCalLog.getLogInfo(); String logInfo = compCalLog.getLogInfo();
if(StringUtils.isNotBlank(logInfo)) { if(StringUtils.isNotBlank(logInfo)) {
logInfo+="替换公式值出错:driveIndId:"+driveIndId+";"+ logInfo+="替换公式值出错:driveIndId:"+driveIndId+";"+
...@@ -279,6 +282,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -279,6 +282,7 @@ public class DriveIndIdObjCalActor extends AbstractActor{
compCalLog.setLogInfo("计算考核指标出错:driveIndId:"+driveIndId+";"+ compCalLog.setLogInfo("计算考核指标出错:driveIndId:"+driveIndId+";"+
"paramEnv:"+env+";formula:"+driveIndFormula+"</n>"); "paramEnv:"+env+";formula:"+driveIndFormula+"</n>");
} }
compCalLog.setStatus(0);
//保存日志 //保存日志
if(compCalLog!=null) { if(compCalLog!=null) {
compareUnitCalLogService.saveOrUndate(compCalLog); compareUnitCalLogService.saveOrUndate(compCalLog);
...@@ -292,6 +296,10 @@ public class DriveIndIdObjCalActor extends AbstractActor{ ...@@ -292,6 +296,10 @@ public class DriveIndIdObjCalActor extends AbstractActor{
} }
}else { }else {
//返回考核指标因为考核指标公式中的数据项不存在而导致的计算错误标识 //返回考核指标因为考核指标公式中的数据项不存在而导致的计算错误标识
//保存日志
if(compCalLog!=null) {
compareUnitCalLogService.saveOrUndate(compCalLog);
}
CalIndAverageAndRankMsg driveIndAverageAndRankMsg = CalIndAverageAndRankMsg driveIndAverageAndRankMsg =
new CalIndAverageAndRankMsg(-1, new CalIndAverageAndRankMsg(-1,
compareId,driveIndId,compareObj,date,"NaN", compareId,driveIndId,compareObj,date,"NaN",
......
...@@ -63,6 +63,7 @@ public class StartCompareUnitCalActor extends AbstractActor{ ...@@ -63,6 +63,7 @@ public class StartCompareUnitCalActor extends AbstractActor{
.match(StartCompareUnitCalMsg.class,startCompareUnitCalMsg -> { .match(StartCompareUnitCalMsg.class,startCompareUnitCalMsg -> {
code = startCompareUnitCalMsg.getCode(); code = startCompareUnitCalMsg.getCode();
isTest = startCompareUnitCalMsg.getIsTest(); isTest = startCompareUnitCalMsg.getIsTest();
String user = startCompareUnitCalMsg.getUser();
List<CompareUnitDef> compareUnitDefs = startCompareUnitCalMsg.getCompareInitDefs(); List<CompareUnitDef> compareUnitDefs = startCompareUnitCalMsg.getCompareInitDefs();
//将对标单元进行分类,需要先执行的先开始进行对标计算 //将对标单元进行分类,需要先执行的先开始进行对标计算
for(CompareUnitDef unitDef : compareUnitDefs) { for(CompareUnitDef unitDef : compareUnitDefs) {
...@@ -88,6 +89,9 @@ public class StartCompareUnitCalActor extends AbstractActor{ ...@@ -88,6 +89,9 @@ public class StartCompareUnitCalActor extends AbstractActor{
CompareUnitCalMsg compareUnitCalMsg = new CompareUnitCalMsg(unitDef, CompareUnitCalMsg compareUnitCalMsg = new CompareUnitCalMsg(unitDef,
startCompareUnitCalMsg.getCode(), startCompareUnitCalMsg.getCode(),
startCompareUnitCalMsg.getIsTest()); startCompareUnitCalMsg.getIsTest());
//运算者
compareUnitCalMsg.setUser(user);
ActorRef compareUnitCalActor = this.getContext() ActorRef compareUnitCalActor = this.getContext()
.actorOf(Props.create(CompareUnitCalActor.class, .actorOf(Props.create(CompareUnitCalActor.class,
()->new CompareUnitCalActor(getSelf()))); ()->new CompareUnitCalActor(getSelf())));
......
...@@ -15,13 +15,23 @@ public class CompareUnitCalMsg implements Serializable{ ...@@ -15,13 +15,23 @@ public class CompareUnitCalMsg implements Serializable{
private String code; private String code;
private String isTest; private String isTest;
private String user;
public CompareUnitCalMsg(CompareUnitDef compareUnitDef,String code,String isTest) { public CompareUnitCalMsg(CompareUnitDef compareUnitDef,String code,String isTest) {
this.compareUnitDef = compareUnitDef; this.compareUnitDef = compareUnitDef;
this.code = code; this.code = code;
this.isTest = isTest; this.isTest = isTest;
} }
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public CompareUnitDef getCompareUnitDef() { public CompareUnitDef getCompareUnitDef() {
return compareUnitDef; return compareUnitDef;
} }
......
...@@ -17,13 +17,23 @@ public class StartCompareUnitCalMsg implements Serializable{ ...@@ -17,13 +17,23 @@ public class StartCompareUnitCalMsg implements Serializable{
private String code; private String code;
private String isTest; private String isTest;
private String user;
public StartCompareUnitCalMsg(List<CompareUnitDef> compareInitDefs,String code,String isTest) { public StartCompareUnitCalMsg(List<CompareUnitDef> compareInitDefs,String code,String isTest) {
this.compareInitDefs.addAll(compareInitDefs); this.compareInitDefs.addAll(compareInitDefs);
this.code = code; this.code = code;
this.setIsTest(isTest); this.setIsTest(isTest);
} }
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public List<CompareUnitDef> getCompareInitDefs() { public List<CompareUnitDef> getCompareInitDefs() {
return compareInitDefs; return compareInitDefs;
} }
......
package com.keymobile.indicators.api.hytobacco; package com.keymobile.indicators.api.hytobacco;
import java.util.ArrayList;
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.indicators.CompareUnitCalLog;
import io.swagger.annotations.ApiParam;
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.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -86,4 +93,7 @@ public class DriveIndCalResultCtrl { ...@@ -86,4 +93,7 @@ public class DriveIndCalResultCtrl {
@RequestParam String code) { @RequestParam String code) {
driveIndCalResultService.deleteCompareUnitData(compareIds, currentDate, sameDate, code); driveIndCalResultService.deleteCompareUnitData(compareIds, currentDate, sameDate, code);
} }
} }
package com.keymobile.indicators.api.hytobacco; package com.keymobile.indicators.api.hytobacco;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.keymobile.indicators.model.entity.shortboard.ShortBoardWarnData; import com.keymobile.indicators.model.entity.shortboard.*;
import com.keymobile.indicators.service.hytobacco.ShortComparedLogService;
import io.swagger.annotations.ApiParam;
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.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -16,9 +22,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -16,9 +22,6 @@ 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.constant.Constants; import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRecord;
import com.keymobile.indicators.model.entity.shortboard.ShortboardUnit;
import com.keymobile.indicators.model.entity.shortboard.ShortboardUnitCatalog;
import com.keymobile.indicators.service.hytobacco.ShortboardRuleService; import com.keymobile.indicators.service.hytobacco.ShortboardRuleService;
import com.keymobile.indicators.service.hytobacco.ShortboardUnitCatalogService; import com.keymobile.indicators.service.hytobacco.ShortboardUnitCatalogService;
import com.keymobile.indicators.service.hytobacco.ShortboardUnitService; import com.keymobile.indicators.service.hytobacco.ShortboardUnitService;
...@@ -37,7 +40,9 @@ public class ShortboardUnitCtrl { ...@@ -37,7 +40,9 @@ public class ShortboardUnitCtrl {
private ShortboardUnitService shortboardUnitService; private ShortboardUnitService shortboardUnitService;
@Autowired @Autowired
private ShortboardRuleService shortboardRuleService; private ShortboardRuleService shortboardRuleService;
@Autowired
private ShortComparedLogService shortComparedLogService;
@ApiOperation(value = "新增/修改短板筛选单元目录", notes = "新增/修改短板筛选单元目录") @ApiOperation(value = "新增/修改短板筛选单元目录", notes = "新增/修改短板筛选单元目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public Integer saveOrUpdateCatalog(@RequestBody ShortboardUnitCatalog shortboardUnitCatalog, public Integer saveOrUpdateCatalog(@RequestBody ShortboardUnitCatalog shortboardUnitCatalog,
...@@ -159,4 +164,23 @@ public class ShortboardUnitCtrl { ...@@ -159,4 +164,23 @@ public class ShortboardUnitCtrl {
@RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "10") int rows)throws Exception{ @RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "10") int rows)throws Exception{
return shortboardUnitService.getShortboardRecordPage(codes, page, rows); return shortboardUnitService.getShortboardRecordPage(codes, page, rows);
} }
@ApiOperation(value = "分页获取短板单元日志", notes = "分页获取短板单元日志")
@PostMapping(value = "/findComparedLogPage")
public Page<ShortComparedLog> findComparedLogPage(@ApiParam("短板运算单元id") @RequestParam(value = "shortUnitId") Integer shortUnitId,
@ApiParam("页码,从1开始") @RequestParam("pageNo") int page,
@ApiParam("每页条数") @RequestParam("pageSize") int pageSize){
PageRequest request = PageRequest.of(page-1,pageSize);
Map<String,Object> params = new HashMap<>();
params.put("page",request.getOffset());
params.put("pageSize",pageSize);
params.put("shortUnitId",shortUnitId);
long count =shortComparedLogService.selectComparedLogCountByParams(params);
List<ShortComparedLog> shortComparedLogs = new ArrayList<>();
if(count>0){
shortComparedLogs=shortComparedLogService.findComparedLogPageByParams(params);
}
return new PageImpl<>(shortComparedLogs,request,count);
}
} }
...@@ -29,7 +29,8 @@ public class CompareUnitCalLog { ...@@ -29,7 +29,8 @@ public class CompareUnitCalLog {
private String startTime; private String startTime;
private String endTime; private String endTime;
private String runStatus;//0:运行中 1:运行完成 private String runStatus;//0:运行中 1:运行完成
private Integer status;//1成功0失败
private String type;//0试运行 1运行
public CompareUnitCalLog(String compareId,Integer date,String startTime,String runStatus) { public CompareUnitCalLog(String compareId,Integer date,String startTime,String runStatus) {
this.compareId = compareId; this.compareId = compareId;
this.date = date; this.date = date;
......
package com.keymobile.indicators.model.entity.shortboard;
import javax.persistence.*;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Date;
/**
* @Description
* @Author Hunter
* @Date 2020-10-22
*/
@Data
@Table ( name ="short_compared_log" )
@ApiModel("短板运算日志")
public class ShortComparedLog implements Serializable {
private static final long serialVersionUID = 4162200769912762515L;
@Id
@Column(name = "id" )
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 运算短板单元id
*/
@ApiModelProperty("运算短板单元id")
@Column(name = "short_unit_id" )
private Integer shortUnitId;
/**
* 短板单元name
*/
@ApiModelProperty("短板单元name")
@Column(name = "short_unit_name" )
private String shortUnitName;
/**
* 日记信息
*/
@ApiModelProperty("日记信息")
@Column(name = "loginfo" )
private String loginfo;
/**
* 1成功0失败 2 运行中
*/
@ApiModelProperty("0失败 1成功 2 运行中")
@Column(name = "status" )
private Integer status;
/**
* 筛选出多少条预警池数据
*/
@ApiModelProperty("筛选出多少条预警池数据")
@Column(name = "value" )
private Integer value;
/**
* 创造者
*/
@ApiModelProperty("创造者")
@Column(name = "creat_user" )
private String creatUser;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@Column(name = "creat_time" )
private Date creatTime;
}
package com.keymobile.indicators.model.mapper.indmapper;
import com.keymobile.indicators.model.entity.shortboard.ShortComparedLog;
import org.apache.ibatis.annotations.Mapper;
import tk.mybatis.mapper.common.BaseMapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface ShortComparedLogMapper extends BaseMapper<ShortComparedLog> {
long selectComparedLogCountByParams(Map<String, Object> params);
List<ShortComparedLog> findComparedLogPageByParams(Map<String, Object> params);
}
...@@ -5,6 +5,8 @@ import java.util.HashMap; ...@@ -5,6 +5,8 @@ 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.indicators.CompareUnitCalLog;
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;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -110,6 +112,9 @@ public class DriveIndCalResultService { ...@@ -110,6 +112,9 @@ public class DriveIndCalResultService {
final ActorSystem system = ActorSystem.create("CompareUnitCalAkka");//创建akka final ActorSystem system = ActorSystem.create("CompareUnitCalAkka");//创建akka
StartCompareUnitCalMsg startCompareUnitCalMsg = new StartCompareUnitCalMsg( StartCompareUnitCalMsg startCompareUnitCalMsg = new StartCompareUnitCalMsg(
sameCompareUnitList,code,isTest); sameCompareUnitList,code,isTest);
startCompareUnitCalMsg.setUser(SystemUserUtil.getCurrentUser());
ActorRef beforeCompareUnitCalActor = system.actorOf(Props.create( ActorRef beforeCompareUnitCalActor = system.actorOf(Props.create(
BeforeCompareUnitCalActor.class,()-> new BeforeCompareUnitCalActor())); BeforeCompareUnitCalActor.class,()-> new BeforeCompareUnitCalActor()));
beforeCompareUnitCalActor.tell(startCompareUnitCalMsg, ActorRef.noSender()); beforeCompareUnitCalActor.tell(startCompareUnitCalMsg, ActorRef.noSender());
...@@ -144,4 +149,5 @@ public class DriveIndCalResultService { ...@@ -144,4 +149,5 @@ public class DriveIndCalResultService {
objScoreCalResultMapper.deleteByCompareIdInAndDateIn(param2); objScoreCalResultMapper.deleteByCompareIdInAndDateIn(param2);
} }
} }
} }
package com.keymobile.indicators.service.hytobacco;
import com.keymobile.indicators.model.entity.shortboard.ShortComparedLog;
import com.keymobile.indicators.model.mapper.indmapper.ShortComparedLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class ShortComparedLogService {
@Autowired
private ShortComparedLogMapper shortComparedLogMapper;
public long selectComparedLogCountByParams(Map<String, Object> params) {
return shortComparedLogMapper.selectComparedLogCountByParams(params);
}
public List<ShortComparedLog> findComparedLogPageByParams(Map<String, Object> params) {
return shortComparedLogMapper.findComparedLogPageByParams(params);
}
}
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
...@@ -9,6 +11,8 @@ import java.util.Map; ...@@ -9,6 +11,8 @@ import java.util.Map;
import com.keymobile.indicators.constant.Constants; import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.shortboard.ShortBoardWarnData; import com.keymobile.indicators.model.entity.shortboard.ShortBoardWarnData;
import com.keymobile.indicators.model.entity.shortboard.ShortComparedLog;
import com.keymobile.indicators.model.mapper.indmapper.ShortComparedLogMapper;
import com.keymobile.indicators.utils.LogManager; import com.keymobile.indicators.utils.LogManager;
import com.keymobile.indicators.utils.SystemUserUtil; import com.keymobile.indicators.utils.SystemUserUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -27,16 +31,19 @@ import com.keymobile.indicators.utils.DateUtils; ...@@ -27,16 +31,19 @@ import com.keymobile.indicators.utils.DateUtils;
@Service @Service
public class ShortboardUnitService { public class ShortboardUnitService {
private Logger logger = LoggerFactory.getLogger(ShortboardUnitService.class); private Logger logger = LoggerFactory.getLogger(ShortboardUnitService.class);
@Autowired @Autowired
private ShortboardUnitMapper shortboardUnitMapper; private ShortboardUnitMapper shortboardUnitMapper;
@Autowired @Autowired
private ShortboardRuleService shortboardRuleService; private ShortboardRuleService shortboardRuleService;
@Autowired @Autowired
private ShortboardRecordMapper shortboardRecordMapper; private ShortboardRecordMapper shortboardRecordMapper;
@Autowired
private ShortComparedLogMapper shortComparedLogMapper;
public Integer saveOrUpdate(ShortboardUnit shortboardUnit,String code,Integer catalogId, public Integer saveOrUpdate(ShortboardUnit shortboardUnit,String code,Integer catalogId,
String catalogIdPath,String user) { String catalogIdPath,String user) {
shortboardUnit.setCode(code); shortboardUnit.setCode(code);
shortboardUnit.setCatalogId(catalogId); shortboardUnit.setCatalogId(catalogId);
shortboardUnit.setCatalogIdPath(catalogIdPath); shortboardUnit.setCatalogIdPath(catalogIdPath);
...@@ -53,11 +60,11 @@ public class ShortboardUnitService { ...@@ -53,11 +60,11 @@ public class ShortboardUnitService {
} }
return shortboardUnit.getId(); return shortboardUnit.getId();
} }
public void delete(List<Integer> ids) { public void delete(List<Integer> ids) {
shortboardUnitMapper.deleteByIdIn(ids); shortboardUnitMapper.deleteByIdIn(ids);
} }
public Map<String,Object> getByCatalogId(Integer catalogId,String keyword,int page,int rows){ public Map<String,Object> getByCatalogId(Integer catalogId,String keyword,int page,int rows){
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
if(StringUtils.isNotBlank(keyword)) { if(StringUtils.isNotBlank(keyword)) {
...@@ -74,7 +81,7 @@ public class ShortboardUnitService { ...@@ -74,7 +81,7 @@ public class ShortboardUnitService {
result.put("data", datas); result.put("data", datas);
return result; return result;
} }
public ShortboardUnit getById(Integer id) { public ShortboardUnit getById(Integer id) {
ShortboardUnit shortboardUnit = shortboardUnitMapper.selectByPrimaryKey(id); ShortboardUnit shortboardUnit = shortboardUnitMapper.selectByPrimaryKey(id);
if(shortboardUnit!=null) { if(shortboardUnit!=null) {
...@@ -82,43 +89,32 @@ public class ShortboardUnitService { ...@@ -82,43 +89,32 @@ public class ShortboardUnitService {
} }
return null; return null;
} }
public List<ShortboardUnit> getByIdList(List<Integer> ids){ public List<ShortboardUnit> getByIdList(List<Integer> ids){
return shortboardUnitMapper.findByIdList(ids); return shortboardUnitMapper.findByIdList(ids);
} }
//保存预览数据生成短板预警池数据 //保存预览数据生成短板预警池数据
@Async @Async
public void getShortboardObjFromUnit(ShortBoardWarnData shortBoardWarnData) throws Exception{ public void getShortboardObjFromUnit(ShortBoardWarnData shortBoardWarnData) throws Exception{
ShortComparedLog shortComparedLog = new ShortComparedLog();
shortComparedLog.setCreatUser(shortBoardWarnData.getUser());
shortComparedLog.setCreatTime(new Date());
shortComparedLog.setShortUnitId(shortBoardWarnData.getId());
shortComparedLog.setStatus(2);
shortComparedLogMapper.insert(shortComparedLog);
LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_UNIT_API,"短板运算id={},开始运算StartTime={}",shortBoardWarnData.getId(),new Date()); LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_UNIT_API,"短板运算id={},开始运算StartTime={}",shortBoardWarnData.getId(),new Date());
List<ShortboardRecord> result = new ArrayList<>(); List<ShortboardRecord> result = new ArrayList<>();
//ShortboardUnit shortboardUnit = this.getById(id);//根据短板单元id获取短板单元 //ShortboardUnit shortboardUnit = this.getById(id);//根据短板单元id获取短板单元
if(shortBoardWarnData!=null) { try {
List<String> compareObjList = shortBoardWarnData.getCompareObjs();//new ArrayList<>(); List<String> compareObjList = shortBoardWarnData.getCompareObjs();//new ArrayList<>();
List<String> driveIndIdList =shortBoardWarnData.getDriveIndIds();// new ArrayList<>(); List<String> driveIndIdList =shortBoardWarnData.getDriveIndIds();// new ArrayList<>();
List<Integer> shortboardIdList = shortBoardWarnData.getShortboardIds();// new ArrayList<>(); List<Integer> shortboardIdList = shortBoardWarnData.getShortboardIds();// new ArrayList<>();
//转换短板对象
// String compareObjsString = shortBoardWarnData.getCommpareObjs();
// if(StringUtils.isNotBlank(compareObjsString)) {
// String[] compareObjs = compareObjsString.split(";");
// compareObjList = Arrays.asList(compareObjs);
// }
//转换考核指标id
// String driveIndIdsString = shortBoardWarnData.getDriveIndIds();
// if(StringUtils.isNotBlank(driveIndIdsString)) {
// String[] driveIndIds = driveIndIdsString.split(";");
// driveIndIdList = Arrays.asList(driveIndIds);
// }
//转换短板规则id
// 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()) { if(!compareObjList.isEmpty() && !driveIndIdList.isEmpty() && !shortboardIdList.isEmpty()) {
result = shortboardRuleService.getObjFromShortboardRule(shortBoardWarnData); result = shortboardRuleService.getObjFromShortboardRule(shortBoardWarnData);
} }
...@@ -133,12 +129,32 @@ public class ShortboardUnitService { ...@@ -133,12 +129,32 @@ public class ShortboardUnitService {
shortboardRecordMapper.batchSave(result); shortboardRecordMapper.batchSave(result);
} }
LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_UNIT_API,"短板运算id={},结束运算endTime={},产生预警数据:{}条",shortBoardWarnData.getId(),new Date(),result.size());
shortComparedLog.setStatus(1);
shortComparedLog.setValue(result.size());
}catch (Exception e){
String message = "";
if(e!=null){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
message=sw.toString();
}
if(message.length()>2000){
message = message.substring(0,2000);
}
shortComparedLog.setStatus(0);
shortComparedLog.setLoginfo(message);
shortComparedLog.setValue(0);
} }
LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_UNIT_API,"短板运算id={},结束运算endTime={},产生预警数据:{}条",shortBoardWarnData.getId(),new Date(),result.size()); shortComparedLogMapper.updateByPrimaryKeySelective(shortComparedLog);
return ; return ;
} }
//根据标识编码分页获取预警池短板数据 //根据标识编码分页获取预警池短板数据
public Map<String,Object> getShortboardRecordPage(List<String> codes,int page,int rows){ public Map<String,Object> getShortboardRecordPage(List<String> codes,int page,int rows){
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
...@@ -153,7 +169,7 @@ public class ShortboardUnitService { ...@@ -153,7 +169,7 @@ public class ShortboardUnitService {
List<ShortboardRecord> resultList = shortboardRecordMapper.getPageByCodeIn(paramMap); List<ShortboardRecord> resultList = shortboardRecordMapper.getPageByCodeIn(paramMap);
result.put("total", count); result.put("total", count);
result.put("data", resultList); result.put("data", resultList);
return result; return result;
} }
} }
<?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.indmapper.ShortComparedLogMapper">
<select id="findComparedLogPageByParams" resultType="com.keymobile.indicators.model.entity.shortboard.ShortComparedLog">
select *
from short_compared_log
<include refid="findWhereSql"></include>
order by creat_time desc
limit #{page}, #{pageSize}
</select>
<select id="selectComparedLogCountByParams" resultType="long">
select count(id)
from short_compared_log
<include refid="findWhereSql"></include>
</select>
<sql id="findWhereSql">
where 1= 1
<if test="shortUnitId != null">
and short_unit_id = #{shortUnitId}
</if>
</sql>
<update id="deleteByIds">
update affiche_info
set
state = 0,updater=#{updater}
where id in (
<foreach collection="ids" item="item" separator=",">
#{item}
</foreach>
)
</update>
<insert id="insertAfficheInfoToAllUser">
insert into affiche_user
(affche_id,user_id)
values
<foreach collection="userIds" item="user" separator=",">
(
#{affcheId}, #{user}
)
</foreach>
</insert>
<delete id="deleteAfficheUserByAffcheIds">
delete FROM affiche_user
where affche_id in (
<foreach collection="affcheIds" item="item" separator=",">
#{item}
</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