Commit f01cbe9f authored by 蔡镇泽's avatar 蔡镇泽

失能评定标准定义新增/编辑

parent d0d1a66c
...@@ -28,15 +28,16 @@ public class DisableAssessmentCriteriaController { ...@@ -28,15 +28,16 @@ public class DisableAssessmentCriteriaController {
private DisableAssessmentCriteriaService disableAssessmentCriteriaService; private DisableAssessmentCriteriaService disableAssessmentCriteriaService;
/** /**
* 失能评定标准定义新增 * 失能评定标准定义新增/编辑
* *
* @param jsonParam json参数: * @param jsonParam json参数:
* <p> * <p>
* aprId aprId为空就新增,aprId不为空就编辑
* organId 适用机构id * organId 适用机构id
* estimateName 失能评定标准名称 * estimateName 失能评定标准名称
* remark 备注 * remark 备注
* status 未生效:0;已生效:1; * status 未生效:0;已生效:1;
* project[]{projectNama,minVal,maxVal,projectScoreCriteria[]{criteria,reference}} 评定项目 * project[]{itemId,projectNama,minVal,maxVal,projectScoreCriteria[]{clauseId,criteria,reference}} 评定项目
* <p> * <p>
* projectNama 评定项目名称 * projectNama 评定项目名称
* minVal 评定项目最小值 * minVal 评定项目最小值
...@@ -45,8 +46,8 @@ public class DisableAssessmentCriteriaController { ...@@ -45,8 +46,8 @@ public class DisableAssessmentCriteriaController {
* criteria 评分标准 * criteria 评分标准
* reference 分值参考 * reference 分值参考
*/ */
@RequestMapping("/addDisableAssessmentCriteria") @RequestMapping("/addOrUpdateDisableAssessmentCriteria")
public Result<Object> addDisableAssessmentCriteria(String jsonParam) { public Result<Object> addOrUpdateDisableAssessmentCriteria(String jsonParam) {
//参数校验 //参数校验
if (StringUtils.isBlank(jsonParam)) { if (StringUtils.isBlank(jsonParam)) {
return Result.failed("参数不能为空!"); return Result.failed("参数不能为空!");
...@@ -98,8 +99,9 @@ public class DisableAssessmentCriteriaController { ...@@ -98,8 +99,9 @@ public class DisableAssessmentCriteriaController {
} }
} }
String remark = jsonObject.getStr("remark"); String remark = jsonObject.getStr("remark");
Long aprId = jsonObject.getLong("aprId");
try { try {
disableAssessmentCriteriaService.addDisableAssessmentCriteria(organId, estimateName, remark, status, project); disableAssessmentCriteriaService.addOrUpdateDisableAssessmentCriteria(aprId, organId, estimateName, remark, status, project);
} catch (Exception e) { } catch (Exception e) {
//添加失败 //添加失败
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
...@@ -117,8 +119,19 @@ public class DisableAssessmentCriteriaController { ...@@ -117,8 +119,19 @@ public class DisableAssessmentCriteriaController {
*/ */
@RequestMapping("/getDisableAssessmentCriteriaList") @RequestMapping("/getDisableAssessmentCriteriaList")
public Result<List<CfgAprVO>> getDisableAssessmentCriteriaList(String organIds, String aprName, String status) { public Result<List<CfgAprVO>> getDisableAssessmentCriteriaList(String organIds, String aprName, String status) {
List<CfgAprVO> cfgAprVOS = disableAssessmentCriteriaService.getDisableAssessmentCriteriaList(organIds, aprName, status); List<CfgAprVO> list = disableAssessmentCriteriaService.getDisableAssessmentCriteriaList(organIds, aprName, status);
return Result.success(cfgAprVOS); return Result.success(list);
}
/**
* 停用失能评定标准
*
* @param aprId 失能评定标准配置id
*/
@RequestMapping("/stopDisableAssessmentCriteria")
public Result<Object> stopDisableAssessmentCriteria(String aprId) {
disableAssessmentCriteriaService.stopDisableAssessmentCriteria(aprId);
return Result.success();
} }
} }
...@@ -13,7 +13,9 @@ import java.util.List; ...@@ -13,7 +13,9 @@ import java.util.List;
*/ */
@Service @Service
public interface DisableAssessmentCriteriaService { public interface DisableAssessmentCriteriaService {
void addDisableAssessmentCriteria(String organId, String estimateName, String remark, Integer status, JSONArray project); void addOrUpdateDisableAssessmentCriteria(Long aprId, String organId, String estimateName, String remark, Integer status, JSONArray project);
List<CfgAprVO> getDisableAssessmentCriteriaList(String organIds, String aprName, String status); List<CfgAprVO> getDisableAssessmentCriteriaList(String organIds, String aprName, String status);
void stopDisableAssessmentCriteria(String aprId);
} }
...@@ -3,6 +3,7 @@ package com.hungraim.ltc.governance.service.impl; ...@@ -3,6 +3,7 @@ package com.hungraim.ltc.governance.service.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hungraim.ltc.governance.dao.ChCfgAprItemClauseMapper; import com.hungraim.ltc.governance.dao.ChCfgAprItemClauseMapper;
import com.hungraim.ltc.governance.dao.ChCfgAprItemMapper; import com.hungraim.ltc.governance.dao.ChCfgAprItemMapper;
import com.hungraim.ltc.governance.dao.ChCfgAprMapper; import com.hungraim.ltc.governance.dao.ChCfgAprMapper;
...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 失能评定标准service * 失能评定标准service
...@@ -36,8 +38,19 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr ...@@ -36,8 +38,19 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public void addDisableAssessmentCriteria(String organId, String estimateName, String remark, Integer status, JSONArray project) { public void addOrUpdateDisableAssessmentCriteria(Long aprId, String organId, String estimateName, String remark, Integer status, JSONArray project) {
Date date = new Date(); Date date = new Date();
if (aprId != null) {//编辑
updateDisableAssessmentCriteria(aprId, organId, estimateName, remark, status, project, date);
} else {//新增
addDisableAssessmentCriteria(organId, estimateName, remark, status, project, date);
}
}
/**
* 失能评定标准定义新增
*/
private void addDisableAssessmentCriteria(String organId, String estimateName, String remark, Integer status, JSONArray project, Date date) {
//鉴定标准配置 //鉴定标准配置
ChCfgApr apr = new ChCfgApr(); ChCfgApr apr = new ChCfgApr();
apr.setOrganId(organId); apr.setOrganId(organId);
...@@ -58,7 +71,6 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr ...@@ -58,7 +71,6 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr
item.setMaxValue(Short.parseShort(maxVal)); item.setMaxValue(Short.parseShort(maxVal));
item.setAprId(apr.getAprId()); item.setAprId(apr.getAprId());
chCfgAprItemMapper.insert(item); chCfgAprItemMapper.insert(item);
//鉴定项目定义明细 //鉴定项目定义明细
JSONArray projectScoreCriteria = itemObject.getJSONArray("projectScoreCriteria"); JSONArray projectScoreCriteria = itemObject.getJSONArray("projectScoreCriteria");
for (int j = 0; j < projectScoreCriteria.size(); j++) { for (int j = 0; j < projectScoreCriteria.size(); j++) {
...@@ -73,7 +85,118 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr ...@@ -73,7 +85,118 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr
chCfgAprItemClauseMapper.insert(clause); chCfgAprItemClauseMapper.insert(clause);
} }
} }
}
/**
* 失能评定标准定义编辑
*/
private void updateDisableAssessmentCriteria(Long aprId, String organId, String estimateName, String remark, Integer status, JSONArray project, Date date) {
//鉴定标准配置
ChCfgApr chCfgApr = chCfgAprMapper.selectById(aprId);
chCfgApr.setOrganId(organId);
chCfgApr.setEstimateName(estimateName);
chCfgApr.setRemark(remark);
if (chCfgApr.getFcd() == null) {
chCfgApr.setFcd(date);//首次操作时间
}
chCfgApr.setLcd(date);
chCfgApr.setStatus(status.shortValue());
chCfgAprMapper.updateById(chCfgApr);
//鉴定项目
List<ChCfgAprItem> itemList = chCfgAprItemMapper.selectList(new QueryWrapper<ChCfgAprItem>().eq("apr_id", aprId));
for (int i = 0; i < project.size(); i++) {
JSONObject itemObject = project.getJSONObject(i);
Long itemId = itemObject.getLong("itemId");
String projectNama = itemObject.getStr("projectNama");
String minVal = itemObject.getStr("minVal");
String maxVal = itemObject.getStr("maxVal");
if (itemId != null) {
//修改id对应的鉴定项目
boolean flag = false;
for (ChCfgAprItem item : itemList) {
if (Objects.equals(item.getItemId(), itemId)) {
if (item.getFcd() == null) {
item.setFcd(date);//首次操作时间
}
item.setItemName(projectNama);
item.setMinValue(Short.parseShort(minVal));
item.setMaxValue(Short.parseShort(maxVal));
chCfgAprItemMapper.updateById(item);
itemList.remove(item);
flag = true;
}
}
if (!flag) {
throw new RuntimeException("无效的itemId!");
}
//鉴定项目定义明细
List<ChCfgAprItemClause> itemClauseList = chCfgAprItemClauseMapper.selectList(new QueryWrapper<ChCfgAprItemClause>().eq("item_id", itemId));
JSONArray projectScoreCriteria = itemObject.getJSONArray("projectScoreCriteria");
for (int j = 0; j < projectScoreCriteria.size(); j++) {
ChCfgAprItemClause clause = new ChCfgAprItemClause();
JSONObject clauseObject = projectScoreCriteria.getJSONObject(j);
Long clauseId = clauseObject.getLong("clauseId");
String criteria = clauseObject.getStr("criteria");
String reference = clauseObject.getStr("reference");
if (clauseId != null) {
flag = false;
for (ChCfgAprItemClause item : itemClauseList) {
if (Objects.equals(item.getClauseId(), clauseId)) {
if (item.getFcd() == null) {
item.setFcd(date);//首次操作时间
}
clause.setClauseDesc(criteria);
clause.setClauseValue(Short.parseShort(reference));
clause.setItemId(itemId);
clause.setAprId(aprId);
chCfgAprItemClauseMapper.updateById(clause);
itemClauseList.remove(item);
flag = true;
}
}
if (!flag) {
throw new RuntimeException("无效的clauseId!");
}
} else {
ChCfgAprItemClause cl = new ChCfgAprItemClause();
cl.setClauseDesc(criteria);
cl.setClauseValue(Short.parseShort(reference));
cl.setItemId(itemId);
cl.setAprId(aprId);
chCfgAprItemClauseMapper.insert(cl);
}
}
//删除多余的评定项目明细
for (ChCfgAprItemClause item : itemClauseList) {
chCfgAprItemClauseMapper.deleteById(item);
}
} else {
//没有对应的鉴定项目就新增
ChCfgAprItem item = new ChCfgAprItem();
item.setItemName(projectNama);
item.setMinValue(Short.parseShort(minVal));
item.setMaxValue(Short.parseShort(maxVal));
item.setAprId(aprId);
chCfgAprItemMapper.insert(item);
//鉴定项目定义明细
JSONArray projectScoreCriteria = itemObject.getJSONArray("projectScoreCriteria");
for (int j = 0; j < projectScoreCriteria.size(); j++) {
ChCfgAprItemClause clause = new ChCfgAprItemClause();
JSONObject clauseObject = projectScoreCriteria.getJSONObject(j);
String criteria = clauseObject.getStr("criteria");
String reference = clauseObject.getStr("reference");
clause.setClauseDesc(criteria);
clause.setClauseValue(Short.parseShort(reference));
clause.setItemId(item.getItemId());
clause.setAprId(aprId);
chCfgAprItemClauseMapper.insert(clause);
}
}
}
//删除多余的评定项目
for (ChCfgAprItem item : itemList) {
chCfgAprItemMapper.deleteById(item);
}
} }
@Override @Override
...@@ -84,4 +207,11 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr ...@@ -84,4 +207,11 @@ public class DisableAssessmentCriteriaServiceImpl implements DisableAssessmentCr
} }
return chCfgAprMapper.getDisableAssessmentCriteriaList(organIdList, aprName, status); return chCfgAprMapper.getDisableAssessmentCriteriaList(organIdList, aprName, status);
} }
@Override
public void stopDisableAssessmentCriteria(String aprId) {
ChCfgApr chCfgApr = chCfgAprMapper.selectById(aprId);
chCfgApr.setStatus((short) 0);
chCfgAprMapper.updateById(chCfgApr);
}
} }
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