提交 b4eb4edb authored 作者: 000516's avatar 000516

城市经理-店内执行汇总看板

package com.sfa.operation.controller.sales.query;
import com.sfa.common.core.constant.RoleConstants;
import com.sfa.common.core.enums.ECode;
import com.sfa.common.core.exception.CheckedException;
import com.sfa.common.security.utils.SecurityUtils;
import com.sfa.operation.config.ConstantValue;
import com.sfa.operation.pojo.sales.request.SalesApRequest;
import com.sfa.operation.service.qc.IQinceMarketEmployeeService;
import com.sfa.operation.service.sales.IApDisplayQueryService;
import com.sfa.operation.service.sales.IApPromotionQueryService;
import com.sfa.system.api.domain.SysRole;
import com.sfa.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* @author : liqiulin
* @date : 2025-12-01 15
* @describe :
*/
@RestController
@RequestMapping("/sales/ap_report/query")
public class APReportQueryController {
@Autowired
private IApDisplayQueryService apDisplayQueryService;
@Autowired
private IQinceMarketEmployeeService qinceMarketEmployeeService;
@Autowired
private ConstantValue constantValue;
/**
* 店内执行-城市经理
* @param request
* @return
*/
@GetMapping("/store_cm")
public Object queryStoreAPReport(SalesApRequest request) {
checkPermission(request);
return apDisplayQueryService.queryStoreAPReport(request);
}
private void checkPermission(SalesApRequest salesApRequest) {
LoginUser loginUser = SecurityUtils.getLoginUser();
String ancestors = loginUser.getSysUser().getDept().getAncestors();
List<SysRole> roles = loginUser.getSysUser().getRoles();
// 不是区域销售部的人员,可以查看所有
if (!ancestors.contains(constantValue.deptYX) && roles.stream().filter(role -> RoleConstants.OPERATION_CENTER_AP_MANAGER.equals(role.getRoleKey())).findFirst().isPresent()) {
return;
}
// 是区域销售部的人员:1、销售查看人客关系;2、大区TM查看当前部门下所有数据
// 判断是否是大区TM
String empNo = loginUser.getUsername();
Optional<SysRole> first = roles.stream().filter(role -> RoleConstants.DISTRICT_AP_MANAGER.equals(role.getRoleKey())).findFirst();
if (first.isPresent()) {
String deptName = loginUser.getSysUser().getDept().getDeptName();
salesApRequest.setDeptNames("000889".equals(empNo) ? Arrays.asList(deptName,"北京特区") : Arrays.asList(deptName));
return;
}
// 不是大区TM,判断是否是销售人员(人客关系)
List<String> dealerCodes = qinceMarketEmployeeService.checkPermission(empNo);
if (dealerCodes.isEmpty()) {
throw new CheckedException(ECode.QC_MARKET_EMP_ERROR);
}
// salesApRequest.setNickName(loginUser.getNickName());
salesApRequest.setDealerCodes(dealerCodes);
}
}
......@@ -24,6 +24,7 @@ public class ZzProQualityCoreController {
*/
@PostMapping("/add")
public void add(@RequestBody ZzProductQualityVo vo) {
vo.setPrdCode(vo.getPrdCode().trim());
LoginUser loginUser = SecurityUtils.getLoginUser();
SysDept dept = loginUser.getSysUser().getDept();
vo.setManufacturersName(dept.getDeptName());
......@@ -37,6 +38,7 @@ public class ZzProQualityCoreController {
*/
@PutMapping("/put")
public void update(@RequestBody ZzProductQualityVo vo) {
vo.setPrdCode(vo.getPrdCode().trim());
LoginUser loginUser = SecurityUtils.getLoginUser();
SysDept dept = loginUser.getSysUser().getDept();
vo.setUpdateBy(loginUser.getNickName());
......
......@@ -13,4 +13,6 @@ public interface ISalesApDisplayDao {
PageInfo page(SalesApWq salesApWq);
void updateDetail(SalesApDisplayDto salesApDisplayDto);
Object queryStoreAPReport(SalesApWq build);
}
......@@ -45,6 +45,11 @@ public class SalesApDisplayDaoImpl implements ISalesApDisplayDao {
salesapdisMapper.updateById(updateDo);
}
@Override
public Object queryStoreAPReport(SalesApWq build) {
return salesapdisMapper.queryStoreAPReport(build);
}
private LambdaQueryWrapper<SalesApDisplay> buildWq(SalesApWq salesApWq) {
LambdaQueryWrapper<SalesApDisplay> qw = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(salesApWq.getDealerCode())) {
......
......@@ -2,8 +2,12 @@ package com.sfa.operation.domain.sales.mapper;
import com.sfa.operation.domain.sales.entity.SalesApDisplay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sfa.operation.domain.sales.wq.SalesApWq;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @author a02200059
* @description 针对表【sales_ap_display(营销中心-活动计划-陈列(计划+执行))】的数据库操作Mapper
......@@ -13,6 +17,7 @@ import org.springframework.stereotype.Repository;
@Repository
public interface SalesApDisplayMapper extends BaseMapper<SalesApDisplay> {
List<Map<String,Object>> queryStoreAPReport(SalesApWq build);
}
......
......@@ -19,8 +19,10 @@ public class SalesApWq {
* 大区/战区
*/
private String deptName;
private List<String> deptNames;
private String nickName;
private List<String> dealerCodes;
private String dealerCodeStrs;
/**
* 经销商编码(精准)/名称(模糊)
*/
......@@ -33,4 +35,12 @@ public class SalesApWq {
* 系统名称
*/
private String lineNameLike;
/**
* 登录人工号
*/
private String empNo;
/**
* 部门编码
*/
private String deptCode;
}
......@@ -29,19 +29,31 @@ public class SalesApRequest {
private String dealerCN;
private String cityManager;
/**
* 大区/战区
* 大区/战区(用来查询大区/战区两列)
*/
private String deptName;
private List<String> deptNames;
/**
* 门店编码/名称(模糊)
*/
private String storeCN;
/**
* 登录人姓名
*/
private String nickName;
private List<String> dealerCodes;
/**
* 系统名称
*/
private String lineNameLike;
/**
* 登录人工号
*/
private String empNo;
/**
* 部门编码
*/
private String deptCode;
// ######################## 通用查询 ########################
......
......@@ -20,4 +20,6 @@ public interface IApDisplayQueryService {
PageInfo slPage(SalesApRequest salesApRequest);
PageInfo jgPage(SalesApRequest salesApRequest);
Object queryStoreAPReport(SalesApRequest request);
}
......@@ -59,6 +59,11 @@ public class ApDisplayQueryServiceImpl implements IApDisplayQueryService {
return salesApDisplayJDao.page(build(salesApRequest));
}
@Override
public Object queryStoreAPReport(SalesApRequest salesApRequest) {
return salesApDisplayDao.queryStoreAPReport(build(salesApRequest));
}
private SalesApWq build(SalesApRequest salesApRequest){
SalesApWq salesApWq = new SalesApWq();
BeanUtils.copyProperties(salesApRequest,salesApWq);
......
......@@ -79,6 +79,231 @@
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id = "commonQueryConditions">
<if test="salesMonth != null">
and sales_month = #{salesMonth}
</if>
<if test="dealerCodes != null">
and dealer_code in
<foreach collection="dealerCodes" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deptNames != null">
and (region_name in
<foreach collection="deptNames" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
or
district_name in
<foreach collection="deptNames" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
)
</if>
</sql>
<select id="queryStoreAPReport" parameterType="com.sfa.operation.domain.sales.wq.SalesApWq" resultType="java.util.Map">
SELECT ar.region_name as regionName,
ar.district_name as districtName,
ar.city_manager as cityManager,
d.主货架计划网点数 as planMsStoreCnt,
d.主货架执行网点数 as execMsStoreCnt,
if(d.主货架计划网点数 is null, null,concat( round( coalesce(d.主货架执行网点数,0) / d.主货架计划网点数 *
100,2) ,'%')) as msExecRate,
d.常规端架计划网点数 as planRegEndcapStoreCnt,
d.常规端架执行网点数 as execRegEndcapStoreCnt,
if(d.常规端架计划网点数 is null, null,concat( round( coalesce(d.常规端架执行网点数,0) / d.常规端架计划网点数
* 100,2) ,'%')) as endcapExecRate,
d.常规地堆计划网点数 as planRegGsStoreCnt,
d.常规地堆执行网点数 as execRegGsStoreCnt,
if(d.常规地堆计划网点数 is null, null,concat( round( coalesce(d.常规地堆执行网点数,0) / d.常规地堆计划网点数
* 100,2) ,'%')) as gsExecRate,
d.多点陈列计划网点数 as planMpDispStoreCnt,
d.多点陈列执行网点数 as execMpDispStoreCnt,
if(d.多点陈列计划网点数 is null, null,concat( round( coalesce(d.多点陈列执行网点数,0) / d.多点陈列计划网点数
* 100,2) ,'%')) as mpDispExecRate,
d.挂条计划网点数 as planHsStoreCnt,
d.挂条执行网点数 as execHsStoreCnt,
if(d.挂条计划网点数 is null, null,concat( round( coalesce(d.挂条执行网点数,0) / d.挂条计划网点数 * 100,2)
,'%')) as HsExecRate,
s.三米两秒挂条计划网点数 as planSLStoreCnt,
s.三米两秒挂条执行网点数 as execSLStoreCnt,
if(s.三米两秒挂条计划网点数 is null, null,concat( round( coalesce(s.三米两秒挂条执行网点数,0) /
s.三米两秒挂条计划网点数 * 100,2) ,'%')) as SLExecRate,
j.批发挂网计划网点数 as planSixJdStoreCnt,
j.批发挂网执行网点数 as execSixJdStoreCnt,
if(j.批发挂网计划网点数 is null, null,concat( round( coalesce(j.批发挂网执行网点数,0) / j.批发挂网计划网点数
* 100,2) ,'%')) as sixJdExecRate,
pd.端架计划网点数 as planEndcapStoreCnt,
pd.端架执行网点数 as execEndcapStoreCnt,
if(pd.端架计划网点数 is null, null,concat( round( coalesce(pd.端架执行网点数,0) / pd.端架计划网点数 * 100,2)
,'%')) as endcapExecRatePromoPeriDisp,
pd.地堆计划网点数 as planGsStoreCnt,
pd.地堆执行网点数 as execGsStoreCnt,
if(pd.地堆计划网点数 is null, null,concat( round( coalesce(pd.地堆执行网点数,0) / pd.地堆计划网点数 * 100,2)
,'%')) as gsExecRatePromoPeriDisp,
pd.其他陈列计划网点数 as planOtherDispStoreCnt,
pd.其他陈列执行网点数 as execOtherDispStoreCnt,
if(pd.其他陈列计划网点数 is null, null,concat( round( coalesce(pd.其他陈列执行网点数,0) / pd.其他陈列计划网点数
* 100,2) ,'%')) as otherDispExecRatePromoPeriDisp,
sd.零食计划网点数 as planSnackStoreCnt,
sd.零食执行网点数 as execSnackStoreCnt,
if(sd.零食计划网点数 is null, null,concat( round( coalesce(sd.零食执行网点数,0) / sd.零食计划网点数 * 100,2)
,'%')) as snackExecRate,
sp.档期计划网点数 as planPromoPeriStoreCnt,
sp.档期开展网点数 as launchPromoPeriStoreCnt,
if(sp.档期计划网点数 is null, null,concat( round( coalesce(sp.档期开展网点数,0) / sp.档期计划网点数 * 100,2)
,'%')) as launchRatePromoPeriExec,
sp.促销规格执行网点数 as execPsStoreCnt,
if(sp.档期计划网点数 is null, null,concat( round( coalesce(sp.促销规格执行网点数,0) / sp.档期计划网点数 *
100,2) ,'%')) as psExecRatePromoPeriExec,
sp.促销口味执行网点数 as execPfStoreCnt,
if(sp.档期计划网点数 is null, null,concat( round( coalesce(sp.促销口味执行网点数,0) / sp.档期计划网点数 *
100,2) ,'%')) as pfExecRatePromoPeriExec,
sp.促销价执行网点数 as execPpStoreCnt,
if(sp.档期计划网点数 is null, null,concat( round( coalesce(sp.促销价执行网点数,0) / sp.档期计划网点数 *
100,2) ,'%')) as ppExecRatePromoPeriExec,
sp.海报计划网点数 as planPosterStoreCnt,
sp.海报执行网点数 as execPosterStoreCnt,
if(sp.海报计划网点数 is null, null,concat( round( coalesce(sp.海报执行网点数,0) / sp.海报计划网点数 * 100,2)
,'%')) as posterExecRate
FROM (
SELECT region_name, district_name, city_manager
FROM sales_ap_display
<where>
<include refid="commonQueryConditions"/>
</where>
UNION
SELECT region_name, district_name, city_manager
FROM sales_ap_display_s
<where>
<include refid="commonQueryConditions"/>
</where>
UNION
SELECT region_name, district_name, city_manager
FROM sales_ap_display_j
<where>
<include refid="commonQueryConditions"/>
</where>
UNION
SELECT region_name, district_name, city_manager
FROM sales_ap_promotion_display
<where>
<include refid="commonQueryConditions"/>
</where>
UNION
SELECT region_name, district_name, city_manager
FROM sales_ap_snacks_display
<where>
<include refid="commonQueryConditions"/>
</where>
UNION
SELECT region_name, district_name, city_manager
FROM sales_ap_promotion
<where>
<include refid="commonQueryConditions"/>
</where>
) AS ar
LEFT JOIN (select region_name,
district_name,
city_manager,
sum(main_shelf_type_sn) as 主货架计划网点数,
sum(if(actual_main_shelf_executed is not null and actual_main_shelf_executed = '执行', 1,
0)) as 主货架执行网点数,
sum(end_cap_qty_sn) as 常规端架计划网点数,
sum(if(actual_end_cap_executed is not null and actual_end_cap_executed = '执行', 1,
0)) as 常规端架执行网点数,
sum(floor_stack_area_sn) as 常规地堆计划网点数,
sum(if(actual_floor_stack_executed is not null and actual_floor_stack_executed = '执行', 1,
0)) as 常规地堆执行网点数,
sum(multi_point_display_sn) as 多点陈列计划网点数,
sum(if(actual_multi_display_executed is not null and actual_multi_display_executed = '执行',
1,
0)) as 多点陈列执行网点数,
sum(hanging_strip_sn) as 挂条计划网点数,
sum(if(hanging_strip_executed is not null and hanging_strip_executed = '执行', 1,
0)) as 挂条执行网点数
from sales_ap_display
<where>
<include refid="commonQueryConditions"/>
</where>
group by region_name, district_name,city_manager) d
ON ar.region_name = d.region_name AND ar.district_name = d.district_name and
ar.city_manager = d.city_manager
LEFT JOIN (select region_name,
district_name,
city_manager,
sum(display_sn60) 三米两秒挂条计划网点数,
sum(actual_display_qty60) 三米两秒挂条执行网点数
from sales_ap_display_s
<where>
<include refid="commonQueryConditions"/>
</where>
group by region_name, district_name,city_manager) s
ON ar.region_name = s.region_name AND ar.district_name = s.district_name and
ar.city_manager = s.city_manager
LEFT JOIN (select region_name,
district_name,
city_manager,
sum(gw_sn6) 批发挂网计划网点数,
sum(actual_gw6) 批发挂网执行网点数
from sales_ap_display_j
<where>
<include refid="commonQueryConditions"/>
</where>
group by region_name, district_name,city_manager) j
ON ar.region_name = j.region_name AND ar.district_name = j.district_name and
ar.city_manager = j.city_manager
left join (select region_name,
district_name,
city_manager,
sum(end_cap_sn) 端架计划网点数,
sum(if(actual_end_cap_executed is not null and actual_end_cap_executed = '执行', 1,
0)) as 端架执行网点数,
sum(floor_stack_sn) 地堆计划网点数,
sum(if(actual_floor_stack_executed is not null and actual_floor_stack_executed = '执行', 1,
0)) as 地堆执行网点数,
sum(other_display_sn) 其他陈列计划网点数,
sum(if(actual_other_display_executed is not null and actual_other_display_executed = '执行',
1, 0)) as 其他陈列执行网点数
from sales_ap_promotion_display
<where>
<include refid="commonQueryConditions"/>
</where>
group by region_name, district_name,city_manager) pd
on ar.region_name = pd.region_name and ar.district_name = pd.district_name and
ar.city_manager = pd.city_manager
left join (select region_name,
district_name,
city_manager,
sum(actual_display_sn) 零食计划网点数,
sum(if(actual_display_sn = 1, if(snack_display_executed = '执行', 1, 0),
if(snack_display_executed = '执行', actual_end_cap_qty, 0))) 零食执行网点数
from sales_ap_snacks_display
<where>
<include refid="commonQueryConditions"/>
</where>
group by region_name, district_name,city_manager) sd
on ar.region_name = sd.region_name and ar.district_name = sd.district_name and
ar.city_manager = sd.city_manager
left join (select region_name,
district_name,
city_manager,
sum(promotion_sn) 档期计划网点数,
sum(if(promotion_implementation_status = '是', 1, 0)) 档期开展网点数,
sum(if(spec_execution_status = '执行', 1, 0)) 促销规格执行网点数,
sum(if(flavor_execution_status = '执行', 1, 0)) 促销口味执行网点数,
sum(if(promotion_price_execution_status = '执行', 1, 0)) 促销价执行网点数,
sum(poster_sn) 海报计划网点数,
sum(if(poster_sn is null, null, if(poster_execution_status = '执行', 1, 0))) 海报执行网点数
from sales_ap_promotion
<where>
<include refid="commonQueryConditions"/>
</where>
group by region_name, district_name,city_manager) sp
on ar.region_name = sp.region_name and ar.district_name = sp.district_name and
ar.city_manager = sp.city_manager
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论