|
|
@ -28,6 +28,7 @@ package com.yxt.anrui.fin.biz.finpaymentrecord; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.codec.Base64; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.base.api.basemanufactorsubscription.BaseManufUpdateDto; |
|
|
@ -59,9 +60,11 @@ import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.base.utils.WordConvertUtils; |
|
|
|
import com.yxt.common.base.utils.WordUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -72,6 +75,7 @@ import java.io.*; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -90,6 +94,7 @@ import static cn.hutool.core.util.ClassLoaderUtil.getClassLoader; |
|
|
|
* @version 1.0 |
|
|
|
* @since 1.0 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class FinPaymentrecordService extends MybatisBaseService<FinPaymentrecordMapper, FinPaymentrecord> { |
|
|
|
|
|
|
@ -343,61 +348,78 @@ public class FinPaymentrecordService extends MybatisBaseService<FinPaymentrecord |
|
|
|
String createBySid = finPaymentrecord.getCreateBySid(); |
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(createBySid).getData(); |
|
|
|
String createByName = sysStaffinfoFeign.fetchBySid(sysUserVo.getStaffSid()).getData().getName(); |
|
|
|
//获取分公司名称
|
|
|
|
SysOrganization sysOrganization = sysOrganizationFeign.selectBySid(finPaymentrecord.getCreateOrgSid()).getData(); |
|
|
|
String createOrgName = sysOrganization.getName(); |
|
|
|
//获取创建部门
|
|
|
|
List<SysStaffOrgVo> sysStaffOrgVos = sysStaffOrgFeign.getSysStaffOrgListByStaffSid(sysUserVo.getStaffSid()).getData(); |
|
|
|
StringBuilder deptName = new StringBuilder(); |
|
|
|
for (SysStaffOrgVo sysStaffOrgVo : sysStaffOrgVos) { |
|
|
|
String orgName = sysStaffOrgVo.getOrgName(); |
|
|
|
deptName.append(orgName).append(" "); |
|
|
|
//部门名称
|
|
|
|
String deptOrgName = sysStaffOrgVo.getOrgName(); |
|
|
|
String deptOrgSid = sysStaffOrgVo.getOrgSid(); |
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationFeign.fetchBySid(deptOrgSid).getData(); |
|
|
|
String psid = sysOrganizationVo.getPsid(); |
|
|
|
SysOrganizationVo sysOrganizationVo1 = sysOrganizationFeign.fetchBySid(psid).getData(); |
|
|
|
String orgName = sysOrganizationVo1.getName(); |
|
|
|
String psid1 = sysOrganizationVo1.getPsid(); |
|
|
|
SysOrganizationVo sysOrganizationVo2 = sysOrganizationFeign.fetchBySid(psid1).getData(); |
|
|
|
String pname = sysOrganizationVo2.getName(); |
|
|
|
deptName.append(pname).append("-").append(orgName).append("-").append(deptOrgName).append(" "); |
|
|
|
} |
|
|
|
//获取分公司名称
|
|
|
|
SysOrganization sysOrganization = sysOrganizationFeign.selectBySid(finPaymentrecord.getCreateOrgSid()).getData(); |
|
|
|
String createOrgName = sysOrganization.getName(); |
|
|
|
//获取审批编号
|
|
|
|
BaseOutsourcingApplicationDetailsVo baseOutsourcingApplicationDetailsVo = baseOutsourcingApplicationFeign.fetchBySid(finPaymentrecord.getApplySid()).getData(); |
|
|
|
BusVehicleApplyDetailsVo busVehicleApplyDetailsVo = busVehicleApplyFeign.fetchSid(finPaymentrecord.getApplySid()).getData(); |
|
|
|
if (StringUtils.isNotBlank(baseOutsourcingApplicationDetailsVo.getApplicationCode())) { |
|
|
|
dataMap.put("applyCode", baseOutsourcingApplicationDetailsVo.getApplicationCode()); |
|
|
|
//获取审批记录
|
|
|
|
FlowRecordVo flowRecordVo = flowTaskFeign.businessFlowRecord(baseOutsourcingApplicationDetailsVo.getProcInstSid()).getData(); |
|
|
|
List<FlowTask> flowList = flowRecordVo.getFlowList(); |
|
|
|
List<FinPaymentrecordSourceLCVo> finPaymentrecordSourceLCVos = new ArrayList<>(); |
|
|
|
for (FlowTask flowTask : flowList) { |
|
|
|
FinPaymentrecordSourceLCVo finPaymentrecordSourceLCVo = new FinPaymentrecordSourceLCVo(); |
|
|
|
finPaymentrecordSourceLCVo.setName(flowTask.getTaskUserInfos().get(0).getAssigneeName()); |
|
|
|
finPaymentrecordSourceLCVo.setComment(flowTask.getComment().getComment()); |
|
|
|
finPaymentrecordSourceLCVo.setSpsj(DateUtil.format(flowTask.getFinishTime(),"yyyy-MM-dd")); |
|
|
|
finPaymentrecordSourceLCVos.add(finPaymentrecordSourceLCVo); |
|
|
|
} |
|
|
|
dataMap.put("lcList", finPaymentrecordSourceLCVos); |
|
|
|
//获取附件名称(文档类型)
|
|
|
|
CommonAppendixVo contract = baseOutsourcingApplicationDetailsVo.getContract(); |
|
|
|
if (contract != null) { |
|
|
|
dataMap.put("fileName", contract.getFileName()); |
|
|
|
if (baseOutsourcingApplicationDetailsVo != null) { |
|
|
|
if (StringUtils.isNotBlank(baseOutsourcingApplicationDetailsVo.getApplicationCode())) { |
|
|
|
dataMap.put("applyCode", baseOutsourcingApplicationDetailsVo.getApplicationCode()); |
|
|
|
//获取审批记录
|
|
|
|
FlowRecordVo flowRecordVo = flowTaskFeign.businessFlowRecord(baseOutsourcingApplicationDetailsVo.getProcInstSid()).getData(); |
|
|
|
List<FlowTask> flowList = flowRecordVo.getFlowList(); |
|
|
|
List<FinPaymentrecordSourceLCVo> finPaymentrecordSourceLCVos = new ArrayList<>(); |
|
|
|
for (FlowTask flowTask : flowList) { |
|
|
|
FinPaymentrecordSourceLCVo finPaymentrecordSourceLCVo = new FinPaymentrecordSourceLCVo(); |
|
|
|
finPaymentrecordSourceLCVo.setName(flowTask.getTaskUserInfos().get(0).getAssigneeName()); |
|
|
|
finPaymentrecordSourceLCVo.setComment(flowTask.getComment().getComment()); |
|
|
|
finPaymentrecordSourceLCVo.setSpsj(DateUtil.format(flowTask.getFinishTime(), "yyyy-MM-dd")); |
|
|
|
finPaymentrecordSourceLCVos.add(finPaymentrecordSourceLCVo); |
|
|
|
} |
|
|
|
dataMap.put("lcList", finPaymentrecordSourceLCVos); |
|
|
|
//获取附件名称(文档类型)
|
|
|
|
CommonAppendixVo contract = baseOutsourcingApplicationDetailsVo.getContract(); |
|
|
|
if (contract != null) { |
|
|
|
dataMap.put("fileName", contract.getFileName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (StringUtils.isNotBlank(busVehicleApplyDetailsVo.getSid())) { |
|
|
|
dataMap.put("applyCode", busVehicleApplyDetailsVo.getApplicationCode()); |
|
|
|
//获取审批记录
|
|
|
|
FlowRecordVo flowRecordVo = flowTaskFeign.businessFlowRecord(busVehicleApplyDetailsVo.getProcInstId()).getData(); |
|
|
|
List<FlowTask> flowList = flowRecordVo.getFlowList(); |
|
|
|
List<FinPaymentrecordSourceLCVo> finPaymentrecordSourceLCVos = new ArrayList<>(); |
|
|
|
for (FlowTask flowTask : flowList) { |
|
|
|
FinPaymentrecordSourceLCVo finPaymentrecordSourceLCVo = new FinPaymentrecordSourceLCVo(); |
|
|
|
finPaymentrecordSourceLCVo.setName(flowTask.getTaskUserInfos().get(0).getAssigneeName()); |
|
|
|
finPaymentrecordSourceLCVo.setComment(flowTask.getComment().getComment()); |
|
|
|
finPaymentrecordSourceLCVo.setSpsj(DateUtil.format(flowTask.getFinishTime(),"yyyy-MM-dd")); |
|
|
|
finPaymentrecordSourceLCVos.add(finPaymentrecordSourceLCVo); |
|
|
|
} |
|
|
|
if (busVehicleApplyDetailsVo != null) { |
|
|
|
if (StringUtils.isNotBlank(busVehicleApplyDetailsVo.getSid())) { |
|
|
|
dataMap.put("applyCode", busVehicleApplyDetailsVo.getApplicationCode()); |
|
|
|
//获取审批记录
|
|
|
|
FlowRecordVo flowRecordVo = flowTaskFeign.businessFlowRecord(busVehicleApplyDetailsVo.getProcInstId()).getData(); |
|
|
|
List<FlowTask> flowList = flowRecordVo.getFlowList(); |
|
|
|
List<FinPaymentrecordSourceLCVo> finPaymentrecordSourceLCVos = new ArrayList<>(); |
|
|
|
for (FlowTask flowTask : flowList) { |
|
|
|
FinPaymentrecordSourceLCVo finPaymentrecordSourceLCVo = new FinPaymentrecordSourceLCVo(); |
|
|
|
finPaymentrecordSourceLCVo.setName(flowTask.getTaskUserInfos().get(0).getAssigneeName()); |
|
|
|
finPaymentrecordSourceLCVo.setComment(flowTask.getComment().getComment()); |
|
|
|
finPaymentrecordSourceLCVo.setSpsj(DateUtil.format(flowTask.getFinishTime(), "yyyy-MM-dd")); |
|
|
|
finPaymentrecordSourceLCVos.add(finPaymentrecordSourceLCVo); |
|
|
|
} |
|
|
|
dataMap.put("lcList", finPaymentrecordSourceLCVos); |
|
|
|
} |
|
|
|
dataMap.put("lcList", finPaymentrecordSourceLCVos); |
|
|
|
} |
|
|
|
dataMap.put("createTime", DateUtil.format(finPaymentrecord.getCreateTime(),"yyyy-MM-dd")); |
|
|
|
dataMap.put("createTime", DateUtil.format(finPaymentrecord.getCreateTime(), "yyyy-MM-dd")); |
|
|
|
dataMap.put("createByName", createByName); |
|
|
|
dataMap.put("createByDeptName", deptName); |
|
|
|
dataMap.put("createOrgName", createOrgName); |
|
|
|
dataMap.put("remarks", finPaymentrecord.getRemarks()); |
|
|
|
dataMap.put("receiveCompany", finPaymentrecord.getReceiveCompany()); |
|
|
|
dataMap.put("receiveBank", finPaymentrecord.getReceiveBank()); |
|
|
|
dataMap.put("receiveBankAccount", finPaymentrecord.getReceiveBankAccount()); |
|
|
|
dataMap.put("cost", finPaymentrecord.getCost()); |
|
|
|
Double aDouble = Double.valueOf(finPaymentrecord.getCost()); |
|
|
|
String s = upperCase2(aDouble); |
|
|
|
dataMap.put("cost", finPaymentrecord.getCost() + " " + "(" + s + ")"); |
|
|
|
dataMap.put("payRemark", finPaymentrecord.getPayRemark()); |
|
|
|
//获取图片路径
|
|
|
|
// String photoPath = "file://D:/anrui/upload/20211227/kbjl_20211227143750186948.jpg";
|
|
|
@ -405,19 +427,27 @@ public class FinPaymentrecordService extends MybatisBaseService<FinPaymentrecord |
|
|
|
String photoPath64 = image2Base64(photoPath); |
|
|
|
dataMap.put("photoPath64", photoPath64);*/ |
|
|
|
//获取模板
|
|
|
|
// 模板路径
|
|
|
|
String sourcePath = "D:\\anrui\\upload\\template\\"; |
|
|
|
File file = new File(getClass().getClassLoader().getResource("ftl/prePaymentApply.ftl").getFile()); |
|
|
|
String dir = getClassLoader().getResource("ftl").getPath(); |
|
|
|
log.info("dir:{}",dir); |
|
|
|
//生成word文件名
|
|
|
|
String targetPath = docPdfComponent.getUploadTemplateUrl(); |
|
|
|
// String targetPath = docPdfComponent.getUploadTemplateUrl();
|
|
|
|
String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
|
|
|
long seconds = System.currentTimeMillis(); |
|
|
|
String typeName = dateStr + seconds + ".doc"; |
|
|
|
WordConvertUtils.creatWord(dataMap, file, targetPath, typeName, dir); |
|
|
|
// 生成文件路径
|
|
|
|
String targetPath = sourcePath + dateStr; |
|
|
|
log.info("dataMap:{}", JSONObject.toJSONString(dataMap)); |
|
|
|
// WordConvertUtils.creatWord(dataMap, file, targetPath, typeName, dir);
|
|
|
|
WordUtils.creatWord(dataMap, "prePaymentApply", sourcePath, targetPath, typeName); |
|
|
|
//新生成的word路径
|
|
|
|
String wordPath = targetPath + typeName; |
|
|
|
String wordPath = targetPath + "\\"+typeName; |
|
|
|
//生成出门证文件名
|
|
|
|
String pdfName = "预付款申请_" + dateStr + seconds + ".pdf"; |
|
|
|
WordConvertUtils.doc2pdf(wordPath, targetPath, pdfName); |
|
|
|
WordUtils.doc2pdf(wordPath, targetPath, pdfName); |
|
|
|
//WordConvertUtils.doc2pdf(wordPath, targetPath, pdfName);
|
|
|
|
return rb.success().setData("/template/" + pdfName); |
|
|
|
} |
|
|
|
|
|
|
@ -505,4 +535,103 @@ public class FinPaymentrecordService extends MybatisBaseService<FinPaymentrecord |
|
|
|
} |
|
|
|
return imgUrl; |
|
|
|
} |
|
|
|
|
|
|
|
public static String upperCase2(double money) { |
|
|
|
String[] upNum = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; |
|
|
|
String[] danwei = {"圆", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"}; |
|
|
|
//取消科学记数法
|
|
|
|
NumberFormat numFormat = NumberFormat.getInstance(); |
|
|
|
numFormat.setMaximumFractionDigits(2);//设置小数位个数
|
|
|
|
numFormat.setGroupingUsed(false);//取消科学技术发
|
|
|
|
String formatNum = numFormat.format(money); |
|
|
|
String strmoney = formatNum + "";//浮点型转为字符型
|
|
|
|
String lastUpNum = "null"; //用于存放上个参数的值
|
|
|
|
String result = "";//返回的结果
|
|
|
|
String[] split = strmoney.split("\\."); |
|
|
|
String strMoney = split[0]; |
|
|
|
String point = ""; |
|
|
|
//小数部分取值处理。
|
|
|
|
if (split.length > 1) { |
|
|
|
point = split[1]; |
|
|
|
if (point.length() == 1) { |
|
|
|
point = point.concat("0"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
point = "0"; |
|
|
|
} |
|
|
|
//大于12位就直接返回。
|
|
|
|
int moneyLen = strMoney.length(); |
|
|
|
if (money == 0) { |
|
|
|
return "零圆整"; |
|
|
|
} |
|
|
|
if (moneyLen > 12) { |
|
|
|
return "金额:" + money + "元,超出大写转换范围。最大金额:999999999999.99元"; |
|
|
|
} |
|
|
|
//整数(integer)部分处理。
|
|
|
|
if (!"0".equals(strMoney)) { |
|
|
|
for (int i = 0; i < moneyLen; i++) { |
|
|
|
String strNum = strMoney.charAt(i) + ""; |
|
|
|
int singleNum = Integer.parseInt(strNum); |
|
|
|
String upSingleNum = upNum[singleNum]; |
|
|
|
//上一为不等于0的情况
|
|
|
|
if (!"零".equals(lastUpNum)) { |
|
|
|
if (!"零".equals(upSingleNum)) { |
|
|
|
result = result.concat(upSingleNum).concat(danwei[moneyLen - i - 1]); |
|
|
|
} else |
|
|
|
//为零但是在万、亿位上要加单位 (moneyLen-i)==9 指的是单位:亿。 (moneyLen-i)==5指的是单位:万
|
|
|
|
if ((moneyLen - i) == 5 || (moneyLen - i) == 9) { |
|
|
|
lastUpNum = ""; |
|
|
|
} else { |
|
|
|
result = result.concat(upSingleNum); |
|
|
|
} |
|
|
|
} |
|
|
|
//上一位为0的情况
|
|
|
|
if ("零".equals(lastUpNum) && !"零".equals(upSingleNum)) { |
|
|
|
result = result.concat(upSingleNum).concat(danwei[moneyLen - i - 1]); |
|
|
|
} |
|
|
|
//捕捉上一位数(lastUpNum)为零的情况做优化。
|
|
|
|
if ((moneyLen - i) == 5 || (moneyLen - i) == 9) { |
|
|
|
//排除加单位时前面为"零"的情况。如:两百零万
|
|
|
|
if ("零".equals(lastUpNum) || "null".equals(lastUpNum)) { |
|
|
|
result = result.substring(0, result.length() - 1); |
|
|
|
} |
|
|
|
if (!result.endsWith("亿")) { |
|
|
|
result = result.concat(danwei[moneyLen - i - 1]); |
|
|
|
} |
|
|
|
lastUpNum = ""; |
|
|
|
} else { |
|
|
|
//把当前大写数字复制给 lastUpNum 用于下次判断
|
|
|
|
lastUpNum = upSingleNum; |
|
|
|
} |
|
|
|
} |
|
|
|
//对几万元整和几亿元整(result:五万零或者五亿零零)做优化。
|
|
|
|
result = result.replaceAll("零零", "零"); |
|
|
|
if (result.endsWith("零")) { |
|
|
|
String substring = result.substring(0, result.length() - 1); |
|
|
|
result = substring; |
|
|
|
} |
|
|
|
result = result.concat("圆"); |
|
|
|
result = result.replaceAll("圆圆", "圆"); |
|
|
|
result = result.replaceAll("万万", "万"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//小数(point)部分处理
|
|
|
|
if ("0".equals(point)) { |
|
|
|
result = result + "整"; |
|
|
|
} else { |
|
|
|
//去 整
|
|
|
|
// if(result.endsWith("整")){
|
|
|
|
// result = result.substring(0,result.length()-1);
|
|
|
|
// }
|
|
|
|
if ((point.charAt(0) + "").equals("0")) { |
|
|
|
result = result.concat(upNum[Integer.parseInt(point.charAt(1) + "")] + "分"); |
|
|
|
} else if ((point.charAt(1) + "").equals("0")) { |
|
|
|
result = result.concat(upNum[Integer.parseInt(point.charAt(0) + "")] + "角"); |
|
|
|
} else { |
|
|
|
result = result.concat(upNum[Integer.parseInt(point.charAt(0) + "")] + "角").concat(upNum[Integer.parseInt(point.charAt(1) + "")] + "分"); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |