收发货统计表问题修改

This commit is contained in:
liujie 2024-05-20 15:26:42 +08:00
parent f5015283f2
commit 649854a9dc
6 changed files with 252 additions and 12 deletions

View File

@ -63,6 +63,7 @@ public class RecordsExcel {
@ApiParam(required = false, value = "业务员名称") @RequestParam(required = false) String staffName,
@ApiParam(required = false, value = "营销区域id(逗号分隔)") @RequestParam(required = false) String areaIds,
@ApiParam(required = false, value = "业务员id(逗号分隔)") @RequestParam(required = false) String staffIds,
@ApiParam(required = false, value = "商品編碼") @RequestParam(required = false) String goodsNo,
@ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
@ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
HttpServletResponse response) throws Exception {
@ -80,6 +81,7 @@ public class RecordsExcel {
params.put("staffName", staffName);
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("goodsNo", goodsNo);
if (StringUtil.isNotEmpty(areaIds)) {
params.put("areaIds", areaIds.split(",", -1));
}
@ -98,6 +100,12 @@ public class RecordsExcel {
receiptRecordsBo.setClientId(String.valueOf(objectMap.get("clientId")));
// 客户U8编码
receiptRecordsBo.setUecode(String.valueOf(objectMap.get("uecode")));
// 商品编码
receiptRecordsBo.setGoodsNo(String.valueOf(objectMap.get("goodsNo")));
// 商品名称
receiptRecordsBo.setGoodsName(String.valueOf(objectMap.get("goodsName")));
// 规格
receiptRecordsBo.setSpecification(String.valueOf(objectMap.get("specification")));
// 营销区域ID
receiptRecordsBo.setAreaId(String.valueOf(objectMap.get("areaId")));
// 营销区域名称
@ -113,6 +121,7 @@ public class RecordsExcel {
map.put("endCode", endCode);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("goodsNo", goodsNo);
List list2 = receiptRecordsService.findGoods(map, ".getMajorNum");
Map map1 = (Map) list2.get(0);
if (map1 != null) {
@ -129,7 +138,9 @@ public class RecordsExcel {
map.put("endCode", endCode);
map.put("invoiceStartTime", startTime);
map.put("invoiceEndTime", endTime);
map.put("goodsNo", goodsNo);
Integer invoiceNum = receiptRecordsService.countAll(map, ".countRecordsByCondition");
invoiceNum = StringUtil.isNullOrEmpty(invoiceNum)? 0:invoiceNum;
receiptRecordsBo.setInvoiceNum(invoiceNum.toString());
// 入库数量 经销商扫码入库数量汇总
map.clear();
@ -138,8 +149,10 @@ public class RecordsExcel {
map.put("endCode", endCode);
map.put("receiveStartTime", startTime);
map.put("receiveEndTime", endTime);
map.put("goodsNo", goodsNo);
map.put("timeFlag", "1");
Integer receiveNum = receiptRecordsService.countAll(map, ".statisticsRecords");
receiveNum = StringUtil.isNullOrEmpty(receiveNum)? 0:receiveNum;
receiptRecordsBo.setReceiveNum(receiveNum.toString());
// 出库数量 经销商扫码出库数量汇总
map.clear();
@ -148,8 +161,10 @@ public class RecordsExcel {
map.put("endCode", endCode);
map.put("deliveryStartTime", startTime);
map.put("deliveryEndTime", endTime);
map.put("goodsNo", goodsNo);
map.put("timeFlag", "2");
Integer deliveryNum = receiptRecordsService.countAll(map, ".statisticsRecords");
deliveryNum = StringUtil.isNullOrEmpty(deliveryNum)? 0:deliveryNum;
receiptRecordsBo.setDeliveryNum(deliveryNum.toString());
// 如果数量都是0,跳出循环
if ("0.00".equals(receiptRecordsBo.getMajorNum()) && (invoiceNum == 0) && (receiveNum == 0) && (deliveryNum == 0)) {
@ -212,6 +227,7 @@ public class RecordsExcel {
map.put("invoiceStartTime", startTime);
map.put("invoiceEndTime", endTime);
Integer invoiceNum = receiptRecordsService.countAll(map, ".countRecordsByCondition");
invoiceNum = StringUtil.isNullOrEmpty(invoiceNum)? 0:invoiceNum;
receiptRecordsBo.setInvoiceNum(invoiceNum.toString());
// 入库数量 经销商扫码入库数量汇总
@ -221,6 +237,7 @@ public class RecordsExcel {
map.put("receiveEndTime", endTime);
map.put("timeFlag", "1");
Integer receiveNum = receiptRecordsService.countAll(map, ".statisticsRecords");
receiveNum = StringUtil.isNullOrEmpty(receiveNum)? 0:receiveNum;
receiptRecordsBo.setReceiveNum(receiveNum.toString());
// 出库数量 经销商扫码出库数量汇总
@ -230,6 +247,7 @@ public class RecordsExcel {
map.put("deliveryEndTime", endTime);
map.put("timeFlag", "2");
Integer deliveryNum = receiptRecordsService.countAll(map, ".statisticsRecords");
deliveryNum = StringUtil.isNullOrEmpty(deliveryNum)? 0:deliveryNum;
receiptRecordsBo.setDeliveryNum(deliveryNum.toString());
// 如果实发数量没有值或者等于0出库率和入库率等于0.00

View File

@ -567,6 +567,7 @@ public class ReceiptRecordsApi extends BaseController {
@ApiParam(required = false, value = "营销区域id") @RequestParam(required = false) String areaId,
@ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
@ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
@ApiParam(required = false, value = "商品編碼") @RequestParam(required = false) String goodsNo,
@ApiParam(required = false, value = "页码", defaultValue = "1") @RequestParam(required = false, value = "page") Integer page,
@ApiParam(required = false, value = "每页条数", defaultValue = "10") @RequestParam(required = false, value = "pageSize") Integer pageSize,
HttpServletRequest request) {
@ -589,6 +590,7 @@ public class ReceiptRecordsApi extends BaseController {
params.put("areaId", areaId);
params.put("page", page);
params.put("pageSize", pageSize);
params.put("goodsNo",goodsNo);
// 分页查询在发货单或者收发货记录中有记录的经销商
PageInfo pageInfo = receiptRecordsService.pageList(params, ".customerRecords1");
List<Map<String, Object>> list = pageInfo.getList();

View File

@ -162,6 +162,7 @@ public class ReceiptRecordsController extends BaseController {
@ApiParam(required = false, value = "业务员id(逗号分隔)") @RequestParam(required = false) String staffIds,
@ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
@ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
@ApiParam(required = false, value = "商品編碼") @RequestParam(required = false) String goodsNo,
@ApiParam(required = false, value = "页码", defaultValue = "1") @RequestParam(required = false, value = "page") Integer page,
@ApiParam(required = false, value = "每页条数", defaultValue = "10") @RequestParam(required = false, value = "pageSize") Integer pageSize,
HttpServletRequest request) {
@ -182,6 +183,7 @@ public class ReceiptRecordsController extends BaseController {
params.put("staffName", staffName);
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("goodsNo",goodsNo);
if (StringUtil.isNotEmpty(areaIds)) {
params.put("areaIds", areaIds.split(",", -1));
}
@ -225,6 +227,7 @@ public class ReceiptRecordsController extends BaseController {
@ApiParam(required = false, value = "业务员id(逗号分隔)") @RequestParam(required = false) String staffIds,
@ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
@ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
@ApiParam(required = false, value = "商品編碼") @RequestParam(required = false) String goodsNo,
HttpServletRequest request) {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
@ -243,6 +246,7 @@ public class ReceiptRecordsController extends BaseController {
map.put("endCode", endCode);
map.put("clientId", clientId);
map.put("clientName", clientName);
map.put("goodsNo", goodsNo);
if (StringUtil.isNotEmpty(areaIds)) {
map.put("areaIds", areaIds.split(",", -1));
}

View File

@ -261,6 +261,12 @@
<where>
AND (a.invoice_time is not null)
AND (a.invoice_client_id is not null)
<if test="goodsNo != null and goodsNo != ''">
AND a.GOODS_NO = #{goodsNo}
</if>
<if test="goodsNo == null or goodsNo == ''">
AND (a.GOODS_NO is null or a.GOODS_NO = '')
</if>
<if test="companyId != null and companyId != ''">
AND a.company_id = #{companyId}
</if>
@ -388,16 +394,23 @@
</if>
</if>
</where>
ORDER BY a.create_time DESC
group by GOODS_NO
-- ORDER BY a.create_time DESC
</select>
<!-- 入库/出库 -->
<select id="statisticsRecords" resultType="Integer" parameterType="map">
SELECT
COUNT(1)
count(1) receiveNum
FROM crm_receipt_records a
LEFT JOIN crm_distributor_user_info b on a.client_id = b.id
<where>
<if test="goodsNo != null and goodsNo != ''">
AND a.GOODS_NO = #{goodsNo}
</if>
<if test="goodsNo == null or goodsNo == ''">
AND (a.GOODS_NO is null or a.GOODS_NO = '')
</if>
<if test="companyId != null and companyId != ''">
AND a.company_id = #{companyId}
</if>
@ -540,6 +553,7 @@
</if>
</if>
</where>
group by GOODS_NO
</select>
<select id="oneById" resultMap="recordsMap" parameterType="map">
@ -958,7 +972,7 @@
</select>
<select id="customerRecords1" resultType="map" parameterType="map">
SELECT
select a.*,b.GOODS_NO "goodsNo",b.GOODS_NAME "goodsName",b.SPECIFICATION "specification" from (SELECT
a.CLIENT_ID "clientId",
MAX( b.distributor_name ) "clientName",
MAX( b.marketing_area_id ) "areaId",
@ -1095,6 +1109,12 @@
</if>
</if>
GROUP BY a.CLIENT_ID
) a cross join crm_invoice_goods b
<where>
<if test="goodsNo != null and goodsNo != ''">
b.GOODS_NO = #{goodsNo}
</if>
</where>
</select>
<insert id="addCustomerCom" parameterType="map">

View File

@ -31,6 +31,24 @@ public class ReceiptRecordsBo implements java.io.Serializable {
@Excel(name = "U8编码", width = 15, orderNum = "2")
private String uecode;
/**
* 商品编码
*/
@Excel(name = "商品编码", width = 15, orderNum = "2")
private String goodsNo;
/**
* 商品名称
*/
@Excel(name = "商品名称", width = 15, orderNum = "2")
private String goodsName;
/**
* 规格
*/
@Excel(name = "规格", width = 15, orderNum = "2")
private String specification;
/**
* 营销区域id
*/
@ -107,6 +125,30 @@ public class ReceiptRecordsBo implements java.io.Serializable {
@Excel(name = "出库数量", width = 15, orderNum = "7")
private String deliveryNum;
public String getGoodsNo() {
return goodsNo;
}
public void setGoodsNo(String goodsNo) {
this.goodsNo = goodsNo;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getSpecification() {
return specification;
}
public void setSpecification(String specification) {
this.specification = specification;
}
/**
* 入库率 入库数量/实发数量*100
*/

View File

@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -99,10 +100,11 @@ public class ReceiptRecordsService {
/**
* @description: 统计每个客户的数据
* @author: mzr
* @date: 2022/05/04
* @author: lj
* @date: 2024/04/09
**/
public void getCountNums(String startCode, String endCode, String startTime, String endTime, List<Map<String, Object>> list) {
public List<Map<String, Object>> getCountNums2(String startCode, String endCode, String startTime, String endTime, String goodsNo, List<Map<String, Object>> list) {
List<Map<String, Object>> resultList = new ArrayList<>();
for (Map<String, Object> objectMap : list) {
String clientId1 = objectMap.get("clientId") + "";
Map<String, Object> map = new HashMap<>();
@ -128,9 +130,49 @@ public class ReceiptRecordsService {
map.put("endCode", endCode);
map.put("invoiceStartTime", startTime);
map.put("invoiceEndTime", endTime);
Integer invoiceNum = this.countAll(map, ".countRecordsByCondition");
map.put("goodsNo", goodsNo);
List<ReceiptRecordsInfo> sfMapList = dao.list(ReceiptRecordsInfo.class.getName() + ".countRecordsByCondition", map);
if(sfMapList.size() == 0){
Map itemMap = new HashMap();
itemMap.put("clientId",objectMap.get("clientId"));
itemMap.put("clientName",objectMap.get("clientName"));
itemMap.put("areaId",objectMap.get("areaId"));
itemMap.put("uecode",objectMap.get("uecode"));
itemMap.put("staffName",objectMap.get("staffName"));
itemMap.put("areaName",objectMap.get("areaName"));
itemMap.put("majorNum",objectMap.get("majorNum"));
itemMap.put("goodsNo","");
itemMap.put("goodsName","");
itemMap.put("specifications","");
itemMap.put("invoiceNum","0");
itemMap.put("receiveNum","0");
itemMap.put("receiveRate","0.00");
itemMap.put("deliveryNum","0");
itemMap.put("deliveryRate","0.00");
resultList.add(itemMap);
continue;
}else{
//合并实发数量
for(int i = 0; i < sfMapList.size(); i++){
Map itemMap = new HashMap();
itemMap.put("clientId",objectMap.get("clientId"));
itemMap.put("clientName",objectMap.get("clientName"));
itemMap.put("areaId",objectMap.get("areaId"));
itemMap.put("uecode",objectMap.get("uecode"));
itemMap.put("staffName",objectMap.get("staffName"));
itemMap.put("areaName",objectMap.get("areaName"));
itemMap.put("majorNum",objectMap.get("majorNum"));
itemMap.put("goodsNo",sfMapList.get(i).getGoodsNo());
itemMap.put("goodsName",sfMapList.get(i).getGoodsName());
itemMap.put("specifications",sfMapList.get(i).getSpecifications());
itemMap.put("invoiceNum",StringUtil.isNullOrEmpty(sfMapList.get(i).getInvoiceNum())?"0":sfMapList.get(i).getInvoiceNum());
resultList.add(itemMap);
}
}
// Integer invoiceNum = this.countAll(map, ".countRecordsByCondition");
// receiptRecordsBo.setInvoiceNum(invoiceNum.toString());
objectMap.put("invoiceNum", invoiceNum.toString());
// objectMap.put("invoiceNum", invoiceNum.toString());
// 入库数量 经销商扫码入库数量汇总
map.clear();
map.put("clientId", clientId1);
@ -139,9 +181,32 @@ public class ReceiptRecordsService {
map.put("receiveStartTime", startTime);
map.put("receiveEndTime", endTime);
map.put("timeFlag", "1");
Integer receiveNum = this.countAll(map, ".statisticsRecords");
List<ReceiptRecordsInfo> rkMapList = dao.list(ReceiptRecordsInfo.class.getName() + ".statisticsRecords", map);
//合并入库数量
for(int i = 0; i < rkMapList.size();i++){
ReceiptRecordsInfo rkRinfo = rkMapList.get(i);
// resultList.stream().filter(x-> x.get("clientId").equals(item.getClientId()) && x.get("goodsNo").equals(item.getGoodsNo()));
resultList.forEach(resultMap->{
boolean rkgoodsNoFlag = StringUtil.isNullOrEmpty(rkRinfo.getGoodsNo());
boolean rsgoodsNoFlag = StringUtil.isNullOrEmpty(resultMap.get("goodsNo"));
//clientid goodsNo匹配 或者 goodsNo都为空时
if((rkRinfo.getClientId().equals(resultMap.get("clientId")))
&& ((rkgoodsNoFlag && rsgoodsNoFlag) || ((!rkgoodsNoFlag && !rsgoodsNoFlag && rkRinfo.getGoodsNo().equals(resultMap.get("goodsNo"))))) ){
resultMap.put("receiveNum",StringUtil.isNullOrEmpty(rkRinfo.getReceiveNum())?"0":rkRinfo.getReceiveNum());
DecimalFormat df = new DecimalFormat("0.00");
Integer invoiceNum = Integer.valueOf(resultMap.get("invoiceNum").toString());
Integer receiveNum = Integer.valueOf(resultMap.get("receiveNum").toString());
// 入库率 入库数量/实发数量*100
resultMap.put("receiveRate", df.format((float) receiveNum / invoiceNum * 100));
}
});
}
// Integer receiveNum = this.countAll(map, ".statisticsRecords");
// receiptRecordsBo.setReceiveNum(receiveNum.toString());
objectMap.put("receiveNum", receiveNum.toString());
// objectMap.put("receiveNum", receiveNum.toString());
// 出库数量 经销商扫码出库数量汇总
map.clear();
map.put("clientId", clientId1);
@ -150,9 +215,98 @@ public class ReceiptRecordsService {
map.put("deliveryStartTime", startTime);
map.put("deliveryEndTime", endTime);
map.put("timeFlag", "2");
Integer deliveryNum = this.countAll(map, ".statisticsRecords");
List<ReceiptRecordsInfo> ckMapList = dao.list(ReceiptRecordsInfo.class.getName() + ".statisticsRecords", map);
// Integer deliveryNum = this.countAll(map, ".statisticsRecords");
// receiptRecordsBo.setDeliveryNum(deliveryNum.toString());
objectMap.put("deliveryNum", deliveryNum.toString());
// objectMap.put("deliveryNum", deliveryNum.toString());
//合并出库数量
for(int i = 0; i < ckMapList.size();i++){
ReceiptRecordsInfo ckRinfo = ckMapList.get(i);
// ckMapList.forEach(item-> {
// resultList.stream().filter(x-> x.get("clientId").equals(item.getClientId()) && x.get("goodsNo").equals(item.getGoodsNo()));
resultList.forEach(resultMap->{
boolean ckgoodsNoFlag = StringUtil.isNullOrEmpty(ckRinfo.getGoodsNo());
boolean rsgoodsNoFlag = StringUtil.isNullOrEmpty(resultMap.get("goodsNo"));
//clientid goodsNo匹配 或者 goodsNo都为空时
if((ckRinfo.getClientId().equals(resultMap.get("clientId")))
&& ((ckgoodsNoFlag && rsgoodsNoFlag) || ((!ckgoodsNoFlag && !rsgoodsNoFlag && ckRinfo.getGoodsNo().equals(resultMap.get("goodsNo"))))) ){
resultMap.put("deliveryNum",StringUtil.isNullOrEmpty(ckRinfo.getReceiveNum())?"0":ckRinfo.getReceiveNum());
DecimalFormat df = new DecimalFormat("0.00");
Integer invoiceNum = Integer.valueOf(resultMap.get("invoiceNum").toString());
Integer deliveryNum = Integer.valueOf(resultMap.get("deliveryNum").toString());
// 出库率 出库数量/实发数量*100
resultMap.put("deliveryRate", df.format((float) deliveryNum / invoiceNum * 100));
}
});
}
}
return resultList;
}
/**
* @description: 统计每个客户的数据
* @author: mzr
* @date: 2022/05/04
**/
public void getCountNums(String startCode, String endCode, String startTime, String endTime, List<Map<String, Object>> list) {
for (Map<String, Object> objectMap : list) {
String clientId1 = objectMap.get("clientId") + "";
Map<String, Object> map = new HashMap<>();
// 应发数量 该经销商发货单的商品的实发数量汇总
map.put("clientId", clientId1);
map.put("startCode", startCode);
map.put("endCode", endCode);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("goodsNo", objectMap.get("goodsNo"));
List list2 = this.findGoods(map, ".getMajorNum");
Map map1 = (Map) list2.get(0);
if (map1 != null) {
String majorNum = StringUtil.isEmpty(map1.get("majorNum")) ? "0.00" : String.format("%.2f", Double.parseDouble(map1.get("majorNum") + ""));
objectMap.put("majorNum", majorNum);
} else {
objectMap.put("majorNum", "0.00");
}
// 实发数量 仓库扫码条数
map.clear();
map.put("clientId", clientId1);
map.put("startCode", startCode);
map.put("endCode", endCode);
map.put("invoiceStartTime", startTime);
map.put("invoiceEndTime", endTime);
map.put("goodsNo", objectMap.get("goodsNo"));
Integer invoiceNum = this.countAll(map, ".countRecordsByCondition");
invoiceNum = StringUtil.isNullOrEmpty(invoiceNum)? 0:invoiceNum;
// receiptRecordsBo.setInvoiceNum(invoiceNum.toString());
objectMap.put("invoiceNum", StringUtil.isNullOrEmpty(invoiceNum)?"0":invoiceNum.toString());
// 入库数量 经销商扫码入库数量汇总
map.clear();
map.put("clientId", clientId1);
map.put("startCode", startCode);
map.put("endCode", endCode);
map.put("receiveStartTime", startTime);
map.put("receiveEndTime", endTime);
map.put("timeFlag", "1");
map.put("goodsNo", objectMap.get("goodsNo"));
Integer receiveNum = this.countAll(map, ".statisticsRecords");
receiveNum = StringUtil.isNullOrEmpty(receiveNum)? 0:receiveNum;
// receiptRecordsBo.setReceiveNum(receiveNum.toString());
objectMap.put("receiveNum", StringUtil.isNullOrEmpty(receiveNum)?"0":receiveNum.toString());
// 出库数量 经销商扫码出库数量汇总
map.clear();
map.put("clientId", clientId1);
map.put("startCode", startCode);
map.put("endCode", endCode);
map.put("deliveryStartTime", startTime);
map.put("deliveryEndTime", endTime);
map.put("timeFlag", "2");
map.put("goodsNo", objectMap.get("goodsNo"));
Integer deliveryNum = this.countAll(map, ".statisticsRecords");
deliveryNum = StringUtil.isNullOrEmpty(deliveryNum)? 0:deliveryNum;
// receiptRecordsBo.setDeliveryNum(deliveryNum.toString());
objectMap.put("deliveryNum", StringUtil.isNullOrEmpty(deliveryNum)? "0":deliveryNum.toString());
if (StringUtil.isNotEmpty(invoiceNum) && (0 != invoiceNum)) {
DecimalFormat df = new DecimalFormat("0.00");