Browse Source

还款情况统计表

master
fanzongzhe0036 3 months ago
parent
commit
f48385158d
  1. 7
      anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeign.java
  2. 5
      anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeignFallback.java
  3. 3
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.java
  4. 113
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.xml
  5. 11
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryRest.java
  6. 125
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryService.java
  7. 409
      yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml

7
anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeign.java

@ -1,8 +1,6 @@
package com.yxt.anrui.riskcenter.api.loanrepaymenthistory; package com.yxt.anrui.riskcenter.api.loanrepaymenthistory;
import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit;
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterQuery;
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo;
import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo; import com.yxt.common.core.vo.PagerVo;
@ -108,6 +106,11 @@ public interface LoanRepaymentHistoryFeign {
@PostMapping("/repaymentStatistics") @PostMapping("/repaymentStatistics")
public ResultBean<PagerVo<RepaymentStatisticsVo>> repaymentStatistics(@RequestBody PagerQuery<RepaymentStatisticsQuery> pq); public ResultBean<PagerVo<RepaymentStatisticsVo>> repaymentStatistics(@RequestBody PagerQuery<RepaymentStatisticsQuery> pq);
@ApiOperation("客户还款情况统计表不分页")
@PostMapping("/repaymentStatisticsList")
public ResultBean<List<RepaymentStatisticsVo>> repaymentStatisticsList(@RequestBody RepaymentStatisticsQuery pq);
@ApiOperation("客户还款明细查询") @ApiOperation("客户还款明细查询")
@PostMapping("/repaymentDetailsList") @PostMapping("/repaymentDetailsList")
public ResultBean<PagerVo<RepaymentDetailsListVo>> repaymentDetailsList(@RequestBody PagerQuery<RepaymentDetailsListQuery> pq); public ResultBean<PagerVo<RepaymentDetailsListVo>> repaymentDetailsList(@RequestBody PagerQuery<RepaymentDetailsListQuery> pq);

5
anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeignFallback.java

@ -102,6 +102,11 @@ public class LoanRepaymentHistoryFeignFallback implements LoanRepaymentHistoryFe
return null; return null;
} }
@Override
public ResultBean<List<RepaymentStatisticsVo>> repaymentStatisticsList(RepaymentStatisticsQuery pq) {
return null;
}
@Override @Override
public ResultBean<PagerVo<RepaymentDetailsListVo>> repaymentDetailsList(PagerQuery<RepaymentDetailsListQuery> pq) { public ResultBean<PagerVo<RepaymentDetailsListVo>> repaymentDetailsList(PagerQuery<RepaymentDetailsListQuery> pq) {
return null; return null;

3
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.java

@ -9,7 +9,6 @@ import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPayme
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails;
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.AppRepaymentHistoryRecord; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.AppRepaymentHistoryRecord;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -88,4 +87,6 @@ public interface LoanRepaymentHistoryMapper extends BaseMapper<LoanRepaymentHist
List<AppRepaymentHistoryRecord> selSchSidAndVinNo(@Param("scheduleSid") String scheduleSid,@Param("vinNo") String vinNo); List<AppRepaymentHistoryRecord> selSchSidAndVinNo(@Param("scheduleSid") String scheduleSid,@Param("vinNo") String vinNo);
IPage<RepaymentStatisticsVo> repaymentStatistics2(IPage<LoanRepaymentHistory> page, @Param(Constants.WRAPPER)QueryWrapper<LoanRepaymentHistory> qw); IPage<RepaymentStatisticsVo> repaymentStatistics2(IPage<LoanRepaymentHistory> page, @Param(Constants.WRAPPER)QueryWrapper<LoanRepaymentHistory> qw);
List<RepaymentStatisticsVo> repaymentStatisticsList(@Param(Constants.WRAPPER)QueryWrapper<LoanRepaymentHistory> qw);
} }

113
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.xml

@ -1008,4 +1008,117 @@
${ew.sqlSegment} ${ew.sqlSegment}
</where> </where>
</select> </select>
<select id="repaymentStatisticsList"
resultType="com.yxt.anrui.riskcenter.api.loanrepaymenthistory.RepaymentStatisticsVo">
SELECT * FROM
(SELECT
c.*,
CASE
WHEN c.dueDate > c.updateDate or c.updateDate IS NULL THEN '1'
WHEN c.dueDate &lt;= c.updateDate AND (c.outstandingMoney + IFNULL(c.fund,0) + IFNULL(c.bankBeInter,0)) > 0 THEN '0'
WHEN c.dueDate &lt;= c.updateDate AND (c.outstandingMoney + IFNULL(c.fund,0) + IFNULL(c.bankBeInter,0)) &lt;= 0 THEN '1'
END AS nowOverdue
FROM
(
SELECT
b.*,
(
SELECT
( fjj.reveivableMoney - fjj.m )
FROM
(
SELECT
IFNULL((
SELECT
SUM( subscriptionMoney )
FROM
anrui_fin.fin_selected_receivables_detailed AS s
WHERE
s.auditState = '3'
AND s.receivablesSid = fj.sid
),
0
) AS m,
fj.*
FROM
( SELECT j.busSid, j.sid, j.reveivableMoney FROM anrui_fin.fin_uncollected_receivables_detailed_jr AS j WHERE j.payCostTitleKey = '006' ) AS fj
) AS fjj
WHERE
fjj.busSid = b.sid
) AS fund
FROM
(
SELECT
pd.busVinSid,
pd.dueDate,
pd.createBySid,
pd.orgSidPath,
pd.sid,
pd.useOrgName,
pd.dept,
pd.bankName,
pd.staffName,
pd.loanContractNo,
pd.vinNo,
pd.bankContractNo,
pd.customer,
pd.borrowerName,
pd.period,
pd.paymentMoney,
pd.paymentInterest AS bankBeInter,
pd.dueMoney,
t.repaidMoney,
t.outstandingMoney,
pd.overdue AS dueOverdue,
pd.updateTime AS updateDate,
CASE
WHEN t.repaidMoney = 0 THEN
'01'
WHEN t.repaidMoney > 0
AND t.repaidMoney &lt; pd.dueMoney THEN '02' WHEN t.repaidMoney > 0
AND t.repaidMoney &lt;= pd.dueMoney THEN
'03'
END AS returnState
FROM
loan_repayment_plan_details AS pd
LEFT JOIN (
SELECT
p.sid,
IFNULL((
SELECT
SUM(
IFNULL( h.actualMoney, 0 ))
FROM
loan_repayment_history AS h
WHERE
h.planDetailSid = p.sid
AND h.updateState = '1'
),
0
) AS repaidMoney,
IFNULL(
(
p.dueMoney - IFNULL((
SELECT
SUM(
IFNULL( h.actualMoney, 0 ))
FROM
loan_repayment_history AS h
WHERE
h.planDetailSid = p.sid
AND h.updateState = '1'
),
0
)),
0
) AS outstandingMoney
FROM
loan_repayment_plan_details AS p
) AS t ON pd.sid = t.sid
) AS b
) c ) a
<where>
${ew.sqlSegment}
</where>
</select>
</mapper> </mapper>

11
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryRest.java

@ -1,16 +1,12 @@
package com.yxt.anrui.riskcenter.biz.loanrepaymenthistory; package com.yxt.anrui.riskcenter.biz.loanrepaymenthistory;
import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempExportVo;
import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit;
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPaymentExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsDto;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsFeign;
import com.yxt.common.base.utils.ExportExcelUtils; import com.yxt.common.base.utils.ExportExcelUtils;
import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.result.ResultBean;
@ -157,6 +153,13 @@ public class LoanRepaymentHistoryRest implements LoanRepaymentHistoryFeign {
return rb.success().setData(pv); return rb.success().setData(pv);
} }
@Override
public ResultBean<List<RepaymentStatisticsVo>> repaymentStatisticsList(RepaymentStatisticsQuery pq) {
ResultBean<List<RepaymentStatisticsVo>> rb = ResultBean.fireFail();
List<RepaymentStatisticsVo> list = loanRepaymentHistoryService.repaymentStatisticsList(pq);
return rb.success().setData(list);
}
@Override @Override
public ResultBean<PagerVo<RepaymentDetailsListVo>> repaymentDetailsList(PagerQuery<RepaymentDetailsListQuery> pq) { public ResultBean<PagerVo<RepaymentDetailsListVo>> repaymentDetailsList(PagerQuery<RepaymentDetailsListQuery> pq) {
ResultBean<PagerVo<RepaymentDetailsListVo>> rb = ResultBean.fireFail(); ResultBean<PagerVo<RepaymentDetailsListVo>> rb = ResultBean.fireFail();

125
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryService.java

@ -2,12 +2,8 @@ package com.yxt.anrui.riskcenter.biz.loanrepaymenthistory;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.math.Money;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.yxt.anrui.base.api.basemodelmodprice.BaseModelModpriceImportReturn;
import com.yxt.anrui.base.api.basemodelmodprice.BaseModelModpriceImportVo;
import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemDetailsVo; import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemDetailsVo;
import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemFeign; import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemFeign;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder; import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder;
@ -16,10 +12,6 @@ import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerDe
import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerFeign; import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerFeign;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign;
import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTemp;
import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempExportVo;
import com.yxt.anrui.fin.api.finmanufacturerbank.FinManufacturerBank;
import com.yxt.anrui.fin.api.finpaymentrecord.FinPaymentrecordDto;
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJR; import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJR;
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJRFeign; import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJRFeign;
import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign; import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign;
@ -28,31 +20,21 @@ import com.yxt.anrui.fin.api.kingdee.voucher.GeneralVoucher;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgVo;
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery;
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; import com.yxt.anrui.portal.api.sysuser.SysUserFeign;
import com.yxt.anrui.portal.api.sysuser.SysUserVo;
import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit;
import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleHistoryRecord; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleHistoryRecord;
import com.yxt.anrui.riskcenter.api.loanfinbank.LoanFinBank; import com.yxt.anrui.riskcenter.api.loanfinbank.LoanFinBank;
import com.yxt.anrui.riskcenter.api.loanmonthlyaccrualapply.LoanMonthlyAccrualApply;
import com.yxt.anrui.riskcenter.api.loanmonthlyaccrualrecord.LoanMonthlyAccrualRecord;
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameter;
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterQuery;
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPaymentExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo;
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.utils.CollectorsUtil; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.utils.CollectorsUtil;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.CheckPayStateVo;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanPlanDetailsVoForLateVoucher; import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanPlanDetailsVoForLateVoucher;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails;
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsDto;
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.AppRepaymentHistoryRecord; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.AppRepaymentHistoryRecord;
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentSchedule; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentSchedule;
import com.yxt.anrui.riskcenter.api.loantransferpaymentrecord.LoanTransferPaymentRecord;
import com.yxt.anrui.riskcenter.biz.loanfinbank.LoanFinBankService; import com.yxt.anrui.riskcenter.biz.loanfinbank.LoanFinBankService;
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService;
import com.yxt.anrui.riskcenter.biz.loanrepaymentschedule.LoanRepaymentScheduleService; import com.yxt.anrui.riskcenter.biz.loanrepaymentschedule.LoanRepaymentScheduleService;
@ -61,7 +43,6 @@ import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo; import com.yxt.common.core.vo.PagerVo;
import com.yxt.messagecenter.api.messageurgeList.MessageUrgeListVo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
@ -85,11 +66,9 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.*;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -1501,6 +1480,108 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen
return p; return p;
} }
public List<RepaymentStatisticsVo> repaymentStatisticsList(RepaymentStatisticsQuery pagerQuery) {
QueryWrapper<LoanRepaymentHistory> qw = new QueryWrapper<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//=======================
PrivilegeQuery privilegeQuery = new PrivilegeQuery();
privilegeQuery.setOrgPath(pagerQuery.getOrgPath());
privilegeQuery.setMenuSid(pagerQuery.getMenuSid());
privilegeQuery.setMenuUrl(pagerQuery.getMenuUrl());
privilegeQuery.setUserSid(pagerQuery.getUserSid());
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery);
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) {
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
String orgSidPath = pagerQuery.getOrgPath();
orgSidPath = orgSidPath + "/";
System.out.println(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("a.orgSidPath", orgSidPath);
} else if ("2".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i2);
qw.like("a.orgSidPath", orgSidPath);
} else if ("3".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i3);
qw.like("a.orgSidPath", orgSidPath);
} else if ("4".equals(orgLevelKey)) {
orgSidPath = orgSidPath.substring(0, i4);
qw.like("a.orgSidPath", orgSidPath);
} else if ("5".equals(orgLevelKey)) {
qw.eq("a.createBySid", pagerQuery.getUserSid());
} else {
List<RepaymentStatisticsVo> p = new ArrayList<>();
return p;
}
} else {
List<RepaymentStatisticsVo> p = new ArrayList<>();
return p;
}
//=======================
if (StringUtils.isNotBlank(pagerQuery.getUseOrgName())) {
qw.like("a.useOrgName", pagerQuery.getUseOrgName());
}
if (StringUtils.isNotBlank(pagerQuery.getVinNo())) {
qw.like("a.vinNo", pagerQuery.getVinNo());
}
if (StringUtils.isNotBlank(pagerQuery.getDept())) {
qw.like("a.dept", pagerQuery.getDept());
}
if (StringUtils.isNotBlank(pagerQuery.getReturnState())) {
qw.eq("a.returnState", pagerQuery.getReturnState());
}
if (StringUtils.isNotBlank(pagerQuery.getStaffName())) {
qw.like("a.staffName", pagerQuery.getStaffName());
}
if (StringUtils.isNotBlank(pagerQuery.getLoanContractNo())) {
qw.like("a.loanContractNo", pagerQuery.getLoanContractNo());
}
if (StringUtils.isNotBlank(pagerQuery.getPeriod())) {
qw.eq("a.period", pagerQuery.getPeriod());
}
if (StringUtils.isNotBlank(pagerQuery.getBankName())) {
qw.like("a.bankName", pagerQuery.getBankName());
}
if (StringUtils.isNotBlank(pagerQuery.getBankContractNo())) {
qw.like("a.bankContractNo", pagerQuery.getBankContractNo());
}
if (StringUtils.isNotBlank(pagerQuery.getCustomer())) {
qw.like("a.customer", pagerQuery.getCustomer());
}
if (StringUtils.isNotBlank(pagerQuery.getBorrowerName())) {
qw.like("a.borrowerName", pagerQuery.getBorrowerName());
}
if (StringUtils.isNotBlank(pagerQuery.getDueOverdue())) {
qw.eq("a.dueOverdue", pagerQuery.getDueOverdue());
}
if (StringUtils.isNotBlank(pagerQuery.getNowOverdue())) {
qw.eq("a.nowOverdue", pagerQuery.getNowOverdue());
}
String dueStartDate = pagerQuery.getDueStartDate();
String dueEndDate = pagerQuery.getDueEndDate();
qw.apply(StringUtils.isNotEmpty(dueStartDate), "date_format (a.dueDate,'%Y-%m-%d') >= date_format('" + dueStartDate + "','%Y-%m-%d')").
apply(StringUtils.isNotEmpty(dueEndDate), "date_format (a.dueDate,'%Y-%m-%d') <= date_format('" + dueEndDate + "','%Y-%m-%d')"
);
String updateStartDate = pagerQuery.getUpdateStartDate();
String updateEndDate = pagerQuery.getUpdateEndDate();
qw.apply(StringUtils.isNotEmpty(updateStartDate), "date_format (a.updateDate,'%Y-%m-%d') >= date_format('" + updateStartDate + "','%Y-%m-%d')").
apply(StringUtils.isNotEmpty(updateEndDate), "date_format (a.updateDate,'%Y-%m-%d') <= date_format('" + updateEndDate + "','%Y-%m-%d')"
);
qw.orderBy(true, true, "a.useOrgName")
.orderBy(true, true, "a.vinNo")
.orderBy(true, true, "a.period")
.orderBy(true, true, "a.loanContractNo")
;
List<RepaymentStatisticsVo> p = baseMapper.repaymentStatisticsList(qw);
return p;
}
/** /**
* 分页方法 * 分页方法
*/ */
@ -2339,4 +2420,6 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen
public List<AppRepaymentHistoryRecord> selSchSidAndVinNo(String scheduleSid, String vinNo) { public List<AppRepaymentHistoryRecord> selSchSidAndVinNo(String scheduleSid, String vinNo) {
return baseMapper.selSchSidAndVinNo(scheduleSid, vinNo); return baseMapper.selSchSidAndVinNo(scheduleSid, vinNo);
} }
} }

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

@ -61,43 +61,6 @@
</select> </select>
<select id="pageBillList" resultType="com.yxt.anrui.as.api.asbusrepairbill.AsBusrepairPageVo"> <select id="pageBillList" resultType="com.yxt.anrui.as.api.asbusrepairbill.AsBusrepairPageVo">
SELECT
wor.billNo AS sid,
a.sid AS billSid,
a.nodeName AS taskName,
wor.billNo,
DATE_FORMAT(a.createTime, '%Y-%m-%d') AS billTime,
a.customerName,
av.vinNo,
av.vehMark,
wor.shortss,
wor.photos AS photoss
FROM
yxt_wms.wms_old_register wor
LEFT JOIN as_busrepair_bill a
ON a.billNo = wor.billNo
LEFT JOIN as_busrepair_bill_vech av
ON a.sid = av.billSid
LEFT JOIN as_busrepair_inventorybill ai
ON ai.sourceBillSid = a.sid
LEFT JOIN as_busrepair_inventorybill_detail ad
ON ai.sid = ad.billSid
LEFT JOIN anrui_portal.sys_organization AS s
ON a.deptSid = s.sid
<where>
${ew.sqlSegment}
AND (a.nodeCode = 3 or a.nodeCode = 5)
</where>
AND (SELECT
COUNT(*)
FROM
as_busrepair_inventorybill_detail ad
WHERE (
ad.oldInventorySid IS NULL
OR ad.oldInventorySid = ''
)
AND ad.`billSid` = ai.sid) > 0
UNION ALL
SELECT SELECT
a.billNo AS sid, a.billNo AS sid,
a.sid AS billSid, a.sid AS billSid,
@ -110,18 +73,80 @@
wor.shortss, wor.shortss,
wor.photos AS photoss wor.photos AS photoss
FROM FROM
as_busrepair_bill_vech av as_busrepair_bill a
LEFT JOIN as_busrepair_bill a LEFT JOIN as_busrepair_bill_vech av ON a.sid = av.billSid
ON a.sid = av.billSid LEFT JOIN as_busrepair_inventorybill ib ON a.sid = ib.sourceBillSid
LEFT JOIN yxt_wms.wms_old_register wor LEFT JOIN as_busrepair_inventorybill_detail id ON ib.sid = id.billSid
ON a.billNo = wor.billNo LEFT JOIN yxt_wms.wms_old_register wor ON a.billNo = wor.billNo
LEFT JOIN anrui_portal.sys_organization AS s LEFT JOIN anrui_portal.sys_organization AS s ON a.deptSid = s.sid
ON a.deptSid = s.sid
<where> <where>
${ew.sqlSegment} ${ew.sqlSegment}
AND a.nodeCode = 3 AND (a.nodeCode = 3 OR a.nodeCode = 5) AND (id.oldIsInInventory = 0 OR id.oldIsInInventory = '' OR
id.oldIsInInventory IS NULL)
</where> </where>
GROUP BY a.sid GROUP BY
a.sid
<!-- SELECT-->
<!-- wor.billNo AS sid,-->
<!-- a.sid AS billSid,-->
<!-- a.nodeName AS taskName,-->
<!-- wor.billNo,-->
<!-- DATE_FORMAT(a.createTime, '%Y-%m-%d') AS billTime,-->
<!-- a.customerName,-->
<!-- av.vinNo,-->
<!-- av.vehMark,-->
<!-- wor.shortss,-->
<!-- wor.photos AS photoss-->
<!-- FROM-->
<!-- yxt_wms.wms_old_register wor-->
<!-- LEFT JOIN as_busrepair_bill a-->
<!-- ON a.billNo = wor.billNo-->
<!-- LEFT JOIN as_busrepair_bill_vech av-->
<!-- ON a.sid = av.billSid-->
<!-- LEFT JOIN as_busrepair_inventorybill ai-->
<!-- ON ai.sourceBillSid = a.sid-->
<!-- LEFT JOIN as_busrepair_inventorybill_detail ad-->
<!-- ON ai.sid = ad.billSid-->
<!-- LEFT JOIN anrui_portal.sys_organization AS s-->
<!-- ON a.deptSid = s.sid-->
<!-- <where>-->
<!-- ${ew.sqlSegment}-->
<!-- AND (a.nodeCode = 3 or a.nodeCode = 5)-->
<!-- </where>-->
<!-- AND (SELECT-->
<!-- COUNT(*)-->
<!-- FROM-->
<!-- as_busrepair_inventorybill_detail ad-->
<!-- WHERE (-->
<!-- ad.oldInventorySid IS NULL-->
<!-- OR ad.oldInventorySid = ''-->
<!-- )-->
<!-- AND ad.`billSid` = ai.sid) > 0-->
<!-- UNION ALL-->
<!-- SELECT-->
<!-- a.billNo AS sid,-->
<!-- a.sid AS billSid,-->
<!-- a.nodeName AS taskName,-->
<!-- a.billNo,-->
<!-- DATE_FORMAT(a.createTime, '%Y-%m-%d') AS billTime,-->
<!-- a.customerName,-->
<!-- av.vinNo,-->
<!-- av.vehMark ,-->
<!-- wor.shortss,-->
<!-- wor.photos AS photoss-->
<!-- FROM-->
<!-- as_busrepair_bill_vech av-->
<!-- LEFT JOIN as_busrepair_bill a-->
<!-- ON a.sid = av.billSid-->
<!-- LEFT JOIN yxt_wms.wms_old_register wor-->
<!-- ON a.billNo = wor.billNo-->
<!-- LEFT JOIN anrui_portal.sys_organization AS s-->
<!-- ON a.deptSid = s.sid-->
<!-- <where>-->
<!-- ${ew.sqlSegment}-->
<!-- AND a.nodeCode = 3-->
<!-- </where>-->
<!-- GROUP BY a.sid-->
</select> </select>
<select id="selectByBillNo" resultType="com.yxt.anrui.as.api.asbusrepairbill.AsBusrepairPageVo"> <select id="selectByBillNo" resultType="com.yxt.anrui.as.api.asbusrepairbill.AsBusrepairPageVo">
@ -244,15 +269,16 @@
</select> </select>
<select id="getToDoNum" resultType="java.lang.Integer"> <select id="getToDoNum" resultType="java.lang.Integer">
SELECT COUNT(a.sid) FROM SELECT COUNT(a.sid)
(SELECT FROM (SELECT b.sid
b.sid FROM as_busrepair_inventorybill_detail AS d
FROM
as_busrepair_inventorybill_detail AS d
LEFT JOIN as_busrepair_inventorybill as i ON d.billSid = i.sid LEFT JOIN as_busrepair_inventorybill as i ON d.billSid = i.sid
LEFT JOIN as_busrepair_bill as b ON i.sourceBillSid = b.sid LEFT JOIN as_busrepair_bill as b ON i.sourceBillSid = b.sid
LEFT JOIN as_busrepair_bill_vech as v ON v.billSid = b.sid LEFT JOIN as_busrepair_bill_vech as v ON v.billSid = b.sid
where d.operUserSid = #{userSid} and d.state = 1 and d.isEnable = 1 and d.currentCount > 0 where d.operUserSid = #{userSid}
and d.state = 1
and d.isEnable = 1
and d.currentCount > 0
GROUP BY i.sourceBillSid) as a GROUP BY i.sourceBillSid) as a
</select> </select>
<select id="selGoodsReceiveByBillSid" <select id="selGoodsReceiveByBillSid"
@ -323,33 +349,28 @@
</select> </select>
<select id="getToDoNum2" resultType="java.lang.Integer"> <select id="getToDoNum2" resultType="java.lang.Integer">
SELECT COUNT(*) FROM SELECT COUNT(*)
(SELECT FROM (SELECT j.*,
j.*,
IF(j.totalCount = j.count, true, false) as isCanSubmit, IF(j.totalCount = j.count, true, false) as isCanSubmit,
concat(j.count, '/', j.totalCount) confrimInfo concat(j.count, '/', j.totalCount) confrimInfo
FROM FROM (
SELECT a.*,
( (
SELECT SELECT COUNT(*)
a.*, FROM as_busrepair_inventorybill_detail AS d
(
SELECT
COUNT(*)
FROM
as_busrepair_inventorybill_detail AS d
LEFT JOIN as_busrepair_inventorybill AS i ON d.billSid = i.sid LEFT JOIN as_busrepair_inventorybill AS i ON d.billSid = i.sid
WHERE WHERE i.sourceBillSid = a.sid
i.sourceBillSid = a.sid AND d.isEnable = 1 and d.currentCount > 0 AND d.isEnable = 1
and d.currentCount > 0
) totalCount, ) totalCount,
( (
SELECT SELECT COUNT(*)
COUNT(*) FROM as_busrepair_inventorybill_detail AS d
FROM
as_busrepair_inventorybill_detail AS d
LEFT JOIN as_busrepair_inventorybill AS i ON d.billSid = i.sid LEFT JOIN as_busrepair_inventorybill AS i ON d.billSid = i.sid
WHERE WHERE i.sourceBillSid = a.sid
i.sourceBillSid = a.sid AND d.state = 2
AND d.state = 2 AND d.isEnable = 1 and d.currentCount > 0 AND d.isEnable = 1
and d.currentCount > 0
) AS count ) AS count
FROM FROM
( (
@ -371,8 +392,7 @@
b.sid b.sid
) a ) a
) AS j ) AS j
WHERE WHERE totalCount != 0) as mm
totalCount != 0) as mm
WHERE mm.isCanSubmit = 1 WHERE mm.isCanSubmit = 1
</select> </select>
@ -386,7 +406,9 @@
(d.state = 2, TRUE, FALSE) AS state (d.state = 2, TRUE, FALSE) AS state
FROM as_busrepair_inventorybill_detail AS d FROM as_busrepair_inventorybill_detail AS d
LEFT JOIN as_busrepair_inventorybill AS i ON d.billSid = i.sid LEFT JOIN as_busrepair_inventorybill AS i ON d.billSid = i.sid
where i.sourceBillSid = #{sid} and d.isEnable = 1 and d.currentCount > 0 where i.sourceBillSid = #{sid}
and d.isEnable = 1
and d.currentCount > 0
</select> </select>
<select id="appRepairs" resultType="com.yxt.anrui.as.api.asbusrepairbill.app.AppBusrepairBillVo"> <select id="appRepairs" resultType="com.yxt.anrui.as.api.asbusrepairbill.app.AppBusrepairBillVo">
SELECT SELECT
@ -436,10 +458,21 @@
d.manufacturerName, d.manufacturerName,
date_format ( a.createTime, '%Y-%m-%d' ) createTime, date_format ( a.createTime, '%Y-%m-%d' ) createTime,
date_format ( a.settleTime, '%Y-%m-%d' ) settleTime, date_format ( a.settleTime, '%Y-%m-%d' ) settleTime,
(IFNULL(SUM(d.count),0) - (SELECT IFNULL(SUM(de.count),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as num, (IFNULL(SUM(d.count),0) - (SELECT IFNULL(SUM(de.count),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN
(IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as discountAmount, as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
(IFNULL(SUM(d.costTotal),0) - (SELECT IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as costTotal, be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as num,
((IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) - (IFNULL(SUM(d.costTotal),0) - (SELECT IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) ) as profit (IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT
JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as discountAmount,
(IFNULL(SUM(d.costTotal),0) - (SELECT IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de
LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as costTotal,
((IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT
JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) - (IFNULL(SUM(d.costTotal),0) - (SELECT
IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as
be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey =
'1') ) ) as profit
FROM FROM
as_busrepair_inventorybill_detail AS d as_busrepair_inventorybill_detail AS d
LEFT JOIN as_busrepair_inventorybill AS b ON d.billSid = b.sid LEFT JOIN as_busrepair_inventorybill AS b ON d.billSid = b.sid
@ -447,7 +480,8 @@
LEFT JOIN yxt_wms.wms_inventory AS i ON d.inventorySid = i.sid LEFT JOIN yxt_wms.wms_inventory AS i ON d.inventorySid = i.sid
WHERE b.busTypeKey = '0' WHERE b.busTypeKey = '0'
GROUP BY GROUP BY
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 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 UNION ALL
SELECT SELECT
a.orgSidPath, a.orgSidPath,
@ -470,7 +504,8 @@
(IFNULL(SUM(s.amount),0) - IFNULL(SUM(s.costTotal),0)) as profit (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 FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as a ON s.billSid = a.sid
GROUP BY GROUP BY
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 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 UNION ALL
SELECT SELECT
a.orgSidPath, a.orgSidPath,
@ -493,7 +528,8 @@
(IFNULL(SUM(s.price),0) - IFNULL(SUM(s.costTotal),0)) as profit (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 FROM as_busrepair_bill_aitem as s LEFT JOIN as_busrepair_bill as a ON s.billSid = a.sid
GROUP BY GROUP BY
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 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 UNION ALL
SELECT SELECT
a.orgSidPath, a.orgSidPath,
@ -516,7 +552,8 @@
(IFNULL(SUM(s.price),0) - IFNULL(SUM(s.costTotal),0)) as profit (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 FROM as_busrepair_bill_aitemspec as s LEFT JOIN as_busrepair_bill as a ON s.billSid = a.sid
GROUP BY GROUP BY
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 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 UNION ALL
SELECT SELECT
s.orgSidPath, s.orgSidPath,
@ -543,7 +580,8 @@
LEFT JOIN yxt_sms.sms_sales_bill AS a ON d.billSid = a.sid 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 LEFT JOIN anrui_portal.sys_organization AS s ON a.deptSid = s.sid
GROUP BY GROUP BY
a.sid,date_format ( a.createTime, '%Y-%m-%d' ),date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid,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> <where>
${ew.sqlSegment} ${ew.sqlSegment}
</where> </where>
@ -564,12 +602,23 @@
d.supplierName, d.supplierName,
d.manufacturerName, d.manufacturerName,
d.price, d.price,
(IFNULL(SUM(d.count),0) - (SELECT IFNULL(SUM(de.count),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as num, (IFNULL(SUM(d.count),0) - (SELECT IFNULL(SUM(de.count),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN
as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as num,
d.discount, d.discount,
(IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as discountAmount, (IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT
JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as discountAmount,
d.cost, d.cost,
(IFNULL(SUM(d.costTotal),0) - (SELECT IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as costTotal, (IFNULL(SUM(d.costTotal),0) - (SELECT IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de
((IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) - (IFNULL(SUM(d.costTotal),0) - (SELECT IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) ) as profit, LEFT JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) as costTotal,
((IFNULL(SUM(d.amount),0) - (SELECT IFNULL(SUM(de.amount),0) FROM as_busrepair_inventorybill_detail as de LEFT
JOIN as_busrepair_inventorybill as be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND
be.sourceBillSid = a.sid AND b.busTypeKey = '1') ) - (IFNULL(SUM(d.costTotal),0) - (SELECT
IFNULL(SUM(de.costTotal),0) FROM as_busrepair_inventorybill_detail as de LEFT JOIN as_busrepair_inventorybill as
be ON de.billSid = be.sid WHERE de.inventorySid = d.inventorySid AND be.sourceBillSid = a.sid AND b.busTypeKey =
'1') ) ) as profit,
a.billNo, a.billNo,
date_format ( a.createTime, '%Y-%m-%d' ) createTime, date_format ( a.createTime, '%Y-%m-%d' ) createTime,
a.dispatchTime, a.dispatchTime,
@ -615,7 +664,8 @@
a.finishTime, a.finishTime,
date_format ( a.settleTime, '%Y-%m-%d' ) settleTime, date_format ( a.settleTime, '%Y-%m-%d' ) settleTime,
a.waitorName, a.waitorName,
(SELECT GROUP_CONCAT( r.repairerName SEPARATOR ',' ) FROM as_busrepair_bill_sitem_repairer as r WHERE r.billSid = a.sid and r.repairitemSid = d.serviceItemSid) as repairerName, (SELECT GROUP_CONCAT( r.repairerName SEPARATOR ',' ) FROM as_busrepair_bill_sitem_repairer as r WHERE r.billSid
= a.sid and r.repairitemSid = d.serviceItemSid) as repairerName,
a.customerName, a.customerName,
v.vinNo, v.vinNo,
v.vehMark, v.vehMark,
@ -655,7 +705,8 @@
v.vinNo, v.vinNo,
v.vehMark, v.vehMark,
v.vehModel v.vehModel
FROM as_busrepair_bill_aitem as d LEFT JOIN as_busrepair_bill as a ON d.billSid = a.sid LEFT JOIN as_busrepair_bill_vech as v ON v.billSid = a.sid FROM as_busrepair_bill_aitem as d LEFT JOIN as_busrepair_bill as a ON d.billSid = a.sid LEFT JOIN
as_busrepair_bill_vech as v ON v.billSid = a.sid
UNION ALL UNION ALL
SELECT SELECT
a.orgSidPath, a.orgSidPath,
@ -688,7 +739,8 @@
v.vinNo, v.vinNo,
v.vehMark, v.vehMark,
v.vehModel v.vehModel
FROM as_busrepair_bill_aitemspec as d LEFT JOIN as_busrepair_bill as a ON d.billSid = a.sid LEFT JOIN as_busrepair_bill_vech as v ON v.billSid = a.sid FROM as_busrepair_bill_aitemspec as d LEFT JOIN as_busrepair_bill as a ON d.billSid = a.sid LEFT JOIN
as_busrepair_bill_vech as v ON v.billSid = a.sid
UNION ALL UNION ALL
SELECT SELECT
s.orgSidPath, s.orgSidPath,
@ -736,7 +788,8 @@
(SELECT n.*, (SELECT n.*,
(n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) turnover, (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) turnover,
(n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) cost, (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.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) - (n.hourAmountCost +
n.goodsAmountCost + n.otherAmountCost)) grossProfit,
(n.packsHourAmount + n.packsGoodsAmount + n.packsOtherAmount) packsReceivable, (n.packsHourAmount + n.packsGoodsAmount + n.packsOtherAmount) packsReceivable,
(n.outHourAmount + n.outGoodsAmount + n.outOtherAmount) outReceivable (n.outHourAmount + n.outGoodsAmount + n.outOtherAmount) outReceivable
FROM FROM
@ -746,26 +799,65 @@
a.`useOrgName`, a.`useOrgName`,
COUNT(*) billNum, COUNT(*) billNum,
IFNULL(SUM(IFNULL(hourAmount,0)),0) hourAmount, 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, (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(addAmount,0)),0) otherAmount,
(IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount, (IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),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) as backAmount, 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 (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) as hourAmountCost, as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid =
( (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, b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime,
((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 '%Y-%m-%d' ) and ab.busTypeKey = 1) as backAmount,
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 (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as b
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ))) otherAmountCost, 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 (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, b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )
( (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, and b.`subject` = '保内') as packsHourAmount,
(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 ( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN
b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保内') as packsOtherAmount, 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 (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, b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )
( (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, and b.`subject` = '保外') as outHourAmount,
(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 ( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN
b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保外') as outOtherAmount, 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 date_format ( a.settleTime, '%Y-%m-%d' ) settleTime
FROM FROM
as_busrepair_bill AS a as_busrepair_bill AS a
@ -783,7 +875,8 @@
(SELECT n.*, (SELECT n.*,
(n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount, (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount,
(n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) totalCost, (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) totalCost,
( (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost))profit ( (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost +
n.otherAmountCost))profit
FROM FROM
(SELECT (SELECT
a.billType, a.billType,
@ -792,15 +885,34 @@
a.`useOrgName`, a.`useOrgName`,
COUNT(*) billNum, COUNT(*) billNum,
IFNULL(SUM(IFNULL(hourAmount,0)),0) hourAmount, 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, ( (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(addAmount,0)),0) otherAmount,
(IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount, (IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) +
(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 IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount,
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(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as b
( (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, ON s.billSid = b.sid WHERE
((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' ))
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 as hourAmountCost,
b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ))) otherAmountCost, ( (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 date_format ( a.settleTime, '%Y-%m-%d' ) settleTime
FROM FROM
as_busrepair_bill AS a as_busrepair_bill AS a
@ -845,15 +957,26 @@
a.settleTime, a.settleTime,
a.deptSid, a.deptSid,
'1' billCount, '1' billCount,
((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE d.contractSid = a.sid) ((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE
- (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 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, = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid)) noMoney,
IFNULL(a.hourAmount,0) hourAmount, 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, ((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.addAmount,0) otherAmount,
IFNULL(a.outAmount,0) + IFNULL(a.subsidyAmount,0) + IFNULL(a.rescueAmount,0) addAmount, 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(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s WHERE s.billSid = a.sid) as
((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 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 FROM
as_busrepair_bill AS a as_busrepair_bill AS a
LEFT JOIN as_arrearsout_apply as sa ON a.sid = sa.pairBillSid LEFT JOIN as_arrearsout_apply as sa ON a.sid = sa.pairBillSid
@ -869,7 +992,8 @@
(SELECT n.*, (SELECT n.*,
(n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount, (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount,
(n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) costTotal, (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) costTotal,
((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost)) profit, ((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost +
n.otherAmountCost)) profit,
IF(n.debt > 0, ( DATEDIFF( NOW(), n.paymentDate )), '0') overDueDays IF(n.debt > 0, ( DATEDIFF( NOW(), n.paymentDate )), '0') overDueDays
FROM FROM
(SELECT (SELECT
@ -887,16 +1011,30 @@
v.vehMark, v.vehMark,
v.vinNo, v.vinNo,
IFNULL(a.hourAmount,0) hourAmount, 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, ((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.addAmount,0) otherAmount,
IFNULL(a.outAmount,0) + IFNULL(a.subsidyAmount,0) + IFNULL(a.rescueAmount,0) addAmount, 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(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s WHERE s.billSid = a.sid) as
((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, hourAmountCost,
((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s WHERE s.billSid = a.sid) + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s WHERE s.billSid = a.sid)) otherAmountCost, ((SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN
(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 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,
((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s WHERE s.billSid = a.sid) +
(SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s WHERE s.billSid = a.sid))
otherAmountCost,
(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) receivedAmount, = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid) receivedAmount,
((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE d.contractSid = a.sid) ((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE
- (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 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)) debt, = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid)) debt,
date_format (aa.promisePaymentDate,'%Y-%m-%d') paymentDate, date_format (aa.promisePaymentDate,'%Y-%m-%d') paymentDate,
a.dockingPeople, a.dockingPeople,
@ -910,14 +1048,11 @@
</where> </where>
</select> </select>
<select id="selOldIsInInventoryCount" resultType="java.lang.Integer"> <select id="selOldIsInInventoryCount" resultType="java.lang.Integer">
SELECT SELECT count(*)
count(*) FROM as_busrepair_inventorybill_detail AS d
FROM
as_busrepair_inventorybill_detail AS d
LEFT JOIN as_busrepair_inventorybill AS b ON d.billSid = b.sid LEFT JOIN as_busrepair_inventorybill AS b ON d.billSid = b.sid
LEFT JOIN as_busrepair_bill AS a ON b.sourceBillSid = a.sid LEFT JOIN as_busrepair_bill AS a ON b.sourceBillSid = a.sid
WHERE WHERE a.sid = #{sid}
a.sid = #{sid}
AND d.isEnable = 1 AND d.isEnable = 1
AND d.currentCount > 0 AND d.currentCount > 0
AND (d.oldIsInInventory != 1 OR d.oldIsInInventory IS NULL OR d.oldIsInInventory = '') AND (d.oldIsInInventory != 1 OR d.oldIsInInventory IS NULL OR d.oldIsInInventory = '')

Loading…
Cancel
Save