[add] 物资采购联系单模版

This commit is contained in:
lcj
2025-08-19 10:10:07 +08:00
parent a661d4f24c
commit a8d8a76fd2
10 changed files with 501 additions and 39 deletions

View File

@ -0,0 +1,289 @@
--- # 临时文件存储位置 避免临时文件被系统清理报错
spring.servlet.multipart.location: /ruoyi/server/temp
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
enabled: false
url: http://localhost:9090/admin
instance:
service-host-type: IP
metadata:
username: ${spring.boot.admin.client.username}
userpassword: ${spring.boot.admin.client.password}
username: @monitor.username@
password: @monitor.password@
--- # snail-job 配置
snail-job:
enabled: false
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
group: "ruoyi_group"
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表
token: "SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
server:
host: 127.0.0.1
port: 17888
# 命名空间UUID 详见 script/sql/ry_job.sql `sj_namespace`表`unique_id`字段
namespace: ${spring.profiles.active}
# 随主应用端口漂移
port: 2${server.port}
# 客户端ip指定
host:
# RPC类型: netty, grpc
rpc-type: grpc
--- # 数据源配置
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
dynamic:
# 性能分析插件(有性能损耗 不建议生产环境使用)
p6spy: false
# 设置默认的数据源或者数据源组,默认值即为 master
primary: master
# 严格模式 匹配不到数据源则报错
strict: true
datasource:
# 主库数据源
master:
type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://192.168.110.2:13386/xinnengyuanlocal?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: xinnengyuanlocal
password: 5Rff6TrihXZAAT5M
# # 从库数据源
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
hikari:
# 最大连接池数量
maxPoolSize: 20
# 最小空闲线程数量
minIdle: 10
# 配置获取连接等待超时的时间
connectionTimeout: 30000
# 校验超时时间
validationTimeout: 5000
# 空闲连接存活最大时间默认10分钟
idleTimeout: 600000
# 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟
maxLifetime: 1800000
# 多久检查一次连接的活性
keepaliveTime: 30000
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring.data:
redis:
# 地址
host: 192.168.110.2
# 端口默认为6379
port: 9287
# 数据库索引
database: 6
# redis 密码必须配置
password: syar23rdsaagdrsa
# 连接超时时间
timeout: 10s
# 是否开启ssl
ssl.enabled: false
# redisson 配置
redisson:
# redis key前缀
keyPrefix:
# 线程池数量
threads: 16
# Netty线程池数量
nettyThreads: 32
# 单节点配置
singleServerConfig:
# 客户端名称
clientName: ${ruoyi.name}
# 最小空闲连接数
connectionMinimumIdleSize: 32
# 连接池大小
connectionPoolSize: 64
# 连接空闲超时,单位:毫秒
idleConnectionTimeout: 10000
# 命令等待超时,单位:毫秒
timeout: 3000
# 发布和订阅连接池大小
subscriptionConnectionPoolSize: 50
--- # mail 邮件发送
mail:
enabled: false
host: smtp.163.com
port: 465
# 是否需要用户名密码验证
auth: true
# 发送方遵循RFC-822标准
from: xxx@163.com
# 用户名注意如果使用foxmail邮箱此处user为qq号
user: xxx@163.com
# 密码注意某些邮箱需要为SMTP服务单独设置密码详情查看相关帮助
pass: xxxxxxxxxx
# 使用 STARTTLS安全连接STARTTLS是对纯文本通信协议的扩展。
starttlsEnable: true
# 使用SSL安全连接
sslEnable: true
# SMTP超时时长单位毫秒缺省值不超时
timeout: 0
# Socket连接超时值单位毫秒缺省值不超时
connectionTimeout: 0
--- # sms 短信 支持 阿里云 腾讯云 云片 等等各式各样的短信服务商
# https://sms4j.com/doc3/ 差异配置文档地址 支持单厂商多配置,可以配置多个同时使用
sms:
# 配置源类型用于标定配置来源(interface,yaml)
config-type: yaml
# 用于标定yml中的配置是否开启短信拦截接口配置不受此限制
restricted: true
# 短信拦截限制单手机号每分钟最大发送,只对开启了拦截的配置有效
minute-max: 1
# 短信拦截限制单手机号每日最大发送量,只对开启了拦截的配置有效
account-max: 30
# 以下配置来自于 org.dromara.sms4j.provider.config.BaseConfig类中
blends:
# 唯一ID 用于发送短信寻找具体配置 随便定义别用中文即可
# 可以同时存在两个相同厂商 例如: ali1 ali2 两个不同的阿里短信账号 也可用于区分租户
config1:
# 框架定义的厂商名称标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
supplier: alibaba
# 有些称为accessKey有些称之为apiKey也有称为sdkKey或者appId。
access-key-id: 您的accessKey
# 称为accessSecret有些称之为apiSecret
access-key-secret: 您的accessKeySecret
signature: 您的短信签名
sdk-app-id: 您的sdkAppId
config2:
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
supplier: tencent
access-key-id: 您的accessKey
access-key-secret: 您的accessKeySecret
signature: 您的短信签名
sdk-app-id: 您的sdkAppId
--- # 三方授权
justauth:
# 前端外网访问地址
address: http://localhost:80
type:
maxkey:
# maxkey 服务器地址
# 注意 如下均配置均不需要修改 maxkey 已经内置好了数据
server-url: http://sso.maxkey.top
client-id: 876892492581044224
client-secret: x1Y5MTMwNzIwMjMxNTM4NDc3Mzche8
redirect-uri: ${justauth.address}/social-callback?source=maxkey
topiam:
# topiam 服务器地址
server-url: http://127.0.0.1:1989/api/v1/authorize/y0q************spq***********8ol
client-id: 449c4*********937************759
client-secret: ac7***********1e0************28d
redirect-uri: ${justauth.address}/social-callback?source=topiam
scopes: [ openid, email, phone, profile ]
qq:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=qq
union-id: false
weibo:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=weibo
gitee:
client-id: 91436b7940090d09c72c7daf85b959cfd5f215d67eea73acbf61b6b590751a98
client-secret: 02c6fcfd70342980cd8dd2f2c06c1a350645d76c754d7a264c4e125f9ba915ac
redirect-uri: ${justauth.address}/social-callback?source=gitee
dingtalk:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=dingtalk
baidu:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=baidu
csdn:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=csdn
coding:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=coding
coding-group-name: xx
oschina:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=oschina
alipay_wallet:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=alipay_wallet
alipay-public-key: MIIB**************DAQAB
wechat_open:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=wechat_open
wechat_mp:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=wechat_mp
wechat_enterprise:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=wechat_enterprise
agent-id: 1000002
gitlab:
client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=gitlab
# 和风天气 https://dev.qweather.com/
weather:
key-id: T65EAABUXC
project-id: 2JTHPUQ5YY
private-key: MC4CAQAwBQYDK2VwBCIEIMAglX7IsxYiTeM+FXXnvCUsIggajeP4s8gAllewm6BN
api-host: n35rk53njv.re.qweatherapi.com
# dxf转 geojson 执行文件名
dxf2GeoJson:
file-name: main
ys7:
app-key: 3acf9f1a43dc4209841e0893003db0a2
app-secret: 4bbf3e9394f55d3af6e3af27b2d3db36
# 斯巴达算法
sparta:
url: http://119.3.204.120:8040
client-id: test
client-secret: 115fcb08fa6742a1b086d9bb80a6ad59
# 身份证加密密钥32 位)
id-card:
encrypt-key: 7ae260d150a14027d2238a1cf80a48ef
recognizer:
url: http://192.168.110.5:50070

View File

@ -1,33 +1,34 @@
package org.dromara.cailiaoshebei.controller;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation;
import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.domain.vo.BusMaterialbatchdemandplanVo;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* 物资-采购联系单
@ -67,6 +68,17 @@ public class BusPurchaseDocController extends BaseController {
ExcelUtil.exportExcel(list, "物资-采购联系单", BusPurchaseDocVo.class, response);
}
/**
* 根据主键导出物资-采购联系单
*/
@SaCheckPermission("cailiaoshebei:purchaseDoc:downloadWord")
@Log(title = "物资-采购联系单", businessType = BusinessType.EXPORT)
@PostMapping("/export/word")
public void exportWordById(@NotNull(message = "主键不能为空") Long id,
HttpServletResponse response) {
busPurchaseDocService.exportWordById(id, response);
}
/**
* 获取物资-采购联系单详细信息
*
@ -75,7 +87,7 @@ public class BusPurchaseDocController extends BaseController {
@SaCheckPermission("cailiaoshebei:purchaseDoc:query")
@GetMapping("/{id}")
public R<BusPurchaseDocVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
@PathVariable Long id) {
return R.ok(busPurchaseDocService.queryById(id));
}
@ -120,7 +132,7 @@ public class BusPurchaseDocController extends BaseController {
*/
@GetMapping("/planList/{id}")
public R<List<BusMaterialbatchdemandplanVo>> list(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
@PathVariable("id") Long id) {
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
.eq(BusPlanDocAssociation::getDocId, id));
List<Long> list1 = list.stream().map(BusPlanDocAssociation::getPlanId).toList();

View File

@ -10,4 +10,5 @@ public class constant {
public static final String MaterialsPlans = "materialsPlans"; //计划
public static final String BatchRequirements = "batchRequirements"; //需求
public static final String EquipmentOrdering = "equipmentOrdering"; //订货
public static final String PURCHASE_DOC_TEMPLATE_PATH = "template/物资采购联系单模版.docx"; // 采购联系单文件路径
}

View File

@ -0,0 +1,23 @@
package org.dromara.cailiaoshebei.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author lilemy
* @date 2025-08-18 16:37
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BusMaterialbatchdemandplanWordDto {
private Integer num;
private String childName;
private String specification;
private String unit;
private Long demandQuantity;
private String remark;
}

View File

@ -0,0 +1,33 @@
package org.dromara.cailiaoshebei.domain.dto;
import lombok.Data;
import java.util.List;
/**
* @author lilemy
* @date 2025-08-18 16:31
*/
@Data
public class BusPurchaseDocWordDto {
private String projectName;
private String docCode;
private String supplier;
private String reason;
private String name;
private String arrivalDate;
private String designDirectorTel;
private String technicalDirectorTel;
private String receivingAddress;
private String contacts;
private String projectDirector;
private String purchasingAgent;
private String preparedDate;
private String signingUnit;
private String signingPerson;
private String signingDate;
private List<BusMaterialbatchdemandplanWordDto> items;
}

View File

@ -1,12 +1,12 @@
package org.dromara.cailiaoshebei.service;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.domain.BusPurchaseDoc;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import org.dromara.cailiaoshebei.domain.BusPurchaseDoc;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import java.math.BigDecimal;
import java.util.Collection;
@ -19,7 +19,7 @@ import java.util.List;
* @author Lion Li
* @date 2025-08-13
*/
public interface IBusPurchaseDocService extends IService<BusPurchaseDoc>{
public interface IBusPurchaseDocService extends IService<BusPurchaseDoc> {
/**
* 查询物资-采购联系单
@ -75,4 +75,11 @@ public interface IBusPurchaseDocService extends IService<BusPurchaseDoc>{
* 创建补货采购单
*/
void create(Long id, HashMap<Long, BigDecimal> map);
/**
* 根据主键导出Word
*
* @param id 主键id
*/
void exportWordById(Long id, HttpServletResponse response);
}

View File

@ -1,17 +1,34 @@
package org.dromara.cailiaoshebei.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.cailiaoshebei.controller.constant;
import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan;
import org.dromara.cailiaoshebei.domain.BusMrpBase;
import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation;
import org.dromara.cailiaoshebei.domain.BusPurchaseDoc;
import org.dromara.cailiaoshebei.domain.bo.BusPlanDocAssociationBo;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.domain.dto.BusMaterialbatchdemandplanWordDto;
import org.dromara.cailiaoshebei.domain.dto.BusPurchaseDocWordDto;
import org.dromara.cailiaoshebei.domain.vo.BusPlanDocAssociationVo;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.mapper.BusPurchaseDocMapper;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
import org.dromara.common.core.domain.event.ProcessEvent;
import org.dromara.common.core.domain.event.ProcessTaskEvent;
@ -19,23 +36,21 @@ import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.oss.exception.OssException;
import org.springframework.beans.BeanUtils;
import org.springframework.context.event.EventListener;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.domain.BusPurchaseDoc;
import org.dromara.cailiaoshebei.mapper.BusPurchaseDocMapper;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -245,6 +260,86 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
planDocAssociationService.saveBatch(busPlanDocAssociations);
}
/**
* 根据主键导出Word
*
* @param id 主键id
*/
@Override
public void exportWordById(Long id, HttpServletResponse response) {
BusPurchaseDoc purchaseDoc = this.getById(id);
if (purchaseDoc == null) {
throw new ServiceException("物料领料单不存在");
}
// 准备数据
List<BusMaterialbatchdemandplan> items = new ArrayList<>();
List<BusPlanDocAssociation> planDocAssociationList = planDocAssociationService.lambdaQuery()
.eq(BusPlanDocAssociation::getDocId, id)
.list();
if (CollUtil.isNotEmpty(planDocAssociationList)) {
List<Long> planIds = planDocAssociationList.stream().map(BusPlanDocAssociation::getPlanId).toList();
items = materialbatchdemandplanService.listByIds(planIds);
}
BusPurchaseDocWordDto data = this.getReplacementDto(purchaseDoc, items);
// 生成文件
try (InputStream is = getClass().getClassLoader().getResourceAsStream(constant.PURCHASE_DOC_TEMPLATE_PATH)) {
if (is == null) {
throw new ServiceException("模板文件不存在");
}
LoopRowTableRenderPolicy hackLoopTableRenderPolicy = new LoopRowTableRenderPolicy();
Configure config = Configure.builder().bind("items", hackLoopTableRenderPolicy).build();
XWPFTemplate template = XWPFTemplate.compile(is, config);
template.render(data);
// 设置响应头,通知浏览器下载 Word 文件
String fileName = URLEncoder.encode("物料领料单_" + id + ".docx", StandardCharsets.UTF_8);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
try (ServletOutputStream out = response.getOutputStream()) {
template.write(out); // 将文件写入响应流
out.flush();
}
template.close();
} catch (IOException e) {
throw new OssException("生成Word文件失败错误信息: " + e.getMessage());
}
}
/**
* 根据实体获取替换数据
*
* @param purchaseDoc 物资-采购联系单对象
* @param items 物资-批次需求计划对象列表
* @return 替换 Word 数据
*/
private BusPurchaseDocWordDto getReplacementDto(BusPurchaseDoc purchaseDoc, List<BusMaterialbatchdemandplan> items) {
BusPurchaseDocWordDto dto = new BusPurchaseDocWordDto();
BeanUtils.copyProperties(purchaseDoc, dto);
// 日期转换
LocalDate arrivalDate = purchaseDoc.getArrivalDate();
dto.setArrivalDate(arrivalDate.format(DateTimeFormatter.ofPattern("yyyy 年 MM 月 dd 日")));
LocalDate signingDate = purchaseDoc.getSigningDate();
dto.setSigningDate(signingDate.format(DateTimeFormatter.ofPattern("yyyy 年 MM 月 dd 日")));
// 明细项信息
if (CollUtil.isNotEmpty(items)) {
List<BusMaterialbatchdemandplanWordDto> dtoItems = new ArrayList<>();
for (int i = 1; i <= items.size(); i++) {
BusMaterialbatchdemandplan item = items.get(i - 1);
BusMaterialbatchdemandplanWordDto itemDto = new BusMaterialbatchdemandplanWordDto();
BeanUtils.copyProperties(item, itemDto);
itemDto.setNum(i);
itemDto.setChildName(item.getName());
dtoItems.add(itemDto);
}
dto.setItems(dtoItems);
} else {
BusMaterialbatchdemandplanWordDto itemDto = new BusMaterialbatchdemandplanWordDto();
itemDto.setNum(1);
dto.setItems(List.of(itemDto));
}
return dto;
}
/**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
* 正常使用只需#processEvent.flowCode=='leave1'

View File

@ -31,7 +31,7 @@ import java.time.LocalTime;
import java.util.*;
@Slf4j
@Component
//@Component
public class AttendanceJob {
@Resource

View File

@ -286,12 +286,14 @@ public class PgsProgressCategoryTemplateServiceImpl extends ServiceImpl<PgsProgr
String name = req.getName();
String unitType = req.getUnitType();
Long projectId = req.getProjectId();
String constructionType = req.getConstructionType();
// 模糊查询
lqw.like(StringUtils.isNotBlank(name), PgsProgressCategoryTemplate::getName, name);
// 精确查询
lqw.in(ObjectUtils.isNotEmpty(projectId), PgsProgressCategoryTemplate::getProjectId, projectId, PgsProgressCategoryConstant.PUBLIC_PROJECT_ID);
lqw.eq(ObjectUtils.isNotEmpty(projectId), PgsProgressCategoryTemplate::getProjectId, projectId);
lqw.eq(StringUtils.isNotBlank(unitType), PgsProgressCategoryTemplate::getUnitType, unitType);
lqw.eq(ObjectUtils.isNotEmpty(parentId), PgsProgressCategoryTemplate::getParentId, parentId);
lqw.eq(StringUtils.isNotBlank(constructionType), PgsProgressCategoryTemplate::getConstructionType, constructionType);
return lqw;
}