Merge pull request 'demand:定制导出性能优化' (#40) from develop into master
Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/40
This commit is contained in:
commit
f46fa4eec8
@ -106,4 +106,13 @@ public interface EmisSettleInvoiceChRecordMapper extends BaseMapper<EmisSettleIn
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteEmisSettleInvoiceChRecordByIds(Long[] ids);
|
public int deleteEmisSettleInvoiceChRecordByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据applySeqNo列表查询额外字段信息
|
||||||
|
*
|
||||||
|
* @param applySeqNoList 申请序号列表
|
||||||
|
* @return 额外字段信息列表
|
||||||
|
*/
|
||||||
|
public List<EmisSettleInvoiceChRecord> selectExtraFieldsByApplySeqNos(
|
||||||
|
@Param("applySeqNoList") List<String> applySeqNoList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,10 +11,7 @@
|
|||||||
package com.xdadan.erp.emis.service.impl;
|
package com.xdadan.erp.emis.service.impl;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -38,6 +35,7 @@ import com.xdadan.erp.emis.service.openbill.hx.HXOrderGoods;
|
|||||||
import com.xdadan.erp.emis.service.openbill.hx.HXOrderInfo;
|
import com.xdadan.erp.emis.service.openbill.hx.HXOrderInfo;
|
||||||
import com.xdadan.erp.emis.service.openbill.hx.HXSdk;
|
import com.xdadan.erp.emis.service.openbill.hx.HXSdk;
|
||||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||||
|
import jodd.util.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -217,14 +215,49 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordListAll(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
|
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordListAll(
|
||||||
|
EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordListAll(emisSettleInvoiceChRecord);
|
if (StringUtil.isNotBlank(emisSettleInvoiceChRecord.getInvoiceNo())) {
|
||||||
|
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper
|
||||||
|
.selectEmisSettleInvoiceChRecordList(emisSettleInvoiceChRecord);
|
||||||
|
setEmisSettleInvoiceChRecords(emisSettleInvoiceChRecords);
|
||||||
|
return emisSettleInvoiceChRecords;
|
||||||
|
}
|
||||||
|
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper
|
||||||
|
.selectEmisSettleInvoiceChRecordListAll(emisSettleInvoiceChRecord);
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
log.info("查询渠道开票记录列表完成, 耗时: {}ms", (endTime - startTime));
|
log.info("查询渠道开票记录列表完成, 耗时: {}ms", (endTime - startTime));
|
||||||
return emisSettleInvoiceChRecords;
|
return emisSettleInvoiceChRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setEmisSettleInvoiceChRecords(List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords) {
|
||||||
|
List<String> applySeqNoList = emisSettleInvoiceChRecords.stream()
|
||||||
|
.map(EmisSettleInvoiceChRecord::getApplySeqNo)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(applySeqNoList)) {
|
||||||
|
List<EmisSettleInvoiceChRecord> extraInfoList = emisSettleInvoiceChRecordMapper
|
||||||
|
.selectExtraFieldsByApplySeqNos(applySeqNoList);
|
||||||
|
|
||||||
|
Map<String, EmisSettleInvoiceChRecord> extraInfoMap = extraInfoList.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
EmisSettleInvoiceChRecord::getApplySeqNo,
|
||||||
|
record -> record,
|
||||||
|
(existing, replacement) -> existing));
|
||||||
|
|
||||||
|
emisSettleInvoiceChRecords.forEach(record -> {
|
||||||
|
EmisSettleInvoiceChRecord extraInfo = extraInfoMap.get(record.getApplySeqNo());
|
||||||
|
if (extraInfo != null) {
|
||||||
|
record.setSendMonth(extraInfo.getSendMonth());
|
||||||
|
record.setSettleType(extraInfo.getSettleType());
|
||||||
|
record.setOpenBillRemark(extraInfo.getOpenBillRemark());
|
||||||
|
record.setPayDays(extraInfo.getPayDays());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkHasSendToHx(String applySeqNo)
|
public int checkHasSendToHx(String applySeqNo)
|
||||||
|
|||||||
@ -705,4 +705,79 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectExtraFieldsByApplySeqNos" resultMap="EmisSettleInvoiceChRecordResult">
|
||||||
|
SELECT
|
||||||
|
a.id,
|
||||||
|
a.apply_seq_no,
|
||||||
|
(
|
||||||
|
SELECT GROUP_CONCAT(DISTINCT CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m')))
|
||||||
|
FROM emis_settle_invoice_ch_record bd
|
||||||
|
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
|
||||||
|
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
|
||||||
|
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
|
||||||
|
) as send_month,
|
||||||
|
(
|
||||||
|
SELECT b.settle_type
|
||||||
|
FROM emis_settle_invoice_ch_record bd
|
||||||
|
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_bill b ON b.settle_bill_no = ibr.settle_bill_no AND b.del_flag = '0'
|
||||||
|
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
|
||||||
|
LIMIT 1
|
||||||
|
) as settle_type,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
CASE
|
||||||
|
WHEN b.settle_type = '2' THEN
|
||||||
|
GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT(
|
||||||
|
CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m ')),
|
||||||
|
b.cust_name
|
||||||
|
) SEPARATOR '-'
|
||||||
|
)
|
||||||
|
ELSE
|
||||||
|
GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT(
|
||||||
|
DATE_FORMAT(w.send_date, '%m%d '),
|
||||||
|
w.send_company
|
||||||
|
) SEPARATOR '-'
|
||||||
|
)
|
||||||
|
END
|
||||||
|
FROM emis_settle_invoice_ch_record bd
|
||||||
|
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
|
||||||
|
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_bill b ON b.settle_bill_no = ibr.settle_bill_no AND b.del_flag = '0'
|
||||||
|
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
|
||||||
|
) as open_bill_remark,
|
||||||
|
(
|
||||||
|
SELECT GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT(
|
||||||
|
DATE_FORMAT(pr.trade_date, '%m/%d'),
|
||||||
|
' 已付(',
|
||||||
|
CASE pr.pay_type
|
||||||
|
WHEN '1' THEN '企业微信收款'
|
||||||
|
WHEN '2' THEN '工行汇款3890'
|
||||||
|
WHEN '3' THEN '微信支付'
|
||||||
|
WHEN '4' THEN '支付宝'
|
||||||
|
WHEN '5' THEN '其他'
|
||||||
|
WHEN '6' THEN '招行付款'
|
||||||
|
ELSE pr.pay_type
|
||||||
|
END,
|
||||||
|
')'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
FROM emis_settle_invoice_ch_record bd
|
||||||
|
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_pay_bill_rel pbr ON ibr.settle_bill_no = pbr.settle_bill_no
|
||||||
|
LEFT JOIN emis_settle_pay_record pr ON pr.pay_id = pbr.pay_id
|
||||||
|
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
|
||||||
|
) as pay_days
|
||||||
|
FROM emis_settle_invoice_ch_record a
|
||||||
|
WHERE a.del_flag = '0'
|
||||||
|
AND a.apply_seq_no IN
|
||||||
|
<foreach collection="applySeqNoList" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user