客户库存盘点明细
This commit is contained in:
parent
7593401491
commit
1424cf2a1e
|
|
@ -4,6 +4,7 @@ import com.yb.lb.common.core.AjaxResult;
|
||||||
import com.yb.lb.common.core.BaseController;
|
import com.yb.lb.common.core.BaseController;
|
||||||
import com.yb.lb.common.utils.ErrorUtils;
|
import com.yb.lb.common.utils.ErrorUtils;
|
||||||
import com.yb.lb.webapp.redis.service.RedisService;
|
import com.yb.lb.webapp.redis.service.RedisService;
|
||||||
|
import com.yb.lb.webapp.stock.service.ClientStockReportService;
|
||||||
import com.yb.lb.webapp.stock.service.InventoryInfoService;
|
import com.yb.lb.webapp.stock.service.InventoryInfoService;
|
||||||
import com.yb.lb.webapp.utils.RoleDateUtils;
|
import com.yb.lb.webapp.utils.RoleDateUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -20,14 +21,14 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户库存查询
|
* 客户库存查询报表
|
||||||
*
|
*
|
||||||
* @author mzr
|
* @author mzr
|
||||||
* @date 2023/11/04
|
* @date 2023/11/04
|
||||||
**/
|
**/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/adminx/stockReport")
|
@RequestMapping("/adminx/stockReport")
|
||||||
@Api(tags = "pc:客户库存查询")
|
@Api(tags = "pc:客户库存查询报表")
|
||||||
public class StockReportController extends BaseController {
|
public class StockReportController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
RedisService redisService;
|
RedisService redisService;
|
||||||
|
|
@ -35,6 +36,8 @@ public class StockReportController extends BaseController {
|
||||||
InventoryInfoService inventoryInfoService;
|
InventoryInfoService inventoryInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
RoleDateUtils roleDateUtils;
|
RoleDateUtils roleDateUtils;
|
||||||
|
@Autowired
|
||||||
|
ClientStockReportService clientStockReportService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 库存查询
|
* @description 库存查询
|
||||||
|
|
@ -121,4 +124,34 @@ public class StockReportController extends BaseController {
|
||||||
return toAjax(inventoryInfoService.findDetailList(params, id));
|
return toAjax(inventoryInfoService.findDetailList(params, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 客户库存盘点明细
|
||||||
|
* @author mzr
|
||||||
|
* @date 2024/10/30
|
||||||
|
**/
|
||||||
|
@ApiOperation("客户库存盘点明细")
|
||||||
|
@PostMapping(value = "/getClientStockReport")
|
||||||
|
public Map<String, Object> getClientStockReport(
|
||||||
|
@ApiParam(required = true, value = "开始日期") @RequestParam(required = true) String startDate,
|
||||||
|
@ApiParam(required = true, value = "结束日期") @RequestParam(required = true) String endDate,
|
||||||
|
@ApiParam(required = false, value = "客户id") @RequestParam(required = false) String clientId,
|
||||||
|
@ApiParam(required = true, value = "页码", defaultValue = "1") @RequestParam(value = "page") Integer pageNum,
|
||||||
|
@ApiParam(required = true, value = "每页条数", defaultValue = "10") @RequestParam(value = "pageSize") Integer pageSize,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
// String token = request.getHeader("token");
|
||||||
|
// if (!redisService.isKey(token)) {
|
||||||
|
// return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录");
|
||||||
|
// }
|
||||||
|
// Map<String, String> tokenMap = redisService.hmget(token);
|
||||||
|
// params.put("companyId", tokenMap.get("companyId"));
|
||||||
|
params.put("startDate", startDate);
|
||||||
|
params.put("endDate", endDate);
|
||||||
|
params.put("clientId", clientId);
|
||||||
|
params.put("page", pageNum);
|
||||||
|
params.put("pageSize", pageSize);
|
||||||
|
return toPage(clientStockReportService.pageList(params, ".getClientStockReportSql"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
<?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.yb.lb.webapp.stock.entity.ClientStockReport">
|
||||||
|
<!-- 字段映射 -->
|
||||||
|
<resultMap id="stockReportMap" type="com.yb.lb.webapp.stock.entity.ClientStockReport">
|
||||||
|
<result column="bill_id" property="billId" jdbcType="VARCHAR" />
|
||||||
|
<result column="bill_no" property="billNo" jdbcType="VARCHAR" />
|
||||||
|
<result column="bill_date" property="billDate" jdbcType="VARCHAR" />
|
||||||
|
<result column="client_id" property="clientId" jdbcType="VARCHAR" />
|
||||||
|
<result column="confirm_status" property="confirmStatus" jdbcType="VARCHAR" />
|
||||||
|
<result column="create_time" property="createTime" jdbcType="VARCHAR" />
|
||||||
|
<result column="goods_id" property="goodsId" jdbcType="VARCHAR" />
|
||||||
|
<result column="goods_no" property="goodsNo" jdbcType="VARCHAR" />
|
||||||
|
<result column="goods_name" property="goodsName" jdbcType="VARCHAR" />
|
||||||
|
<result column="unit_id" property="unitId" jdbcType="VARCHAR" />
|
||||||
|
<result column="unit_name" property="unitName" jdbcType="VARCHAR" />
|
||||||
|
<result column="specifications" property="specifications" jdbcType="VARCHAR" />
|
||||||
|
<result column="goods_type_id" property="goodsTypeId" jdbcType="VARCHAR" />
|
||||||
|
<result column="goods_type_name" property="goodsTypeName" jdbcType="VARCHAR" />
|
||||||
|
<result column="last_num" property="lastNum" jdbcType="VARCHAR" />
|
||||||
|
<result column="count_num" property="countNum" jdbcType="VARCHAR" />
|
||||||
|
<result column="diff_num" property="diffNum" jdbcType="VARCHAR" />
|
||||||
|
<result column="company_id" property="companyId" jdbcType="VARCHAR" />
|
||||||
|
<result column="remark" property="remark" jdbcType="VARCHAR" />
|
||||||
|
<result column="prod_date" property="prodDate" jdbcType="VARCHAR" />
|
||||||
|
<result column="distributor_name" property="clientName" jdbcType="VARCHAR" />
|
||||||
|
<result column="join_fhd_num" property="joinFhdNum" jdbcType="VARCHAR" />
|
||||||
|
<result column="distributor_no" property="distributorNo" jdbcType="VARCHAR" />
|
||||||
|
<result column="uecode" property="uecode" jdbcType="VARCHAR" />
|
||||||
|
<result column="create_name" property="createName" jdbcType="VARCHAR" />
|
||||||
|
<result column="create_time" property="createTime" jdbcType="VARCHAR" />
|
||||||
|
<result column="area_no" property="areaNo" jdbcType="VARCHAR" />
|
||||||
|
<result column="area_name" property="areaName" jdbcType="VARCHAR" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 表查询字段 -->
|
||||||
|
<sql id="allColumns">
|
||||||
|
a.id, a.bill_id, a.bill_no, a.bill_date, a.client_id, a.confirm_status, a.create_time, a.goods_id,
|
||||||
|
a.goods_no, a.last_num, a.count_num, a.diff_num, a.company_id, a.remark, a.prod_date,a.join_fhd_num,
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 根据条件参数查询盘点子表列表 -->
|
||||||
|
<select id="findCrmInventoryDetailByCondition" resultMap="stockReportMap" parameterType="map">
|
||||||
|
SELECT
|
||||||
|
<include refid="allColumns" />
|
||||||
|
b.goods_name, b.unit_id, b.unit_name, b.specifications, b.goods_type_id, b.goods_type_name
|
||||||
|
FROM crm_inventory_detail a
|
||||||
|
LEFT JOIN crm_goods_info b ON a.goods_no = b.goods_no and a.company_id = b.company_id
|
||||||
|
<where>
|
||||||
|
<if test="billId != null and billId != ''">
|
||||||
|
AND a.bill_id = #{billId}
|
||||||
|
</if>
|
||||||
|
<if test="clientId != null and clientId != ''">
|
||||||
|
AND a.client_id = #{clientId}
|
||||||
|
</if>
|
||||||
|
<if test="confirmStatus != null and confirmStatus != ''">
|
||||||
|
AND a.confirm_status = #{confirmStatus}
|
||||||
|
</if>
|
||||||
|
<if test="goodsNo != null and goodsNo != ''">
|
||||||
|
AND a.goods_no = #{goodsNo}
|
||||||
|
</if>
|
||||||
|
<if test="companyId != null and companyId != ''">
|
||||||
|
AND a.company_id = #{companyId}
|
||||||
|
</if>
|
||||||
|
<if test="startDateP != null and startDateP !=''">
|
||||||
|
AND TO_CHAR(TO_DATE(SUBSTR(a.prod_date,1,10),'yyyy-MM-dd'),'yyyy-MM-dd') >=
|
||||||
|
TO_CHAR(TO_DATE(SUBSTR(#{startDateP},1,10),'yyyy-MM-dd'),'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
<if test="endDateP != null and endDateP !=''">
|
||||||
|
AND TO_CHAR(TO_DATE(SUBSTR(a.prod_date,1,10),'yyyy-MM-dd'),'yyyy-MM-dd') <=
|
||||||
|
TO_CHAR(TO_DATE(SUBSTR(#{endDateP},1,10),'yyyy-MM-dd'),'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY a.bill_date DESC,a.create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 客户库存盘点明细 -->
|
||||||
|
<select id="getClientStockReportSql" resultType="map" parameterType="map">
|
||||||
|
SELECT t0.uecode "uecode",
|
||||||
|
t0.distributor_name "clientName",
|
||||||
|
NVL(t1.bill_date, '---') "billDate",
|
||||||
|
NVL(t1.count_num, 0) "countNum",
|
||||||
|
NVL(t1.goods_num, 0) "goodsNum",
|
||||||
|
NVL(t2.bill_num, 0) "billNum"
|
||||||
|
FROM crm_distributor_user_info t0
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT tt1.*,
|
||||||
|
ROW_NUMBER() OVER ( PARTITION BY tt1.client_id ORDER BY tt1.bill_date DESC, tt1.create_time DESC ) AS rn
|
||||||
|
FROM (
|
||||||
|
SELECT a.bill_no,
|
||||||
|
a.bill_date,
|
||||||
|
a.client_id,
|
||||||
|
a.create_time,
|
||||||
|
b.count_num,
|
||||||
|
b.goods_num
|
||||||
|
FROM crm_inventory_info a
|
||||||
|
LEFT JOIN pd1 b ON a.id = b.bill_id
|
||||||
|
WHERE a.confirm_status = '1'
|
||||||
|
<if test="startDate != null and startDate !=''">
|
||||||
|
AND TO_CHAR(TO_DATE(SUBSTR(a.bill_date,1,10),'yyyy-MM-dd'),'yyyy-MM-dd') >=
|
||||||
|
TO_CHAR(TO_DATE(SUBSTR(#{startDate},1,10),'yyyy-MM-dd'),'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
<if test="endDate != null and endDate !=''">
|
||||||
|
AND TO_CHAR(TO_DATE(SUBSTR(a.bill_date,1,10),'yyyy-MM-dd'),'yyyy-MM-dd') <=
|
||||||
|
TO_CHAR(TO_DATE(SUBSTR(#{endDate},1,10),'yyyy-MM-dd'),'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
) tt1
|
||||||
|
) temp
|
||||||
|
WHERE rn = 1
|
||||||
|
) t1 ON t0.id = t1.client_id
|
||||||
|
LEFT JOIN (SELECT client_id, COUNT(1) bill_num
|
||||||
|
FROM crm_inventory_info
|
||||||
|
WHERE confirm_status = '1'
|
||||||
|
<if test="startDate != null and startDate !=''">
|
||||||
|
AND TO_CHAR(TO_DATE(SUBSTR(bill_date,1,10),'yyyy-MM-dd'),'yyyy-MM-dd') >=
|
||||||
|
TO_CHAR(TO_DATE(SUBSTR(#{startDate},1,10),'yyyy-MM-dd'),'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
<if test="endDate != null and endDate !=''">
|
||||||
|
AND TO_CHAR(TO_DATE(SUBSTR(bill_date,1,10),'yyyy-MM-dd'),'yyyy-MM-dd') <=
|
||||||
|
TO_CHAR(TO_DATE(SUBSTR(#{endDate},1,10),'yyyy-MM-dd'),'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
GROUP BY client_id) t2 ON t0.id = t2.client_id
|
||||||
|
WHERE t0.status = '1'
|
||||||
|
AND t0.documents_status = '1'
|
||||||
|
AND t0.uecode IS NOT NULL
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.yb.lb.webapp.stock.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户库存盘点报表
|
||||||
|
*
|
||||||
|
* @author mzr
|
||||||
|
* @version 1.0.0 2024-10-29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ClientStockReport implements java.io.Serializable {
|
||||||
|
/** 版本号 */
|
||||||
|
private static final long serialVersionUID = -1267096003093637603L;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.yb.lb.webapp.stock.service;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.yb.lb.common.base.oracle.BaseOracleDao;
|
||||||
|
import com.yb.lb.webapp.stock.entity.ClientStockReport;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盘点单
|
||||||
|
*
|
||||||
|
* @author mzr
|
||||||
|
* @date 2024/10/30
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class ClientStockReportService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BaseOracleDao<ClientStockReport> dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 分页查询
|
||||||
|
* @author mzr
|
||||||
|
* @date 2024/10/30
|
||||||
|
**/
|
||||||
|
public PageInfo pageList(Map<String, Object> params, String id) {
|
||||||
|
return dao.pageList(ClientStockReport.class.getName() + id, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 查询所有
|
||||||
|
* @author mzr
|
||||||
|
* @date 2024/10/30
|
||||||
|
**/
|
||||||
|
public List findList(Map<String, Object> params, String id) {
|
||||||
|
return dao.list(ClientStockReport.class.getName() + id, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue