|
@@ -0,0 +1,238 @@
|
|
|
|
+package com.jeeplus.test.workClientInfo.service;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+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.oss.domain.WorkAttachment;
|
|
|
|
+import com.jeeplus.test.oss.mapper.OssServiceMapper;
|
|
|
|
+import com.jeeplus.test.oss.service.OssService;
|
|
|
|
+import com.jeeplus.test.workClientInfo.domain.WorkClientBank;
|
|
|
|
+import com.jeeplus.test.workClientInfo.domain.WorkClientInfo;
|
|
|
|
+import com.jeeplus.test.workClientInfo.domain.WorkClientLinkman;
|
|
|
|
+import com.jeeplus.test.workClientInfo.domain.dto.PageInfoDto;
|
|
|
|
+import com.jeeplus.test.workClientInfo.domain.dto.WorkClientInfosDto;
|
|
|
|
+import com.jeeplus.test.workClientInfo.mapper.WorkClientBankMapper;
|
|
|
|
+import com.jeeplus.test.workClientInfo.mapper.WorkClientInfoMapper;
|
|
|
|
+import com.jeeplus.test.workClientInfo.mapper.WorkClientLinkmanMapper;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
|
|
+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;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+public class WorkClientService {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private WorkClientInfoMapper workClientInfoMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private WorkClientBankMapper workClientBankMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private WorkClientLinkmanMapper workClientLinkmanMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private OssServiceMapper ossServiceMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private OssService ossService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户信息列表
|
|
|
|
+ * @param pageInfoDto
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Page<WorkClientInfo> list(PageInfoDto pageInfoDto) {
|
|
|
|
+ Page<WorkClientInfo> page = new Page<>(pageInfoDto.getPageNumber(), pageInfoDto.getPageSize());
|
|
|
|
+ LambdaQueryWrapper<WorkClientInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ if (StringUtils.isNotEmpty(pageInfoDto.getName())) {
|
|
|
|
+ lambdaQueryWrapper.eq(WorkClientInfo::getName, pageInfoDto.getName());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(pageInfoDto.getAreaId())) {
|
|
|
|
+ lambdaQueryWrapper.eq(WorkClientInfo::getAreaId, pageInfoDto.getAreaId());
|
|
|
|
+ }
|
|
|
|
+ lambdaQueryWrapper.orderByDesc(WorkClientInfo::getUpdateDate);
|
|
|
|
+ Page<WorkClientInfo> infoPage = workClientInfoMapper.selectPage(page, lambdaQueryWrapper);
|
|
|
|
+ return infoPage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户信息保存
|
|
|
|
+ * @param workClientInfosDto
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String add(WorkClientInfosDto workClientInfosDto) {
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO dto = UserUtils.getCurrentUserDTO();
|
|
|
|
+ //客户信息处理
|
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
+ WorkClientInfo workClientInfo = workClientInfosDto.getWorkClientInfo();
|
|
|
|
+ workClientInfo.setId(id);
|
|
|
|
+ workClientInfo.setCreateBy(dto.getId());
|
|
|
|
+ workClientInfo.setCreateDate(new Date());
|
|
|
|
+ workClientInfo.setUpdateBy(dto.getId());
|
|
|
|
+ workClientInfo.setUpdateDate(new Date());
|
|
|
|
+ workClientInfo.setCompanyId(dto.getCompanyDTO().getId());
|
|
|
|
+ workClientInfo.setOfficeId(dto.getOfficeDTO().getId());
|
|
|
|
+ workClientInfoMapper.insert(workClientInfo);
|
|
|
|
+ //开户行信息处理
|
|
|
|
+ List<WorkClientBank> workClientBank = workClientInfosDto.getWorkClientBank();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(workClientBank)) {
|
|
|
|
+ workClientBank.stream().forEach(i -> {
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+ i.setCreateBy(dto.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(dto.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setClientId(id);
|
|
|
|
+ workClientBankMapper.insert(i);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //联系人信息处理
|
|
|
|
+ List<WorkClientLinkman> workClientLinkman = workClientInfosDto.getWorkClientLinkman();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(workClientLinkman)) {
|
|
|
|
+ workClientLinkman.stream().forEach(i -> {
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+ i.setCreateBy(dto.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(dto.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setClientId(id);
|
|
|
|
+ workClientLinkmanMapper.insert(i);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //附件信息处理
|
|
|
|
+ List<WorkAttachment> workAttachments = workClientInfosDto.getWorkAttachments();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(workAttachments)) {
|
|
|
|
+ int j = 1;
|
|
|
|
+ for (WorkAttachment i : workAttachments) {
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+ i.setCreateBy(dto.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(dto.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setAttachmentId(id);
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ ossServiceMapper.insert(i);
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "添加完成!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户信息删除
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String removeById (String id) {
|
|
|
|
+ //客户信息删除
|
|
|
|
+ workClientInfoMapper.deleteById(id);
|
|
|
|
+ //客户关联开户行信息删除
|
|
|
|
+ LambdaQueryWrapper<WorkClientBank> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(WorkClientBank::getClientId, id);
|
|
|
|
+ workClientBankMapper.delete(wrapper);
|
|
|
|
+ //客户关联紧急联系人信息删除
|
|
|
|
+ LambdaQueryWrapper<WorkClientLinkman> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper1.eq(WorkClientLinkman::getClientId, id);
|
|
|
|
+ workClientLinkmanMapper.delete(wrapper1);
|
|
|
|
+ //客户关联附件信息删除
|
|
|
|
+ LambdaQueryWrapper<WorkAttachment> wrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper2.eq(WorkAttachment::getAttachmentId, id);
|
|
|
|
+ ossServiceMapper.delete(wrapper2);
|
|
|
|
+ return "删除完成!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户信息查询
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public WorkClientInfosDto findById (String id) {
|
|
|
|
+ WorkClientInfosDto dto = new WorkClientInfosDto();
|
|
|
|
+ //客户信息查询
|
|
|
|
+ dto.setWorkClientInfo(workClientInfoMapper.selectById(id));
|
|
|
|
+ //客户关联开户行信息查询
|
|
|
|
+ LambdaQueryWrapper<WorkClientBank> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(WorkClientBank::getClientId, id);
|
|
|
|
+ wrapper.orderByDesc(WorkClientBank::getUpdateDate);
|
|
|
|
+ dto.setWorkClientBank(workClientBankMapper.selectList(wrapper));
|
|
|
|
+ //客户关联紧急联系人信息查询
|
|
|
|
+ LambdaQueryWrapper<WorkClientLinkman> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper1.eq(WorkClientLinkman::getClientId, id);
|
|
|
|
+ wrapper1.orderByDesc(WorkClientLinkman::getUpdateDate);
|
|
|
|
+ dto.setWorkClientLinkman(workClientLinkmanMapper.selectList(wrapper1));
|
|
|
|
+ //客户关联附件信息查询
|
|
|
|
+ LambdaQueryWrapper<WorkAttachment> wrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper2.eq(WorkAttachment::getAttachmentId, id);
|
|
|
|
+ wrapper2.orderByAsc(WorkAttachment::getSort);
|
|
|
|
+ dto.setWorkAttachments(ossServiceMapper.selectList(wrapper2));
|
|
|
|
+ return dto;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 客户信息更新
|
|
|
|
+ * @param workClientInfosDto
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public String update(WorkClientInfosDto workClientInfosDto) {
|
|
|
|
+ //获取当前登录人信息
|
|
|
|
+ UserDTO dto = UserUtils.getCurrentUserDTO();
|
|
|
|
+ //客户信息处理
|
|
|
|
+ WorkClientInfo workClientInfo = workClientInfosDto.getWorkClientInfo();
|
|
|
|
+ workClientInfo.setUpdateBy(dto.getId());
|
|
|
|
+ workClientInfo.setUpdateDate(new Date());
|
|
|
|
+ workClientInfo.setCompanyId(dto.getCompanyDTO().getId());
|
|
|
|
+ workClientInfo.setOfficeId(dto.getOfficeDTO().getId());
|
|
|
|
+ workClientInfoMapper.updateById(workClientInfo);
|
|
|
|
+ //开户行信息处理(先删除原有数据,再进行数据添加)
|
|
|
|
+ List<WorkClientBank> workClientBank = workClientInfosDto.getWorkClientBank();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(workClientBank)) {
|
|
|
|
+ LambdaQueryWrapper<WorkClientBank> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(WorkClientBank::getClientId, workClientInfo.getId());
|
|
|
|
+ workClientBankMapper.delete(wrapper);
|
|
|
|
+ workClientBank.stream().forEach(i -> {
|
|
|
|
+ i.setCreateBy(dto.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(dto.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setClientId(workClientInfo.getId());
|
|
|
|
+ workClientBankMapper.insert(i);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //联系人信息处理
|
|
|
|
+ List<WorkClientLinkman> workClientLinkman = workClientInfosDto.getWorkClientLinkman();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(workClientLinkman)) {
|
|
|
|
+ LambdaQueryWrapper<WorkClientLinkman> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(WorkClientLinkman::getClientId, workClientInfo.getId());
|
|
|
|
+ workClientLinkmanMapper.delete(wrapper);
|
|
|
|
+ workClientLinkman.stream().forEach(i -> {
|
|
|
|
+ i.setCreateBy(dto.getId());
|
|
|
|
+ i.setCreateDate(new Date());
|
|
|
|
+ i.setUpdateBy(dto.getId());
|
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
|
+ i.setClientId(workClientInfo.getId());
|
|
|
|
+ workClientLinkmanMapper.insert(i);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //附件信息处理
|
|
|
|
+ List<WorkAttachment> workAttachments = workClientInfosDto.getWorkAttachments();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(workAttachments)) {
|
|
|
|
+ workAttachments.stream().forEach(i -> i.setAttachmentId(workClientInfo.getId()));
|
|
|
|
+ ossService.saveMsg(workAttachments);
|
|
|
|
+ }
|
|
|
|
+ return "更新完成!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|