|
@@ -0,0 +1,165 @@
|
|
|
|
+package com.jeeplus.test.workContract.service;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.jeeplus.test.oss.service.OssService;
|
|
|
|
+import com.jeeplus.test.workClientInfo.domain.WorkClientInfo;
|
|
|
|
+import com.jeeplus.test.workClientInfo.mapper.WorkClientInfoMapper;
|
|
|
|
+import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
|
+import com.jeeplus.sys.utils.StringUtils;
|
|
|
|
+import com.jeeplus.sys.utils.UserUtils;
|
|
|
|
+import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
|
|
+import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
|
|
+import com.jeeplus.test.oss.mapper.OssServiceMapper;
|
|
|
|
+import com.jeeplus.test.workContract.domain.WorkContractInfo;
|
|
|
|
+import com.jeeplus.test.workContract.mapper.WorkContractInfoMapper;
|
|
|
|
+import com.jeeplus.test.workContract.service.dto.WorkContractInfoDto;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.UUID;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class WorkContractService {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private WorkContractInfoMapper workContractInfoMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private WorkClientInfoMapper workClientInfoMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private OssServiceMapper ossServiceMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private OssService ossService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SerialnumTplService serialnumTplService;
|
|
|
|
+
|
|
|
|
+ private final String BIZ_CODE = "htdj";
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户信息列表
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public IPage<WorkContractInfo> list(Page<WorkContractInfo> page, QueryWrapper<WorkContractInfo> queryWrapper, String clientName, String[] contractDates, String[] contractAmounts) {
|
|
|
|
+ queryWrapper.eq("a.del_flag","0");
|
|
|
|
+ if (StringUtils.isNotEmpty(clientName)) {
|
|
|
|
+ queryWrapper.like("b.name", clientName);
|
|
|
|
+ }
|
|
|
|
+ if (contractDates != null) {
|
|
|
|
+ queryWrapper.between("a.contract_date", contractDates[0], contractDates[1]);
|
|
|
|
+ }
|
|
|
|
+ if (contractAmounts != null) {
|
|
|
|
+ if (StringUtils.isNotEmpty(contractAmounts[0])) {
|
|
|
|
+ queryWrapper.ge("a.contract_amount", contractAmounts[0]);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(contractAmounts[1])) {
|
|
|
|
+ queryWrapper.le("a.contract_amount", contractAmounts[1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ IPage<WorkContractInfo> pageList = workContractInfoMapper.findPageList(page, queryWrapper);
|
|
|
|
+ return pageList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记新增
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String add(WorkContractInfoDto workContractInfoDto) throws Exception{
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
|
+ //合同编号生成
|
|
|
|
+ String serialNum = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), BIZ_CODE);
|
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
+ WorkContractInfo info = new WorkContractInfo();
|
|
|
|
+ BeanUtils.copyProperties(workContractInfoDto, info);
|
|
|
|
+ info.setId(id);
|
|
|
|
+ info.setNo(serialNum);
|
|
|
|
+ info.setCreateBy(userDTO.getId());
|
|
|
|
+ info.setCreateDate(new Date());
|
|
|
|
+ info.setUpdateBy(userDTO.getId());
|
|
|
|
+ info.setUpdateDate(new Date());
|
|
|
|
+ workContractInfoMapper.insert(info);
|
|
|
|
+ List<WorkAttachment> list = workContractInfoDto.getWorkAttachmentList();
|
|
|
|
+ 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++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "操作完成";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记修改
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String update(WorkContractInfoDto workContractInfoDto) throws Exception{
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
|
+ //合同编号生成
|
|
|
|
+ String serialNum = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), BIZ_CODE);
|
|
|
|
+ WorkContractInfo info = new WorkContractInfo();
|
|
|
|
+ BeanUtils.copyProperties(workContractInfoDto, info);
|
|
|
|
+ info.setNo(serialNum);
|
|
|
|
+ info.setUpdateBy(userDTO.getId());
|
|
|
|
+ info.setUpdateDate(new Date());
|
|
|
|
+ workContractInfoMapper.updateById(info);
|
|
|
|
+ List<WorkAttachment> list = workContractInfoDto.getWorkAttachmentList();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ list.stream().forEach(i -> i.setAttachmentId(info.getId()));
|
|
|
|
+ ossService.saveMsg(list);
|
|
|
|
+ }
|
|
|
|
+ return "操作完成";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记删除
|
|
|
|
+ */
|
|
|
|
+ public String removeById(String id) {
|
|
|
|
+ workContractInfoMapper.deleteById(id);
|
|
|
|
+ // 附件删除
|
|
|
|
+ LambdaQueryWrapper<WorkAttachment> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(WorkAttachment::getAttachmentId, id);
|
|
|
|
+ ossServiceMapper.delete(wrapper);
|
|
|
|
+ return "删除完成!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同登记查询
|
|
|
|
+ */
|
|
|
|
+ public WorkContractInfoDto findById(String id) {
|
|
|
|
+ WorkContractInfoDto dto = new WorkContractInfoDto();
|
|
|
|
+ WorkContractInfo info = workContractInfoMapper.findById(id);
|
|
|
|
+ BeanUtils.copyProperties(info, dto);
|
|
|
|
+ // 查询客户信息
|
|
|
|
+ if (StringUtils.isNotEmpty(dto.getClientId())) {
|
|
|
|
+ WorkClientInfo workClientInfo = workClientInfoMapper.selectById(dto.getClientId());
|
|
|
|
+ dto.setClientName(workClientInfo.getName());
|
|
|
|
+ }
|
|
|
|
+ // 查询附件信息
|
|
|
|
+ LambdaQueryWrapper<WorkAttachment> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(WorkAttachment::getAttachmentId, id);
|
|
|
|
+ wrapper.orderByAsc(WorkAttachment::getSort);
|
|
|
|
+ dto.setWorkAttachmentList(ossServiceMapper.selectList(wrapper));
|
|
|
|
+ return dto;
|
|
|
|
+ }
|
|
|
|
+}
|