35 changed files with 948 additions and 102 deletions
@ -0,0 +1,21 @@ |
|||
package com.qs.serve.modules.bms.entity.vo; |
|||
|
|||
import com.qs.serve.modules.bms.entity.BmsMasterUser; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2022/11/15 |
|||
*/ |
|||
@Data |
|||
public class BmsMasterUserCenterVo extends BmsMasterUser { |
|||
|
|||
private String userCode; |
|||
|
|||
private String userName; |
|||
|
|||
private String centerCode; |
|||
|
|||
private String centerName; |
|||
|
|||
} |
@ -0,0 +1,61 @@ |
|||
package com.qs.serve.modules.his.entity; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import javax.validation.constraints.NotNull; |
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* 供应商负责人 实体类 |
|||
* @author YenHex |
|||
* @since 2022-11-15 |
|||
*/ |
|||
@Data |
|||
@TableName("his_user_supplier") |
|||
public class HisUserSupplier implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** id */ |
|||
@TableId(type = IdType.AUTO) |
|||
private Long id; |
|||
|
|||
/** 用户id */ |
|||
@NotBlank(message = "用户id不能为空") |
|||
@Length(max = 32,message = "用户id长度不能超过32字") |
|||
private String userId; |
|||
|
|||
/** 供应商id */ |
|||
@NotNull(message = "供应商id不能为空") |
|||
private Long supplierId; |
|||
|
|||
/** 类型:0=销售区域;1=行政区域 */ |
|||
private Integer type; |
|||
|
|||
/** 区域id */ |
|||
@Length(max = 32,message = "区域id长度不能超过32字") |
|||
private String regionId; |
|||
|
|||
/** 主要负责人 */ |
|||
@NotNull(message = "主要负责人不能为空") |
|||
private Integer masterFlag; |
|||
|
|||
/** 创建时间 */ |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private LocalDateTime createTime; |
|||
|
|||
} |
|||
|
@ -0,0 +1,14 @@ |
|||
package com.qs.serve.modules.his.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.qs.serve.modules.his.entity.HisUserSupplier; |
|||
|
|||
/** |
|||
* 供应商负责人 Mapper |
|||
* @author YenHex |
|||
* @date 2022-11-15 |
|||
*/ |
|||
public interface HisUserSupplierMapper extends BaseMapper<HisUserSupplier> { |
|||
|
|||
} |
|||
|
@ -0,0 +1,29 @@ |
|||
package com.qs.serve.modules.his.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.qs.serve.modules.his.entity.HisUserSupplier; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 供应商负责人 服务接口 |
|||
* @author YenHex |
|||
* @date 2022-11-15 |
|||
*/ |
|||
public interface HisUserSupplierService extends IService<HisUserSupplier> { |
|||
|
|||
/** |
|||
* 初始化 |
|||
* @param userId |
|||
* @return |
|||
*/ |
|||
boolean initByUserId(String userId); |
|||
|
|||
/** |
|||
* 删除 |
|||
* @return |
|||
*/ |
|||
void cleanTable(); |
|||
|
|||
} |
|||
|
@ -0,0 +1,130 @@ |
|||
package com.qs.serve.modules.his.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.qs.serve.common.util.CollectionUtil; |
|||
import com.qs.serve.modules.bms.entity.BmsRegion; |
|||
import com.qs.serve.modules.bms.entity.BmsRegion2; |
|||
import com.qs.serve.modules.bms.entity.BmsRegionUser; |
|||
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|||
import com.qs.serve.modules.bms.service.BmsRegion2Service; |
|||
import com.qs.serve.modules.bms.service.BmsRegionService; |
|||
import com.qs.serve.modules.bms.service.BmsRegionUserService; |
|||
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
import com.qs.serve.modules.his.entity.HisUserSupplier; |
|||
import com.qs.serve.modules.his.service.HisUserSupplierService; |
|||
import com.qs.serve.modules.his.mapper.HisUserSupplierMapper; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 供应商负责人 服务实现类 |
|||
* @author YenHex |
|||
* @since 2022-11-15 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@AllArgsConstructor |
|||
public class HisUserSupplierServiceImpl extends ServiceImpl<HisUserSupplierMapper,HisUserSupplier> implements HisUserSupplierService { |
|||
|
|||
private BmsSupplierService bmsSupplierService; |
|||
private BmsRegionService saleRegionService; |
|||
private BmsRegion2Service bizRegionService; |
|||
private BmsRegionUserService regionUserService; |
|||
|
|||
@Override |
|||
public boolean initByUserId(String userId) { |
|||
LambdaQueryWrapper<HisUserSupplier> lqwExist = new LambdaQueryWrapper<>(); |
|||
lqwExist.eq(HisUserSupplier::getUserId,userId); |
|||
long count = this.count(lqwExist); |
|||
if(count>0L){ |
|||
return true; |
|||
} |
|||
BmsSupplier param = new BmsSupplier(); |
|||
param.setCurrUserId(userId); |
|||
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param); |
|||
List<HisUserSupplier> userSuppliers = new ArrayList<>(); |
|||
for (BmsSupplier supplier : list) { |
|||
HisUserSupplier userSupplier = new HisUserSupplier(); |
|||
userSupplier.setUserId(userId); |
|||
userSupplier.setSupplierId(Long.parseLong(supplier.getId())); |
|||
userSupplier.setType(3); |
|||
userSupplier.setMasterFlag(supplier.getMasterFlag()); |
|||
userSuppliers.add(userSupplier); |
|||
} |
|||
LambdaQueryWrapper<BmsRegionUser> regionUserLqw = new LambdaQueryWrapper<>(); |
|||
regionUserLqw.eq(BmsRegionUser::getUserId,userId); |
|||
List<BmsRegionUser> regionUsers = regionUserService.list(regionUserLqw); |
|||
List<String> regionSaleIds = regionUsers.stream() |
|||
.filter(a->a.getType().equals(0)) |
|||
.map(BmsRegionUser::getRegionId) |
|||
.collect(Collectors.toList()); |
|||
if(regionSaleIds.size()>0){ |
|||
List<BmsRegion> saleRegions = saleRegionService.listByIds(regionSaleIds); |
|||
Map<Integer,List<BmsRegion>> saleRegionsMap = saleRegions.stream().collect(Collectors.groupingBy(BmsRegion::getLevel)); |
|||
List<String> regionIds01 = saleRegionsMap.get(1).stream().map(BmsRegion::getId).collect(Collectors.toList()); |
|||
List<String> regionIds02 = saleRegionsMap.get(2).stream().map(BmsRegion::getId).collect(Collectors.toList()); |
|||
List<String> regionIds03 = saleRegionsMap.get(3).stream().map(BmsRegion::getId).collect(Collectors.toList()); |
|||
toHisUserSupplier(userSuppliers,regionIds01,1,userId); |
|||
toHisUserSupplier(userSuppliers,regionIds02,2,userId); |
|||
toHisUserSupplier(userSuppliers,regionIds03,3,userId); |
|||
} |
|||
List<String> regionBizIds = regionUsers.stream() |
|||
.filter(a->a.getType().equals(1)) |
|||
.map(BmsRegionUser::getRegionId) |
|||
.collect(Collectors.toList()); |
|||
if(regionBizIds.size()>0){ |
|||
List<BmsRegion2> bizRegions = bizRegionService.listByIds(regionBizIds); |
|||
Map<Integer,List<BmsRegion2>> saleRegionsMap = bizRegions.stream().collect(Collectors.groupingBy(BmsRegion2::getLevel)); |
|||
List<String> regionIds01 = saleRegionsMap.get(1).stream().map(BmsRegion2::getId).collect(Collectors.toList()); |
|||
List<String> regionIds02 = saleRegionsMap.get(2).stream().map(BmsRegion2::getId).collect(Collectors.toList()); |
|||
List<String> regionIds03 = saleRegionsMap.get(3).stream().map(BmsRegion2::getId).collect(Collectors.toList()); |
|||
toHisUserSupplier(userSuppliers,regionIds01,1,userId); |
|||
toHisUserSupplier(userSuppliers,regionIds02,2,userId); |
|||
toHisUserSupplier(userSuppliers,regionIds03,3,userId); |
|||
} |
|||
if(userSuppliers.size()>0){ |
|||
this.saveBatch(userSuppliers); |
|||
}else { |
|||
HisUserSupplier userSupplier = new HisUserSupplier(); |
|||
userSupplier.setUserId(userId); |
|||
userSupplier.setSupplierId(0L); |
|||
userSupplier.setType(9); |
|||
this.save(userSupplier); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
private void toHisUserSupplier(List<HisUserSupplier> userSuppliers,List<String> regionIds,Integer level,String userId){ |
|||
if(regionIds.size()>0){ |
|||
LambdaQueryWrapper<BmsSupplier> lqw = new LambdaQueryWrapper<>(); |
|||
if(level.equals(1)){ |
|||
lqw.in(BmsSupplier::getRegionFirst,regionIds); |
|||
}else if(level.equals(2)){ |
|||
lqw.in(BmsSupplier::getRegionSecond,regionIds); |
|||
}else if(level.equals(3)){ |
|||
lqw.in(BmsSupplier::getRegionThird,regionIds); |
|||
} |
|||
List<BmsSupplier> supplierList = bmsSupplierService.list(lqw); |
|||
for (BmsSupplier supplier : supplierList) { |
|||
HisUserSupplier userSupplier = new HisUserSupplier(); |
|||
userSupplier.setUserId(userId); |
|||
userSupplier.setSupplierId(Long.parseLong(supplier.getId())); |
|||
userSupplier.setType(0); |
|||
userSupplier.setMasterFlag(supplier.getMasterFlag()); |
|||
userSuppliers.add(userSupplier); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void cleanTable() { |
|||
this.remove(new QueryWrapper<>()); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,72 @@ |
|||
package com.qs.serve.modules.tbs.entity.vo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import com.qs.serve.modules.tbs.entity.TbsBudgetCondition; |
|||
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 预算 实体类 |
|||
* @author YenHex |
|||
* @since 2022-11-12 |
|||
*/ |
|||
@Data |
|||
public class TbsBudgetVo implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** id */ |
|||
private Long id; |
|||
|
|||
/** 科目id */ |
|||
private Long subjectId; |
|||
|
|||
/** 科目编码 */ |
|||
private String subjectCode; |
|||
|
|||
/** 科目名称 */ |
|||
private String subjectName; |
|||
|
|||
/** 成本中心id */ |
|||
private Long centerId; |
|||
|
|||
private String centerType; |
|||
|
|||
/** 成本中心编码 */ |
|||
private String centerCode; |
|||
|
|||
/** 成本中心名称 */ |
|||
private String centerName; |
|||
|
|||
/** 考核期id */ |
|||
private Long scheduleId; |
|||
|
|||
/** 考核期编码 */ |
|||
private String scheduleCode; |
|||
|
|||
/** 考核期名称 */ |
|||
private String scheduleName; |
|||
|
|||
/** 备注 */ |
|||
private String remark; |
|||
|
|||
private List<?> brandConditions; |
|||
private List<?> categoryConditions; |
|||
private List<?> seriesConditions; |
|||
private List<?> skuConditions; |
|||
private List<?> spuConditions; |
|||
private List<?> scheduleItem; |
|||
|
|||
} |
|||
|
@ -1,14 +0,0 @@ |
|||
package com.qs.serve.modules.tbs.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.qs.serve.modules.tbs.entity.TbsBudgetCondition; |
|||
|
|||
/** |
|||
* 预算条件 Mapper |
|||
* @author YenHex |
|||
* @date 2022-11-08 |
|||
*/ |
|||
public interface TbsBudgetConditionMapper extends BaseMapper<TbsBudgetCondition> { |
|||
|
|||
} |
|||
|
@ -0,0 +1,147 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.qs.serve.modules.tbs.mapper.TbsBudgetMapper"> |
|||
|
|||
<resultMap id="tbsBudgetMap" type="com.qs.serve.modules.tbs.entity.TbsBudget" > |
|||
<result property="id" column="id"/> |
|||
<result property="subjectId" column="subject_id"/> |
|||
<result property="subjectCode" column="subject_code"/> |
|||
<result property="subjectName" column="subject_name"/> |
|||
<result property="centerType" column="center_type"/> |
|||
<result property="centerId" column="center_id"/> |
|||
<result property="centerCode" column="center_code"/> |
|||
<result property="centerName" column="center_name"/> |
|||
<result property="scheduleId" column="schedule_id"/> |
|||
<result property="scheduleCode" column="schedule_code"/> |
|||
<result property="scheduleName" column="schedule_name"/> |
|||
<result property="remark" column="remark"/> |
|||
<result property="createTime" column="create_time"/> |
|||
<result property="updateTime" column="update_time"/> |
|||
<result property="tenantId" column="tenant_id"/> |
|||
<result property="createBy" column="create_by"/> |
|||
<result property="updateBy" column="update_by"/> |
|||
<result property="delFlag" column="del_flag"/> |
|||
</resultMap> |
|||
|
|||
<sql id="tbsBudgetSql"> |
|||
tbs_budget.`id`, |
|||
tbs_budget.`subject_id`, |
|||
tbs_budget.`subject_code`, |
|||
tbs_budget.`subject_name`, |
|||
tbs_budget.`center_type`, |
|||
tbs_budget.`center_id`, |
|||
tbs_budget.`center_code`, |
|||
tbs_budget.`center_name`, |
|||
tbs_budget.`schedule_id`, |
|||
tbs_budget.`schedule_code`, |
|||
tbs_budget.`schedule_name`, |
|||
tbs_budget.`remark`, |
|||
tbs_budget.`create_time`, |
|||
tbs_budget.`update_time`, |
|||
tbs_budget.`tenant_id`, |
|||
tbs_budget.`create_by`, |
|||
tbs_budget.`update_by`, |
|||
tbs_budget.`del_flag` </sql> |
|||
|
|||
<select id="selectTbsBudgetList" parameterType="com.qs.serve.modules.tbs.entity.TbsBudget" resultMap="tbsBudgetMap"> |
|||
SELECT <include refid="tbsBudgetSql"/> FROM `tbs_budget` `tbs_budget` |
|||
<where> |
|||
<if test="query.id != null"> and `tbs_budget`.`id` = #{query.id}</if> |
|||
<if test="query.subjectId != null"> and `tbs_budget`.`subject_id` = #{query.subjectId}</if> |
|||
<if test="query.subjectCode != null and query.subjectCode != ''"> and `tbs_budget`.`subject_code` = #{query.subjectCode}</if> |
|||
<if test="query.subjectName != null and query.subjectName != ''"> and `tbs_budget`.`subject_name` = #{query.subjectName}</if> |
|||
<if test="query.centerId != null"> and `tbs_budget`.`center_id` = #{query.centerId}</if> |
|||
<if test="query.centerCode != null and query.centerCode != ''"> and `tbs_budget`.`center_code` = #{query.centerCode}</if> |
|||
<if test="query.centerName != null and query.centerName != ''"> and `tbs_budget`.`center_name` = #{query.centerName}</if> |
|||
<if test="query.scheduleId != null"> and `tbs_budget`.`schedule_id` = #{query.scheduleId}</if> |
|||
<if test="query.scheduleCode != null and query.scheduleCode != ''"> and `tbs_budget`.`schedule_code` = #{query.scheduleCode}</if> |
|||
<if test="query.scheduleName != null and query.scheduleName != ''"> and `tbs_budget`.`schedule_name` = #{query.scheduleName}</if> |
|||
<if test="query.remark != null and query.remark != ''"> and `tbs_budget`.`remark` = #{query.remark}</if> |
|||
<if test="query.createTime != null"> and `tbs_budget`.`create_time` = #{query.createTime}</if> |
|||
<if test="query.updateTime != null"> and `tbs_budget`.`update_time` = #{query.updateTime}</if> |
|||
<if test="query.tenantId != null and query.tenantId != ''"> and `tbs_budget`.`tenant_id` = #{query.tenantId}</if> |
|||
<if test="query.createBy != null and query.createBy != ''"> and `tbs_budget`.`create_by` = #{query.createBy}</if> |
|||
<if test="query.updateBy != null and query.updateBy != ''"> and `tbs_budget`.`update_by` = #{query.updateBy}</if> |
|||
<if test="query.delFlag != null and query.delFlag != ''"> and `tbs_budget`.`del_flag` = #{query.delFlag}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectBudgetId" resultType="java.lang.Long"> |
|||
SELECT `tbs_budget`.`id` |
|||
FROM `tbs_budget` `tbs_budget` |
|||
LEFT JOIN `tbs_budget_condition` `tbs_budget_condition` ON `tbs_budget`.`id` = `tbs_budget_condition`.`budget_id` |
|||
<where> |
|||
<if test="query.subjectValue != null and query.subjectValue != ''"> |
|||
and ( |
|||
`tbs_budget`.`subject_code` like concat('%',#{query.subjectValue},'%') |
|||
or |
|||
`tbs_budget`.`subject_name` like concat('%',#{query.subjectValue},'%') |
|||
) |
|||
</if> |
|||
<if test="query.centerValue != null and query.centerValue != ''"> |
|||
and ( |
|||
`tbs_budget`.`center_code` like concat('%',#{query.centerValue},'%') |
|||
or |
|||
`tbs_budget`.`center_name` like concat('%',#{query.centerValue},'%') |
|||
) |
|||
</if> |
|||
<if test="query.scheduleId != null"> and `tbs_budget`.`schedule_id` = #{query.scheduleId}</if> |
|||
<if test="query.scheduleCode != null and query.scheduleCode != ''"> and `tbs_budget`.`schedule_code` = #{query.scheduleCode}</if> |
|||
<if test="query.scheduleName != null and query.scheduleName != ''"> and `tbs_budget`.`schedule_name` = #{query.scheduleName}</if> |
|||
<if test="query.brandValue != null and query.brandValue != ''"> |
|||
and ( |
|||
`tbs_budget_condition`.`target_type` = 'brand' |
|||
and ( |
|||
`tbs_budget_condition`.`target_name` like concat('%',#{query.brandValue},'%') |
|||
or |
|||
`tbs_budget_condition`.`target_code` like concat('%',#{query.brandValue},'%') |
|||
) |
|||
) |
|||
</if> |
|||
<if test="query.categoryValue != null and query.categoryValue != ''"> |
|||
and ( |
|||
`tbs_budget_condition`.`target_type` = 'category' |
|||
and ( |
|||
`tbs_budget_condition`.`target_name` like concat('%',#{query.categoryValue},'%') |
|||
or |
|||
`tbs_budget_condition`.`target_code` like concat('%',#{query.categoryValue},'%') |
|||
) |
|||
) |
|||
</if> |
|||
<if test="query.seriesValue != null and query.seriesValue != ''"> |
|||
and ( |
|||
`tbs_budget_condition`.`target_type` = 'series' |
|||
and ( |
|||
`tbs_budget_condition`.`target_name` like concat('%',#{query.seriesValue},'%') |
|||
or |
|||
`tbs_budget_condition`.`target_code` like concat('%',#{query.seriesValue},'%') |
|||
) |
|||
) |
|||
</if> |
|||
<if test="query.skuValue != null and query.skuValue != ''"> |
|||
and ( |
|||
`tbs_budget_condition`.`target_type` = 'sku' |
|||
and ( |
|||
`tbs_budget_condition`.`target_name` like concat('%',#{query.skuValue},'%') |
|||
or |
|||
`tbs_budget_condition`.`target_code` like concat('%',#{query.skuValue},'%') |
|||
) |
|||
) |
|||
</if> |
|||
<if test="query.spuValue != null and query.spuValue != ''"> |
|||
and ( |
|||
`tbs_budget_condition`.`target_type` = 'spu' |
|||
and ( |
|||
`tbs_budget_condition`.`target_name` like concat('%',#{query.spuValue},'%') |
|||
or |
|||
`tbs_budget_condition`.`target_code` like concat('%',#{query.spuValue},'%') |
|||
) |
|||
) |
|||
</if> |
|||
</where> |
|||
GROUP BY `tbs_budget`.`id` |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue