|
@ -29,6 +29,8 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
import com.yxt.common.base.config.component.DocPdfComponent; |
|
|
|
|
|
import com.yxt.common.base.utils.WordConvertUtils; |
|
|
import com.yxt.sms.biz.smsgoods.SmsGoods; |
|
|
import com.yxt.sms.biz.smsgoods.SmsGoods; |
|
|
import com.yxt.sms.biz.smsgoods.SmsGoodsService; |
|
|
import com.yxt.sms.biz.smsgoods.SmsGoodsService; |
|
|
import com.yxt.sms.biz.smssalesbill.report.*; |
|
|
import com.yxt.sms.biz.smssalesbill.report.*; |
|
@ -46,6 +48,7 @@ import com.yxt.sms.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
import com.yxt.sms.feign.portal.sysorganization.SysOrganizationVo; |
|
|
import com.yxt.sms.feign.portal.sysorganization.SysOrganizationVo; |
|
|
import com.yxt.sms.feign.privilege.PrivilegeQuery; |
|
|
import com.yxt.sms.feign.privilege.PrivilegeQuery; |
|
|
import com.yxt.sms.feign.sysuser.SysUserFeign; |
|
|
import com.yxt.sms.feign.sysuser.SysUserFeign; |
|
|
|
|
|
import com.yxt.sms.feign.sysuser.SysUserVo; |
|
|
import com.yxt.sms.feign.wms.wmsinventory.*; |
|
|
import com.yxt.sms.feign.wms.wmsinventory.*; |
|
|
import com.yxt.sms.feign.wms.wmsinventoryrecord.WmsInventoryRecordDto; |
|
|
import com.yxt.sms.feign.wms.wmsinventoryrecord.WmsInventoryRecordDto; |
|
|
import com.yxt.sms.feign.wms.wmsinventoryrecord.WmsInventoryRecordFeign; |
|
|
import com.yxt.sms.feign.wms.wmsinventoryrecord.WmsInventoryRecordFeign; |
|
@ -64,6 +67,8 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.io.InputStream; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
@ -103,7 +108,8 @@ public class SmsSalesBillService extends MybatisBaseService<SmsSalesBillMapper, |
|
|
private SysUserFeign sysUserFeign; |
|
|
private SysUserFeign sysUserFeign; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DocPdfComponent docPdfComponent; |
|
|
private QueryWrapper<SmsSalesBill> createQueryWrapper(SmsSalesBillQuery query) { |
|
|
private QueryWrapper<SmsSalesBill> createQueryWrapper(SmsSalesBillQuery query) { |
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
@ -319,12 +325,12 @@ public class SmsSalesBillService extends MybatisBaseService<SmsSalesBillMapper, |
|
|
for (SmsSalesBillDetail smsSalesBillDetail : billDetailList) { |
|
|
for (SmsSalesBillDetail smsSalesBillDetail : billDetailList) { |
|
|
SalesGoodsVo salesGoodsVo = new SalesGoodsVo(); |
|
|
SalesGoodsVo salesGoodsVo = new SalesGoodsVo(); |
|
|
BeanUtil.copyProperties(smsSalesBillDetail, salesGoodsVo); |
|
|
BeanUtil.copyProperties(smsSalesBillDetail, salesGoodsVo); |
|
|
SmsGoods goods = smsGoodsService.fetchEntityByGoodsID(smsSalesBillDetail.getGoodsID()); |
|
|
// SmsGoods goods = smsGoodsService.fetchEntityByGoodsID(smsSalesBillDetail.getGoodsID());
|
|
|
if (null != goods) { |
|
|
// if (null != goods) {
|
|
|
if (StringUtils.isNotBlank(goods.getSupplierName())) { |
|
|
// if (StringUtils.isNotBlank(goods.getSupplierName())) {
|
|
|
salesGoodsVo.setSupplierName(goods.getSupplierName()); |
|
|
// salesGoodsVo.setSupplierName(goods.getSupplierName());
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
goodsVos.add(salesGoodsVo); |
|
|
goodsVos.add(salesGoodsVo); |
|
|
} |
|
|
} |
|
|
vo.setGoodsVos(goodsVos); |
|
|
vo.setGoodsVos(goodsVos); |
|
@ -352,6 +358,9 @@ public class SmsSalesBillService extends MybatisBaseService<SmsSalesBillMapper, |
|
|
if (null != aitem.getPrice()) { |
|
|
if (null != aitem.getPrice()) { |
|
|
aitemVo.setPrice(aitem.getPrice().toString()); |
|
|
aitemVo.setPrice(aitem.getPrice().toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
if (null != aitem.getAitemPrice()) { |
|
|
|
|
|
aitemVo.setAitemPrice(aitem.getAitemPrice().toString()); |
|
|
|
|
|
} |
|
|
aitemVos.add(aitemVo); |
|
|
aitemVos.add(aitemVo); |
|
|
} |
|
|
} |
|
|
vo.setAitemVos(aitemVos); |
|
|
vo.setAitemVos(aitemVos); |
|
@ -380,12 +389,12 @@ public class SmsSalesBillService extends MybatisBaseService<SmsSalesBillMapper, |
|
|
SmsWmsInventorySalesQuery query = pq.getParams(); |
|
|
SmsWmsInventorySalesQuery query = pq.getParams(); |
|
|
QueryWrapper<SmsGoods> qw = new QueryWrapper<>(); |
|
|
QueryWrapper<SmsGoods> qw = new QueryWrapper<>(); |
|
|
if (StringUtils.isNotBlank(query.getGoodsName())) { |
|
|
if (StringUtils.isNotBlank(query.getGoodsName())) { |
|
|
qw.like("s.goodsSpuName", query.getGoodsName()); |
|
|
qw.and(wrapper -> wrapper.like("i.goodsSpuName", query.getGoodsName()).or().like("i.goodsSkuCode", query.getGoodsName())); |
|
|
} |
|
|
} |
|
|
if (StringUtils.isNotBlank(query.getUseOrgSid())) { |
|
|
if (StringUtils.isNotBlank(query.getUseOrgSid())) { |
|
|
qw.like("s.useOrgSid", query.getUseOrgSid()); |
|
|
qw.eq("s.useOrgSid", query.getUseOrgSid()); |
|
|
} |
|
|
} |
|
|
qw.apply("s.currentCount > 0"); |
|
|
qw.apply("i.count > 0"); |
|
|
IPage<SmsSalesBill> page = PagerUtil.queryToPage(pq); |
|
|
IPage<SmsSalesBill> page = PagerUtil.queryToPage(pq); |
|
|
IPage<SmsWmsInventorySalesVo> pagging = baseMapper.listPageSalesGoods(page, qw); |
|
|
IPage<SmsWmsInventorySalesVo> pagging = baseMapper.listPageSalesGoods(page, qw); |
|
|
PagerVo<SmsWmsInventorySalesVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
PagerVo<SmsWmsInventorySalesVo> p = PagerUtil.pageToVo(pagging, null); |
|
@ -612,4 +621,179 @@ public class SmsSalesBillService extends MybatisBaseService<SmsSalesBillMapper, |
|
|
PagerVo<SmsBillListReturnGoodsVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
PagerVo<SmsBillListReturnGoodsVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
return p; |
|
|
return p; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<String> printSmsBill(PrintPdfQuery query) { |
|
|
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
|
|
PrintPdfVo vo = new PrintPdfVo(); |
|
|
|
|
|
String filePath = ""; |
|
|
|
|
|
String company = ""; |
|
|
|
|
|
String dept = ""; |
|
|
|
|
|
String userName = ""; |
|
|
|
|
|
String sid = query.getSid(); //单据sid
|
|
|
|
|
|
BigDecimal sumMoney2 = BigDecimal.ZERO; //维修项目合计
|
|
|
|
|
|
String subject = ""; |
|
|
|
|
|
SysOrganizationVo u = sysOrganizationFeign.fetchBySid(query.getUseOrgSid()).getData(); |
|
|
|
|
|
if (null != u) { |
|
|
|
|
|
dept = u.getName(); |
|
|
|
|
|
} |
|
|
|
|
|
SysOrganizationVo c = sysOrganizationFeign.fetchBySid(query.getCreateOrgSid()).getData(); |
|
|
|
|
|
if (null != c) { |
|
|
|
|
|
company = c.getName(); |
|
|
|
|
|
} |
|
|
|
|
|
SysUserVo userVo = sysUserFeign.fetchBySid(query.getUserSid()).getData(); |
|
|
|
|
|
if (null != userVo) { |
|
|
|
|
|
userName = userVo.getName(); |
|
|
|
|
|
} |
|
|
|
|
|
vo.setCompany(company); |
|
|
|
|
|
vo.setDept(dept); |
|
|
|
|
|
vo.setUserName(userName); |
|
|
|
|
|
SmsSalesBill detailsVo = fetchBySid(sid); |
|
|
|
|
|
if (null != detailsVo) { |
|
|
|
|
|
if (StringUtils.isNotBlank(detailsVo.getCustomerName())) { |
|
|
|
|
|
vo.setCustomer(detailsVo.getCustomerName()); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(detailsVo.getBillNo())) { |
|
|
|
|
|
vo.setBillNo(detailsVo.getBillNo()); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(detailsVo.getMobile())) { |
|
|
|
|
|
vo.setMobile(detailsVo.getMobile()); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(detailsVo.getVehMark())) { |
|
|
|
|
|
vo.setVehMark(detailsVo.getVehMark()); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(detailsVo.getVinNo())) { |
|
|
|
|
|
vo.setVinNo(detailsVo.getVinNo()); |
|
|
|
|
|
} |
|
|
|
|
|
SmsSalesBillInvoice invoiceVo = smsSalesBillInvoiceService.fetchByMainSid(sid); |
|
|
|
|
|
if (null != invoiceVo) { |
|
|
|
|
|
if (null != invoiceVo.getIsInvoicing()) { |
|
|
|
|
|
if (invoiceVo.getIsInvoicing().intValue() == 1) { |
|
|
|
|
|
vo.setIsKp("是"); |
|
|
|
|
|
} else { |
|
|
|
|
|
vo.setIsKp("否"); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
vo.setIsKp("否"); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
vo.setIsKp("否"); |
|
|
|
|
|
} |
|
|
|
|
|
List<SmsSalesBillDetail> detailsVos = smsSalesBillDetailService.fetchByMainSid(sid); |
|
|
|
|
|
if (!detailsVos.isEmpty()) { |
|
|
|
|
|
List<PrintPdfDetailsPdfVo> goodsPdfVos = new ArrayList<>(); |
|
|
|
|
|
for (int i = 0; i < detailsVos.size(); i++) { |
|
|
|
|
|
SmsSalesBillDetail goodsDetailsVo = detailsVos.get(i); |
|
|
|
|
|
PrintPdfDetailsPdfVo goodsPdfVo = new PrintPdfDetailsPdfVo(); |
|
|
|
|
|
BeanUtil.copyProperties(goodsDetailsVo, goodsPdfVo); |
|
|
|
|
|
goodsPdfVo.setSortNo(String.valueOf(i + 1)); |
|
|
|
|
|
BigDecimal price = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal count = BigDecimal.ZERO; |
|
|
|
|
|
if (null != goodsDetailsVo.getPrice()) { |
|
|
|
|
|
price = goodsDetailsVo.getPrice(); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != goodsDetailsVo.getCount()) { |
|
|
|
|
|
count = goodsDetailsVo.getCount(); |
|
|
|
|
|
} |
|
|
|
|
|
BigDecimal amount = price.multiply(count); |
|
|
|
|
|
goodsPdfVos.add(goodsPdfVo); |
|
|
|
|
|
sumMoney2.add(amount); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
vo.setAmountTotal(sumMoney2.toString()); |
|
|
|
|
|
String caps2 = bigDecimalToLocalStr(sumMoney2); |
|
|
|
|
|
vo.setCaps(caps2); |
|
|
|
|
|
vo.setUserName(userName); |
|
|
|
|
|
vo.setNowDate(DateUtil.formatDate(new Date())); |
|
|
|
|
|
String path = createPrintSmsPdf(vo); |
|
|
|
|
|
filePath = path; |
|
|
|
|
|
} |
|
|
|
|
|
return rb.success().setData(filePath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String createPrintSmsPdf(PrintPdfVo vo) { |
|
|
|
|
|
String finalPath = ""; |
|
|
|
|
|
Map<String, Object> dataMap = new HashMap(); |
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
|
|
dataMap.put("company", vo.getCompany()); |
|
|
|
|
|
dataMap.put("dept", vo.getDept()); |
|
|
|
|
|
dataMap.put("customer", vo.getCustomer()); |
|
|
|
|
|
dataMap.put("billNo", vo.getBillNo()); |
|
|
|
|
|
dataMap.put("vinNo", vo.getVinNo()); |
|
|
|
|
|
dataMap.put("mobile", vo.getMobile()); |
|
|
|
|
|
dataMap.put("vehMark", vo.getVehMark()); |
|
|
|
|
|
dataMap.put("isKp", vo.getIsKp()); |
|
|
|
|
|
dataMap.put("caps", vo.getCaps()); |
|
|
|
|
|
dataMap.put("amountTotal", vo.getAmountTotal()); |
|
|
|
|
|
dataMap.put("userName", vo.getUserName()); |
|
|
|
|
|
dataMap.put("nowDate", vo.getNowDate()); |
|
|
|
|
|
List<PrintPdfDetailsPdfVo> goods = vo.getGoods(); |
|
|
|
|
|
if (!goods.isEmpty()) { |
|
|
|
|
|
for (PrintPdfDetailsPdfVo good : goods) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
map.put("sortNo", good.getSortNo()); |
|
|
|
|
|
map.put("goodsSpuName", good.getGoodsSpuName()); |
|
|
|
|
|
map.put("goodsSkuCode", good.getGoodsSkuCode()); |
|
|
|
|
|
map.put("goodsSkuOwnSpec", good.getGoodsSkuOwnSpec()); |
|
|
|
|
|
map.put("unit", good.getUnit()); |
|
|
|
|
|
map.put("count", good.getCount()); |
|
|
|
|
|
map.put("price", good.getPrice()); |
|
|
|
|
|
map.put("amount", good.getAmount()); |
|
|
|
|
|
map.put("discountAmount", good.getDiscountAmount()); |
|
|
|
|
|
map.put("discount", good.getDiscount()); |
|
|
|
|
|
map.put("remarks", good.getRemarks()); |
|
|
|
|
|
list.add(map); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
dataMap.put("list", list); |
|
|
|
|
|
String temp = "/template/"; |
|
|
|
|
|
String targetPath = docPdfComponent.getUploadTemplateUrl(); |
|
|
|
|
|
String ftl = "ftl/xiaoshoudan.ftl"; |
|
|
|
|
|
try { |
|
|
|
|
|
//获取模板
|
|
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(ftl); |
|
|
|
|
|
//生成word文件名
|
|
|
|
|
|
String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
|
|
|
|
|
long seconds = System.currentTimeMillis(); |
|
|
|
|
|
String typeName = dateStr + seconds + ".doc"; |
|
|
|
|
|
File file = new File(targetPath + "templateSettle" + seconds + ".ftl"); |
|
|
|
|
|
File dir = new File(targetPath); |
|
|
|
|
|
WordConvertUtils.inputStreamToFile(inputStream, file); |
|
|
|
|
|
WordConvertUtils.creatWord1(dataMap, file, targetPath, typeName, dir); |
|
|
|
|
|
//新生成的word路径
|
|
|
|
|
|
String wordPath = targetPath + typeName; |
|
|
|
|
|
String pdfName = "配件销售单" + dateStr + seconds + ".pdf"; |
|
|
|
|
|
WordConvertUtils.doc2pdf(wordPath, targetPath, pdfName); |
|
|
|
|
|
finalPath = temp + pdfName; |
|
|
|
|
|
} catch (NoClassDefFoundError e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
finalPath = targetPath; |
|
|
|
|
|
} |
|
|
|
|
|
return finalPath; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static String bigDecimalToLocalStr(BigDecimal bigDecimal) { |
|
|
|
|
|
String[] chinese = new String[]{"", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万"}; |
|
|
|
|
|
String[] numChinese = new String[]{"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; |
|
|
|
|
|
String[] afterChinese = new String[]{"角", "分"}; |
|
|
|
|
|
String str = String.valueOf(bigDecimal); |
|
|
|
|
|
String[] arr = str.split("\\."); |
|
|
|
|
|
char[] chars = arr[0].toCharArray(); |
|
|
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
|
|
for (int i = 0; i < chars.length; ++i) { |
|
|
|
|
|
sb.append(numChinese[Integer.valueOf(String.valueOf(chars[i])).intValue()]).append(chinese[chars.length - i - 1]); |
|
|
|
|
|
} |
|
|
|
|
|
if (arr.length == 1) { |
|
|
|
|
|
return sb.toString() + "元整"; |
|
|
|
|
|
} else if (arr[1].length() > 2) { |
|
|
|
|
|
throw new IllegalArgumentException("人民币大写转换BigDecimal只能保留2位小数"); |
|
|
|
|
|
} else { |
|
|
|
|
|
sb.append("元"); |
|
|
|
|
|
char[] chars1 = arr[1].toCharArray(); |
|
|
|
|
|
for (int i = 0; i < chars1.length; ++i) { |
|
|
|
|
|
sb.append(numChinese[Integer.valueOf(String.valueOf(chars1[i])).intValue()]).append(afterChinese[i]); |
|
|
|
|
|
} |
|
|
|
|
|
return sb.toString(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|