|
|
@@ -158,22 +158,20 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
158
|
158
|
*/
|
|
159
|
159
|
@Override
|
|
160
|
160
|
public List<MsCaseApplicationVO> list(MsCaseApplicationReq req) {
|
|
161
|
|
- // admin查询所有案件
|
|
162
|
|
- if (StrUtil.equals(SecurityUtils.getUsername(), "admin")) {
|
|
163
|
|
- startPage();
|
|
164
|
|
- List<MsCaseApplicationVO> list = msCaseApplicationMapper.list(req, null);
|
|
165
|
|
- for (MsCaseApplicationVO vo : list) {
|
|
166
|
|
- vo.setSignButtonFlag(0);
|
|
167
|
|
- }
|
|
168
|
|
- return list;
|
|
169
|
|
- }
|
|
|
161
|
+
|
|
170
|
162
|
// 根据用户查询角色
|
|
171
|
163
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
172
|
164
|
// 根据id查询用户
|
|
173
|
165
|
SysUser sysUser = sysUserMapper.selectUserById(loginUser.getUserId());
|
|
174
|
166
|
List<SysRole> roles = loginUser.getUser().getRoles();
|
|
175
|
|
- if (CollectionUtil.isEmpty(roles)) {
|
|
176
|
|
- throw new ServiceException("该用户未指定角色");
|
|
|
167
|
+ if (StrUtil.equals(SecurityUtils.getUsername(), "admin")||CollectionUtil.isEmpty(roles)) {
|
|
|
168
|
+ // 如果角色为空,按admin处理,查所有案件
|
|
|
169
|
+ startPage();
|
|
|
170
|
+ List<MsCaseApplicationVO> list = msCaseApplicationMapper.list(req, null);
|
|
|
171
|
+ for (MsCaseApplicationVO vo : list) {
|
|
|
172
|
+ vo.setSignButtonFlag(0);
|
|
|
173
|
+ }
|
|
|
174
|
+ return list;
|
|
177
|
175
|
}
|
|
178
|
176
|
req.setUserName(SecurityUtils.getUsername());
|
|
179
|
177
|
req.setContactTelphoneAgent(sysUser.getPhonenumber());
|
|
|
@@ -353,10 +351,29 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
353
|
351
|
return vo;
|
|
354
|
352
|
}
|
|
355
|
353
|
|
|
|
354
|
+ /**
|
|
|
355
|
+ * 根据案件id或者案件编号查询详情
|
|
|
356
|
+ * @param id
|
|
|
357
|
+ * @param caseNum
|
|
|
358
|
+ * @param
|
|
|
359
|
+ * @return
|
|
|
360
|
+ */
|
|
356
|
361
|
@Override
|
|
357
|
|
- public MsCaseApplicationVO selectById(Long id) {
|
|
|
362
|
+ public MsCaseApplicationVO selectById(Long id,String caseNum ) {
|
|
|
363
|
+ // 根据案件id或者案件编号查询详情
|
|
358
|
364
|
MsCaseApplicationVO vo = new MsCaseApplicationVO();
|
|
359
|
|
- MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id);
|
|
|
365
|
+ MsCaseApplication caseApplication = null;
|
|
|
366
|
+ if(id!=null) {
|
|
|
367
|
+ caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id);
|
|
|
368
|
+ }else {
|
|
|
369
|
+ // 根据案件编号查
|
|
|
370
|
+ Example example = new Example(MsCaseApplication.class);
|
|
|
371
|
+ example.createCriteria().andEqualTo("caseNum", caseNum);
|
|
|
372
|
+ caseApplication = msCaseApplicationMapper.selectOneByExample(example);
|
|
|
373
|
+ }
|
|
|
374
|
+ if(caseApplication==null){
|
|
|
375
|
+ return vo;
|
|
|
376
|
+ }
|
|
360
|
377
|
BeanUtil.copyProperties(caseApplication, vo);
|
|
361
|
378
|
// 查询案件相关人员
|
|
362
|
379
|
MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id);
|
|
|
@@ -369,6 +386,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
369
|
386
|
vo.setColumnValueList(columnValueVOS);
|
|
370
|
387
|
// 查询拒绝原因
|
|
371
|
388
|
vo.setReason(auditMapper.selectByCaseId(id,caseApplication.getCaseFlowId()));
|
|
|
389
|
+ // todo 在日志表查詢结束时间返回
|
|
|
390
|
+ vo.setEndTime(caseLogRecordMapper.selectEndTimeByCaseId(caseApplication.getId(),"结束"));
|
|
372
|
391
|
return vo;
|
|
373
|
392
|
}
|
|
374
|
393
|
|
|
|
@@ -380,21 +399,36 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
380
|
399
|
*/
|
|
381
|
400
|
@Transactional
|
|
382
|
401
|
@Override
|
|
383
|
|
- public int insert(MsCaseApplicationVO caseApplication) {
|
|
384
|
|
- if (caseApplication.getId() == null) {
|
|
385
|
|
- caseApplication.setId(IdWorkerUtil.getId());
|
|
386
|
|
- }
|
|
|
402
|
+ public String insert(MsCaseApplicationVO caseApplication) {
|
|
387
|
403
|
|
|
388
|
|
- // 根据角色获取案件流程
|
|
389
|
|
- List<MsCaseFlow> caseFlows= selectCaseFlows();
|
|
|
404
|
+
|
|
|
405
|
+ // todo 第三方调用该接口,未绑定角色,暂时不根据角色查询流程,根据角色获取案件流程
|
|
|
406
|
+ /** List<MsCaseFlow> caseFlows= selectCaseFlows();
|
|
390
|
407
|
if (CollectionUtil.isEmpty(caseFlows)) {
|
|
391
|
|
- throw new ServiceException("该角色为绑定案件流程");
|
|
|
408
|
+ throw new ServiceException("该角色未绑定案件流程");
|
|
392
|
409
|
}
|
|
|
410
|
+ */
|
|
393
|
411
|
// 设置模板id,根据机构代码查询模板
|
|
394
|
|
- Long templateId = templateManageMapper.selectByCreditCode(creditCode);
|
|
|
412
|
+ Long templateId = getTemplate();
|
|
395
|
413
|
caseApplication.setTemplateId(templateId);
|
|
|
414
|
+ // 获取第一个流程节点
|
|
|
415
|
+ MsCaseFlow caseFlow = getCaseFlow();
|
|
|
416
|
+ return insert(caseApplication,caseFlow);
|
|
396
|
417
|
|
|
397
|
|
- MsCaseFlow caseFlow = caseFlows.get(0);
|
|
|
418
|
+ }
|
|
|
419
|
+
|
|
|
420
|
+ /**
|
|
|
421
|
+ * 新增案件
|
|
|
422
|
+ * @param caseApplication
|
|
|
423
|
+ * @param caseFlow
|
|
|
424
|
+ * @return
|
|
|
425
|
+ */
|
|
|
426
|
+ @Transactional
|
|
|
427
|
+ @Override
|
|
|
428
|
+ public String insert(MsCaseApplicationVO caseApplication, MsCaseFlow caseFlow) {
|
|
|
429
|
+ if (caseApplication.getId() == null) {
|
|
|
430
|
+ caseApplication.setId(IdWorkerUtil.getId());
|
|
|
431
|
+ }
|
|
398
|
432
|
caseApplication.setCaseStatusName(caseFlow.getCaseStatusName());
|
|
399
|
433
|
caseApplication.setCaseFlowId(caseFlow.getId());
|
|
400
|
434
|
caseApplication.setCreateTime(new Date());
|
|
|
@@ -416,51 +450,51 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
416
|
450
|
if (msCaseApplicationMapper.insertSelective(caseApplication) > 0) {
|
|
417
|
451
|
List<MsCaseAttach> caseAttachList = caseApplication.getCaseAttachList();
|
|
418
|
452
|
// 保存案件相关人员
|
|
419
|
|
- // 设置申请机构
|
|
420
|
|
- if (StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==1) {
|
|
421
|
|
- // 组装申请机构
|
|
422
|
|
- // insertDept(affiliate);
|
|
423
|
|
- // 新增申请机构和代理人
|
|
424
|
|
- caseApplicationService.insertAgentUser(affiliate);
|
|
425
|
|
- }else if(StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==0){
|
|
426
|
|
- // 查询申请人角色id
|
|
427
|
|
- Long roleId = roleMapper.selectRoleIdByName("申请人");
|
|
428
|
|
- caseApplicationService.insertApplicantUser(affiliate,false,roleId);
|
|
429
|
|
- caseApplicationService.insertApplicantUser(affiliate,true,roleId);
|
|
430
|
|
-
|
|
|
453
|
+ // 设置申请机构
|
|
|
454
|
+ if (StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==1) {
|
|
|
455
|
+ // 组装申请机构
|
|
|
456
|
+ // insertDept(affiliate);
|
|
|
457
|
+ // 新增申请机构和代理人
|
|
|
458
|
+ caseApplicationService.insertAgentUser(affiliate);
|
|
|
459
|
+ }else if(StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==0){
|
|
|
460
|
+ // 查询申请人角色id
|
|
|
461
|
+ Long roleId = roleMapper.selectRoleIdByName("申请人");
|
|
|
462
|
+ caseApplicationService.insertApplicantUser(affiliate,false,roleId);
|
|
|
463
|
+ caseApplicationService.insertApplicantUser(affiliate,true,roleId);
|
|
431
|
464
|
|
|
432
|
|
- }
|
|
433
|
|
- // 压缩包导入,则根据身份证号获取性别和出生日期
|
|
434
|
|
- if (caseApplication.isImportFlag() && StrUtil.isNotEmpty(affiliate.getRespondentIdentityNum())) {
|
|
435
|
|
- setBirthByIdentityNum(affiliate);
|
|
436
|
|
- }
|
|
437
|
|
- if (StrUtil.isNotEmpty(affiliate.getAgentEmail())) {
|
|
438
|
|
- affiliate.setAgentEmail(affiliate.getAgentEmail().replace("\n", "").replaceAll("\\s", ""));
|
|
439
|
|
- }
|
|
440
|
|
- if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
|
|
441
|
|
- affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
|
|
442
|
|
- }
|
|
443
|
|
- msCaseAffiliateMapper.insert(affiliate);
|
|
444
|
|
- // 批量生成调解申请书
|
|
445
|
|
- MsCaseApplicationReq req = new MsCaseApplicationReq();
|
|
446
|
|
- req.setCaseFlowId(caseFlow.getId());
|
|
447
|
|
- if(!caseApplication.isImportFlag()) {
|
|
448
|
|
- req.setId(caseApplication.getId());
|
|
449
|
|
- }else {
|
|
450
|
|
- // 压缩包导入
|
|
451
|
|
- req.setBatchNumber(caseApplication.getBatchNumber());
|
|
452
|
|
- }
|
|
453
|
|
- // 生成调解申请书
|
|
454
|
|
- if(affiliate.getOrganizeFlag()==0){
|
|
455
|
|
- // 自然人
|
|
456
|
|
- req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode());
|
|
457
|
|
- }else {
|
|
458
|
|
- // 机构
|
|
459
|
|
- req.setTemplateType(TemplateTypeEnum.MEDIATION_APPLICATION.getCode());
|
|
460
|
|
- }
|
|
461
|
|
- req.setTemplateId(String.valueOf(templateId));
|
|
462
|
465
|
|
|
463
|
|
- caseApplicationService.generateApplication(req);
|
|
|
466
|
+ }
|
|
|
467
|
+ // 压缩包导入,则根据身份证号获取性别和出生日期
|
|
|
468
|
+ if (caseApplication.isImportFlag() && StrUtil.isNotEmpty(affiliate.getRespondentIdentityNum())) {
|
|
|
469
|
+ setBirthByIdentityNum(affiliate);
|
|
|
470
|
+ }
|
|
|
471
|
+ if (StrUtil.isNotEmpty(affiliate.getAgentEmail())) {
|
|
|
472
|
+ affiliate.setAgentEmail(affiliate.getAgentEmail().replace("\n", "").replaceAll("\\s", ""));
|
|
|
473
|
+ }
|
|
|
474
|
+ if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
|
|
|
475
|
+ affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
|
|
|
476
|
+ }
|
|
|
477
|
+ msCaseAffiliateMapper.insert(affiliate);
|
|
|
478
|
+ // 批量生成调解申请书
|
|
|
479
|
+ MsCaseApplicationReq req = new MsCaseApplicationReq();
|
|
|
480
|
+ req.setCaseFlowId(caseFlow.getId());
|
|
|
481
|
+ if(!caseApplication.isImportFlag()) {
|
|
|
482
|
+ req.setId(caseApplication.getId());
|
|
|
483
|
+ }else {
|
|
|
484
|
+ // 压缩包导入
|
|
|
485
|
+ req.setBatchNumber(caseApplication.getBatchNumber());
|
|
|
486
|
+ }
|
|
|
487
|
+ // 生成调解申请书
|
|
|
488
|
+ if(affiliate.getOrganizeFlag()==0){
|
|
|
489
|
+ // 自然人
|
|
|
490
|
+ req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode());
|
|
|
491
|
+ }else {
|
|
|
492
|
+ // 机构
|
|
|
493
|
+ req.setTemplateType(TemplateTypeEnum.MEDIATION_APPLICATION.getCode());
|
|
|
494
|
+ }
|
|
|
495
|
+ req.setTemplateId(String.valueOf(caseApplication.getTemplateId()));
|
|
|
496
|
+ // todo 部署放开
|
|
|
497
|
+ caseApplicationService.generateApplication(req);
|
|
464
|
498
|
// 保存案件附件
|
|
465
|
499
|
if (CollectionUtil.isNotEmpty(caseAttachList)) {
|
|
466
|
500
|
for (MsCaseAttach caseAttach : caseAttachList) {
|
|
|
@@ -482,10 +516,61 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
482
|
516
|
columnValueMapper.batchSave(columnValueList);
|
|
483
|
517
|
}
|
|
484
|
518
|
CaseLogUtils.insertCaseLog(caseApplication.getId(), 0, "新增案件", "");
|
|
485
|
|
- return 1;
|
|
|
519
|
+ return caseApplication.getCaseNum();
|
|
|
520
|
+ }
|
|
|
521
|
+
|
|
|
522
|
+ return "";
|
|
|
523
|
+ }
|
|
|
524
|
+
|
|
|
525
|
+ /**
|
|
|
526
|
+ * 获取第一个流程节点
|
|
|
527
|
+ * @return
|
|
|
528
|
+ */
|
|
|
529
|
+ private MsCaseFlow getCaseFlow() {
|
|
|
530
|
+
|
|
|
531
|
+ // 查询所有流程节点
|
|
|
532
|
+ Example flowExample = new Example(MsCaseFlow.class);
|
|
|
533
|
+ flowExample.setOrderByClause("sort asc");
|
|
|
534
|
+ List<MsCaseFlow> caseFlows = caseFlowMapper.selectByExample(flowExample);
|
|
|
535
|
+ if (CollectionUtil.isEmpty(caseFlows)) {
|
|
|
536
|
+ throw new ServiceException("请先配置流程");
|
|
486
|
537
|
}
|
|
|
538
|
+ return caseFlows.get(0);
|
|
|
539
|
+ }
|
|
|
540
|
+
|
|
|
541
|
+ /**
|
|
|
542
|
+ * 获取模板id
|
|
|
543
|
+ * @return
|
|
|
544
|
+ */
|
|
|
545
|
+ private Long getTemplate() {
|
|
487
|
546
|
|
|
488
|
|
- return 0;
|
|
|
547
|
+ return templateManageMapper.selectByCreditCode(creditCode);
|
|
|
548
|
+ }
|
|
|
549
|
+
|
|
|
550
|
+ /**
|
|
|
551
|
+ * 批量新增
|
|
|
552
|
+ * @param vo
|
|
|
553
|
+ * @return
|
|
|
554
|
+ */
|
|
|
555
|
+ @Transactional
|
|
|
556
|
+ @Override
|
|
|
557
|
+ public AjaxResult batchInsert(MsCaseBatchInsertVO vo) {
|
|
|
558
|
+ if(CollectionUtil.isEmpty(vo.getList())){
|
|
|
559
|
+ return AjaxResult.error("案件不能为空");
|
|
|
560
|
+ }
|
|
|
561
|
+ // 设置模板id,根据机构代码查询模板
|
|
|
562
|
+ Long templateId = getTemplate();
|
|
|
563
|
+ // 获取第一个流程节点
|
|
|
564
|
+ MsCaseFlow caseFlow = getCaseFlow();
|
|
|
565
|
+ List<String> caseNumList = new ArrayList<>();
|
|
|
566
|
+ for (MsCaseApplicationVO caseApplicationVO : vo.getList()) {
|
|
|
567
|
+ caseApplicationVO.setTemplateId(templateId);
|
|
|
568
|
+ String caseNum = caseApplicationService.insert(caseApplicationVO, caseFlow);
|
|
|
569
|
+ caseNumList.add(caseNum);
|
|
|
570
|
+ }
|
|
|
571
|
+ AjaxResult success = AjaxResult.success();
|
|
|
572
|
+ success.put("caseNumList",caseNumList);
|
|
|
573
|
+ return success;
|
|
489
|
574
|
}
|
|
490
|
575
|
|
|
491
|
576
|
/**
|
|
|
@@ -518,6 +603,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
518
|
603
|
sysUser.setNickName(name);
|
|
519
|
604
|
sysUser.setPhonenumber(phone);
|
|
520
|
605
|
sysUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
|
|
|
606
|
+ sysUser.setIdType(affiliate.getIdType());
|
|
|
607
|
+ sysUser.setNationality(affiliate.getNationality());
|
|
521
|
608
|
sysUser.setCreateBy(SecurityUtils.getUsername());
|
|
522
|
609
|
userMapper.insertUser(sysUser);
|
|
523
|
610
|
userRoleMapper.insertUserRole(sysUser.getUserId(), roleId);
|
|
|
@@ -565,7 +652,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
565
|
652
|
example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
566
|
653
|
List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example);
|
|
567
|
654
|
if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) {
|
|
568
|
|
- throw new ServiceException("该角色为绑定案件流程");
|
|
|
655
|
+ throw new ServiceException("该角色未绑定案件流程");
|
|
569
|
656
|
}
|
|
570
|
657
|
Example flowExample = new Example(MsCaseFlow.class);
|
|
571
|
658
|
flowExample.setOrderByClause("sort asc");
|
|
|
@@ -1672,7 +1759,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
1672
|
1759
|
if (CollectionUtil.isEmpty(users)) {
|
|
1673
|
1760
|
return AjaxResult.error("暂无调解员");
|
|
1674
|
1761
|
}
|
|
1675
|
|
- // todo 根据角色查询是否已经选择了调解员进行回显
|
|
|
1762
|
+ // 根据角色查询是否已经选择了调解员进行回显
|
|
1676
|
1763
|
List<Long> userIds = users.stream().map(SysUser::getUserId).collect(Collectors.toList());
|
|
1677
|
1764
|
// 状态为未结束的是待办数量,结束的是已办数量
|
|
1678
|
1765
|
Map<Long, List<MsCaseApplication>> caseMap=null;
|
|
|
@@ -3887,6 +3974,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
3887
|
3974
|
agentUser.setNickName(affiliate.getNameAgent());
|
|
3888
|
3975
|
agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
|
|
3889
|
3976
|
agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
|
|
|
3977
|
+ agentUser.setNationality(affiliate.getNationality());
|
|
|
3978
|
+ agentUser.setIdType(affiliate.getIdType());
|
|
3890
|
3979
|
// agentUser.setDeptId(Long.valueOf(affiliate.getApplicationId()));
|
|
3891
|
3980
|
userMapper.insertUser(agentUser);
|
|
3892
|
3981
|
userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
|