|
@ -3,10 +3,7 @@ package com.ruoyi.financial.service.impl; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.text.DecimalFormat; |
|
|
import java.text.DecimalFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.Date; |
|
|
import java.util.*; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
@ -21,6 +18,7 @@ import com.ruoyi.system.mapper.SysCustomerMapper; |
|
|
import com.ruoyi.system.mapper.SysSalesOrderMapper; |
|
|
import com.ruoyi.system.mapper.SysSalesOrderMapper; |
|
|
import com.ruoyi.system.service.ISysSalesOrderService; |
|
|
import com.ruoyi.system.service.ISysSalesOrderService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.ruoyi.financial.mapper.FinancialReceivablesMapper; |
|
|
import com.ruoyi.financial.mapper.FinancialReceivablesMapper; |
|
@ -28,6 +26,7 @@ import com.ruoyi.financial.domain.FinancialReceivables; |
|
|
import com.ruoyi.financial.service.IFinancialReceivablesService; |
|
|
import com.ruoyi.financial.service.IFinancialReceivablesService; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.thymeleaf.util.NumberUtils; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 财务应收账款Service业务层处理 |
|
|
* 财务应收账款Service业务层处理 |
|
@ -294,7 +293,6 @@ public class FinancialReceivablesServiceImpl implements IFinancialReceivablesSer |
|
|
if (StringUtils.isEmpty(maxCode)) { |
|
|
if (StringUtils.isEmpty(maxCode)) { |
|
|
return prefix + "001"; |
|
|
return prefix + "001"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 解析并递增编号
|
|
|
// 解析并递增编号
|
|
|
int sequence = Integer.parseInt(maxCode.substring(4)) + 1; // 假设前4位为固定部分
|
|
|
int sequence = Integer.parseInt(maxCode.substring(4)) + 1; // 假设前4位为固定部分
|
|
|
|
|
|
|
|
@ -308,4 +306,58 @@ public class FinancialReceivablesServiceImpl implements IFinancialReceivablesSer |
|
|
return prefix + df.format(sequence); |
|
|
return prefix + df.format(sequence); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*设置导出模板数据*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public Map<String, Object> exportTemplate(Long id) throws NoSuchBeanDefinitionException { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
//需要传输导出的值有:借方科目,开户银行,年,月,日,
|
|
|
|
|
|
//凭证信息批量:包含收款摘要,金额字符串截取,位数从亿开始,亿,千万,百万,十万,万,千,百,十,元,角,分。小数点后俩位为角,分,小数点不需要显示,
|
|
|
|
|
|
//将以上信息通过map传输出去
|
|
|
|
|
|
FinancialReceivables financialReceivables = financialReceivablesMapper.selectFinancialReceivablesById(id); |
|
|
|
|
|
List<Map<String, Object>> financialReceivablesRecordsAmountList = new ArrayList<>(); |
|
|
|
|
|
//接收拆分的数字
|
|
|
|
|
|
FinancialReceivablesRecords financialReceivablesRecords = new FinancialReceivablesRecords(); |
|
|
|
|
|
List<FinancialReceivablesRecords> financialReceivablesRecordsList = receivablesRecordsMapper.selectFinancialReceivablesRecordsListByCode(financialReceivables.getFinancialReceivablesCode()); |
|
|
|
|
|
for (FinancialReceivablesRecords financialReceivablesRecord : financialReceivablesRecordsList) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
return map; |
|
|
|
|
|
} |
|
|
|
|
|
/*切割返回数字*/ |
|
|
|
|
|
public Map<String, Object> splitNumber(FinancialReceivablesRecords financialReceivablesRecord) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
/*获取当前传输过来的*/ |
|
|
|
|
|
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); |
|
|
|
|
|
String integerPart = amount.toBigInteger().toString(); // 获取整数部分
|
|
|
|
|
|
String decimalPart = amount.remainder(BigDecimal.ONE).multiply(new BigDecimal(100)).toBigInteger().toString(); // 获取小数部分(角分)
|
|
|
|
|
|
int unitIndex = 0; |
|
|
|
|
|
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));} |
|
|
|
|
|
unitIndex++; |
|
|
|
|
|
if (unitIndex == units.size()) {unitIndex = 0;} |
|
|
|
|
|
} |
|
|
|
|
|
// Adding decimal part
|
|
|
|
|
|
if (decimalPart.length() < 2) {decimalPart += "0";} |
|
|
|
|
|
result.add(decimalPart.substring(0, 1)); |
|
|
|
|
|
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),""); |
|
|
|
|
|
} |
|
|
|
|
|
//收款摘要
|
|
|
|
|
|
map.put("receivablesAbstract",financialReceivablesRecord.getReceivablesAbstract()); |
|
|
|
|
|
//金额对象
|
|
|
|
|
|
map.put("receivablesPrice",map1); |
|
|
|
|
|
return map; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|