Commit a44beb64 by zhangkb

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

parent 60785873
...@@ -54,8 +54,9 @@ public class IndicatorsDefCtrl { ...@@ -54,8 +54,9 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "新建考核指标", notes = "新建考核指标") @ApiOperation(value = "新建考核指标", notes = "新建考核指标")
@PostMapping(value = "/createDriveInd") @PostMapping(value = "/createDriveInd")
public void createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam Integer catalogId, public void createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) throws Exception{ @RequestParam String catalogIdPath,@RequestParam String user,
driveIndDefService.saveOrUpdate(driveIndDef, catalogId, catalogIdPath, user); @RequestParam String shortboardIds) throws Exception{
driveIndDefService.saveOrUpdate(driveIndDef, catalogId, catalogIdPath, user,shortboardIds);
} }
@ApiOperation(value = "删除考核指标", notes = "删除考核指标") @ApiOperation(value = "删除考核指标", notes = "删除考核指标")
......
...@@ -73,4 +73,11 @@ public class ShortboardRuleCtrl { ...@@ -73,4 +73,11 @@ public class ShortboardRuleCtrl {
public ShortboardRule findById(@RequestParam Integer id) { public ShortboardRule findById(@RequestParam Integer id) {
return shortboardRuleService.getById(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{ ...@@ -18,9 +18,9 @@ public class ShortboardDriveIndRel{
private Integer id; private Integer id;
private Integer shortboardRuleId;//短板规则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.driveIndDefId = driveIndDefId;
this.shortboardRuleId = shortboardRuleId; this.shortboardRuleId = shortboardRuleId;
} }
......
...@@ -16,7 +16,9 @@ import org.springframework.stereotype.Service; ...@@ -16,7 +16,9 @@ import org.springframework.stereotype.Service;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.googlecode.aviator.AviatorEvaluator; import com.googlecode.aviator.AviatorEvaluator;
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.mapper.indicators.DriveIndDefMapper; import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
@Service @Service
...@@ -27,9 +29,11 @@ public class DriveIndDefService { ...@@ -27,9 +29,11 @@ public class DriveIndDefService {
private DriveIndDefVersionService driveIndDefVersionService; private DriveIndDefVersionService driveIndDefVersionService;
@Autowired @Autowired
private BaseIndDataService baseIndDataService; private BaseIndDataService baseIndDataService;
@Autowired
private ShortboardDriveIndRelMapper shortboardDriveIndRelMapper;
public String saveOrUpdate(DriveIndDef driveIndDef,Integer catalogId,String catalogIdPath,String user) public String saveOrUpdate(DriveIndDef driveIndDef,Integer catalogId,String catalogIdPath,
throws Exception{ String user,String shortboardIds)throws Exception{
if(StringUtils.isBlank(driveIndDef.getIndId())) { if(StringUtils.isBlank(driveIndDef.getIndId())) {
return "indId can not be null"; return "indId can not be null";
} }
...@@ -56,6 +60,27 @@ public class DriveIndDefService { ...@@ -56,6 +60,27 @@ public class DriveIndDefService {
driveIndDefMapper.updateByPrimaryKey(driveIndDef); 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(); return "success;driveIndId:"+driveIndDef.getIndId();
} }
......
...@@ -232,7 +232,14 @@ public class CalculateUtils { ...@@ -232,7 +232,14 @@ public class CalculateUtils {
// formula = formula.replace("[1002]", "5"); // formula = formula.replace("[1002]", "5");
// String result1 = AviatorEvaluator.execute(formula).toString(); // String result1 = AviatorEvaluator.execute(formula).toString();
// System.out.println(result1); // System.out.println(result1);
Double b = (double) Math.abs(34-50); // Double b = (double) Math.abs(34-50);
System.out.println(b); // 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 @@ ...@@ -127,5 +127,6 @@
<foreach item="id" collection="compareObjs" open="(" close=")" separator=","> <foreach item="id" collection="compareObjs" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
order by rank asc
</select> </select>
</mapper> </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