|
@@ -1,14 +1,22 @@
|
|
|
package com.rongwei.zhsw.system.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.rongwe.zhsw.system.domain.SwBillManagementPaidDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwBillingRecordDo;
|
|
|
+import com.rongwe.zhsw.system.domain.SwPrintRepairConfigDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwUserManagementDo;
|
|
|
import com.rongwe.zhsw.system.vo.PrintReceiptVo;
|
|
|
+import com.rongwei.rwadmincommon.system.dao.SysDictDao;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysDictDo;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
+import com.rongwei.zhsw.system.dao.SwPrintRepairConfigDao;
|
|
|
import com.rongwei.zhsw.system.service.PrintService;
|
|
|
+import com.rongwei.zhsw.system.utils.NumberToChineseUppercaseUtils;
|
|
|
+import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -22,6 +30,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.rongwei.zhsw.system.utils.SaveConstans.billReccord.FULLREFUNDSTATUS;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* PrintServiceImpl class
|
|
|
*
|
|
@@ -37,6 +46,11 @@ public class PrintServiceImpl implements PrintService {
|
|
|
private SwUserManagementServiceImpl swUserManagementService;
|
|
|
@Autowired
|
|
|
private SwBillManagementPaidServiceImpl swBillManagementPaidService;
|
|
|
+ @Autowired
|
|
|
+ private SwPrintRepairConfigDao swPrintRepairConfigDao;
|
|
|
+ @Autowired
|
|
|
+ private SysDictDao sysDictDao;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public R printReceipt(List<String> ids) {
|
|
@@ -51,6 +65,8 @@ public class PrintServiceImpl implements PrintService {
|
|
|
if (b) {
|
|
|
throw new CustomException("存在全额退款记录,不可打印票据");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// 户号
|
|
|
List<String> accountList = swBillingRecordDos.stream().map(SwBillingRecordDo::getUsernumber).collect(Collectors.toList());
|
|
|
// 用户信息
|
|
@@ -62,21 +78,25 @@ public class PrintServiceImpl implements PrintService {
|
|
|
.eq(SwBillManagementPaidDo::getDeleted, "0")
|
|
|
.in(SwBillManagementPaidDo::getUsernumber, accountList)
|
|
|
.in(SwBillManagementPaidDo::getPaymentrecordid, ids));
|
|
|
- List<PrintReceiptVo> receiptVoList = new ArrayList<>();
|
|
|
+
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String dateStr = sdf.format(date);
|
|
|
// 生成票据导出所需要的数据
|
|
|
- PrintReceiptVo printReceiptVo;
|
|
|
// 用户信息
|
|
|
SwUserManagementDo swUserManagementDo;
|
|
|
- // 用水信息
|
|
|
- PrintReceiptVo.WaterUsageInfo waterUsageInfo;
|
|
|
+
|
|
|
+ SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
|
|
|
|
// 账单信息
|
|
|
List<SwBillManagementPaidDo> swBillManagementPaidDoList;
|
|
|
+ List<List<Object>> datas = new ArrayList<>();
|
|
|
+ /****************************数据组装开始******************************************/
|
|
|
+ List<SysDictDo> sysDictDoList = sysDictDao.selectList(new LambdaQueryWrapper<SysDictDo>()
|
|
|
+ .eq(BaseDo::getDeleted, "0")
|
|
|
+ .eq(SysDictDo::getDicttype, "water-use-type"));
|
|
|
for (SwBillingRecordDo swBillingRecordDo : swBillingRecordDos) {
|
|
|
- printReceiptVo = new PrintReceiptVo();
|
|
|
+ List<Object> listData = new ArrayList<>();
|
|
|
swUserManagementDo = swUserManagementDos.stream()
|
|
|
.filter(data -> data.getUsernumber().equals(swBillingRecordDo.getUsernumber()))
|
|
|
.findFirst()
|
|
@@ -85,34 +105,113 @@ public class PrintServiceImpl implements PrintService {
|
|
|
log.error("户号:{}不存在", swBillingRecordDo.getUsernumber());
|
|
|
throw new CustomException("以下户号: " + swBillingRecordDo.getUsernumber() + "不存在");
|
|
|
}
|
|
|
- printReceiptVo.setPrintDateStr(dateStr);
|
|
|
- printReceiptVo.setAccount(swUserManagementDo.getUsernumber());
|
|
|
- printReceiptVo.setName(swUserManagementDo.getUsername());
|
|
|
- printReceiptVo.setUserType(swUserManagementDo.getUsertype());
|
|
|
- printReceiptVo.setAddress(swUserManagementDo.getAddress());
|
|
|
- printReceiptVo.setBalance(swUserManagementDo.getAccountbalance().stripTrailingZeros());
|
|
|
+ listData.add(dateStr);
|
|
|
+ listData.add(swUserManagementDo.getUsernumber());
|
|
|
+ listData.add(swUserManagementDo.getAccountbalance().stripTrailingZeros());
|
|
|
+ String usertype = swUserManagementDo.getUsertype();
|
|
|
+ SysDictDo sysDictDo = sysDictDoList.stream().filter(dict -> dict.getValue().equals(usertype)).findFirst().orElse(null);
|
|
|
+ listData.add(sysDictDo == null ? "" : sysDictDo.getName());
|
|
|
+ listData.add(swUserManagementDo.getUsername());
|
|
|
+ listData.add(swUserManagementDo.getAddress());
|
|
|
+
|
|
|
+
|
|
|
swBillManagementPaidDoList = managementPaidDos.stream()
|
|
|
.filter(info -> swBillingRecordDo.getId().equals(info.getPaymentrecordid()) &&
|
|
|
- swBillingRecordDo.getUsernumber().equals(info.getUsernumber()))
|
|
|
+ swBillingRecordDo.getUsernumber().equals(info.getUsernumber()))
|
|
|
.sorted(Comparator.comparing(SwBillManagementPaidDo::getThismeterreadingdate))
|
|
|
.collect(Collectors.toList());
|
|
|
- List<PrintReceiptVo.WaterUsageInfo> waterUsageInfoList = new ArrayList<>();
|
|
|
for (SwBillManagementPaidDo swBillManagementPaidDo : swBillManagementPaidDoList) {
|
|
|
// 账单对应的用水信息
|
|
|
- waterUsageInfo = new PrintReceiptVo.WaterUsageInfo();
|
|
|
- waterUsageInfo.setMeterReadingDate(sdf.format(swBillManagementPaidDo.getThismeterreadingdate()));
|
|
|
- waterUsageInfo.setPreviousReading(swBillManagementPaidDo.getLastmeterreading().stripTrailingZeros());
|
|
|
- waterUsageInfo.setCurrentReading(swBillManagementPaidDo.getThismeterreading().stripTrailingZeros());
|
|
|
- waterUsageInfo.setWaterUsage(swBillManagementPaidDo.getCurrentwateruse().stripTrailingZeros());
|
|
|
- waterUsageInfo.setUnitPrice(swBillManagementPaidDo.getUnitprice().stripTrailingZeros());
|
|
|
- waterUsageInfo.setTotalPrice(swBillManagementPaidDo.getOughttohavepaid().stripTrailingZeros());
|
|
|
- waterUsageInfo.setReliefAmount(swBillManagementPaidDo.getFeewaiver().stripTrailingZeros());
|
|
|
- waterUsageInfo.setPenalty(swBillManagementPaidDo.getLatefees().stripTrailingZeros());
|
|
|
- waterUsageInfoList.add(waterUsageInfo);
|
|
|
+ listData.add(sdf.format(swBillManagementPaidDo.getThismeterreadingdate()));
|
|
|
+ listData.add(swBillManagementPaidDo.getLastmeterreading().stripTrailingZeros());
|
|
|
+ listData.add(swBillManagementPaidDo.getThismeterreading().stripTrailingZeros());
|
|
|
+ listData.add(swBillManagementPaidDo.getCurrentwateruse().stripTrailingZeros());
|
|
|
+ listData.add(swBillManagementPaidDo.getUnitprice().stripTrailingZeros());
|
|
|
+ listData.add(swBillManagementPaidDo.getOughttohavepaid().stripTrailingZeros());
|
|
|
+ listData.add(swBillManagementPaidDo.getFeewaiver().stripTrailingZeros());
|
|
|
+ listData.add(swBillManagementPaidDo.getLatefees().stripTrailingZeros());
|
|
|
+ }
|
|
|
+ listData.add(NumberToChineseUppercaseUtils.convert(swBillingRecordDo.getPaidin()));
|
|
|
+ listData.add(swBillingRecordDo.getPaidin());
|
|
|
+ listData.add(currentUser.getCreateusername());
|
|
|
+ datas.add(listData);
|
|
|
+ }
|
|
|
+ /********数据组装结束************/
|
|
|
+ // 打印参数组装
|
|
|
+ String unit = "mm";
|
|
|
+ List<List<PrintReceiptVo>> returnData = new ArrayList<>();
|
|
|
+ PrintReceiptVo printReceiptVo;
|
|
|
+ // 获取配置信息
|
|
|
+ List<SwPrintRepairConfigDo> swPrintRepairConfigDos = swPrintRepairConfigDao.selectList(new LambdaQueryWrapper<SwPrintRepairConfigDo>()
|
|
|
+ .eq(SwPrintRepairConfigDo::getDeleted, "0")
|
|
|
+ .orderByAsc(SwPrintRepairConfigDo::getSerialnum));
|
|
|
+ for (List<Object> data : datas) {
|
|
|
+ List<PrintReceiptVo> receiptVoList= new ArrayList<>();
|
|
|
+ List<Object> basicData = data.subList(0, 7);
|
|
|
+ // 获取中间需要被巡航的数据
|
|
|
+ List<Object> loopData = data.subList(6, data.size() - 3);
|
|
|
+ // 获取最后3条记录
|
|
|
+ List<Object> footData = data.subList(data.size() - 3, data.size());
|
|
|
+ /*********用户基本信息打印参数组装*************/
|
|
|
+ for (int i = 0; i < basicData.size(); i++) {
|
|
|
+ printReceiptVo = new PrintReceiptVo();
|
|
|
+ if (i == 0) {
|
|
|
+ printReceiptVo.setFp("1");//纵向打印
|
|
|
+ printReceiptVo.setSp(swPrintRepairConfigDos.get(i).getTopspace().toString());
|
|
|
+ printReceiptVo.setTp(swPrintRepairConfigDos.get(i).getLeftspace().toString());
|
|
|
+ printReceiptVo.setFop(swPrintRepairConfigDos.get(i).getContent());
|
|
|
+ } else {
|
|
|
+ printReceiptVo.setFp(swPrintRepairConfigDos.get(i).getTopspace() + unit);
|
|
|
+ printReceiptVo.setSp(swPrintRepairConfigDos.get(i).getLeftspace() + unit);
|
|
|
+ printReceiptVo.setTp(swPrintRepairConfigDos.get(i).getWidthspace() + unit);
|
|
|
+ printReceiptVo.setFop(swPrintRepairConfigDos.get(i).getHeightspace() + unit);
|
|
|
+ printReceiptVo.setFip(swPrintRepairConfigDos.get(i).getContent() + basicData.get(i-1));
|
|
|
+ }
|
|
|
+ receiptVoList.add(printReceiptVo);
|
|
|
}
|
|
|
- printReceiptVo.setWaterUsageInfos(waterUsageInfoList);
|
|
|
- receiptVoList.add(printReceiptVo);
|
|
|
+ /*******************循环部分数据组装 ************************/
|
|
|
+ int initialTop = 0;
|
|
|
+ List<SwPrintRepairConfigDo> headConfig = swPrintRepairConfigDos.subList(7, 15);
|
|
|
+ // 表头
|
|
|
+ for (SwPrintRepairConfigDo swPrintRepairConfigDo : headConfig) {
|
|
|
+ printReceiptVo = new PrintReceiptVo();
|
|
|
+ printReceiptVo.setFp(swPrintRepairConfigDo.getTopspace() + unit);
|
|
|
+ printReceiptVo.setSp(swPrintRepairConfigDo.getLeftspace() + unit);
|
|
|
+ printReceiptVo.setTp(swPrintRepairConfigDo.getWidthspace() + unit);
|
|
|
+ printReceiptVo.setFop(swPrintRepairConfigDo.getHeightspace() + unit);
|
|
|
+ printReceiptVo.setFip(swPrintRepairConfigDo.getContent());
|
|
|
+ initialTop = swPrintRepairConfigDo.getTopspace();
|
|
|
+ receiptVoList.add(printReceiptVo);
|
|
|
+ }
|
|
|
+ // 内容
|
|
|
+ List<List<Object>> partition = Lists.partition(loopData, 8);
|
|
|
+ for (int i = 0; i < partition.size(); i++) {
|
|
|
+ initialTop = initialTop + 5*(i+1);
|
|
|
+ List<Object> dataList = partition.get(i);
|
|
|
+ for (int j = 0; j < dataList.size(); j++) {
|
|
|
+ printReceiptVo = new PrintReceiptVo();
|
|
|
+ printReceiptVo.setFp(initialTop + unit);
|
|
|
+ printReceiptVo.setSp(headConfig.get(j).getLeftspace() + unit);
|
|
|
+ printReceiptVo.setTp(headConfig.get(j).getWidthspace() + unit);
|
|
|
+ printReceiptVo.setFop(headConfig.get(j).getHeightspace() + unit);
|
|
|
+ printReceiptVo.setFip(dataList.get(j).toString());
|
|
|
+ receiptVoList.add(printReceiptVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*****************金额等信息组装********************/
|
|
|
+ for (int i = 0; i < footData.size(); i++) {
|
|
|
+ printReceiptVo = new PrintReceiptVo();
|
|
|
+ printReceiptVo.setFp(swPrintRepairConfigDos.get(15 + i).getTopspace() + unit);
|
|
|
+ printReceiptVo.setSp(swPrintRepairConfigDos.get(15 + i).getLeftspace() + unit);
|
|
|
+ printReceiptVo.setTp(swPrintRepairConfigDos.get(15 + i).getWidthspace() + unit);
|
|
|
+ printReceiptVo.setFop(swPrintRepairConfigDos.get(15 + i).getHeightspace() + unit);
|
|
|
+ printReceiptVo.setFip(swPrintRepairConfigDos.get(15 + i).getContent() + footData.get(i));
|
|
|
+ receiptVoList.add(printReceiptVo);
|
|
|
+ }
|
|
|
+ returnData.add(receiptVoList);
|
|
|
}
|
|
|
- return R.ok(receiptVoList);
|
|
|
+ return R.ok(returnData);
|
|
|
}
|
|
|
+
|
|
|
}
|