Commit aa550bd4 authored by fangxinjiang's avatar fangxinjiang

B端服务添加

parent c2bf35c2
......@@ -26,6 +26,7 @@ import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 客户信息
......@@ -250,5 +251,6 @@ public class TCustomerInfo extends BaseEntity {
@Schema(description = "账户余额")
private BigDecimal balance;
private List<String> customerIds;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.util.List;
/**
* @program: master
* @description: b端回显的客户信息包装类
* @author: pwang
* @create: 2020-08-26 19:47
**/
@Data
@Tag(name = "b端回显的客户信息包装类")
public class CustomerForBusinessVo {
//已有的客户信息
@Schema(name = "已有的客户信息")
private List<String> hadCustomer;
//已有的结算主体信息
@Schema(name = "已有的结算主体信息")
private List<String> hadSettle;
//客户分页信息
/* @Schema(name = "客户分页信息")
Page<TCustomerInfo> customerInfoPage;
//结算主体
@Schema(name = "客户信息")
private List<TCustomerInfo> customerList;*/
//结算主体
@Schema(name = "结算主体")
private List<TSettleDomain> settleDomainList;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class CustomerOwnerSelectVo implements Serializable {
/**
* 单位名称
*/
private String customerName;
/**
* 单位编码
*/
private String customerCode;
/**
* 单位ID
*/
private String customerId;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @program: master
* @description: 分页展示包装类
* @author: pwang
* @create: 2019-09-02 11:40
**/
@Tag(name = "结算主体表分页包装类")
@Data
public class TSettleDomainVo extends TSettleDomain implements Serializable {
/**
*客户名称
**/
@Schema(description = "客户编码", name = "customerCode")
//非本表字段
@TableField(exist = false)
private String customerCode;
/**
*客户名称
**/
@Schema(description = "客户名称", name = "customerName")
//非本表字段
@TableField(exist = false)
private String customerName;
/**
*客户id
**/
//非本表字段
@TableField(exist = false)
private String customerId;
/**
* 归属服务公司Id(乙方)
*/
@Schema(description = "归属服务公司Id(合同属性)", name = "businessSubject")
//非本表字段
@TableField(exist = false)
private String businessSubject;
/**
* 归属服务公司名称
*/
@Schema(description = "归属服务公司名称(合同属性)", name = "businessSubject")
//非本表字段
@TableField(exist = false)
private String businessSubjectName;
/**
*合同名称
**/
//非本表字段
@TableField(exist = false)
private String contractName;
//业务类型
@TableField(exist = false)
@Schema(description = "业务类型")
private String businessType;
//业务类型细分
@TableField(exist = false)
@Schema(description = "业务细分")
private String businessSub;
@TableField(exist = false)
@Schema(description = "创建月(需求变更查FIRST_PASS_TIME)")
private String createMonth;
/**************************************结算主体改造新增字段2021-03-17 开始*********************************************/
@Schema(description = "业务类型分类", name = "businessPrimaryType")
private String businessPrimaryType;
@Schema(description = "业务类型二级分类", name = "businessSecondType")
private String businessSecondType;
@Schema(description = "业务类型三级分类", name = "businessThirdType")
private String businessThirdType;
/**
* 0:人事;1:非人事
*/
@Schema(description = "0:人事;1:非人事", name = "type")
private Integer type;
/**************************************结算主体改造新增字段2021-03-17 结束********************************************/
/**************************************结算主体改造可先不关联合同2021-05-17 开始********************************************/
/**
* 创建类型:0 合同之后 1 合同之前
*/
@Schema(description = "创建类型:0:合同之后 1:合同之前", name = "createType")
private String createType;
/**
* 关联合同:0是1否
*/
@Schema(description = "关联合同:0是1否", name = "relateFlag")
private String relateFlag;
/**
* 异常说明
*/
@Schema(description = "异常说明", name = "exceptionRemark")
private String exceptionRemark;
/**************************************结算主体改造可先不关联合同2021-05-17 结算主体改造新增字段2021-03-17 结束****************/
/**
* B端 传参 客户ID
*/
@TableField(exist = false)
private List<String> customerIds;
/**
* B端 传参 结算主体ID
*/
@TableField(exist = false)
private List<String> settleDomainIds;
}
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteUserService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.MSetttleCustomerUser;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCustomerInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.service.MSetttleCustomerUserService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TSettleDomainService;
import com.yifu.cloud.plus.v1.yifu.archives.utils.ListWrapper;
import com.yifu.cloud.plus.v1.yifu.archives.vo.CustomerForBusinessVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.CustomerOwnerSelectVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.EmpBusinessConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ServiceNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* B端接口-客户信息相关
* @program: master
* @description: b端控制器
* @author: pwang
* @create: 2020-08-25 11:07
**/
@RestController
@AllArgsConstructor
@RequestMapping(value = "/customerBusiness/customerInfo")
@Tag(name = "B端接口-客户信息相关")
@Slf4j
public class CustomerBusinessContoller {
private final TSettleDomainService tSettleDomainService;
private final MSetttleCustomerUserService mSetttleCustomerUserService;
private final RemoteUserService remoteUserService;
private static final String CREATE_TIME_COLNUM = "CREATE_TIME"; //客户创建时间
private final RedisUtil redisUtil;
private final UpmsDaprUtils upmsDaprUtils;
/**
* 简单分页查询
* @param page 分页对象
* @param tCustomerInfo 客户信息
* @return
*/
@Operation(description = "B端客户单位分页查询")
@GetMapping("/customerPage")
public R<IPage<TCustomerInfo>> getCustomerInfoPage(Page<TCustomerInfo> page, TCustomerInfo tCustomerInfo, String customerIdStr) {
if (Common.isNotNull(customerIdStr)){
tCustomerInfo.setCustomerIds(Common.initStrToList(customerIdStr,CommonConstants.COMMA_STRING));
}
page.addOrder(OrderItem.desc(CREATE_TIME_COLNUM));
return null; // TODO new R<>(tCustomerInfoService.getTCustomerInfoPageForB(page,tCustomerInfo));
}
/**
* 简单分页查询
*
* @param page 分页对象
* @param tSettleDomain 结算主体表
* @return
*/
@Operation(description = "B端结算主体简单分页查询")
@GetMapping("/settleDomainPage")
public R<IPage<TSettleDomainVo>> settleDomainPage(Page<TSettleDomainVo> page, TSettleDomainVo tSettleDomain, String customerIdStr) {
YifuUser user = SecurityUtils.getUser();
if(null == user){
return R.failed(CommonConstants.USER_FAIL);
}
// 按客户ID查询结算主体
if (Common.isNotNull(customerIdStr)){
tSettleDomain.setCustomerIds(Common.initStrToList(customerIdStr,CommonConstants.COMMA_STRING));
}else {
// 按权限查询结算主体
List<String> settleDomainIds;
boolean flag = !SecurityUtils.isHaveAllOrg(ServiceNameConstants.CLIENT_ID_HR_B, user);
if (flag) {
settleDomainIds = null;// TODO user.getSettleIdList();
if (Common.isEmpty(settleDomainIds)) {
return R.failed(EmpBusinessConstants.noSettleDomainAuth);
}
tSettleDomain.setSettleDomainIds(settleDomainIds);
}
}
page.addOrder(OrderItem.desc("CREATE_TIME"));
return null;// TODO new R(tSettleDomainService.getTSettleDomainPageB(page, tSettleDomain));
}
/**
* 获取客户下的结算主体(未删除、不是审核不通过的)
* name = "customerId", value = "客户id"
*/
@Operation(description = "获取客户下的结算主体")
@GetMapping("/getSettleDomain/{customerId}")
public R<List<TSettleDomain>> getSettleDomain(@PathVariable String customerId) {
return new R<>(tSettleDomainService.list(getSettleDomainWrapper(CollUtil.toList(customerId))));
}
/**
* 保存客户结算主体关系
*/
@Operation(description = "保存客户结算主体关系")
@PostMapping("/batch/saveMSetttleCustomerUser")
public R<List<TSettleDomain>> saveMSetttleCustomerUser(@Valid @RequestBody ListWrapper<MSetttleCustomerUser> mSetttleCustomerUser) {
if(Common.isNotNull(mSetttleCustomerUser.getList())){
//先删后增
String userId = mSetttleCustomerUser.getList().get(0).getUserId();
mSetttleCustomerUserService.remove(Wrappers.<MSetttleCustomerUser>lambdaQuery().eq(MSetttleCustomerUser::getUserId, userId));
if(mSetttleCustomerUserService.saveBatch(mSetttleCustomerUser.getList())){
//清除用户缓存
R<SysUser> simpleUser = upmsDaprUtils.getSimpleUser(userId);
log.info("清除b端结算主体缓存开始");
if(null != simpleUser && null != simpleUser.getData()){
SysUser user = simpleUser.getData();
log.info("清除b端结算主体缓存: "+ ServiceNameConstants.UMPS_SERVICE + "_user_details::" + user.getUsername());
redisUtil.remove(ServiceNameConstants.UMPS_SERVICE + "_user_details::" + user.getUsername());
if( Common.isNotNull(user.getPhone())){
log.info("清除b端结算主体缓存: "+ ServiceNameConstants.UMPS_SERVICE + "_user_details_phone::" + user.getPhone());
redisUtil.remove(ServiceNameConstants.UMPS_SERVICE + "_user_details_phone::" + user.getPhone());
}
}
return R.ok();
}else {
return R.failed("保存失败,数据入库异常!");
}
}else{
return R.failed("保存失败,对象为空!");
}
}
/**
* 获取用户回显数据
* name = "userId", value = "用户id")
*/
@Operation(description = "获取用户回显数据")
@GetMapping("/CustomerForBusinessVo/{userId}")
public R<CustomerForBusinessVo> getCustomerForBusinessVo(@PathVariable String userId) {
CustomerForBusinessVo result = new CustomerForBusinessVo();
//查回显数据
List<MSetttleCustomerUser> list = mSetttleCustomerUserService.list(Wrappers.<MSetttleCustomerUser>lambdaQuery().eq(MSetttleCustomerUser::getUserId, userId));
if(Common.isNotNull(list)){
//已有权限的结算主体
List<String> setttleList = new ArrayList<>();
List<String> customerList = new ArrayList<>();
Map<String,String> customerMap = new HashMap<>();
Map<String,String> settleMap = new HashMap<>();
for(MSetttleCustomerUser cu :list){
settleMap.put(cu.getSettleId(),cu.getSettleId());
customerMap.put(cu.getCustomerId(),cu.getCustomerId());
}
if (Common.isNotNull(customerMap)){
customerList = customerMap.values().stream().collect(Collectors.toList());
}
if (Common.isNotNull(settleMap)){
setttleList = settleMap.values().stream().collect(Collectors.toList());
}
result.setHadSettle(setttleList);
result.setHadCustomer(customerList);
// 获取所有有权限的客户信息 TODO
//result.setCustomerList(tCustomerInfoService.list(Wrappers.<TCustomerInfo>query().lambda().in(TCustomerInfo::getId,customerList)));
//获取该客户下的主体
result.setSettleDomainList(tSettleDomainService.list(getSettleDomainWrapper(customerList)));
}
return new R<>(result);
}
/**
* 获取结算主体的查询条件(未删除、非审核不通过的)
* @Author pwang
* @Date 2020-09-21 14:13
* @param customerIds
* @return
**/
private LambdaQueryWrapper<TSettleDomain> getSettleDomainWrapper(List<String> customerIds) {
return Wrappers.<TSettleDomain>lambdaQuery().in(TSettleDomain::getCustomerId,customerIds).ne(TSettleDomain::getDpAuditFlag, CommonConstants.ONE_STRING);
}
/**
* b端获取用户的结算主体 无分页
* @param settleName, value = "结算主体名称"
* @param limit, value = "最大返回条数,【1-50】之间的正整数,不传默认为20"
* @return
*/
@Operation(description = "获取项目-无分页")
@GetMapping("/ownSettleDomainNoPage")
public R<List<TSettleDomain>> ownSettleDomainNoPage(String settleName,Integer limit) {
YifuUser user = SecurityUtils.getUser();
if(null == user){
return R.failed("非法用户!");
}
//管理员权限
if(SecurityUtils.isHaveAllOrg(ServiceNameConstants.CLIENT_ID_HR_B,user)){
//验证参数
if(null == limit){
limit = 20;
}
if( CommonConstants.dingleDigitIntArray[0] > limit || 50 <= limit){
return R.failed("参数传0到50的整数!");
}
//拼接条件
LambdaQueryWrapper<TSettleDomain> wrapper = Wrappers.<TSettleDomain>lambdaQuery();
if(Common.isNotNull(settleName)){
wrapper.like(TSettleDomain::getDepartName,settleName);
}
wrapper.last("limit " + limit);
return new R<>(tSettleDomainService.list(wrapper));
}else{
return new R<>(tSettleDomainService.getOwnSettleDomainNoPage(user.getId().toString(),settleName));
}
}
/**
* b端获取用户的结算主体
* @ApiImplicitParam(name = "settleName", value = "结算主体名称"),
* @ApiImplicitParam(name = "limit", value = "最大返回条数,【1-50】之间的正整数,不传默认为20"
*/
@Operation(description = "获取项目")
@GetMapping("/ownSettleDomain")
public R<IPage<TSettleDomainVo> > getOwnSettleDomain(Page<TSettleDomainVo> page, TSettleDomainVo vo) {
YifuUser user = SecurityUtils.getUser();
if(null == user){
return R.failed("非法用户!");
}
//管理员权限
/*if(SecurityUtils.isHaveAllOrg(ServiceNameConstants.CLIENT_ID_HR_B,user)){
return new R(tSettleDomainService.getPage(page, vo));
}else{
}*/
return new R(tSettleDomainService.getOwnSettleDomain(page,user.getId().toString(),vo.getDepartName()));
}
/**
* 获取权限内所有客户下拉项
* @author fxj
* @date 2021-11-03
* @param page
* @param customerName
* @return
*/
@Operation(description = "获取权限内所有客户下拉项")
@GetMapping("/getCustomerOwnerPage")
public R<IPage<CustomerOwnerSelectVo> > getCustomerOwnerPage(Page<CustomerOwnerSelectVo> page, String customerName) {
return null;// TODO tSettleDomainService.getCustomerOwnerPage(page,customerName);
}
}
......@@ -24,6 +24,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.vo.IdNameNoVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ProjectSetInfoVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -78,4 +79,8 @@ public interface TSettleDomainMapper extends BaseMapper<TSettleDomain> {
List<ProjectSetInfoVo> getSetInfoByCodes(@Param(value = "codes") List<String> codes);
List<TSettleDomain> getSettleInfoByCodes(@Param(value = "codes") List<String> codes);
List<TSettleDomain> getOwnSettleDomainNoPage(@Param("userId") String userId, @Param("name") String name);
IPage<TSettleDomainVo> getOwnSettleDomain(Page page, @Param("userId") String userId, @Param("name") String name);
}
......@@ -108,4 +108,7 @@ public interface TSettleDomainService extends IService<TSettleDomain> {
R updateProjectInfo(List<TSettleDomainEkpVo> list);
List<TSettleDomain> getOwnSettleDomainNoPage(String toString, String settleName);
R<IPage<TSettleDomainVo>> getOwnSettleDomain(Page<TSettleDomainVo> page, String userId, String name);
}
......@@ -46,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -394,4 +395,18 @@ public class TSettleDomainServiceImpl extends ServiceImpl<TSettleDomainMapper, T
}
return true;
}
@Override
public List<TSettleDomain> getOwnSettleDomainNoPage(String userId, String settleName) {
if(Common.isNotNull(userId)){
return baseMapper.getOwnSettleDomainNoPage(userId,settleName);
}
return Collections.emptyList();
}
@Override
public R<IPage<TSettleDomainVo>> getOwnSettleDomain(Page<TSettleDomainVo> page, String userId, String name) {
if(Common.isNotNull(userId)){
return R.ok(baseMapper.getOwnSettleDomain(page,userId,name),CommonConstants.RESULT_DATA_SUCESS);
}
return (R<IPage<TSettleDomainVo>>) Collections.emptyList();
}
}
package com.yifu.cloud.plus.v1.yifu.archives.utils;
import lombok.Getter;
import lombok.Setter;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @program: master
* @description: 验证list对象
* @author: pwang
* @create: 2020-07-29 20:17
**/
@Getter
@Setter
public class ListWrapper<E> implements Serializable {
private static final long serialVersionUID = 1L;
@Valid
private List<E> list;
public ListWrapper() {
list = new ArrayList<>();
}
public ListWrapper(List<E> list) {
this.list = list;
}
}
......@@ -311,4 +311,30 @@
</foreach>
</if>
</select>
<select id="getOwnSettleDomainNoPage" resultMap="tSettleDomainMap">
SELECT
<include refid="Base_Column_List"/>
FROM
t_settle_domain a
where
1=1
<if test="name != null and name.trim() != ''">
and a.DEPART_NAME like concat("%",#{name},"%")
</if>
and a.id in (select b.settle_id from m_setttle_customer_user b where b.user_id = #{userId}) and a.DELETE_FLAG = '0'
</select>
<select id="getOwnSettleDomain" resultMap="tSettleDomainMap">
SELECT
<include refid="Base_Column_List"/>
FROM
t_settle_domain a
where
1=1
<if test="name != null and name.trim() != ''">
and a.DEPART_NAME like concat("%",#{name},"%")
</if>
and a.id in (select b.settle_id from m_setttle_customer_user b where b.user_id = #{userId}) and a.DELETE_FLAG = '0'
</select>
</mapper>
......@@ -79,6 +79,12 @@
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-business-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
package com.yifu.cloud.plus.v1.yifu.common.core.constant;
/**
* B端员工及合同相关静态数据
* @Author fxj
* @Date 2020-08-25
**/
public class EmpBusinessConstants {
private EmpBusinessConstants(){
throw new IllegalStateException("EmpBusinessConstants class");
}
public static final String empContractSituationNew = "新签";
public static final String empContractSituationRenew = "续签";
public static final int ninety = 90;
public static final String noSettleDomainAuth = "无结算主体权限,请联系管理员分配!";
public static final String selectSettleDomainOrCallManager = "请选择项目或联系管理员分配权限!";
}
package com.yifu.cloud.plus.v1.yifu.common.dapr.util;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaMap;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo;
......@@ -81,4 +82,12 @@ public class UpmsDaprUtils {
}
return allUserVoR;
}
public R<SysUser> getSimpleUser(String userId) {
R<SysUser> userR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId(),"/user/inner/getSimpleUser",userId, SysUser.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(userR)){
return R.failed("获取所有用户数据失败!");
}
return userR;
}
}
......@@ -17,6 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.common.security.util;
import cn.hutool.core.util.StrUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import lombok.experimental.UtilityClass;
......@@ -90,4 +91,12 @@ public class SecurityUtils {
YifuUser user = getUser();
return null != user && null != user.getClientRoleMap() ? user.getClientRoleMap().get(client) : null;
}
public static boolean isHaveAllOrg(String clientIdHrB, YifuUser user) {
if ( (CommonConstants.ONE_STRING.equals(user.getId()))){
return true;
}else{
return false;
}
}
}
......@@ -372,6 +372,12 @@ public class UserController {
return userIds.toString();
}
@Inner
@PostMapping(value = {"/inner/getSimpleUser"})
public SysUser getSimpleUser(@RequestBody String userId) {
return userService.getById(userId);
}
/**
* @param nickName 用户名称
* @return 上级部门用户列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment