|
@@ -8,10 +8,12 @@ import com.jeeplus.core.domain.BaseEntity;
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
|
+import com.jeeplus.test.cw.contractRegistration.domain.ContractFile;
|
|
import com.jeeplus.test.cw.contractRegistration.domain.ContractInfo;
|
|
import com.jeeplus.test.cw.contractRegistration.domain.ContractInfo;
|
|
import com.jeeplus.test.cw.contractRegistration.mapper.ContractInfoMapper;
|
|
import com.jeeplus.test.cw.contractRegistration.mapper.ContractInfoMapper;
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
|
|
+import com.jeeplus.test.oss.mapper.OssServiceMapper;
|
|
import com.jeeplus.test.reimbursement.reimbursementType.domain.ReimbursementTypeInfo;
|
|
import com.jeeplus.test.reimbursement.reimbursementType.domain.ReimbursementTypeInfo;
|
|
import com.jeeplus.test.workContract.domain.WorkContractInfo;
|
|
import com.jeeplus.test.workContract.domain.WorkContractInfo;
|
|
import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
|
|
import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
|
|
@@ -23,6 +25,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.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
@@ -40,6 +43,9 @@ public class ContractInfoService {
|
|
@Resource
|
|
@Resource
|
|
private SerialnumTplService serialnumTplService;
|
|
private SerialnumTplService serialnumTplService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private OssServiceMapper ossServiceMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据id修改status
|
|
* 根据id修改status
|
|
*/
|
|
*/
|
|
@@ -89,7 +95,7 @@ public class ContractInfoService {
|
|
}
|
|
}
|
|
//8、归档状态
|
|
//8、归档状态
|
|
if (StringUtils.isNotEmpty(info.getFiledType())) {
|
|
if (StringUtils.isNotEmpty(info.getFiledType())) {
|
|
- wrapper.like("b.filed_type", info.getFiledType());
|
|
|
|
|
|
+ wrapper.like("a.filed_type", info.getFiledType());
|
|
}
|
|
}
|
|
wrapper.eq("a.del_flag","0");
|
|
wrapper.eq("a.del_flag","0");
|
|
IPage<ContractInfo> pageList = mapper.findPageList(page, wrapper);
|
|
IPage<ContractInfo> pageList = mapper.findPageList(page, wrapper);
|
|
@@ -100,11 +106,48 @@ public class ContractInfoService {
|
|
/**
|
|
/**
|
|
* 合同登记查询
|
|
* 合同登记查询
|
|
*/
|
|
*/
|
|
|
|
+ public ContractInfo findByContractId(String id) {
|
|
|
|
+
|
|
|
|
+ //根据id判断是file表的id,还是info表的id
|
|
|
|
+// ContractFile byId = mapper.getById(id);
|
|
|
|
+// ContractInfo dto = null;
|
|
|
|
+// if (byId != null){
|
|
|
|
+// dto = mapper.findByContractId(id);
|
|
|
|
+// }else {
|
|
|
|
+// dto = mapper.findById(id);
|
|
|
|
+// }
|
|
|
|
+ ContractInfo dto = mapper.findById(id);
|
|
|
|
+ if (dto != null){
|
|
|
|
+ dto.setContractStatus("新创建");
|
|
|
|
+ // 查询附件信息
|
|
|
|
+ List<WorkAttachmentDto> dtos = mapper.findDtos(id);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dtos)) {
|
|
|
|
+ for (WorkAttachmentDto i : dtos) {
|
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dto.setContractProperList(dtos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return dto;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记查询
|
|
|
|
+ */
|
|
public ContractInfo findById(String id) {
|
|
public ContractInfo findById(String id) {
|
|
|
|
|
|
ContractInfo dto = mapper.findById(id);
|
|
ContractInfo dto = mapper.findById(id);
|
|
if (dto != null){
|
|
if (dto != null){
|
|
dto.setContractStatus("新创建");
|
|
dto.setContractStatus("新创建");
|
|
|
|
+ // 查询附件信息
|
|
|
|
+ List<WorkAttachmentDto> dtos = mapper.findDtos(id);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dtos)) {
|
|
|
|
+ for (WorkAttachmentDto i : dtos) {
|
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dto.setContractProperList(dtos);
|
|
}
|
|
}
|
|
|
|
|
|
return dto;
|
|
return dto;
|
|
@@ -147,6 +190,10 @@ public class ContractInfoService {
|
|
int num = Integer.parseInt(contractInfo.getChangeNum()) + 1;
|
|
int num = Integer.parseInt(contractInfo.getChangeNum()) + 1;
|
|
contractInfo.setChangeNum(num + "");
|
|
contractInfo.setChangeNum(num + "");
|
|
mapper.updateById(contractInfo);
|
|
mapper.updateById(contractInfo);
|
|
|
|
+ List<WorkAttachmentDto> list = info.getContractProperList();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ updateFiles(list, userDTO, info.getId());
|
|
|
|
+ }
|
|
|
|
|
|
return info.getId();
|
|
return info.getId();
|
|
}
|
|
}
|
|
@@ -169,10 +216,100 @@ public class ContractInfoService {
|
|
info.setCreateBy(userDTO.getId());
|
|
info.setCreateBy(userDTO.getId());
|
|
info.setCreateDate(new Date());
|
|
info.setCreateDate(new Date());
|
|
info.setUpdateBy(userDTO.getId());
|
|
info.setUpdateBy(userDTO.getId());
|
|
-
|
|
|
|
info.setUpdateDate(new Date());
|
|
info.setUpdateDate(new Date());
|
|
mapper.insert(info);
|
|
mapper.insert(info);
|
|
|
|
+ List<WorkAttachmentDto> list = contractInfo.getContractProperList();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ saveFiles(list, userDTO, id);
|
|
|
|
+ }
|
|
|
|
|
|
return id;
|
|
return id;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存附件信息
|
|
|
|
+ * @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.getCreateBy().setId(userDTO.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+// i.getUpdateBy().setId(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("cwWorkContract");
|
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
|
+ 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 = mapper.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 = mapper.findIsExit(id, dto.getName());
|
|
|
|
+ if (isExit == 0) {
|
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
|
+ //包含了url、size、name
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+// i.getUpdateBy().setId(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("cwWorkContract");
|
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|