Browse Source

售后报表

master
fanzongzhe 7 months ago
parent
commit
c4e8f3675c
  1. 30
      yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/BusinessSummaryQuery.java
  2. 108
      yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/BusinessSummaryVo.java
  3. 31
      yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/DebtBusinessQuery.java
  4. 70
      yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/DebtBusinessVo.java
  5. 30
      yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/OutInsuranceBusinessQuery.java
  6. 70
      yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/OutInsuranceBusinessVo.java
  7. 9
      yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.java
  8. 143
      yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml
  9. 30
      yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillRest.java
  10. 194
      yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillService.java

30
yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/BusinessSummaryQuery.java

@ -0,0 +1,30 @@
package com.yxt.anrui.as.api.asbusrepairbill.report;
import com.yxt.common.core.query.Query;
import lombok.Data;
/**
* @author Fan
* @description
* @date 2024/11/8 8:59
*/
@Data
public class BusinessSummaryQuery implements Query {
/**
* 1本日2本月3本年
*/
private String dateType;
private String menuUrl;
private String orgPath;
/**
* 结算结束
*/
private String settleEndTime;
/**
* 结算开始
*/
private String settleStartTime;
private String userSid;
}

108
yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/BusinessSummaryVo.java

@ -0,0 +1,108 @@
package com.yxt.anrui.as.api.asbusrepairbill.report;
import com.yxt.common.core.vo.Vo;
import lombok.Data;
/**
* @author Fan
* @description
* @date 2024/11/8 8:59
*/
@Data
public class BusinessSummaryVo implements Vo {
/**
* 附加项目
*/
private String addAmount;
/**
* 退货
*/
private String backAmount;
/**
* 涉及单数
*/
private String billNum;
/**
* 成本
*/
private String cost;
/**
* 门店
*/
private String deptName;
/**
* 材料
*/
private String goodsAmount;
/**
* 材料成本
*/
private String goodsAmountCost;
/**
* 毛利润
*/
private String grossProfit;
/**
* 工时
*/
private String hourAmount;
/**
* 工时成本
*/
private String hourAmountCost;
/**
* 其他附件项目
*/
private String otherAmount;
/**
* 其他附加项目成本
*/
private String otherAmountCost;
/**
* 保外用料
*/
private String outGoodsAmount;
/**
* 保外工时
*/
private String outHourAmount;
/**
* 保外附加
*/
private String outOtherAmount;
/**
* 保外应收
*/
private String outReceivable;
/**
* 三包用料
*/
private String packsGoodsAmount;
/**
* 三包工时
*/
private String packsHourAmount;
/**
* 三包附加
*/
private String packsOtherAmount;
/**
* 三包应收
*/
private String packsReceivable;
/**
* 结算时间
*/
private String settleTime;
/**
* 营业额
*/
private String turnover;
/**
* 分公司
*/
private String useOrgName;
}

31
yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/DebtBusinessQuery.java

@ -0,0 +1,31 @@
package com.yxt.anrui.as.api.asbusrepairbill.report;
import com.yxt.common.core.query.Query;
import lombok.Data;
/**
* @author Fan
* @description
* @date 2024/11/8 11:21
*/
@Data
public class DebtBusinessQuery implements Query {
/**
* 1本日2本月3本年
*/
private String dateType;
private String menuUrl;
private String orgPath;
/**
* 结算结束
*/
private String settleEndTime;
/**
* 结算开始
*/
private String settleStartTime;
private String userSid;
}

70
yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/DebtBusinessVo.java

@ -0,0 +1,70 @@
package com.yxt.anrui.as.api.asbusrepairbill.report;
import com.yxt.common.core.vo.Vo;
import lombok.Data;
/**
* @author Fan
* @description
* @date 2024/11/8 11:21
*/
@Data
public class DebtBusinessVo implements Vo {
/**
* 附加费
*/
private String addAmount;
/**
* 单数
*/
private String billNum;
/**
* 维修类型
*/
private String billType;
/**
* 当前欠款金额
*/
private String debtAmount;
/**
* 当前欠款单数
*/
private String debtNum;
/**
* 门店
*/
private String deptName;
/**
* 材料费
*/
private String goodsAmount;
/**
* 材料成本
*/
private String goodsAmountCost;
/**
* 工时费
*/
private String hourAmount;
/**
* 工时成本
*/
private String hourAmountCost;
/**
* 其他附加费
*/
private String otherAmount;
/**
* 应收合计
*/
private String totalAmount;
/**
* 成本合计
*/
private String totalCost;
/**
* 分公司
*/
private String useOrgName;
}

30
yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/OutInsuranceBusinessQuery.java

@ -0,0 +1,30 @@
package com.yxt.anrui.as.api.asbusrepairbill.report;
import com.yxt.common.core.query.Query;
import lombok.Data;
/**
* @author Fan
* @description
* @date 2024/11/8 10:57
*/
@Data
public class OutInsuranceBusinessQuery implements Query {
/**
* 1本日2本月3本年
*/
private String dateType;
private String menuUrl;
private String orgPath;
/**
* 结算结束
*/
private String settleEndTime;
/**
* 结算开始
*/
private String settleStartTime;
private String userSid;
}

70
yxt-as/src/main/java/com/yxt/anrui/as/api/asbusrepairbill/report/OutInsuranceBusinessVo.java

@ -0,0 +1,70 @@
package com.yxt.anrui.as.api.asbusrepairbill.report;
import com.yxt.common.core.vo.Vo;
import lombok.Data;
/**
* @author Fan
* @description
* @date 2024/11/8 10:57
*/
@Data
public class OutInsuranceBusinessVo implements Vo {
/**
* 附加费
*/
private String addAmount;
/**
* 涉及单数
*/
private String billNum;
/**
* 维修类型
*/
private String billType;
/**
* 门店
*/
private String deptName;
/**
* 材料费
*/
private String goodsAmount;
/**
* 材料成本
*/
private String goodsAmountCost;
/**
* 工时费
*/
private String hourAmount;
/**
* 工时成本
*/
private String hourAmountCost;
/**
* 其他附加费
*/
private String otherAmount;
/**
* 附加成本
*/
private String otherAmountCost;
/**
* 利润合计
*/
private String profit;
/**
* 收入合计
*/
private String totalAmount;
/**
* 成本合计
*/
private String totalCost;
/**
* 分公司
*/
private String useOrgName;
}

9
yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.java

@ -6,8 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.anrui.as.api.asbusrepairbill.*;
import com.yxt.anrui.as.api.asbusrepairbill.app.*;
import com.yxt.anrui.as.api.asbusrepairbill.report.BusDetailsVo;
import com.yxt.anrui.as.api.asbusrepairbill.report.SummaryVo;
import com.yxt.anrui.as.api.asbusrepairbill.report.*;
import com.yxt.anrui.as.api.asbusrepairinventorybilldetail.SitemsVo;
import com.yxt.common.core.result.ResultBean;
import org.apache.ibatis.annotations.Mapper;
@ -71,4 +70,10 @@ public interface AsBusrepairBillMapper extends BaseMapper<AsBusrepairBill> {
IPage<SummaryVo> Summary(IPage<AsBusrepairBill> page,@Param(Constants.WRAPPER) QueryWrapper<AsBusrepairBill> qw);
IPage<BusDetailsVo> busDetailsList(IPage<AsBusrepairBill> page, @Param(Constants.WRAPPER) QueryWrapper<AsBusrepairBill> qw);
IPage<BusinessSummaryVo> businessSummary(IPage<AsBusrepairBill> page,@Param(Constants.WRAPPER) QueryWrapper<AsBusrepairBill> qw);
IPage<OutInsuranceBusinessVo> outInsuranceBusiness(IPage<AsBusrepairBill> page, @Param(Constants.WRAPPER) QueryWrapper<AsBusrepairBill> qw);
IPage<DebtBusinessVo> debtBusiness(IPage<AsBusrepairBill> page, @Param(Constants.WRAPPER) QueryWrapper<AsBusrepairBill> qw);
}

143
yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml

@ -370,7 +370,7 @@
LEFT JOIN yxt_wms.wms_inventory AS i ON d.inventorySid = i.sid
WHERE b.busTypeKey = '0'
GROUP BY
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.useOrgSid,d.inventorySid,a.billType,a.`subject`,d.billBusTypeValue,a.nodeCode
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,d.inventorySid,a.billType,a.`subject`,d.billBusTypeValue,a.nodeCode
UNION ALL
SELECT
a.orgSidPath,
@ -393,7 +393,7 @@
(IFNULL(SUM(s.amount),0) - IFNULL(SUM(s.costTotal),0)) as profit
FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as a ON s.billSid = a.sid
GROUP BY
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.useOrgSid,a.billType,a.`subject`,s.billBusTypeValue,a.nodeCode
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,a.billType,a.`subject`,s.billBusTypeValue,a.nodeCode
UNION ALL
SELECT
a.orgSidPath,
@ -416,7 +416,7 @@
(IFNULL(SUM(s.price),0) - IFNULL(SUM(s.costTotal),0)) as profit
FROM as_busrepair_bill_aitem as s LEFT JOIN as_busrepair_bill as a ON s.billSid = a.sid
GROUP BY
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.useOrgSid,a.billType,a.`subject`,s.billBusTypeValue,a.nodeCode
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,a.billType,a.`subject`,s.billBusTypeValue,a.nodeCode
UNION ALL
SELECT
a.orgSidPath,
@ -439,7 +439,7 @@
(IFNULL(SUM(s.price),0) - IFNULL(SUM(s.costTotal),0)) as profit
FROM as_busrepair_bill_aitemspec as s LEFT JOIN as_busrepair_bill as a ON s.billSid = a.sid
GROUP BY
a.sid,s.attachItem,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.useOrgSid,a.billType,a.`subject`,s.billBusTypeValue,a.nodeCode
a.sid,s.attachItem,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,a.billType,a.`subject`,s.billBusTypeValue,a.nodeCode
UNION ALL
SELECT
s.orgSidPath,
@ -466,7 +466,7 @@
LEFT JOIN yxt_sms.sms_sales_bill AS a ON d.billSid = a.sid
LEFT JOIN anrui_portal.sys_organization AS s ON a.deptSid = s.sid
GROUP BY
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.useOrgSid,d.billBusTypeValue) as m
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,d.billBusTypeValue) as m
<where>
${ew.sqlSegment}
</where>
@ -653,4 +653,137 @@
${ew.sqlSegment}
</where>
</select>
<select id="businessSummary" resultType="com.yxt.anrui.as.api.asbusrepairbill.report.BusinessSummaryVo">
SELECT * FROM
(SELECT n.*,
(n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) turnover,
(n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) cost,
((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost)) grossProfit,
(n.packsHourAmount + n.packsGoodsAmount + n.packsOtherAmount) packsReceivable,
(n.outHourAmount + n.outGoodsAmount + n.outOtherAmount) outReceivable
FROM
(SELECT
a.orgSidPath,
a.`deptName`,
a.`useOrgName`,
COUNT(*) billNum,
IFNULL(SUM(IFNULL(hourAmount,0)),0) hourAmount,
(SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0) as goodsAmount,
IFNULL(SUM(IFNULL(addAmount,0)),0) otherAmount,
(IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount,
(SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) as backAmount,
(SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) as hourAmountCost,
( (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) ) goodsAmountCost,
((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ))) otherAmountCost,
(SELECT IFNULL(SUM(IFNULL(b.hourAmount,0)),0) FROM as_busrepair_bill as b WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保内') as packsHourAmount,
( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0 and b.`subject` = '保内') - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1 and b.`subject` = '保内') ) packsGoodsAmount,
(SELECT IFNULL(SUM(IFNULL(addAmount,0)),0) + IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0) FROM as_busrepair_bill as b WHERE
b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保内') as packsOtherAmount,
(SELECT IFNULL(SUM(IFNULL(b.hourAmount,0)),0) FROM as_busrepair_bill as b WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保外') as outHourAmount,
( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0 and b.`subject` = '保外') - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1 and b.`subject` = '保外') ) outGoodsAmount,
(SELECT IFNULL(SUM(IFNULL(addAmount,0)),0) + IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0) FROM as_busrepair_bill as b WHERE
b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保外') as outOtherAmount,
date_format ( a.settleTime, '%Y-%m-%d' ) settleTime
FROM
as_busrepair_bill AS a
WHERE a.nodeCode = '6'
GROUP BY
date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid) as n) as m
<where>
${ew.sqlSegment}
</where>
</select>
<select id="outInsuranceBusiness"
resultType="com.yxt.anrui.as.api.asbusrepairbill.report.OutInsuranceBusinessVo">
SELECT * FROM
(SELECT n.*,
(n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount,
(n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) totalCost,
( (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost))profit
FROM
(SELECT
a.billType,
a.orgSidPath,
a.`deptName`,
a.`useOrgName`,
COUNT(*) billNum,
IFNULL(SUM(IFNULL(hourAmount,0)),0) hourAmount,
( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) ) goodsAmount,
IFNULL(SUM(IFNULL(addAmount,0)),0) otherAmount,
(IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount,
(SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) as hourAmountCost,
( (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) ) goodsAmountCost,
((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ))) otherAmountCost,
date_format ( a.settleTime, '%Y-%m-%d' ) settleTime
FROM
as_busrepair_bill AS a
WHERE a.nodeCode = '6' and a.`subject` = '保外'
GROUP BY
date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,a.billType) n) m
<where>
${ew.sqlSegment}
</where>
</select>
<select id="debtBusiness" resultType="com.yxt.anrui.as.api.asbusrepairbill.report.DebtBusinessVo">
SELECT * FROM
(SELECT
billType,
orgSidPath,
`deptName`,
`useOrgName`,
settleTime,
deptSid,
SUM(billCount) billNum,
SUM(totalAmount) totalAmount,
SUM(totalCost) totalCost,
SUM(noMoney) debtAmount,
SUM(hourAmount) hourAmount,
SUM(goodsAmount) goodsAmount,
SUM(otherAmount) otherAmount,
SUM(addAmount) addAmount,
SUM(hourAmountCost) hourAmountCost,
SUM(goodsAmountCost) goodsAmountCost,
SUM(noMoneyCount) debtNum
FROM
(SELECT n.*,
(n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount,
(n.hourAmountCost + n.goodsAmountCost) totalCost,
IF(n.noMoney > 0, '1', '0') noMoneyCount
FROM
(SELECT
a.billType,
a.orgSidPath,
a.`deptName`,
a.`useOrgName`,
a.settleTime,
a.deptSid,
'1' billCount,
((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE d.contractSid = a.sid)
- (SELECT IFNULL(SUM(sd.subscriptionMoney),0) FROM anrui_fin.fin_selected_receivables_detailed as sd LEFT JOIN anrui_fin.fin_uncollected_receivables_detailed as fd ON sd.receivablesSid
= fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid)) noMoney,
IFNULL(a.hourAmount,0) hourAmount,
((SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 1)) goodsAmount,
IFNULL(a.addAmount,0) otherAmount,
IFNULL(a.outAmount,0) + IFNULL(a.subsidyAmount,0) + IFNULL(a.rescueAmount,0) addAmount,
(SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s WHERE s.billSid = a.sid) as hourAmountCost,
((SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 1)) goodsAmountCost
FROM
as_busrepair_bill AS a
LEFT JOIN as_arrearsout_apply as sa ON a.sid = sa.pairBillSid
WHERE sa.nodeState = '已办结' and a.nodeCode = '6') as n) k
GROUP BY k.billType, k.deptSid,k.settleTime) m
<where>
${ew.sqlSegment}
</where>
</select>
</mapper>

30
yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillRest.java

@ -2,10 +2,7 @@ package com.yxt.anrui.as.biz.asbusrepairbill;
import com.yxt.anrui.as.api.asbusrepairbill.*;
import com.yxt.anrui.as.api.asbusrepairbill.app.*;
import com.yxt.anrui.as.api.asbusrepairbill.report.BusDetailsQuery;
import com.yxt.anrui.as.api.asbusrepairbill.report.BusDetailsVo;
import com.yxt.anrui.as.api.asbusrepairbill.report.SummaryQuery;
import com.yxt.anrui.as.api.asbusrepairbill.report.SummaryVo;
import com.yxt.anrui.as.api.asbusrepairbill.report.*;
import com.yxt.anrui.as.api.asbusrepairbillinvoice.AsBusrepairBillInvoice;
import com.yxt.anrui.as.api.asbusrepairbillsitem.AsBusrepairBillSitem;
import com.yxt.anrui.as.api.asbusrepairbillsitemrepairer.AsBusrepairBillSitemRepairer;
@ -311,12 +308,35 @@ public class AsBusrepairBillRest {
}
@PostMapping("/busDetailsList")
@ApiOperation("业务汇总")
@ApiOperation("业务明细")
ResultBean<PagerVo<BusDetailsVo>> busDetailsList(@RequestBody PagerQuery<BusDetailsQuery> pagerQuery) {
ResultBean<PagerVo<BusDetailsVo>> rb = ResultBean.fireFail();
PagerVo<BusDetailsVo> pv = asBusrepairBillService.busDetailsList(pagerQuery);
return rb.success().setData(pv);
}
@PostMapping("/businessSummary")
@ApiOperation("营业汇总表")
ResultBean<PagerVo<BusinessSummaryVo>> businessSummary(@RequestBody PagerQuery<BusinessSummaryQuery> pq) {
ResultBean<PagerVo<BusinessSummaryVo>> rb = ResultBean.fireFail();
PagerVo<BusinessSummaryVo> pv = asBusrepairBillService.businessSummary(pq);
return rb.success().setData(pv);
}
@PostMapping("/outInsuranceBusiness")
@ApiOperation("营业分析1(保外)")
ResultBean<PagerVo<OutInsuranceBusinessVo>> outInsuranceBusiness(@RequestBody PagerQuery<OutInsuranceBusinessQuery> pq) {
ResultBean<PagerVo<OutInsuranceBusinessVo>> rb = ResultBean.fireFail();
PagerVo<OutInsuranceBusinessVo> pv = asBusrepairBillService.outInsuranceBusiness(pq);
return rb.success().setData(pv);
}
@PostMapping("/debtBusiness")
@ApiOperation("营业分析2(欠款)")
ResultBean<PagerVo<DebtBusinessVo>> debtBusiness(@RequestBody PagerQuery<DebtBusinessQuery> pq) {
ResultBean<PagerVo<DebtBusinessVo>> rb = ResultBean.fireFail();
PagerVo<DebtBusinessVo> pv = asBusrepairBillService.debtBusiness(pq);
return rb.success().setData(pv);
}
}

194
yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillService.java

@ -9,10 +9,7 @@ import com.yxt.anrui.as.api.asappendix.AsAppendix;
import com.yxt.anrui.as.api.asbillsettelapply.AsBillSettelApplyDto;
import com.yxt.anrui.as.api.asbusrepairbill.*;
import com.yxt.anrui.as.api.asbusrepairbill.app.*;
import com.yxt.anrui.as.api.asbusrepairbill.report.BusDetailsQuery;
import com.yxt.anrui.as.api.asbusrepairbill.report.BusDetailsVo;
import com.yxt.anrui.as.api.asbusrepairbill.report.SummaryQuery;
import com.yxt.anrui.as.api.asbusrepairbill.report.SummaryVo;
import com.yxt.anrui.as.api.asbusrepairbill.report.*;
import com.yxt.anrui.as.api.asbusrepairbillaitem.AsBusrepairBillAitem;
import com.yxt.anrui.as.api.asbusrepairbillaitemspec.AsBusrepairBillAitemspec;
import com.yxt.anrui.as.api.asbusrepairbillinsurance.AsBusrepairBillInsurance;
@ -2722,4 +2719,193 @@ public class AsBusrepairBillService extends MybatisBaseService<AsBusrepairBillMa
PagerVo<BusDetailsVo> p = PagerUtil.pageToVo(pagging, null);
return p;
}
public PagerVo<BusinessSummaryVo> businessSummary(PagerQuery<BusinessSummaryQuery> pq) {
BusinessSummaryQuery query = pq.getParams();
QueryWrapper<AsBusrepairBill> qw = new QueryWrapper<>();
PrivilegeQuery privilegeQuery = new PrivilegeQuery();
privilegeQuery.setOrgPath(query.getOrgPath());
privilegeQuery.setUserSid(query.getUserSid());
privilegeQuery.setMenuUrl(query.getMenuUrl());
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery);
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) {
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
String orgSidPath = query.getOrgPath();
orgSidPath = orgSidPath + "/";
int i1 = orgSidPath.indexOf("/");
int i2 = orgSidPath.indexOf("/", i1 + 1);
int i3 = orgSidPath.indexOf("/", i2 + 1);
int i4 = orgSidPath.indexOf("/", i3 + 1);
String orgLevelKey = defaultIdReltBean.getData();
if ("1".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i1);
qw.like("m.orgSidPath", orgSidPath);
} else if ("2".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i2);
qw.like("m.orgSidPath", orgSidPath);
} else if ("3".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i3);
qw.like("m.orgSidPath", orgSidPath);
} else if ("4".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i4);
qw.like("m.orgSidPath", orgSidPath);
} else if ("5".equals(orgLevelKey)) {
// qw.eq("a.createBySid", query.getUserSid());
} else {
PagerVo<BusinessSummaryVo> p = new PagerVo<>();
return p;
}
} else {
PagerVo<BusinessSummaryVo> p = new PagerVo<>();
return p;
}
if (StringUtils.isNotBlank(query.getDateType())) {
String dateType = query.getDateType();
if (dateType.equals("1")) {
//本日
qw.apply("m.settleTime = CURDATE()");
} else if (dateType.equals("2")) {
//本月
qw.apply("m.settleTime >= date_add(curdate(), interval - day(curdate()) + 1 day) AND m.settleTime <= last_day(curdate())");
} else if (dateType.equals("3")) {
//本年
qw.apply("m.settleTime >= date_sub(curdate(), interval dayofyear(curdate())-1 day) AND m.settleTime <= concat(year(curdate()),'-12-31')");
}
}
//结算时间
qw.apply(StringUtils.isNotBlank(query.getSettleStartTime()), "date_format (m.settleTime,'%Y-%m-%d') >= date_format('" + query.getSettleStartTime() + "','%Y-%m-%d')").
apply(StringUtils.isNotBlank(query.getSettleEndTime()), "date_format (m.settleTime,'%Y-%m-%d') <= date_format('" + query.getSettleEndTime() + "','%Y-%m-%d')"
);
IPage<AsBusrepairBill> page = PagerUtil.queryToPage(pq);
IPage<BusinessSummaryVo> pagging = baseMapper.businessSummary(page, qw);
PagerVo<BusinessSummaryVo> p = PagerUtil.pageToVo(pagging, null);
return p;
}
public PagerVo<OutInsuranceBusinessVo> outInsuranceBusiness(PagerQuery<OutInsuranceBusinessQuery> pq) {
OutInsuranceBusinessQuery query = pq.getParams();
QueryWrapper<AsBusrepairBill> qw = new QueryWrapper<>();
PrivilegeQuery privilegeQuery = new PrivilegeQuery();
privilegeQuery.setOrgPath(query.getOrgPath());
privilegeQuery.setUserSid(query.getUserSid());
privilegeQuery.setMenuUrl(query.getMenuUrl());
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery);
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) {
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
String orgSidPath = query.getOrgPath();
orgSidPath = orgSidPath + "/";
int i1 = orgSidPath.indexOf("/");
int i2 = orgSidPath.indexOf("/", i1 + 1);
int i3 = orgSidPath.indexOf("/", i2 + 1);
int i4 = orgSidPath.indexOf("/", i3 + 1);
String orgLevelKey = defaultIdReltBean.getData();
if ("1".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i1);
qw.like("m.orgSidPath", orgSidPath);
} else if ("2".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i2);
qw.like("m.orgSidPath", orgSidPath);
} else if ("3".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i3);
qw.like("m.orgSidPath", orgSidPath);
} else if ("4".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i4);
qw.like("m.orgSidPath", orgSidPath);
} else if ("5".equals(orgLevelKey)) {
// qw.eq("a.createBySid", query.getUserSid());
} else {
PagerVo<OutInsuranceBusinessVo> p = new PagerVo<>();
return p;
}
} else {
PagerVo<OutInsuranceBusinessVo> p = new PagerVo<>();
return p;
}
if (StringUtils.isNotBlank(query.getDateType())) {
String dateType = query.getDateType();
if (dateType.equals("1")) {
//本日
qw.apply("m.settleTime = CURDATE()");
} else if (dateType.equals("2")) {
//本月
qw.apply("m.settleTime >= date_add(curdate(), interval - day(curdate()) + 1 day) AND m.settleTime <= last_day(curdate())");
} else if (dateType.equals("3")) {
//本年
qw.apply("m.settleTime >= date_sub(curdate(), interval dayofyear(curdate())-1 day) AND m.settleTime <= concat(year(curdate()),'-12-31')");
}
}
//结算时间
qw.apply(StringUtils.isNotBlank(query.getSettleStartTime()), "date_format (m.settleTime,'%Y-%m-%d') >= date_format('" + query.getSettleStartTime() + "','%Y-%m-%d')").
apply(StringUtils.isNotBlank(query.getSettleEndTime()), "date_format (m.settleTime,'%Y-%m-%d') <= date_format('" + query.getSettleEndTime() + "','%Y-%m-%d')"
);
IPage<AsBusrepairBill> page = PagerUtil.queryToPage(pq);
IPage<OutInsuranceBusinessVo> pagging = baseMapper.outInsuranceBusiness(page, qw);
PagerVo<OutInsuranceBusinessVo> p = PagerUtil.pageToVo(pagging, null);
return p;
}
public PagerVo<DebtBusinessVo> debtBusiness(PagerQuery<DebtBusinessQuery> pq) {
DebtBusinessQuery query = pq.getParams();
QueryWrapper<AsBusrepairBill> qw = new QueryWrapper<>();
PrivilegeQuery privilegeQuery = new PrivilegeQuery();
privilegeQuery.setOrgPath(query.getOrgPath());
privilegeQuery.setUserSid(query.getUserSid());
privilegeQuery.setMenuUrl(query.getMenuUrl());
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery);
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) {
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
String orgSidPath = query.getOrgPath();
orgSidPath = orgSidPath + "/";
int i1 = orgSidPath.indexOf("/");
int i2 = orgSidPath.indexOf("/", i1 + 1);
int i3 = orgSidPath.indexOf("/", i2 + 1);
int i4 = orgSidPath.indexOf("/", i3 + 1);
String orgLevelKey = defaultIdReltBean.getData();
if ("1".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i1);
qw.like("m.orgSidPath", orgSidPath);
} else if ("2".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i2);
qw.like("m.orgSidPath", orgSidPath);
} else if ("3".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i3);
qw.like("m.orgSidPath", orgSidPath);
} else if ("4".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i4);
qw.like("m.orgSidPath", orgSidPath);
} else if ("5".equals(orgLevelKey)) {
// qw.eq("a.createBySid", query.getUserSid());
} else {
PagerVo<DebtBusinessVo> p = new PagerVo<>();
return p;
}
} else {
PagerVo<DebtBusinessVo> p = new PagerVo<>();
return p;
}
if (StringUtils.isNotBlank(query.getDateType())) {
String dateType = query.getDateType();
if (dateType.equals("1")) {
//本日
qw.apply("m.settleTime = CURDATE()");
} else if (dateType.equals("2")) {
//本月
qw.apply("m.settleTime >= date_add(curdate(), interval - day(curdate()) + 1 day) AND m.settleTime <= last_day(curdate())");
} else if (dateType.equals("3")) {
//本年
qw.apply("m.settleTime >= date_sub(curdate(), interval dayofyear(curdate())-1 day) AND m.settleTime <= concat(year(curdate()),'-12-31')");
}
}
//结算时间
qw.apply(StringUtils.isNotBlank(query.getSettleStartTime()), "date_format (m.settleTime,'%Y-%m-%d') >= date_format('" + query.getSettleStartTime() + "','%Y-%m-%d')").
apply(StringUtils.isNotBlank(query.getSettleEndTime()), "date_format (m.settleTime,'%Y-%m-%d') <= date_format('" + query.getSettleEndTime() + "','%Y-%m-%d')"
);
IPage<AsBusrepairBill> page = PagerUtil.queryToPage(pq);
IPage<DebtBusinessVo> pagging = baseMapper.debtBusiness(page, qw);
PagerVo<DebtBusinessVo> p = PagerUtil.pageToVo(pagging, null);
return p;
}
}

Loading…
Cancel
Save