Commit a44beb64 by zhangkb

指标短板筛选规则接口代码提交

parent 60785873
......@@ -54,8 +54,9 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "新建考核指标", notes = "新建考核指标")
@PostMapping(value = "/createDriveInd")
public void createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) throws Exception{
driveIndDefService.saveOrUpdate(driveIndDef, catalogId, catalogIdPath, user);
@RequestParam String catalogIdPath,@RequestParam String user,
@RequestParam String shortboardIds) throws Exception{
driveIndDefService.saveOrUpdate(driveIndDef, catalogId, catalogIdPath, user,shortboardIds);
}
@ApiOperation(value = "删除考核指标", notes = "删除考核指标")
......
......@@ -73,4 +73,11 @@ public class ShortboardRuleCtrl {
public ShortboardRule findById(@RequestParam Integer id) {
return shortboardRuleService.getById(id);
}
@ApiOperation(value = "根据短板规则筛选短板单位", notes = "根据短板规则筛选短板单位")
@PostMapping(value = "/getShortboardObj")
public List<Map<String,Object>> getObjShortboard(@RequestParam String compareId,@RequestParam int date,
@RequestParam List<String> compareObjs,@RequestParam List<String> driveIds)throws Exception{
return shortboardRuleService.getObjShortboard(compareId, date, compareObjs, driveIds);
}
}
......@@ -18,9 +18,9 @@ public class ShortboardDriveIndRel{
private Integer id;
private Integer shortboardRuleId;//短板规则id
private Integer driveIndDefId;//考核指标id
private String driveIndDefId;//考核指标id
public ShortboardDriveIndRel(Integer driveIndDefId,Integer shortboardRuleId) {
public ShortboardDriveIndRel(String driveIndDefId,Integer shortboardRuleId) {
this.driveIndDefId = driveIndDefId;
this.shortboardRuleId = shortboardRuleId;
}
......
......@@ -16,7 +16,9 @@ import org.springframework.stereotype.Service;
import com.google.common.collect.Maps;
import com.googlecode.aviator.AviatorEvaluator;
import com.keymobile.indicators.model.entity.indicators.DriveIndDef;
import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel;
import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper;
import com.keymobile.indicators.utils.CalculateUtils;
@Service
......@@ -27,9 +29,11 @@ public class DriveIndDefService {
private DriveIndDefVersionService driveIndDefVersionService;
@Autowired
private BaseIndDataService baseIndDataService;
@Autowired
private ShortboardDriveIndRelMapper shortboardDriveIndRelMapper;
public String saveOrUpdate(DriveIndDef driveIndDef,Integer catalogId,String catalogIdPath,String user)
throws Exception{
public String saveOrUpdate(DriveIndDef driveIndDef,Integer catalogId,String catalogIdPath,
String user,String shortboardIds)throws Exception{
if(StringUtils.isBlank(driveIndDef.getIndId())) {
return "indId can not be null";
}
......@@ -56,6 +60,27 @@ public class DriveIndDefService {
driveIndDefMapper.updateByPrimaryKey(driveIndDef);
}
}
//插入短板筛选规则
if(StringUtils.isNotBlank(shortboardIds)) {
//查找考核指标之前关联的短板筛选规则
List<ShortboardDriveIndRel> relations = shortboardDriveIndRelMapper.
findByDriveIndDefId(driveIndDef.getIndId());
if(!relations.isEmpty()) {
for(ShortboardDriveIndRel relation : relations) {
shortboardDriveIndRelMapper.delete(relation);
}
}
//新建关联关系
String[] shortboards = shortboardIds.split(";");
for(String shortboardId : shortboards) {
ShortboardDriveIndRel relation = new ShortboardDriveIndRel(driveIndDef.getIndId(),
Integer.parseInt(shortboardId));
ShortboardDriveIndRel isExistRel = shortboardDriveIndRelMapper.selectOne(relation);
if(isExistRel==null) {
shortboardDriveIndRelMapper.insert(relation);
}
}
}
return "success;driveIndId:"+driveIndDef.getIndId();
}
......
......@@ -232,7 +232,14 @@ public class CalculateUtils {
// formula = formula.replace("[1002]", "5");
// String result1 = AviatorEvaluator.execute(formula).toString();
// System.out.println(result1);
Double b = (double) Math.abs(34-50);
System.out.println(b);
// Double b = (double) Math.abs(34-50);
// System.out.println(b);
List<String> listA = new ArrayList<>();
listA.add("a");
listA.add("b");
listA.add("c");
List<String> listB = new ArrayList<>();
listA.retainAll(listB);
System.out.println(listA);
}
}
......@@ -127,5 +127,6 @@
<foreach item="id" collection="compareObjs" open="(" close=")" separator=",">
#{id}
</foreach>
order by rank asc
</select>
</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