|
@@ -9,6 +9,7 @@ import com.jeeplus.test.workClientInfo.domain.WorkClientInfo;
|
|
import com.jeeplus.test.workClientInfo.domain.dto.WorkClientInfosDto;
|
|
import com.jeeplus.test.workClientInfo.domain.dto.WorkClientInfosDto;
|
|
import com.jeeplus.test.workClientInfo.mapper.WorkClientInfoMapper;
|
|
import com.jeeplus.test.workClientInfo.mapper.WorkClientInfoMapper;
|
|
import com.jeeplus.test.workClientInfo.service.WorkClientService;
|
|
import com.jeeplus.test.workClientInfo.service.WorkClientService;
|
|
|
|
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -26,9 +27,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class WorkContractService {
|
|
public class WorkContractService {
|
|
@@ -40,13 +39,20 @@ public class WorkContractService {
|
|
private OssServiceMapper ossServiceMapper;
|
|
private OssServiceMapper ossServiceMapper;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private OssService ossService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
private SerialnumTplService serialnumTplService;
|
|
private SerialnumTplService serialnumTplService;
|
|
|
|
|
|
private final String BIZ_CODE = "htdj";
|
|
private final String BIZ_CODE = "htdj";
|
|
|
|
|
|
|
|
+ public String saveInfo(WorkContractInfoDto workContractInfoDto) throws Exception {
|
|
|
|
+ if (StringUtils.isNotEmpty(workContractInfoDto.getId())) {
|
|
|
|
+ WorkContractInfo info = workContractInfoMapper.selectById(workContractInfoDto.getId());
|
|
|
|
+ if (info != null) {
|
|
|
|
+ return update(workContractInfoDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return add(workContractInfoDto);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 客户信息列表
|
|
* 客户信息列表
|
|
* @param
|
|
* @param
|
|
@@ -91,20 +97,9 @@ public class WorkContractService {
|
|
info.setUpdateBy(userDTO.getId());
|
|
info.setUpdateBy(userDTO.getId());
|
|
info.setUpdateDate(new Date());
|
|
info.setUpdateDate(new Date());
|
|
workContractInfoMapper.insert(info);
|
|
workContractInfoMapper.insert(info);
|
|
- List<WorkAttachment> list = workContractInfoDto.getWorkAttachmentList();
|
|
|
|
|
|
+ List<WorkAttachmentDto> list = workContractInfoDto.getWorkAttachmentList();
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
- int j = 1;
|
|
|
|
- for (WorkAttachment i : list) {
|
|
|
|
- i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
- i.setCreateBy(userDTO.getId());
|
|
|
|
- i.setCreateDate(new Date());
|
|
|
|
- i.setUpdateBy(userDTO.getId());
|
|
|
|
- i.setUpdateDate(new Date());
|
|
|
|
- i.setAttachmentId(id);
|
|
|
|
- i.setSort(j);
|
|
|
|
- ossServiceMapper.insert(i);
|
|
|
|
- j++;
|
|
|
|
- }
|
|
|
|
|
|
+ saveFiles(list, userDTO, id);
|
|
}
|
|
}
|
|
return id;
|
|
return id;
|
|
}
|
|
}
|
|
@@ -124,10 +119,9 @@ public class WorkContractService {
|
|
info.setUpdateBy(userDTO.getId());
|
|
info.setUpdateBy(userDTO.getId());
|
|
info.setUpdateDate(new Date());
|
|
info.setUpdateDate(new Date());
|
|
workContractInfoMapper.updateById(info);
|
|
workContractInfoMapper.updateById(info);
|
|
- List<WorkAttachment> list = workContractInfoDto.getWorkAttachmentList();
|
|
|
|
|
|
+ List<WorkAttachmentDto> list = workContractInfoDto.getWorkAttachmentList();
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
- list.stream().forEach(i -> i.setAttachmentId(info.getId()));
|
|
|
|
- ossService.saveMsg(list);
|
|
|
|
|
|
+ updateFiles(list, userDTO, workContractInfoDto.getId());
|
|
}
|
|
}
|
|
return workContractInfoDto.getId();
|
|
return workContractInfoDto.getId();
|
|
}
|
|
}
|
|
@@ -152,10 +146,107 @@ public class WorkContractService {
|
|
WorkContractInfo info = workContractInfoMapper.findById(id);
|
|
WorkContractInfo info = workContractInfoMapper.findById(id);
|
|
BeanUtils.copyProperties(info, dto);
|
|
BeanUtils.copyProperties(info, dto);
|
|
// 查询附件信息
|
|
// 查询附件信息
|
|
- LambdaQueryWrapper<WorkAttachment> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
- wrapper.eq(WorkAttachment::getAttachmentId, id);
|
|
|
|
- wrapper.orderByAsc(WorkAttachment::getSort);
|
|
|
|
- dto.setWorkAttachmentList(ossServiceMapper.selectList(wrapper));
|
|
|
|
|
|
+ List<WorkAttachmentDto> dtos = workContractInfoMapper.findDtos(id);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dtos)) {
|
|
|
|
+ for (WorkAttachmentDto i : dtos) {
|
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dto.setWorkAttachmentList(dtos);
|
|
return dto;
|
|
return dto;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id修改status
|
|
|
|
+ */
|
|
|
|
+ public void updateStatusById(WorkContractInfoDto workContractInfoDto) {
|
|
|
|
+ workContractInfoMapper.updateStatusById(workContractInfoDto.getId(), workContractInfoDto.getStatus());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存附件信息
|
|
|
|
+ * @param list 待保存的附件列表
|
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
|
+ * @param id 关联id
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void saveFiles(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
|
|
|
|
+ int j = 1;
|
|
|
|
+ for (WorkAttachmentDto dto : list) {
|
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
|
+ //包含了url、size、name
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+ i.setCreateBy(userDTO.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(userDTO.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setDelFlag(0);
|
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
|
+ //文件类型处理
|
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(strings)) {
|
|
|
|
+ i.setType(strings.get(1));
|
|
|
|
+ }
|
|
|
|
+ i.setAttachmentId(id);
|
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
|
+ i.setAttachmentFlag("workcontract");
|
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ ossServiceMapper.insert(i);
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改附件信息
|
|
|
|
+ * @param list 待修改的附件列表
|
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
|
+ * @param id 关联id
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void updateFiles(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
|
|
|
|
+ int j = 1;
|
|
|
|
+ String names = new String();
|
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
|
+ for (WorkAttachmentDto dto : list) {
|
|
|
|
+ names = names + "," +dto.getUrl();
|
|
|
|
+ }
|
|
|
|
+ //查询保存的附件信息
|
|
|
|
+ List<WorkAttachment> infoList = workContractInfoMapper.findList(id);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(infoList)) {
|
|
|
|
+ for (WorkAttachment i : infoList) {
|
|
|
|
+ if (!names.contains(i.getUrl())) {
|
|
|
|
+ ossServiceMapper.deleteById(i.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //保存信息
|
|
|
|
+ for (WorkAttachmentDto dto : list) {
|
|
|
|
+ //判断是否存在
|
|
|
|
+ Integer isExit = workContractInfoMapper.findIsExit(id, dto.getName());
|
|
|
|
+ if (isExit == 0) {
|
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
|
+ //包含了url、size、name
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+ i.setCreateBy(userDTO.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(userDTO.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setDelFlag(0);
|
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
|
+ //文件类型处理
|
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(strings)) {
|
|
|
|
+ i.setType(strings.get(1));
|
|
|
|
+ }
|
|
|
|
+ i.setAttachmentId(id);
|
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
|
+ i.setAttachmentFlag("workcontract");
|
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ ossServiceMapper.insert(i);
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|