|
@@ -0,0 +1,99 @@
|
|
|
+package cn.cslg.pas.service.business;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.dto.business.OtherReferencesDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+import cn.cslg.pas.domain.business.AssoOtherReferencesFile;
|
|
|
+import cn.cslg.pas.domain.business.LitigationHistory;
|
|
|
+import cn.cslg.pas.domain.business.OtherReferences;
|
|
|
+import cn.cslg.pas.exception.XiaoShiException;
|
|
|
+import cn.cslg.pas.mapper.OtherReferencesMapper;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 其他参考资料
|
|
|
+ * @Author xiexiang
|
|
|
+ * @Date 2024/1/17
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class OtherReferencesService extends ServiceImpl<OtherReferencesMapper, OtherReferences> {
|
|
|
+ @Autowired
|
|
|
+ private LoginUtils loginUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CacheUtils cacheUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PermissionService permissionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AssoOtherReferencesFileService assoReferencesFileService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增or更新其他参考资料
|
|
|
+ * @param otherReferencesDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Integer saveOrUpdate(OtherReferencesDTO otherReferencesDTO){
|
|
|
+ if (otherReferencesDTO == null) {
|
|
|
+ throw new XiaoShiException("入参为空");
|
|
|
+ }
|
|
|
+ Integer id = otherReferencesDTO.getId();
|
|
|
+ List<String> fileGuids = otherReferencesDTO.getFileGuids();
|
|
|
+ OtherReferences otherReferences = new OtherReferences();
|
|
|
+ if (id != null) {
|
|
|
+ //update
|
|
|
+ otherReferences = this.getById(id);
|
|
|
+ BeanUtils.copyProperties(otherReferencesDTO, otherReferences);
|
|
|
+ otherReferences.updateById();
|
|
|
+ if (!fileGuids.isEmpty()) {
|
|
|
+ //先删除 后添加
|
|
|
+ LambdaQueryWrapper<AssoOtherReferencesFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AssoOtherReferencesFile::getOtherReferencesId, id);
|
|
|
+ assoReferencesFileService.remove(queryWrapper);
|
|
|
+ List<Integer> fileIds = this.addFile(otherReferences.getId(), fileGuids);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BeanUtils.copyProperties(otherReferencesDTO, otherReferences);
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException("未查询到当前登陆人");
|
|
|
+ }
|
|
|
+ otherReferences.setCreateId(personnelVO.getId());
|
|
|
+ otherReferences.insert();
|
|
|
+ if (!fileGuids.isEmpty()) {
|
|
|
+ //先删除 后添加
|
|
|
+ List<Integer> fileIds = this.addFile(otherReferences.getId(), fileGuids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return otherReferences.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Integer> addFile(Integer id, List<String> fileGuids){
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
+ if (!fileGuids.isEmpty()) {
|
|
|
+ List<AssoOtherReferencesFile> assoOtherReferencesFiles = new ArrayList<>();
|
|
|
+ fileGuids.forEach(item -> {
|
|
|
+ AssoOtherReferencesFile assoOtherReferencesFile = new AssoOtherReferencesFile();
|
|
|
+ assoOtherReferencesFile.setOtherReferencesId(id);
|
|
|
+ assoOtherReferencesFile.setFileGuid(item);
|
|
|
+ assoOtherReferencesFiles.add(assoOtherReferencesFile);
|
|
|
+ });
|
|
|
+ assoReferencesFileService.saveBatch(assoOtherReferencesFiles);
|
|
|
+ }
|
|
|
+ return ids;
|
|
|
+ }
|
|
|
+}
|