提交 1350e406 authored 作者: 吕本才's avatar 吕本才

1、修改入参为集合,页面可以多选

上级 9a09838f
...@@ -6,7 +6,8 @@ import com.link.bi.service.FinanceOrderDetailService; ...@@ -6,7 +6,8 @@ import com.link.bi.service.FinanceOrderDetailService;
import com.sfa.common.core.web.controller.BaseController; import com.sfa.common.core.web.controller.BaseController;
import com.sfa.common.security.annotation.RequiresPermissions; import com.sfa.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -26,8 +27,8 @@ public class FinanceOrderQueryController extends BaseController { ...@@ -26,8 +27,8 @@ public class FinanceOrderQueryController extends BaseController {
* 财务成本聚合查询 * 财务成本聚合查询
*/ */
@RequiresPermissions("bi:finance:list") @RequiresPermissions("bi:finance:list")
@GetMapping("/cost/list") @PostMapping("/cost/list")
public PageInfo selectBiFinanceCostList(FinanceCostVo financeCostVo) { public PageInfo selectBiFinanceCostList(@RequestBody FinanceCostVo financeCostVo) {
return detailService.selectBiFinanceCostList(financeCostVo); return detailService.selectBiFinanceCostList(financeCostVo);
} }
...@@ -36,8 +37,8 @@ public class FinanceOrderQueryController extends BaseController { ...@@ -36,8 +37,8 @@ public class FinanceOrderQueryController extends BaseController {
* 财务成本聚合查询 * 财务成本聚合查询
*/ */
@RequiresPermissions("bi:finance:list") @RequiresPermissions("bi:finance:list")
@GetMapping("/cost/detail/list") @PostMapping("/cost/detail/list")
public PageInfo selectBiFinanceCostDetailList(FinanceCostVo financeCostVo) { public PageInfo selectBiFinanceCostDetailList(@RequestBody FinanceCostVo financeCostVo) {
return detailService.selectBiFinanceCostDetailList(financeCostVo); return detailService.selectBiFinanceCostDetailList(financeCostVo);
} }
......
...@@ -15,7 +15,7 @@ import java.math.BigDecimal; ...@@ -15,7 +15,7 @@ import java.math.BigDecimal;
public class FinanceBaseProduct { public class FinanceBaseProduct {
// 唯一标识主键 // 唯一标识主键
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private int fbpId; private Integer fbpId;
// 料号 // 料号
private String prdCode; private String prdCode;
// 品名 // 品名
......
...@@ -16,7 +16,7 @@ import java.time.LocalDateTime; ...@@ -16,7 +16,7 @@ import java.time.LocalDateTime;
public class FinanceBaseZbjType { public class FinanceBaseZbjType {
// 唯一键 // 唯一键
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private long fbztId; private Long fbztId;
// 分销商名称 // 分销商名称
private String fenxiaoName; private String fenxiaoName;
// 直播间渠道类型 有分销商id,不是以上几类的,统一为达人 没有分销商id的,默认为商城 // 直播间渠道类型 有分销商id,不是以上几类的,统一为达人 没有分销商id的,默认为商城
......
...@@ -2,6 +2,9 @@ package com.link.bi.domain.wq; ...@@ -2,6 +2,9 @@ package com.link.bi.domain.wq;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List;
/** /**
* @author : liqiulin * @author : liqiulin
* @date : 2024-11-22 17 * @date : 2024-11-22 17
...@@ -12,5 +15,21 @@ public class FinanceCostWq { ...@@ -12,5 +15,21 @@ public class FinanceCostWq {
// 入参 查询类型 // 入参 查询类型
private String type; private String type;
// 入参 查询值 // 入参 查询值
private String value; // private String value;
// private String zbjQdType;
// private String flavor;
// private String specName;
// private String series;
// private String goodsName;
// 入参 时间开始时间
private Date startDate;
// 入参 时间结束时间
private Date endDate;
private List<String> zbjQdType;
private List<String> flavor;
private List<String> specName;
private List<String> series;
private List<String> goodsName;
} }
...@@ -3,13 +3,11 @@ package com.link.bi.pojo.request; ...@@ -3,13 +3,11 @@ package com.link.bi.pojo.request;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
public class FinanceCostVo { public class FinanceCostVo {
// 入参 查询类型
private String type;
// 入参 查询值
private String value;
// 入参 分页当前页 // 入参 分页当前页
private String pageNum; private String pageNum;
// 入参 分页大小 // 入参 分页大小
...@@ -21,4 +19,11 @@ public class FinanceCostVo { ...@@ -21,4 +19,11 @@ public class FinanceCostVo {
// 入参 时间结束时间 // 入参 时间结束时间
private Date endDate; private Date endDate;
private List<String> zbjQdType;
private List<String> flavor;
private List<String> specName;
private List<String> series;
private List<String> goodsName;
} }
...@@ -28,12 +28,10 @@ public class FinanceBiListDto { ...@@ -28,12 +28,10 @@ public class FinanceBiListDto {
private BigDecimal actualCostSum; private BigDecimal actualCostSum;
private BigDecimal standardCostSum; private BigDecimal standardCostSum;
// 查询类型
private String queryType;
// 实际成本毛利 // 实际成本毛利
// private BigDecimal actualCostGrossProfitSum; private BigDecimal actualCostGrossProfitSum;
// 标准成本毛利 // 标准成本毛利
// private BigDecimal standardCostGrossProfitSum; private BigDecimal standardCostGrossProfitSum;
} }
package com.link.bi.service.impl; package com.link.bi.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.link.bi.domain.dao.IFinanceOrderDetailDao; import com.link.bi.domain.dao.IFinanceOrderDetailDao;
...@@ -10,11 +11,13 @@ import com.link.bi.pojo.request.FinanceCostVo; ...@@ -10,11 +11,13 @@ import com.link.bi.pojo.request.FinanceCostVo;
import com.link.bi.pojo.response.FinanceBiListDto; import com.link.bi.pojo.response.FinanceBiListDto;
import com.link.bi.pojo.response.FinanceOrderDetailListDto; import com.link.bi.pojo.response.FinanceOrderDetailListDto;
import com.link.bi.service.FinanceOrderDetailService; import com.link.bi.service.FinanceOrderDetailService;
import com.sfa.common.core.utils.DateUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -51,12 +54,22 @@ public class FinanceOrderDetailServiceImpl extends ServiceImpl<FinanceOrderDetai ...@@ -51,12 +54,22 @@ public class FinanceOrderDetailServiceImpl extends ServiceImpl<FinanceOrderDetai
public PageInfo<FinanceBiListDto> selectBiFinanceCostList(FinanceCostVo financeCostVo) { public PageInfo<FinanceBiListDto> selectBiFinanceCostList(FinanceCostVo financeCostVo) {
FinanceCostWq qw = new FinanceCostWq(); FinanceCostWq qw = new FinanceCostWq();
BeanUtils.copyProperties(financeCostVo, qw); BeanUtils.copyProperties(financeCostVo, qw);
// 初始化开始日期和结束日期
if (ObjectUtil.isAllNotEmpty(qw.getStartDate(),qw.getEndDate())) {
qw.setStartDate(DateUtils.dateStart(DateUtils.dateStart(qw.getStartDate())));
qw.setEndDate(DateUtils.dateStart(DateUtils.dateStart(DateUtils.addDays(qw.getEndDate(), 1))));
}else{
qw.setStartDate(DateUtils.dateStart(-31));
qw.setEndDate(DateUtils.dateStart(new Date()));
}
PageInfo<FinanceOrderDetail> orderDetailPageInfo = detailDao.selectBiFinanceCostList(qw); PageInfo<FinanceOrderDetail> orderDetailPageInfo = detailDao.selectBiFinanceCostList(qw);
PageInfo<FinanceBiListDto> pageInfo = new PageInfo<>(); PageInfo<FinanceBiListDto> pageInfo = new PageInfo<>();
BeanUtils.copyProperties(orderDetailPageInfo, pageInfo); BeanUtils.copyProperties(orderDetailPageInfo, pageInfo);
pageInfo.setList(orderDetailPageInfo.getList().stream().map(item -> { pageInfo.setList(orderDetailPageInfo.getList().stream().map(item -> {
FinanceBiListDto dto = new FinanceBiListDto(); FinanceBiListDto dto = new FinanceBiListDto();
BeanUtils.copyProperties(item, dto); BeanUtils.copyProperties(item, dto);
dto.setActualCostGrossProfitSum(dto.getShareAmountSum().subtract(dto.getActualCostSum()));
dto.setStandardCostGrossProfitSum(dto.getShareAmountSum().subtract(dto.getStandardCostSum()));
return dto; return dto;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
return pageInfo; return pageInfo;
...@@ -67,6 +80,7 @@ public class FinanceOrderDetailServiceImpl extends ServiceImpl<FinanceOrderDetai ...@@ -67,6 +80,7 @@ public class FinanceOrderDetailServiceImpl extends ServiceImpl<FinanceOrderDetai
FinanceCostWq qw = new FinanceCostWq(); FinanceCostWq qw = new FinanceCostWq();
BeanUtils.copyProperties(financeCostVo, qw); BeanUtils.copyProperties(financeCostVo, qw);
PageInfo<FinanceOrderDetail> financeOrderDetailPageInfo = detailDao.selectBiFinanceCostDetailList(qw); PageInfo<FinanceOrderDetail> financeOrderDetailPageInfo = detailDao.selectBiFinanceCostDetailList(qw);
PageInfo<FinanceOrderDetailListDto> pageInfo = new PageInfo<>(); PageInfo<FinanceOrderDetailListDto> pageInfo = new PageInfo<>();
BeanUtils.copyProperties(financeOrderDetailPageInfo, pageInfo); BeanUtils.copyProperties(financeOrderDetailPageInfo, pageInfo);
pageInfo.setList(financeOrderDetailPageInfo.getList().stream().map(item -> { pageInfo.setList(financeOrderDetailPageInfo.getList().stream().map(item -> {
......
...@@ -36,8 +36,8 @@ import java.util.*; ...@@ -36,8 +36,8 @@ import java.util.*;
public class FinanceOrderServiceImpl extends ServiceImpl<FinanceOrderMapper, FinanceOrder> implements FinanceOrderService { public class FinanceOrderServiceImpl extends ServiceImpl<FinanceOrderMapper, FinanceOrder> implements FinanceOrderService {
@Autowired @Autowired
IFinanceOrderDao orderDao; IFinanceOrderDao orderDao;
@Autowired // @Autowired
WangdiantongUtil wangdiantongUtil; // WangdiantongUtil wangdiantongUtil;
@Autowired @Autowired
FinanceOrderDetailService detailService; FinanceOrderDetailService detailService;
...@@ -83,7 +83,8 @@ public class FinanceOrderServiceImpl extends ServiceImpl<FinanceOrderMapper, Fin ...@@ -83,7 +83,8 @@ public class FinanceOrderServiceImpl extends ServiceImpl<FinanceOrderMapper, Fin
} }
log.info("查询订单参数:开始时间{},结束时间{}", DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime)); log.info("查询订单参数:开始时间{},结束时间{}", DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
List<FinanceOrder> orders = wangdiantongUtil.queryWithDetail(startTime, endTime); List<FinanceOrder> orders = new ArrayList<>();
// wangdiantongUtil.queryWithDetail(startTime, endTime);
if (ObjectUtils.isEmpty(orders)) { if (ObjectUtils.isEmpty(orders)) {
throw new ServiceException("旺店通没有查询到订单数据"); throw new ServiceException("旺店通没有查询到订单数据");
......
package com.link.bi.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.util.DateUtils;
import com.lark.oapi.okhttp.*;
import com.link.bi.domain.entity.FinanceOrder;
import com.sfa.common.core.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import java.util.*;
@Slf4j
@Component
public class WangdiantongUtil {
/**
* 卖家账号/接口账号/盐/接口名称
*/
public List<FinanceOrder> queryWithDetail(Date startTime, Date endTime) {
List<FinanceOrder> orderAllList = new ArrayList<>();
try {
int total = 0;
int size = 0;
int page_no = 0;
do {
String url = "http://wdt.wangdian.cn/openapi";
String sid = "wxl3";
String key = "wxl3-ota";
String salt = "78784988049166748bfdc83273ebb990";
String appsecret = "c65bd645bbed704bb7982037f9b948e3";
String method = "sales.TradeQuery.queryWithDetail";
String v = "1.0";
HashMap<String, Object> params = new HashMap<>();
params.put("start_time", DateUtils.format(startTime));
params.put("end_time", DateUtils.format(endTime));
params.put("status", "110");
params.put("time_type", 2);
List<HashMap<String, Object>> paramsList = Arrays.asList(params);
String signParams = appsecret + "body" + JSONObject.toJSONString(paramsList) + "calc_total1" + "key" + key
+ "method" + method + "page_no"+ page_no + "page_size200" + "salt" + salt + "sid" + sid +
"timestamp" + (System.currentTimeMillis() / 1000 - 1325347200) + "v" + v + appsecret;
String sign = DigestUtils.md5DigestAsHex(signParams.toString().getBytes());
log.debug(signParams);
log.debug(sign);
StringBuilder urlParams = new StringBuilder()
.append("sid=").append(sid)
.append("&key=").append(key)
.append("&salt=").append(salt)
.append("&method=").append(method)
.append("&v=").append(v)
.append("&timestamp=").append(System.currentTimeMillis() / 1000 - 1325347200)
.append("&sign=").append(sign)
.append("&page_size=").append(200)
.append("&page_no=").append(page_no)
.append("&calc_total=").append(1);
log.info("查询订单数据url:" + url + "?" + urlParams);
RequestBody body = RequestBody.create(MediaType.get("application/json"), JSONObject.toJSONString(paramsList));
Request urlRequestBuild = new Request.Builder().url(url + "?" + urlParams).post(body).build();
OkHttpClient client = new OkHttpClient();
Response execute = client.newCall(urlRequestBuild).execute();
JSONObject responseJson = JSONObject.parseObject(execute.body().string());
JSONObject dataR = responseJson.getJSONObject("data");
JSONObject messageJson = responseJson.getJSONObject("message");
if(ObjectUtils.isNotEmpty(messageJson)){
log.error("访问旺店通接口错误"+messageJson.toString());
throw new ServiceException("访问旺店通接口错误"+messageJson.toString());
}
Integer totalCount = dataR.getInteger("total_count");
JSONArray order = dataR.getJSONArray("order");
total = totalCount;
log.info("当前时间段{}-{},总条数totalCount:{}", DateUtils.format(startTime), DateUtils.format(endTime),totalCount);
log.info("当前时间段{}-{},查询返回的order条数:{}", DateUtils.format(startTime),DateUtils.format(endTime), order.size());
List<FinanceOrder> orders = JSONArray.parseArray(order.toString(), FinanceOrder.class, JSONReader.Feature.SupportSmartMatch);
orderAllList.addAll(orders);
size = orderAllList.size();
page_no ++;
} while ( size < total);
return orderAllList;
} catch (Exception e) {
// 记录异常日志
log.error("异常信息:{}"+e.getMessage(),e);
return orderAllList;
}
}
}
...@@ -6,19 +6,26 @@ ...@@ -6,19 +6,26 @@
<!-- 根据 聚合类型和值 查询聚合记录 --> <!-- 根据 聚合类型和值 查询聚合记录 -->
<select id="selectBiFinanceCostList" resultMap="BaseResultMap"> <select id="selectBiFinanceCostList" resultMap="BaseResultMap">
select select
<if test="wq.zbjDdType!= null and wq.zbjDdType!= '' "> <if test=" (wq.zbjQdType == null or wq.zbjQdType.isEmpty() )
and (wq.goodsName== null or wq.goodsName.isEmpty() )
and (wq.specName== null or wq.specName.isEmpty() )
and (wq.flavor== null or wq.flavor.isEmpty() )
and (wq.series== null or wq.series.isEmpty() ) ">
zbj_qd_type, zbj_qd_type,
</if> </if>
<if test="wq.goodsName!= null and wq.goodsName!= '' "> <if test="wq.zbjQdType!= null and !wq.zbjQdType.isEmpty() ">
zbj_qd_type,
</if>
<if test="wq.goodsName!= null and !wq.goodsName.isEmpty() ">
goods_no,goods_name, goods_no,goods_name,
</if> </if>
<if test="wq.specName!= null and wq.specName!= '' "> <if test="wq.specName!= null and !wq.specName.isEmpty() ">
spec_name_erp, spec_name_erp,
</if> </if>
<if test="wq.flavor!= null and wq.flavor!= '' "> <if test="wq.flavor!= null and !wq.flavor.isEmpty() ">
flavor_erp, flavor_erp,
</if> </if>
<if test="wq.series!= null and wq.series!= '' "> <if test="wq.series!= null and !wq.series.isEmpty() ">
series, series,
</if> </if>
...@@ -28,37 +35,69 @@ ...@@ -28,37 +35,69 @@
from finance_order_detail fod from finance_order_detail fod
<where> <where>
<if test="wq.zbjDdType!= null and wq.zbjDdType!= '' "> <if test="wq.zbjQdType!= null and !wq.zbjQdType.isEmpty() ">
and fod.zbj_qd_type= #{wq.zbjDdType} and fod.zbj_qd_type in
<foreach collection="wq.zbjQdType" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.goodsName!= null and wq.goodsName!= '' "> <if test="wq.goodsName!= null and !wq.goodsName.isEmpty() ">
and fod.goods_name like concat('%', #{wq.goodsName}, '%') and fod.goods_name in
<foreach collection="wq.goodsName" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.specName!= null and wq.specName!= '' "> <if test="wq.specName!= null and !wq.specName.isEmpty() ">
and fod.spec_name_erp= #{wq.specName} and fod.spec_name_erp
<foreach collection="wq.specName" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.flavor!= null and wq.flavor!= '' "> <if test="wq.flavor!= null and !wq.flavor.isEmpty() ">
and fod.flavor_erp= #{wq.flavor} and fod.flavor_erp in
<foreach collection="wq.flavor" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.series!= null and wq.series!= '' "> <if test="wq.series!= null and !wq.series.isEmpty() ">
and fod.series= #{wq.series} and fod.series in
<foreach collection="wq.flavor" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="wq.startDate!= null ">
and fod.consign_time between #{wq.startDate} and #{wq.endDate}
</if> </if>
</where> </where>
<if test="wq.zbjDdType!= null and wq.zbjDdType!= '' ">
group by zbj_qd_type
group by
<trim suffixOverrides="," suffix="">
<if test=" (wq.zbjQdType == null or wq.zbjQdType .isEmpty() )
and (wq.goodsName== null or wq.goodsName.isEmpty() )
and (wq.specName== null or wq.specName.isEmpty() )
and (wq.flavor== null or wq.flavor.isEmpty() )
and (wq.series== null or wq.series.isEmpty() ) ">
zbj_qd_type,
</if> </if>
<if test="wq.goodsName!= null and wq.goodsName!= '' "> <if test="wq.zbjQdType!= null and !wq.zbjQdType.isEmpty() ">
group by goods_no ,goods_name zbj_qd_type,
</if>
<if test="wq.goodsName!= null and !wq.goodsName.isEmpty() ">
goods_no ,goods_name,
</if> </if>
<if test="wq.specName!= null and wq.specName!= '' "> <if test="wq.specName!= null and !wq.specName.isEmpty() ">
group by spec_name_erp spec_name_erp,
</if> </if>
<if test="wq.flavor!= null and wq.flavor!= '' "> <if test="wq.flavor!= null and !wq.flavor.isEmpty() ">
group by flavor_erp flavor_erp,
</if> </if>
<if test="wq.series!= null and wq.series!= '' "> <if test="wq.series!= null and !wq.series.isEmpty() ">
group by series series,
</if> </if>
</trim>
</select> </select>
<!-- 根据 类型和聚合的值 查询详情记录 --> <!-- 根据 类型和聚合的值 查询详情记录 -->
...@@ -67,22 +106,37 @@ ...@@ -67,22 +106,37 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from finance_order_detail fod from finance_order_detail fod
<where> <where>
<if test="wq.zbjDdType!= null and wq.zbjDdType!= '' "> <if test="wq.zbjQdType!= null and !wq.zbjQdType.isEmpty() ">
and fod.zbj_qd_type= #{wq.zbjDdType} and fod.zbj_qd_type in
<foreach collection="wq.zbjQdType" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.goodsName!= null and wq.goodsName!= '' "> <if test="wq.goodsName!= null and !wq.goodsName.isEmpty() ">
and fod.goods_name like concat('%', #{wq.goodsName}, '%') and fod.goods_name in
<foreach collection="wq.goodsName" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.specName!= null and wq.specName!= '' "> <if test="wq.specName!= null and !wq.specName.isEmpty() ">
and fod.spec_name_erp= #{wq.specName} and fod.spec_name_erp in
<foreach collection="wq.specName" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.flavor!= null and wq.flavor!= '' "> <if test="wq.flavor!= null and !wq.flavor.isEmpty() ">
and fod.flavor_erp= #{wq.flavor} and fod.flavor_erp in
<foreach collection="wq.flavor" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="wq.series!= null and wq.series!= '' "> <if test="wq.series!= null and !wq.series.isEmpty() ">
and fod.series= #{wq.series} and fod.series in
<foreach collection="wq.series" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
</where> </where>
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论