|
@@ -0,0 +1,246 @@
|
|
|
+package com.sooka.sponest.lawenforcement.lawCase.service.impl;
|
|
|
+
|
|
|
+import com.ruoyi.common.core.utils.DateUtils;
|
|
|
+import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
|
+import com.ruoyi.common.core.utils.uuid.IdUtils;
|
|
|
+import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
|
|
|
+import com.ruoyi.common.datascope.base.service.BaseService;
|
|
|
+import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
+import com.ruoyi.system.api.RemoteConfigService;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.domain.LawenforcementAttach;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.domain.LawenforcementCase;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.domain.LawenforcementCaseLog;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.mapper.LawenforcementAttachMapper;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.mapper.LawenforcementCaseLogMapper;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.mapper.LawenforcementCaseMapper;
|
|
|
+import com.sooka.sponest.lawenforcement.lawCase.service.ILawenforcementCaseService;
|
|
|
+import com.sooka.sponest.lawenforcement.utils.DataConstants;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 案件Service业务层处理
|
|
|
+ *
|
|
|
+ * @author 韩福成
|
|
|
+ * @date 2024-10-10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class LawenforcementCaseServiceImpl extends BaseService implements ILawenforcementCaseService {
|
|
|
+ @Autowired
|
|
|
+ private LawenforcementCaseMapper lawenforcementCaseMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LawenforcementCaseLogMapper lawenforcementCaseLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LawenforcementAttachMapper lawenforcementAttachMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询案件
|
|
|
+ *
|
|
|
+ * @param id 案件主键
|
|
|
+ * @return 案件
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public LawenforcementCase selectLawenforcementCaseById(String id) {
|
|
|
+ LawenforcementCase lawenforcementCase = lawenforcementCaseMapper.selectLawenforcementCaseById(id);
|
|
|
+ List<LawenforcementCaseLog> logList = lawenforcementCaseLogMapper.getLogByCaseId(id);
|
|
|
+ LawenforcementAttach attach = new LawenforcementAttach();
|
|
|
+ attach.setBusId(id);
|
|
|
+ List<LawenforcementAttach> fileList = lawenforcementAttachMapper.selectLawenforcementAttachList(attach);
|
|
|
+ for (LawenforcementAttach file : fileList) {
|
|
|
+ StringBuilder newDiles = new StringBuilder();
|
|
|
+ String suffix = file.getAttachPath().substring(file.getAttachPath().lastIndexOf(".")+1);
|
|
|
+ if (suffix.equals("pdf")){
|
|
|
+ String fileurl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DataConstants.DOWNLOAD_URL).getData();
|
|
|
+ String filename = file.getFileName();
|
|
|
+ String group = file.getAttachPath().substring(0, file.getAttachPath().indexOf('/'));
|
|
|
+ newDiles.append(fileurl).append("Download?fileName=").append(filename).append("&&group=").append(group).append("&&path=").append(file.getAttachPath().substring(file.getAttachPath().indexOf('/') + 1)).append("+").append(filename);
|
|
|
+ file.setAttachPath(newDiles.toString());
|
|
|
+ }else {
|
|
|
+ String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DataConstants.FILE_URL).getData();
|
|
|
+ newDiles.append(fileUrl).append(file.getAttachPath());
|
|
|
+ file.setAttachPath(newDiles.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lawenforcementCase.setLogList(logList);
|
|
|
+ lawenforcementCase.setFileList(fileList);
|
|
|
+ return lawenforcementCase;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询案件列表
|
|
|
+ *
|
|
|
+ * @param lawenforcementCase 案件
|
|
|
+ * @return 案件
|
|
|
+ */
|
|
|
+ @DataScopeMutiDept(deptAlias = "d")
|
|
|
+ @Override
|
|
|
+ public List<LawenforcementCase> selectLawenforcementCaseList(LawenforcementCase lawenforcementCase) {
|
|
|
+ setSookaDataBase(lawenforcementCase);
|
|
|
+ return lawenforcementCaseMapper.selectLawenforcementCaseList(lawenforcementCase);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增案件
|
|
|
+ *
|
|
|
+ * @param lawenforcementCase 案件
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int insertLawenforcementCase(LawenforcementCase lawenforcementCase) {
|
|
|
+ //新增案件
|
|
|
+ lawenforcementCase.setId(IdUtils.simpleUUID());
|
|
|
+ lawenforcementCase.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
+ lawenforcementCase.setCreateTime(DateUtils.getNowDate());
|
|
|
+ lawenforcementCase.setCreateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ lawenforcementCase.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
+ lawenforcementCase.setDeptName(SecurityUtils.getLoginUser().getSysUser().getDeptNames());
|
|
|
+ lawenforcementCase.setState("state_1");
|
|
|
+ int inserted = lawenforcementCaseMapper.insertLawenforcementCase(lawenforcementCase);
|
|
|
+ //新增案件日志
|
|
|
+ LawenforcementCaseLog lawenforcementCaseLog = new LawenforcementCaseLog();
|
|
|
+ lawenforcementCaseLog.setId(IdUtils.simpleUUID());
|
|
|
+ lawenforcementCaseLog.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
+ lawenforcementCaseLog.setCreateTime(DateUtils.getNowDate());
|
|
|
+ lawenforcementCaseLog.setCreateName( SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ lawenforcementCaseLog.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
+ lawenforcementCaseLog.setDeptName(SecurityUtils.getLoginUser().getSysUser().getDeptNames());
|
|
|
+ lawenforcementCaseLog.setCaseId(lawenforcementCase.getId());
|
|
|
+ lawenforcementCaseLog.setState("state_1");
|
|
|
+ lawenforcementCaseLog.setContent(lawenforcementCase.getContent());
|
|
|
+ lawenforcementCaseLogMapper.insertLawenforcementCaseLog(lawenforcementCaseLog);
|
|
|
+ //附件
|
|
|
+ lawenforcementAttachMapper.deleteByBusId(lawenforcementCase.getId());//删掉旧数据
|
|
|
+ if (StringUtils.isNotEmpty(lawenforcementCase.getFileNamesOne())||StringUtils.isNotEmpty(lawenforcementCase.getDescribeOne())){
|
|
|
+ LawenforcementAttach centerdataTFile = new LawenforcementAttach();
|
|
|
+ centerdataTFile.setBusId(lawenforcementCase.getId());
|
|
|
+ centerdataTFile.setFileName(lawenforcementCase.getFileNamesOne());
|
|
|
+ String fileUrl = getString(lawenforcementCase.getDataOne());
|
|
|
+ centerdataTFile.setAttachPath(fileUrl);
|
|
|
+ centerdataTFile.setAttachSorts(1L);
|
|
|
+ centerdataTFile.setDescribe(lawenforcementCase.getDescribeOne());
|
|
|
+ centerdataTFile.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
+ centerdataTFile.setCreateTime(DateUtils.getNowDate());
|
|
|
+ centerdataTFile.setCreateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ lawenforcementAttachMapper.insertLawenforcementAttach(centerdataTFile);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(lawenforcementCase.getFileNamesTwo())||StringUtils.isNotEmpty(lawenforcementCase.getDescribeTwo())){
|
|
|
+ LawenforcementAttach centerdataTFile = new LawenforcementAttach();
|
|
|
+ centerdataTFile.setBusId(lawenforcementCase.getId());
|
|
|
+ centerdataTFile.setFileName(lawenforcementCase.getFileNamesTwo());
|
|
|
+ String fileUrl = getString(lawenforcementCase.getDataTwo());
|
|
|
+ centerdataTFile.setAttachPath(fileUrl);
|
|
|
+ centerdataTFile.setAttachSorts(2L);
|
|
|
+ centerdataTFile.setDescribe(lawenforcementCase.getDescribeTwo());
|
|
|
+ centerdataTFile.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
+ centerdataTFile.setCreateTime(DateUtils.getNowDate());
|
|
|
+ centerdataTFile.setCreateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ lawenforcementAttachMapper.insertLawenforcementAttach(centerdataTFile);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(lawenforcementCase.getFileNamesThree())||StringUtils.isNotEmpty(lawenforcementCase.getDescribeThree())){
|
|
|
+ LawenforcementAttach centerdataTFile = new LawenforcementAttach();
|
|
|
+ centerdataTFile.setBusId(lawenforcementCase.getId());
|
|
|
+ centerdataTFile.setFileName(lawenforcementCase.getFileNamesThree());
|
|
|
+ String fileUrl = getString(lawenforcementCase.getDataThree());
|
|
|
+ centerdataTFile.setAttachPath(fileUrl);
|
|
|
+ centerdataTFile.setAttachSorts(3L);
|
|
|
+ centerdataTFile.setDescribe(lawenforcementCase.getDescribeThree());
|
|
|
+ centerdataTFile.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
+ centerdataTFile.setCreateTime(DateUtils.getNowDate());
|
|
|
+ centerdataTFile.setCreateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ lawenforcementAttachMapper.insertLawenforcementAttach(centerdataTFile);
|
|
|
+ }
|
|
|
+ return inserted;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getString(String file) {
|
|
|
+ String fileUrl = null;
|
|
|
+ if (file.indexOf('+') > -1 || file.indexOf("&&") > -1) {
|
|
|
+ if (file.indexOf('+') > -1) {
|
|
|
+ fileUrl = file.substring(0, file.indexOf('+'));
|
|
|
+ } else {
|
|
|
+ fileUrl = file;
|
|
|
+ }
|
|
|
+ String[] fileurls = fileUrl.split("&&");
|
|
|
+ fileUrl = fileurls[1].substring(fileurls[1].indexOf('=') + 1) + "/" + fileurls[2].substring(fileurls[2].indexOf('=') + 1);
|
|
|
+ } else {
|
|
|
+ fileUrl = file;
|
|
|
+ }
|
|
|
+ return fileUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改案件
|
|
|
+ *
|
|
|
+ * @param lawenforcementCase 案件
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateLawenforcementCase(LawenforcementCase lawenforcementCase) {
|
|
|
+ LawenforcementCaseLog lawenforcementCaseLog = new LawenforcementCaseLog();
|
|
|
+ lawenforcementCaseLog.setId(IdUtils.simpleUUID());
|
|
|
+ lawenforcementCaseLog.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
+ lawenforcementCaseLog.setCreateTime(DateUtils.getNowDate());
|
|
|
+ lawenforcementCaseLog.setCreateName( SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ lawenforcementCaseLog.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
+ lawenforcementCaseLog.setDeptName(SecurityUtils.getLoginUser().getSysUser().getDeptNames());
|
|
|
+ lawenforcementCaseLog.setCaseId(lawenforcementCase.getId());
|
|
|
+ lawenforcementCaseLog.setState(lawenforcementCase.getState());
|
|
|
+ lawenforcementCaseLog.setContent(lawenforcementCase.getContent());
|
|
|
+ int inserted = lawenforcementCaseLogMapper.insertLawenforcementCaseLog(lawenforcementCaseLog);
|
|
|
+ if (lawenforcementCase.getState().equals("state_5")){
|
|
|
+ List<LawenforcementCaseLog> logList = lawenforcementCaseLogMapper.getLogByCaseId(lawenforcementCase.getId());
|
|
|
+ long count = logList.stream().filter(obj -> obj.getState().equals("state_5")).count();
|
|
|
+ if (count>=5){
|
|
|
+ lawenforcementCase.setUpdateBy(SecurityUtils.getUserId());
|
|
|
+ lawenforcementCase.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ lawenforcementCase.setUpdateName( SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ return lawenforcementCaseMapper.updateLawenforcementCase(lawenforcementCase);
|
|
|
+ }
|
|
|
+ return inserted;
|
|
|
+ }else {
|
|
|
+ lawenforcementCase.setUpdateBy(SecurityUtils.getUserId());
|
|
|
+ lawenforcementCase.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ lawenforcementCase.setUpdateName( SecurityUtils.getLoginUser().getSysUser().getNickName());
|
|
|
+ return lawenforcementCaseMapper.updateLawenforcementCase(lawenforcementCase);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除案件
|
|
|
+ *
|
|
|
+ * @param ids 需要删除的案件主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteLawenforcementCaseByIds(String[] ids) {
|
|
|
+ return lawenforcementCaseMapper.deleteLawenforcementCaseByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除案件信息
|
|
|
+ *
|
|
|
+ * @param id 案件主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteLawenforcementCaseById(String id) {
|
|
|
+ return lawenforcementCaseMapper.deleteLawenforcementCaseById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 按部门查看日志
|
|
|
+ *
|
|
|
+ * @author 韩福成
|
|
|
+ * @date 2024/10/11 下午2:50
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int getCaseLog(LawenforcementCase lawenforcementCase) {
|
|
|
+ return lawenforcementCaseLogMapper.getCaseLog(lawenforcementCase);
|
|
|
+ }
|
|
|
+}
|