Commit 5a11dd4a by zhangkb

修改删除基础项判断是否有关联,有无法删除提示;

parent 9dcc48d3
...@@ -62,8 +62,8 @@ public class IndicatorsDefCtrl { ...@@ -62,8 +62,8 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "删除基础指标", notes = "删除基础指标") @ApiOperation(value = "删除基础指标", notes = "删除基础指标")
@PostMapping(value = "/deleteBaseInd") @PostMapping(value = "/deleteBaseInd")
public void deleteBaseInd(@RequestParam List<String> indIds) throws Exception{ public String deleteBaseInd(@RequestParam List<String> indIds) throws Exception{
baseIndDefService.delete(indIds); return baseIndDefService.delete(indIds);
} }
@ApiOperation(value = "根据id查询基础指标详情", notes = "根据id查询基础指标详情") @ApiOperation(value = "根据id查询基础指标详情", notes = "根据id查询基础指标详情")
......
...@@ -18,4 +18,6 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{ ...@@ -18,4 +18,6 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{
public void deleteByCatalogIdIn(@Param("catalogIds")List<Integer> catalogIds); public void deleteByCatalogIdIn(@Param("catalogIds")List<Integer> catalogIds);
public String getMaxIndId(@Param("code")String code,@Param("length")int length); public String getMaxIndId(@Param("code")String code,@Param("length")int length);
public List<BaseIndDef> getByIndFormatLike(@Param("indId")String indId);
} }
...@@ -22,4 +22,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{ ...@@ -22,4 +22,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
public List<DriveIndDef> getByIdList(@Param("ids")List<String> ids); public List<DriveIndDef> getByIdList(@Param("ids")List<String> ids);
public List<DriveIndDef> getByScorecardId(@Param("scorecardId")Integer scorecardId); public List<DriveIndDef> getByScorecardId(@Param("scorecardId")Integer scorecardId);
public List<DriveIndDef> getByIndFormatLike(@Param("indId")String indId);
} }
...@@ -20,6 +20,8 @@ public class BaseIndDefService { ...@@ -20,6 +20,8 @@ public class BaseIndDefService {
private BaseIndDefVersionService baseIndDefVersionService; private BaseIndDefVersionService baseIndDefVersionService;
@Autowired @Autowired
private IndicatorsRelService indRelService; private IndicatorsRelService indRelService;
@Autowired
private DriveIndDefService driveIndDefService;
public String saveOrUpdate(BaseIndDef baseIndDef,Integer catalogId, public String saveOrUpdate(BaseIndDef baseIndDef,Integer catalogId,
String catalogIdPath,String user,String isUpdate,String code) String catalogIdPath,String user,String isUpdate,String code)
...@@ -73,11 +75,25 @@ public class BaseIndDefService { ...@@ -73,11 +75,25 @@ public class BaseIndDefService {
return baseIndDefMapper.selectOne(baseIndDef); return baseIndDefMapper.selectOne(baseIndDef);
} }
public void delete(List<String> indIds) throws Exception{ public String delete(List<String> indIds) throws Exception{
StringBuilder message = new StringBuilder("");
for(String indId : indIds) { for(String indId : indIds) {
baseIndDefMapper.deleteByPrimaryKey(indId); if(driveIndDefService.getByIndFormatLike(indId).isEmpty()&&
baseIndDefVersionService.updateIsDeleteStatus(indId, "1");//标识已删除 this.getByIndFormatLike(indId).isEmpty()) {//基础项都没有关联指标才能删除
baseIndDefMapper.deleteByPrimaryKey(indId);
baseIndDefVersionService.updateIsDeleteStatus(indId, "1");//标识已删除
}else {
BaseIndDef baseIndDef = this.getById(indId);
if(baseIndDef!=null) {
message.append("'").append(baseIndDef.getIndName())
.append("'").append("有关联的基础项或者指标,无法删除;");
}
}
} }
if(StringUtils.isBlank(message.toString())) {
message.append("删除成功");
}
return message.toString();
} }
public Map<String,Object> getByPageAndKeyword(Integer catalogId,String keyword, public Map<String,Object> getByPageAndKeyword(Integer catalogId,String keyword,
...@@ -118,4 +134,8 @@ public class BaseIndDefService { ...@@ -118,4 +134,8 @@ public class BaseIndDefService {
} }
return maxId; return maxId;
} }
public List<BaseIndDef> getByIndFormatLike(String indId){
return baseIndDefMapper.getByIndFormatLike("%"+indId+";%");
}
} }
...@@ -223,4 +223,9 @@ public class DriveIndDefService { ...@@ -223,4 +223,9 @@ public class DriveIndDefService {
public List<DriveIndDef> getByScorecardId(Integer scorecardId){ public List<DriveIndDef> getByScorecardId(Integer scorecardId){
return driveIndDefMapper.getByScorecardId(scorecardId); return driveIndDefMapper.getByScorecardId(scorecardId);
} }
//根据基础项id获取关联的考核指标公式
public List<DriveIndDef> getByIndFormatLike(String indId){
return driveIndDefMapper.getByIndFormatLike("%"+indId+";%");
}
} }
...@@ -40,4 +40,10 @@ ...@@ -40,4 +40,10 @@
from base_ind_def from base_ind_def
where ind_id like #{code} and LENGTH(ind_id)=#{length} where ind_id like #{code} and LENGTH(ind_id)=#{length}
</select> </select>
<select id="getByIndFormatLike" resultType="com.keymobile.indicators.model.entity.indicators.BaseIndDef" >
select *
from base_ind_def
where ind_format like #{indId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -55,4 +55,10 @@ ...@@ -55,4 +55,10 @@
from drive_ind_def from drive_ind_def
where ind_cal_score_rule=#{scorecardId} where ind_cal_score_rule=#{scorecardId}
</select> </select>
<select id="getByIndFormatLike" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndDef">
select *
from drive_ind_def
where ind_format like #{indId}
</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