|
@@ -3,25 +3,27 @@ package com.jeeplus.test.cw.workClientInfo.service;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+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.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
+import com.jeeplus.sys.domain.User;
|
|
|
+import com.jeeplus.sys.mapper.UserMapper;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
import com.jeeplus.test.cw.projectRecords.domain.CwProjectClientInfo;
|
|
|
import com.jeeplus.test.cw.projectRecords.mapper.CwProjectClientInfoMapper;
|
|
|
-import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
|
|
|
-import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBilling;
|
|
|
-import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientContact;
|
|
|
-import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientType;
|
|
|
+import com.jeeplus.test.cw.workClientInfo.domain.*;
|
|
|
import com.jeeplus.test.cw.workClientInfo.mapper.*;
|
|
|
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
|
|
|
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBillingDTO;
|
|
|
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientContactDTO;
|
|
|
+import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientTempDTO;
|
|
|
import com.jeeplus.test.cw.workClientInfo.service.mapstruct.CwWorkClientBaseWrapper;
|
|
|
import com.jeeplus.test.cw.workClientInfo.service.mapstruct.CwWorkClientBillingWrapper;
|
|
|
import com.jeeplus.test.cw.workClientInfo.service.mapstruct.CwWorkClientContactWrapper;
|
|
@@ -34,8 +36,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.sql.Array;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -60,6 +65,10 @@ public class CwWorkClientService extends ServiceImpl<CwWorkClientBaseMapper, CwW
|
|
|
private OssService ossService;
|
|
|
@Resource
|
|
|
private CwProjectClientInfoMapper cwProjectClientInfoMapper;
|
|
|
+ @Resource
|
|
|
+ private CwWorkClientTempService cwWorkClientTempService;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
|
|
|
|
|
|
public IPage<CwWorkClientBaseDTO> findList(Page<CwWorkClientBaseDTO> page, CwWorkClientBaseDTO cwWorkClientBaseDTO) throws Exception{
|
|
@@ -84,6 +93,19 @@ public class CwWorkClientService extends ServiceImpl<CwWorkClientBaseMapper, CwW
|
|
|
return new Page<>();
|
|
|
}
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(cwWorkClientBaseDTO.getUpdateUserName())) {
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().lambda().like(User::getName, cwWorkClientBaseDTO.getUpdateUserName()));
|
|
|
+ if (CollectionUtil.isNotEmpty(userList)) {
|
|
|
+ List<String> userIds = userList.stream().distinct().map(User::getId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(userIds)) {
|
|
|
+ queryWrapper.in("cw_wcb.update_user",userIds);
|
|
|
+ } else {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return cwWorkClientBaseMapper.findList(page, queryWrapper);
|
|
|
}
|
|
@@ -170,6 +192,8 @@ public class CwWorkClientService extends ServiceImpl<CwWorkClientBaseMapper, CwW
|
|
|
UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
String no = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwWorkClientBaseDTO.BIZ_CODE);
|
|
|
cwWorkClientBase.setNo(no);
|
|
|
+ cwWorkClientBase.setUpdateUser(userDTO.getId());
|
|
|
+ cwWorkClientBase.setStatus("0");
|
|
|
}
|
|
|
}
|
|
|
this.saveOrUpdate(cwWorkClientBase);
|
|
@@ -251,4 +275,162 @@ public class CwWorkClientService extends ServiceImpl<CwWorkClientBaseMapper, CwW
|
|
|
return "操作成功";
|
|
|
}
|
|
|
|
|
|
+ // 其他人发起修改申请
|
|
|
+ public synchronized ResponseEntity<Map<String,String>> pushUpdate(String id) {
|
|
|
+ CwWorkClientBaseDTO cwWorkClientBaseDTO = this.queryById(id);
|
|
|
+ String jsonString = JSON.toJSONString(cwWorkClientBaseDTO);
|
|
|
+ CwWorkClientTemp temp = new CwWorkClientTemp();
|
|
|
+ temp.setSourceData(jsonString);
|
|
|
+ temp.setClientId(id);
|
|
|
+ temp.setStatus("2");
|
|
|
+ cwWorkClientTempService.save(temp);
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("id", temp.getId());
|
|
|
+ return ResponseEntity.ok (map);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 终止修改申请
|
|
|
+ public ResponseEntity stopUpdate(String id) throws Exception{
|
|
|
+ CwWorkClientBase cwWorkClientBase = this.getById(id);
|
|
|
+ CwWorkClientTemp cwWorkClientTemp = cwWorkClientTempService.getById(cwWorkClientBase.getUpdateRequestId());
|
|
|
+ cwWorkClientTemp.setStatus("6"); // 6取消申请
|
|
|
+ cwWorkClientTempService.updateById(cwWorkClientTemp);
|
|
|
+ CwWorkClientBaseDTO cwWorkClientBaseDTO = JSON.parseObject(cwWorkClientTemp.getSourceData(), CwWorkClientBaseDTO.class);
|
|
|
+ this.saveForm(cwWorkClientBaseDTO);
|
|
|
+ return ResponseEntity.ok ("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 驳回/修改/通过申请
|
|
|
+ public ResponseEntity rebackOrAgreeUpdate(String id, String type) {
|
|
|
+ CwWorkClientBase cwWorkClientBase = this.getById(id);
|
|
|
+ CwWorkClientTemp cwWorkClientTemp = cwWorkClientTempService.getById(cwWorkClientBase.getUpdateRequestId());
|
|
|
+ if ("reject".equals(type)){
|
|
|
+ cwWorkClientTemp.setStatus("4");
|
|
|
+ }
|
|
|
+ if ("reback".equals(type)){
|
|
|
+ cwWorkClientTemp.setStatus("3");
|
|
|
+ }
|
|
|
+ if ("reback_push".equals(type)){
|
|
|
+ // 撤回后重新发起修改
|
|
|
+ cwWorkClientTemp.setStatus("2");
|
|
|
+ }
|
|
|
+ if ("agree".equals(type)){
|
|
|
+ cwWorkClientTemp.setStatus("5");
|
|
|
+ cwWorkClientBase.setUpdateUser(cwWorkClientBase.getRequestUserId()); // 审核通过后,拥有人改为当前申请人
|
|
|
+ cwWorkClientBase.setRequestUserId(""); // 审核通过后,当前申请人清空
|
|
|
+ cwWorkClientBase.setUpdateRequestId(""); // 审核通过后,修改申请临时表id清空
|
|
|
+ this.updateById(cwWorkClientBase);
|
|
|
+ }
|
|
|
+ if ("reapply".equals(type)){
|
|
|
+ cwWorkClientTemp.setStatus("2");
|
|
|
+ }
|
|
|
+ cwWorkClientTempService.updateById(cwWorkClientTemp);
|
|
|
+ return ResponseEntity.ok ("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询社会统一信用代码是否存在
|
|
|
+ public ResponseEntity<Map<String,String>> queryUscCodeIsUse(String uscCode) {
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ // 根据社会统一信用代码查询
|
|
|
+ List<CwWorkClientBase> list = this.list(new QueryWrapper<CwWorkClientBase>().lambda().eq(CwWorkClientBase::getUscCode, uscCode).orderByDesc(CwWorkClientBase::getCreateDate).last("limit 1"));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ CwWorkClientBase cwWorkClientBase = list.get(0);
|
|
|
+ if (ObjectUtil.isNotEmpty(cwWorkClientBase)) {
|
|
|
+ // 客户数据拥有人不是空时,按正常流程走数据,数据的拥有人是不可能为空的
|
|
|
+ if (StringUtils.isNotBlank(cwWorkClientBase.getUpdateUser())){
|
|
|
+ // updateUser和当前登录人相等,说明这条数据的拥有人是自己,反之不是自己
|
|
|
+ if (userDTO.getId().equals(cwWorkClientBase.getUpdateUser())) {
|
|
|
+ map.put("use","1"); // 数据拥有人是自己,则返回1,打开修改弹出框
|
|
|
+ } else {
|
|
|
+ map.put("use","0"); // 数据拥有人不是自己,则返回0,打开修改申请
|
|
|
+ }
|
|
|
+ if ("0".equals(cwWorkClientBase.getStatus()) || "5".equals(cwWorkClientBase.getStatus())) {
|
|
|
+ map.put("isUpdate","true"); // 查询到的数据目前可修改
|
|
|
+ } else {
|
|
|
+ map.put("isUpdate","false"); // 查询到的数据目前不可修改,数据正在修改中
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("id",cwWorkClientBase.getId());
|
|
|
+ return ResponseEntity.ok(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("use","false"); // 能走到这行代码,说明就没查到数据,uscCode不存在,可以使用
|
|
|
+ return ResponseEntity.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询客户名称是否存在
|
|
|
+ public ResponseEntity<Map<String,String>> queryNameIsUse(String name) {
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ // 根据客户名称查询
|
|
|
+ List<CwWorkClientBase> list = this.list(new QueryWrapper<CwWorkClientBase>().lambda().eq(CwWorkClientBase::getName, name).orderByDesc(CwWorkClientBase::getCreateDate).last("limit 1"));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ CwWorkClientBase cwWorkClientBase = list.get(0);
|
|
|
+ if (ObjectUtil.isNotEmpty(cwWorkClientBase)) {
|
|
|
+ // 客户数据拥有人不是空时,按正常流程走数据,正确数据的拥有人是不可能为空的
|
|
|
+ if (StringUtils.isNotBlank(cwWorkClientBase.getUpdateUser())){
|
|
|
+ // updateUser和当前登录人相等,说明这条数据的拥有人是自己,反之不是自己
|
|
|
+ if (userDTO.getId().equals(cwWorkClientBase.getUpdateUser())) {
|
|
|
+ map.put("use","1"); // 数据拥有人是自己,则返回1,打开修改弹出框
|
|
|
+ } else {
|
|
|
+ map.put("use","0"); // 数据拥有人不是自己,则返回0,打开修改申请
|
|
|
+ }
|
|
|
+ if ("0".equals(cwWorkClientBase.getStatus()) || "5".equals(cwWorkClientBase.getStatus())) {
|
|
|
+ map.put("isUpdate","true"); // 查询到的数据目前可修改
|
|
|
+ } else {
|
|
|
+ map.put("isUpdate","false"); // 查询到的数据目前不可修改,数据正在修改中
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("id",cwWorkClientBase.getId());
|
|
|
+ return ResponseEntity.ok(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("use","false"); // 能走到这行代码,说明就没查到数据,客户名称不存在,可以使用
|
|
|
+ return ResponseEntity.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据客户id查询
|
|
|
+ public ResponseEntity<String> queryUscCodeById(String id) {
|
|
|
+ CwWorkClientBase cwWorkClientBase = this.getById(id);
|
|
|
+ return ResponseEntity.ok(cwWorkClientBase.getUscCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据客户id查询
|
|
|
+ public ResponseEntity<String> queryNameById(String id) {
|
|
|
+ CwWorkClientBase cwWorkClientBase = this.getById(id);
|
|
|
+ return ResponseEntity.ok(cwWorkClientBase.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据客户id查询修改历史
|
|
|
+ public ResponseEntity<List<CwWorkClientTempDTO>> queryUpdateLogList(CwWorkClientTempDTO tempDto) {
|
|
|
+ QueryWrapper<CwWorkClientTemp> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.orderByDesc("temp.create_date");
|
|
|
+ if (ObjectUtil.isNotEmpty(tempDto)) {
|
|
|
+ if (StringUtils.isNotBlank(tempDto.getClientId())) {
|
|
|
+ queryWrapper.eq("temp.client_id", tempDto.getClientId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tempDto.getCreateName())) {
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().lambda().like(User::getName, tempDto.getCreateName()));
|
|
|
+ if (CollectionUtil.isNotEmpty(userList)) {
|
|
|
+ List<String> userIds = userList.stream().distinct().map(User::getId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(userIds)) {
|
|
|
+ queryWrapper.in("temp.create_by",userIds);
|
|
|
+ } else {
|
|
|
+ return ResponseEntity.ok(new ArrayList<CwWorkClientTempDTO>());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResponseEntity.ok(new ArrayList<CwWorkClientTempDTO>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tempDto.getStatus())) {
|
|
|
+ queryWrapper.eq("temp.status",tempDto.getStatus());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tempDto.getClientNo())) {
|
|
|
+ queryWrapper.like("cw_wcb.no",tempDto.getClientNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseEntity.ok(cwWorkClientBaseMapper.queryUpdateLogList(queryWrapper));
|
|
|
+ }
|
|
|
+
|
|
|
}
|