|
@@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
+import com.fdkankan.manage.common.ResultData;
|
|
|
import com.fdkankan.manage.entity.Case;
|
|
|
import com.fdkankan.manage.entity.CaseNum;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
+import com.fdkankan.manage.httpClient.client.FdKKClient;
|
|
|
import com.fdkankan.manage.mapper.ICaseMapper;
|
|
|
import com.fdkankan.manage.service.ICaseNumService;
|
|
|
import com.fdkankan.manage.service.ICaseService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage.util.CaseNumTypeUtil;
|
|
|
import com.fdkankan.manage.vo.request.CaseNumType;
|
|
|
import com.fdkankan.manage.vo.request.CaseParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -65,10 +68,12 @@ public class CaseServiceImpl extends ServiceImpl<ICaseMapper, Case> implements I
|
|
|
public void checkNumInCase(String num) {
|
|
|
List<Case> caseByNum = getCaseByNum(num);
|
|
|
if(!caseByNum.isEmpty()){
|
|
|
- throw new BusinessException(ResultCode.NUM_IN_CASE);
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_EXIST);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ FdKKClient fdKKClient;
|
|
|
@Override
|
|
|
public void addOrUpdate(CaseParam param) {
|
|
|
Case caseEntity;
|
|
@@ -82,24 +87,59 @@ public class CaseServiceImpl extends ServiceImpl<ICaseMapper, Case> implements I
|
|
|
caseEntity.setUpdateTime(null);
|
|
|
this.saveOrUpdate(caseEntity);
|
|
|
|
|
|
- if(param.getCaseId() != null){
|
|
|
+ if(param.getSceneNumParam().isEmpty()){
|
|
|
+ caseNumService.delByCaseId(caseEntity.getCaseId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CaseNumType> newParam = new ArrayList<>();
|
|
|
+ for (CaseNumType caseNumType : param.getSceneNumParam()) {
|
|
|
+ List<Integer> numType = CaseNumTypeUtil.getNumType(caseNumType.getType());
|
|
|
|
|
|
- HashMap<Integer,CaseNumType> map = caseNumService.getCaseNumTypeByCaseId(param.getCaseId());
|
|
|
- List<Integer> typeKes = param.getSceneNumParam().stream().map(CaseNumType::getType).collect(Collectors.toList());
|
|
|
- for (Integer key : map.keySet()) {
|
|
|
- if(!typeKes.contains(key)){
|
|
|
- caseNumService.delByCaseIdAndNumList(param.getCaseId(),map.get(key).getNumList(),key);
|
|
|
- }
|
|
|
+ for (Integer type : numType) {
|
|
|
+ List<String> numList = caseNumType.getNumList().stream().filter(e -> CaseNumTypeUtil.getCaseNumType(e, caseNumType.getType()).equals(type)).collect(Collectors.toList());
|
|
|
+ CaseNumType numType1 = new CaseNumType();
|
|
|
+ numType1.setType(type);
|
|
|
+ numType1.setNumList(numList);
|
|
|
+ newParam.add(numType1);
|
|
|
}
|
|
|
+ }
|
|
|
+ param.setSceneNumParam(newParam);
|
|
|
|
|
|
- for (CaseNumType paramType : param.getSceneNumParam()) {
|
|
|
- CaseNumType dbType = map.get(paramType.getType());
|
|
|
- List<String> delNums = dbType.getNumList().stream().filter(e -> !paramType.getNumList().contains(e)).collect(Collectors.toList());
|
|
|
- List<String> addNums = paramType.getNumList().stream().filter(e -> !dbType.getNumList().contains(e)).collect(Collectors.toList());
|
|
|
- caseNumService.saveByCaseIdAndNumList(param.getCaseId(),addNums,paramType.getType());
|
|
|
- caseNumService.delByCaseIdAndNumList(param.getCaseId(),delNums,paramType.getType());
|
|
|
+ try {
|
|
|
+ ResultData resultData = fdKKClient.addScene(param, StpUtil.getTokenValue());
|
|
|
+ if(resultData.getCode() !=0){
|
|
|
+ throw new BusinessException(resultData.getCode(),resultData.getMessage());
|
|
|
}
|
|
|
+ }catch (BusinessException e){
|
|
|
+ throw e;
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+// HashMap<Integer,CaseNumType> map = caseNumService.getCaseNumTypeByCaseId(caseEntity.getCaseId());
|
|
|
+// List<Integer> typeKes = param.getSceneNumParam().stream().map(CaseNumType::getType).collect(Collectors.toList());
|
|
|
+// for (Integer key : map.keySet()) {
|
|
|
+// if(!typeKes.contains(key)){
|
|
|
+// caseNumService.delByCaseIdAndNumList(caseEntity.getCaseId(),map.get(key).getNumList(),key);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// for (CaseNumType paramType : param.getSceneNumParam()) {
|
|
|
+// CaseNumType dbType = map.get(paramType.getType());
|
|
|
+// if(dbType == null || dbType.getNumList().isEmpty()){
|
|
|
+// caseNumService.saveByCaseIdAndNumList(caseEntity.getCaseId(),paramType.getNumList(),paramType.getType());
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<String> delNums = dbType.getNumList().stream().filter(e -> !paramType.getNumList().contains(e)).collect(Collectors.toList());
|
|
|
+// caseNumService.delByCaseIdAndNumList(caseEntity.getCaseId(),delNums,paramType.getType());
|
|
|
+//
|
|
|
+// List<String> addNums = paramType.getNumList().stream().filter(e -> !dbType.getNumList().contains(e)).collect(Collectors.toList());
|
|
|
+// caseNumService.saveByCaseIdAndNumList(caseEntity.getCaseId(),addNums,paramType.getType());
|
|
|
+// }
|
|
|
+
|
|
|
}
|
|
|
}
|