|
|
@ -1,15 +1,24 @@ |
|
|
|
package com.ruoyi.financial.service.impl; |
|
|
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigInteger; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.write.builder.ExcelWriterBuilder; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.financial.domain.FinancialReceivablesRecords; |
|
|
|
import com.ruoyi.financial.domain.VO.ExportFinancialReceivablesVo; |
|
|
|
import com.ruoyi.financial.domain.VO.FinancialReceivablesRecordsVO; |
|
|
|
import com.ruoyi.financial.mapper.FinancialReceivablesRecordsMapper; |
|
|
|
import com.ruoyi.system.domain.SysCustomerVo; |
|
|
@ -28,6 +37,8 @@ import com.ruoyi.common.core.text.Convert; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.thymeleaf.util.NumberUtils; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
/** |
|
|
|
* 财务应收账款Service业务层处理 |
|
|
|
* |
|
|
@ -308,33 +319,55 @@ public class FinancialReceivablesServiceImpl implements IFinancialReceivablesSer |
|
|
|
|
|
|
|
/*设置导出模板数据*/ |
|
|
|
@Override |
|
|
|
public Map<String, Object> exportTemplate(Long id) throws NoSuchBeanDefinitionException { |
|
|
|
public Map<String, Object> exportTemplate(List<FinancialReceivablesRecords> financialReceivablesRecordsList) throws NoSuchBeanDefinitionException, IOException { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
//需要传输导出的值有:借方科目,开户银行,年,月,日,
|
|
|
|
//需要传输导出的值有:借方科目,开户银行,
|
|
|
|
//现在时间截取后 年,月,日, 格式为转换 yyyy MM dd,
|
|
|
|
//凭证信息批量:包含收款摘要,金额字符串截取,位数从亿开始,亿,千万,百万,十万,万,千,百,十,元,角,分。小数点后俩位为角,分,小数点不需要显示,
|
|
|
|
//将以上信息通过map传输出去
|
|
|
|
FinancialReceivables financialReceivables = financialReceivablesMapper.selectFinancialReceivablesById(id); |
|
|
|
List<Map<String, Object>> financialReceivablesRecordsAmountList = new ArrayList<>(); |
|
|
|
BigDecimal amount = BigDecimal.ZERO; |
|
|
|
List<ExportFinancialReceivablesVo> list = new ArrayList<>(); |
|
|
|
String date = DateUtils.getDate(); |
|
|
|
String[] dateArray = date.split("-"); |
|
|
|
map.put("year", dateArray[0]); |
|
|
|
map.put("month", dateArray[1]); |
|
|
|
map.put("day", dateArray[2]); |
|
|
|
//接收拆分的数字
|
|
|
|
FinancialReceivablesRecords financialReceivablesRecords = new FinancialReceivablesRecords(); |
|
|
|
List<FinancialReceivablesRecords> financialReceivablesRecordsList = receivablesRecordsMapper.selectFinancialReceivablesRecordsListByCode(financialReceivables.getFinancialReceivablesCode()); |
|
|
|
for (FinancialReceivablesRecords financialReceivablesRecord : financialReceivablesRecordsList) { |
|
|
|
|
|
|
|
//对于财务分割的数据,需要合计。
|
|
|
|
if (financialReceivablesRecord.getReceivablesPrice() != null){ |
|
|
|
amount = amount.add(financialReceivablesRecord.getReceivablesPrice().setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
}else if (financialReceivablesRecord.getReceivablesPrice() == null){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
ExportFinancialReceivablesVo exportFinancialReceivablesVo1 = splitNumber(financialReceivablesRecord); |
|
|
|
String receivablesAbstract = financialReceivablesRecord.getReceivablesAbstract(); |
|
|
|
//收款摘要
|
|
|
|
exportFinancialReceivablesVo1.setReceivablesAbstract(receivablesAbstract); |
|
|
|
list.add(exportFinancialReceivablesVo1); |
|
|
|
} |
|
|
|
map.put("list",list); |
|
|
|
FinancialReceivablesRecords financialReceivablesRecord = new FinancialReceivablesRecords(); |
|
|
|
financialReceivablesRecord.setReceivablesPrice(amount); |
|
|
|
map.put("amount",splitNumber(financialReceivablesRecord)); |
|
|
|
map.put("loginName",ShiroUtils.getLoginName()); |
|
|
|
return map; |
|
|
|
} |
|
|
|
/*切割返回数字*/ |
|
|
|
public Map<String, Object> splitNumber(FinancialReceivablesRecords financialReceivablesRecord) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
public ExportFinancialReceivablesVo splitNumber(FinancialReceivablesRecords financialReceivablesRecord) { |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
ExportFinancialReceivablesVo exportFinancialReceivablesVo = new ExportFinancialReceivablesVo(); |
|
|
|
/*获取当前传输过来的*/ |
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
List<String> result = new ArrayList<>(); |
|
|
|
List<String> units = Arrays.asList("亿", "千万", "百万", "十万", "万", "千", "百", "十", "元", "角", "分"); |
|
|
|
List<String> unitKey = Arrays.asList("fen", "jiao", "yuan", "shi", "bai", "qian", "wan", "shiw", "baiw", "qianw", "yi"); |
|
|
|
BigDecimal amount = financialReceivablesRecord.getReceivablesPrice().setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
BigDecimal amount = financialReceivablesRecord.getReceivablesPrice(); |
|
|
|
String integerPart = amount.toBigInteger().toString(); // 获取整数部分
|
|
|
|
String decimalPart = amount.remainder(BigDecimal.ONE).multiply(new BigDecimal(100)).toBigInteger().toString(); // 获取小数部分(角分)
|
|
|
|
int unitIndex = 0; |
|
|
|
for (int i = 0; i < unitKey.size() - 1; i++) { |
|
|
|
map.put(unitKey.get(i), ""); |
|
|
|
} |
|
|
|
for (int i = integerPart.length() - 1; i >= 0; i--) { |
|
|
|
char digit = integerPart.charAt(i); |
|
|
|
if (digit != '0' || !units.get(unitIndex).isEmpty()) {result.add(0, String.valueOf(digit));} |
|
|
@ -347,17 +380,21 @@ public class FinancialReceivablesServiceImpl implements IFinancialReceivablesSer |
|
|
|
result.add(decimalPart.substring(1, 2)); |
|
|
|
/*根据长度设备map中的Stirng参数,调用对等获取实现map*/ |
|
|
|
for (int i = 0; i < result.size(); i++) { |
|
|
|
String unitKeyValue = unitKey.get(result.size() - i); |
|
|
|
map1.put(unitKeyValue,result.get(i)); |
|
|
|
} |
|
|
|
for (int j = result.size() - 1 ; j < unitKey.size(); j ++){ |
|
|
|
map1.put(unitKey.get(j),""); |
|
|
|
String unitKeyValue = unitKey.get((result.size() -1) - i); |
|
|
|
map.put(unitKeyValue,result.get(i)); |
|
|
|
} |
|
|
|
//收款摘要
|
|
|
|
map.put("receivablesAbstract",financialReceivablesRecord.getReceivablesAbstract()); |
|
|
|
exportFinancialReceivablesVo.setYi(map.get("yi")); |
|
|
|
exportFinancialReceivablesVo.setQianw(map.get("qianw")); |
|
|
|
exportFinancialReceivablesVo.setBaiw(map.get("baiw")); |
|
|
|
exportFinancialReceivablesVo.setShi(map.get("shiw")); |
|
|
|
exportFinancialReceivablesVo.setWan(map.get("wan")); |
|
|
|
exportFinancialReceivablesVo.setQian(map.get("qian")); |
|
|
|
exportFinancialReceivablesVo.setBai(map.get("bai")); |
|
|
|
exportFinancialReceivablesVo.setShi(map.get("shi")); |
|
|
|
exportFinancialReceivablesVo.setYuan(map.get("yuan")); |
|
|
|
exportFinancialReceivablesVo.setJiao(map.get("jiao")); |
|
|
|
exportFinancialReceivablesVo.setFen(map.get("fen")); |
|
|
|
//金额对象
|
|
|
|
map.put("receivablesPrice",map1); |
|
|
|
return map; |
|
|
|
return exportFinancialReceivablesVo; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|