Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dcs-plan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
INET-TWO
server
dcs-plan
Commits
2430f82b
Commit
2430f82b
authored
Sep 27, 2024
by
wei
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
启动流程,生成附件
parent
7648f6b5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
2496 additions
and
32 deletions
+2496
-32
Constants.java
...n/java/com/yonde/dcs/plan/common/constants/Constants.java
+5
-0
SignConstants.java
...va/com/yonde/dcs/plan/common/constants/SignConstants.java
+119
-0
pom.xml
dcs-plan-core/pom.xml
+10
-0
ExtExpenditureContractController.java
...lan/core/controller/ExtExpenditureContractController.java
+32
-15
ContractUtils.java
...n/java/com/yonde/dcs/plan/core/factory/ContractUtils.java
+94
-0
AutoTaskService.java
...java/com/yonde/dcs/plan/core/service/AutoTaskService.java
+7
-2
ExtExpenditureContractService.java
.../dcs/plan/core/service/ExtExpenditureContractService.java
+34
-0
AutoTaskServiceImpl.java
...yonde/dcs/plan/core/service/impl/AutoTaskServiceImpl.java
+28
-0
ExtExpenditureContractServiceImpl.java
.../core/service/impl/ExtExpenditureContractServiceImpl.java
+264
-15
CommonUtils.java
...c/main/java/com/yonde/dcs/plan/core/util/CommonUtils.java
+22
-0
Word2PdfJacobUtil.java
.../java/com/yonde/dcs/plan/core/util/Word2PdfJacobUtil.java
+82
-0
WorkFlowUtil.java
.../main/java/com/yonde/dcs/plan/core/util/WorkFlowUtil.java
+251
-0
CommonWord.java
...rc/main/java/com/yonde/dcs/plan/core/word/CommonWord.java
+502
-0
DocFont.java
...e/src/main/java/com/yonde/dcs/plan/core/word/DocFont.java
+35
-0
DocumentDispatch.java
...n/java/com/yonde/dcs/plan/core/word/DocumentDispatch.java
+202
-0
DownloadPictures.java
...n/java/com/yonde/dcs/plan/core/word/DownloadPictures.java
+38
-0
ImportWordService.java
.../java/com/yonde/dcs/plan/core/word/ImportWordService.java
+140
-0
UpdateWordText.java
...ain/java/com/yonde/dcs/plan/core/word/UpdateWordText.java
+631
-0
No files found.
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/constants/Constants.java
View file @
2430f82b
...
...
@@ -20,6 +20,11 @@ public class Constants {
*/
public
static
final
String
PDF_FILE
=
"DOC_PDF_FILE"
;
/**
* app 内部名称
*/
public
static
final
String
APPLICATION_INNER_NAME
=
"dcs-plan"
;
/**
* minio桶名称
*/
...
...
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/constants/SignConstants.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
common
.
constants
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* @author xfchai
* @ClassName SignConstants.java
* @Description 常量属性
* @createTime 2021/09/02 14:42:00
*/
public
final
class
SignConstants
{
//签名取值
public
static
final
String
SIGN_KEY_PREPARED
=
"编制"
;
public
static
final
String
SIGN_KEY_TSSH
=
"同室审核"
;
public
static
final
String
SIGN_KEY_FXTZSSH
=
"分系统总师审核"
;
public
static
final
String
SIGN_KEY_GY
=
"工艺"
;
public
static
final
String
SIGN_KEY_QF
=
"签发"
;
public
static
final
String
SIGN_KEY_ZTSSH
=
"总体室审核"
;
public
static
final
String
SIGN_KEY_APPROVED
=
"批准"
;
public
static
final
String
SIGN_KEY_STANDARD
=
"标准化"
;
public
static
final
String
SIGN_KEY_ZTS
=
"总体室"
;
public
static
final
String
SIGN_KEY_ZTSQS
=
"总体室签审"
;
public
static
final
String
SIGN_KEY_TZSH
=
"提资审核"
;
public
static
final
String
SIGN_KEY_SH
=
"审核"
;
public
static
final
String
SIGN_KEY_CLJD
=
"编制不符合项处理单处理决定任务"
;
public
static
final
String
SIGN_KEY_SWYZ
=
"编制不符合项处理单实物验证项任务"
;
public
static
final
String
SIGN_KEY_SQSH
=
"申请审核"
;
public
static
final
String
SIGN_KEY_CHECKER
=
"校核"
;
public
static
final
String
SIGN_KEY_SD
=
"审定"
;
public
static
final
String
SIGN_KEY_JKHQ
=
"接口会签"
;
public
static
final
String
SIGN_KEY_CGB
=
"采购部会签"
;
public
static
final
String
SIGN_KEY_SCB
=
"市场部会签"
;
public
static
final
String
SIGN_KEY_CPYF
=
"产品研发部复核"
;
public
static
final
String
SIGN_KEY_PBB
=
"品保部"
;
public
static
final
String
SIGN_ZBB
=
"质保部签审"
;
public
static
final
String
SIGN_SJX
=
"设计项签审"
;
public
static
final
String
SIGN_ZTS
=
"总体室签审"
;
public
static
final
String
SIGN_GCB
=
"工程部签审"
;
public
static
final
String
SIGN_SD
=
"审定"
;
public
static
final
String
SIGN_KEY_ZTSJKSC
=
"总体室接口审查"
;
public
static
final
String
SIGN_KEY_ZXSC
=
"专项审查"
;
public
static
final
String
SIGN_KEY_JKHQSC
=
"接口会签审查"
;
//NCR审查单模板变量(质保部签审)
public
static
final
String
ZBBprocessName
=
"ZBBprocessName"
;
public
static
final
String
ZBBremark
=
"ZBBremark"
;
public
static
final
String
ZBBfzr_photo
=
"ZBBfzr_photo"
;
public
static
final
String
ZBBfzr_date
=
"ZBBfzr_date"
;
//NCR审查单模板变量(设计项签审)
public
static
final
String
SJXprocessName
=
"SJXprocessName"
;
public
static
final
String
SJXremark
=
"SJXremark"
;
public
static
final
String
SJXfzr_photo
=
"SJXfzr_photo"
;
public
static
final
String
SJXfzr_date
=
"SJXfzr_date"
;
//NCR审查单模板变量(总体室签审)
public
static
final
String
ZTSprocessName
=
"ZTSprocessName"
;
public
static
final
String
ZTSremark
=
"ZTSremark"
;
public
static
final
String
ZTSfzr_photo
=
"ZTSfzr_photo"
;
public
static
final
String
ZTSfzr_date
=
"ZTSfzr_date"
;
//NCR审查单模板变量(工程部签审)
public
static
final
String
GCBprocessName
=
"GCBprocessName"
;
public
static
final
String
GCBremark
=
"GCBremark"
;
public
static
final
String
GCBfzr_photo
=
"GCBfzr_photo"
;
public
static
final
String
GCBfzr_date
=
"GCBfzr_date"
;
/**
* 定义流程判断节点常量
*/
public
final
static
List
WfResultList
=
Arrays
.
asList
(
"通过"
,
"提交签审"
,
"提交审阅"
,
"提交"
,
"提交提资审阅"
,
"不需要总体室会签"
,
"外协采购单位(过工程部)"
,
"设计协同单位及其他"
);
/**
* 定义总体室签审节点名称
*/
public
final
static
List
ZTSSignTaskList
=
Arrays
.
asList
(
SIGN_KEY_ZTS
,
SIGN_ZTS
,
SIGN_KEY_ZTSJKSC
);
/**
* 定义流程路由常量
*/
public
final
static
List
WfRoutingList
=
Arrays
.
asList
(
"通过"
,
"提交"
);
/**
* 流程 节点名称
*/
public
static
final
HashMap
<
String
,
String
>
SignNodeMap
=
new
HashMap
()
{{
put
(
"编制"
,
"BKBZ"
);
put
(
"校对"
,
"BKJD"
);
put
(
"审定"
,
"BKSD"
);
put
(
"标检"
,
"BKBJ"
);
put
(
"数据审核"
,
"BKSJ"
);
put
(
"管理审核"
,
"BKGL"
);
put
(
"资料员审核"
,
"BKZL"
);
put
(
"标审"
,
"BKBS"
);
put
(
"会签"
,
"BKHQ"
);
put
(
"工艺室分发辅制会签"
,
"BKFZ"
);
put
(
"工艺主制会签"
,
"BKZZ"
);
put
(
"审核"
,
"BKSH"
);
put
(
"批准"
,
"BKPZ"
);
put
(
"待审阅"
,
"BKDS"
);
put
(
"设总签审"
,
"BKSZ"
);
put
(
"总体室签审"
,
"BKZT"
);
put
(
"总体室接口工程师签审设总综合检查人"
,
"BKJK"
);
put
(
"综合检查"
,
"BKZH"
);
}};
/**
* 流程 节点名称
*/
public
static
final
HashMap
<
String
,
String
>
InterfaceSignNodeMap
=
new
HashMap
()
{
{
put
(
"审核"
,
"TKSK"
);
put
(
"提资方设总签审"
,
"TKSZ"
);
put
(
"提资中"
,
"TKTJ"
);
put
(
"总体室接口工程师签审"
,
"TKZT"
);
}
};
}
\ No newline at end of file
dcs-plan-core/pom.xml
View file @
2430f82b
...
...
@@ -74,6 +74,16 @@
<groupId>
com.yonde.dex
</groupId>
<artifactId>
dex-secretcode-plugin-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
<version>
5.2.12.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
ooxml-schemas
</artifactId>
<version>
1.4
</version>
</dependency>
</dependencies>
</project>
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/controller/ExtExpenditureContractController.java
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
controller
;
import
org.springframework.stereotype.Controller
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.validation.annotation.Validated
;
import
java.util.List
;
import
com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.*
;
import
com.yonde.dcs.plan.core.controller.shadow.ExtExpenditureContractControllerShadow
;
import
com.yonde.dcs.plan.core.service.AutoTaskService
;
import
com.yonde.dcs.plan.core.service.ExtExpenditureContractService
;
import
com.yonde.dex.basedata.entity.api.ApiResult
;
import
com.yonde.dcs.plan.core.controller.shadow.ExtExpenditureContractControllerShadow
;
import
javax.annotation.Resource
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
* @description: ExtExpenditureContract-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-24 16:48:59
**/
* @description: ExtExpenditureContract-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-24 16:48:59
**/
@Api
(
tags
=
"ExtExpenditureContract管理服务"
)
@RequestMapping
(
"/ExtExpenditureContract"
)
@ResponseBody
()
@Controller
(
ExtExpenditureContractController
.
BEAN_NAME
)
public
class
ExtExpenditureContractController
<
V
extends
ExtExpenditureContractVO
,
S
extends
ExtExpenditureContractService
<
V
>>
extends
ExtExpenditureContractControllerShadow
<
V
,
S
>
{
@Autowired
private
ExtExpenditureContractService
extExpenditureContractService
;
@Autowired
private
AutoTaskService
autoTaskService
;
@ApiOperation
(
"发起审批流程"
)
@PostMapping
({
"startWorkflow"
})
public
ApiResult
startWorkflow
(
@RequestParam
(
"id"
)
Long
id
)
{
return
ApiResult
.
ok
(
extExpenditureContractService
.
startWorkflow
(
id
),
"操作完成"
);
}
@ApiOperation
(
value
=
"生成word签字"
,
notes
=
"生成word签字"
,
httpMethod
=
"POST"
)
@PostMapping
(
value
=
"/generateContractWordSign"
)
public
void
generateContractWordSign
(
@RequestParam
(
"documentId"
)
Long
contractId
,
@RequestParam
(
"fileName"
)
String
fileName
)
{
autoTaskService
.
generateContractWordSign
(
contractId
,
fileName
);
}
}
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/factory/ContractUtils.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
factory
;
import
cn.hutool.core.io.FileUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yonde.dcs.plan.common.constants.Constants
;
import
com.yonde.dcs.plan.common.constants.SignConstants
;
import
com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO
;
import
com.yonde.dcs.plan.core.service.ExtExpenditureContractService
;
import
com.yonde.dcs.plan.core.word.ImportWordService
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessTaskVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @author weihongda
* @ClassName ContractUtils.java
* @Description 合同
* @createTime 2022/02/22 14:35:00
*/
@Component
public
class
ContractUtils
{
@Autowired
private
ExtExpenditureContractService
extExpenditureContractService
;
@Autowired
private
ImportWordService
importWordService
;
/**
* 填充评审会议资料数据
*
* @param
* @return
*/
public
JSONObject
settingDocData
(
ExtExpenditureContractVO
expenditureContractVO
,
DxWfProcessInfoVO
wfProcessInfoVO
)
{
String
path
=
Constants
.
MTEMPLATE_ABSOLUTE_PATH
;
String
file
=
expenditureContractVO
.
getSubTypeName
();
String
outFilePath
=
Constants
.
MERGER_FILE_ABSOLUTE_PATH
+
expenditureContractVO
.
getSubTypeName
()
+
"\\"
+
expenditureContractVO
.
getNumber
()
+
"\\"
;
//生成特定的文档目录,保存生成的word文件
FileUtil
.
mkdir
(
outFilePath
);
//获取动态属性
/*Map<String, Object> dynamicAttrs = expenditureContractVO.getDynamicAttrs();
String content = Objects.isNull(dynamicAttrs.get("content")) ? "" : (String) dynamicAttrs.get("content");
String designPhase = Objects.isNull(dynamicAttrs.get("designPhase")) ? "" : (String) dynamicAttrs.get("designPhase");*/
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
expenditureContractVO
);
//项目代号
/*String projectCode = ObjectUtils.isEmpty(v.getDxDocumentExpand().getProjectCode()) ? "" : v.getDxDocumentExpand().getProjectCode();
jsonObject.put("projectCode", extDocService.searchDictDataByDictCode(Constants.PROJECT_CODE, projectCode));
jsonObject.put("projectCode", projectCode);*/
//合同名称
//合同乙方
//合同编号
//合同金额
//合同密级
//合同乙方保密资质等级
//合同类型
//学校/院归口管理部门
//合同成果形式
//成果交付地点(样机存放地方)
//起止时间
//承办部门
//经办人
//
//页数
//jsonObject.put("pages",v.getDxDocumentExpand().getAttachPages());
//获取参与者
List
<
DxWfProcessTaskVO
>
activities
=
wfProcessInfoVO
.
getHistoryInfo
();
if
(!
CollectionUtils
.
isEmpty
(
activities
))
{
//写入签名数据
jsonObject
.
put
(
"bz_photo"
,
extExpenditureContractService
.
getSignImage
(
activities
,
SignConstants
.
SIGN_KEY_PREPARED
));
jsonObject
.
put
(
"bz_date"
,
extExpenditureContractService
.
getEndDate
(
activities
,
SignConstants
.
SIGN_KEY_PREPARED
));
jsonObject
.
put
(
"sh_photo"
,
extExpenditureContractService
.
getSignImage
(
activities
,
SignConstants
.
SIGN_KEY_SH
));
jsonObject
.
put
(
"sh_date"
,
extExpenditureContractService
.
getEndDate
(
activities
,
SignConstants
.
SIGN_KEY_SH
));
//总体室审核
jsonObject
.
put
(
"zts_photo"
,
extExpenditureContractService
.
getSignImage
(
activities
,
SignConstants
.
SIGN_KEY_ZTSSH
));
jsonObject
.
put
(
"zts_date"
,
extExpenditureContractService
.
getEndDate
(
activities
,
SignConstants
.
SIGN_KEY_ZTSSH
));
jsonObject
.
put
(
"pz_photo"
,
extExpenditureContractService
.
getSignImage
(
activities
,
SignConstants
.
SIGN_KEY_APPROVED
));
jsonObject
.
put
(
"pz_date"
,
extExpenditureContractService
.
getEndDate
(
activities
,
SignConstants
.
SIGN_KEY_APPROVED
));
}
//模板名称
importWordService
.
getWordAllTable
(
jsonObject
,
path
+
file
+
".docx"
,
outFilePath
+
"outFile.docx"
);
return
jsonObject
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/AutoTaskService.java
View file @
2430f82b
...
...
@@ -2,9 +2,7 @@ package com.yonde.dcs.plan.core.service;
import
com.yonde.dex.user.common.vo.DxOrganizationVO
;
import
java.util.List
;
import
java.util.Map
;
/**
* @program: inet-pdm-service
...
...
@@ -16,4 +14,11 @@ public interface AutoTaskService {
List
<
DxOrganizationVO
>
searchOrgNameByUserId
(
Long
userId
,
String
code
);
/**
* 生成word签字
*
* @param contractId
* @param fileName
*/
void
generateContractWordSign
(
Long
contractId
,
String
fileName
);
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/ExtExpenditureContractService.java
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
service
;
import
com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO
;
import
com.yonde.dcs.plan.core.factory.ContractUtils
;
import
com.yonde.dcs.plan.core.service.shadow.ExtExpenditureContractServiceShadow
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessTaskVO
;
import
java.util.List
;
/**
* @description: ExtExpenditureContract-service
* @author: dexadmin
...
...
@@ -10,4 +16,32 @@ import com.yonde.dcs.plan.core.service.shadow.ExtExpenditureContractServiceShado
**/
public
interface
ExtExpenditureContractService
<
V
extends
ExtExpenditureContractVO
>
extends
ExtExpenditureContractServiceShadow
<
V
>
{
ExtExpenditureContractVO
startWorkflow
(
Long
id
);
void
print
(
int
contractType
);
ExtExpenditureContractVO
findExpenditureContractObjFileLinks
(
Long
contractId
);
void
generateContractWordSign
(
ExtExpenditureContractVO
expenditureContractVO
,
Class
<
ContractUtils
>
contractUtilsClass
,
DxWfProcessInfoVO
wfProcessInfoVO
,
String
fileName
);
/**
* 获取签名图片(4.1新)
*
* @param dxWfProcessTaskVO
* @param activityName
* @return
*/
// TODO: xpc 将WfTaskDefinitionVO改为DxWfActivityVO
String
getSignImage
(
List
<
DxWfProcessTaskVO
>
dxWfProcessTaskVO
,
String
activityName
);
/**
* 获取签名日期(4.1新)
*
* @param dxWfProcessTaskVO
* @param activityName
* @return
*/
// TODO: xpc 将WfTaskDefinitionVO改为DxWfActivityVO
String
getEndDate
(
List
<
DxWfProcessTaskVO
>
dxWfProcessTaskVO
,
String
activityName
);
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/AutoTaskServiceImpl.java
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
service
.
impl
;
import
com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO
;
import
com.yonde.dcs.plan.core.factory.ContractUtils
;
import
com.yonde.dcs.plan.core.service.AutoTaskService
;
import
com.yonde.dcs.plan.core.service.ExtExpenditureContractService
;
import
com.yonde.dcs.plan.core.service.ExtPlanService
;
import
com.yonde.dcs.plan.core.util.WorkFlowUtil
;
import
com.yonde.dex.user.common.vo.DxOrganizationVO
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -23,6 +29,12 @@ public class AutoTaskServiceImpl implements AutoTaskService {
@Autowired
private
ExtPlanService
extPlanService
;
@Autowired
private
WorkFlowUtil
workFlowUtil
;
@Autowired
private
ExtExpenditureContractService
extExpenditureContractService
;
/**
* 通过userId获取组织名
*
...
...
@@ -34,4 +46,20 @@ public class AutoTaskServiceImpl implements AutoTaskService {
return
extPlanService
.
searchOrgNameByUserId
(
userId
,
code
);
}
@Override
public
void
generateContractWordSign
(
Long
contractId
,
String
fileName
)
{
//深度查询展开ObjLink
ExtExpenditureContractVO
expenditureContractVO
=
extExpenditureContractService
.
findExpenditureContractObjFileLinks
(
contractId
);
log
.
info
(
"自动任务======生成word签名开始"
);
DxWfProcessVO
wfProcessInstVO
=
workFlowUtil
.
getWfProcessInst
(
expenditureContractVO
);
DxWfProcessInfoVO
wfProcessInfoVO
=
workFlowUtil
.
getProcessInstDetail
(
wfProcessInstVO
);
String
subTypeName
=
expenditureContractVO
.
getSubTypeName
();
log
.
info
(
"自动任务======生成word签名进行中,文档SubTypeName:{}"
,
subTypeName
);
extExpenditureContractService
.
generateContractWordSign
(
expenditureContractVO
,
ContractUtils
.
class
,
wfProcessInfoVO
,
fileName
);
//保存附件
extExpenditureContractService
.
saveRecursion
(
expenditureContractVO
);
log
.
info
(
"自动任务======生成word签名完成"
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtExpenditureContractServiceImpl.java
View file @
2430f82b
This diff is collapsed.
Click to expand it.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/util/CommonUtils.java
View file @
2430f82b
...
...
@@ -4,12 +4,15 @@ import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import
com.yonde.dex.dict.feign.DictDataFeignService
;
import
com.yonde.dex.dict.service.vo.DictDataVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Field
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
...
...
@@ -98,4 +101,23 @@ public class CommonUtils {
return
true
;
}
/**
* 获取字典中文密级
*
* @param key
* @return
*/
public
static
String
getSecretCode
(
String
key
)
{
if
(
Strings
.
isEmpty
(
key
))
{
return
""
;
}
DictDataFeignService
dictService
=
ApplicationContextUtil
.
getBean
(
DictDataFeignService
.
class
);
String
secretKey
=
"SecretCode"
;
List
<
DictDataVO
>
dictData
=
dictService
.
getDictDatas
(
secretKey
);
Map
<
String
,
String
>
dictMap
=
new
HashMap
<>();
for
(
DictDataVO
dict
:
dictData
)
{
dictMap
.
put
(
dict
.
getDictKey
(),
dict
.
getDictValue
());
}
return
dictMap
.
get
(
key
);
}
}
\ No newline at end of file
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/util/Word2PdfJacobUtil.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
util
;
import
com.jacob.activeX.ActiveXComponent
;
import
com.jacob.com.ComThread
;
import
com.jacob.com.Dispatch
;
import
com.jacob.com.Variant
;
import
com.yonde.dcs.plan.core.word.DocumentDispatch
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @author xfchai
* @ClassName Word2PdfJacobUtil.java
* @Description word转pdf
* @createTime 2021/12/28 11:31:00
*/
@Slf4j
public
class
Word2PdfJacobUtil
{
/* 转PDF格式值 */
private
static
final
int
wdFormatPDF
=
17
;
/**
* word转pdf
*
* @param fileAbsolutePath
* @param toAddress
* @throws Exception
*/
public
static
void
wordToPDF
(
String
fileAbsolutePath
,
String
toAddress
)
throws
Exception
{
DocumentDispatch
documentDispatch
=
new
DocumentDispatch
();
documentDispatch
.
init
(
fileAbsolutePath
);
documentDispatch
.
wordToPdf
(
toAddress
);
documentDispatch
.
close
();
}
/**
* Word文档转换
*
* @param inputFile
* @param pdfFile
*/
public
static
boolean
word2PDF
(
String
inputFile
,
String
pdfFile
)
{
ComThread
.
InitMTA
(
true
);
long
start
=
System
.
currentTimeMillis
();
ActiveXComponent
app
=
null
;
Dispatch
doc
=
null
;
try
{
// 创建一个word对象
app
=
new
ActiveXComponent
(
"Word.Application"
);
// 不可见打开word
app
.
setProperty
(
"Visible"
,
new
Variant
(
false
));
// 禁用宏
app
.
setProperty
(
"AutomationSecurity"
,
new
Variant
(
3
));
// 获取文挡属性
Dispatch
docs
=
app
.
getProperty
(
"Documents"
).
toDispatch
();
log
.
info
(
"打开文档 >>> "
+
inputFile
);
// Object[]第三个参数是表示“是否只读方式打开”
// 调用Documents对象中Open方法打开文档,并返回打开的文档对象Document
doc
=
Dispatch
.
call
(
docs
,
"Open"
,
inputFile
,
false
,
true
).
toDispatch
();
log
.
info
(
"转换文档 ["
+
inputFile
+
"] >>> ["
+
pdfFile
+
"]"
);
// 调用Document对象的SaveAs方法,将文档保存为pdf格式
// word保存为pdf格式宏,值为17
Dispatch
.
call
(
doc
,
"SaveAs"
,
pdfFile
,
wdFormatPDF
);
long
end
=
System
.
currentTimeMillis
();
log
.
info
(
"用时:"
+
(
end
-
start
)
+
"ms."
);
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"========Error:文档转换失败:"
+
e
.
getMessage
());
}
finally
{
Dispatch
.
call
(
doc
,
"Close"
,
false
);
log
.
info
(
"关闭文档"
);
if
(
app
!=
null
)
app
.
invoke
(
"Quit"
,
new
Variant
[]{});
// 如果没有这句话,winword.exe进程将不会关闭
ComThread
.
Release
();
ComThread
.
quitMainSTA
();
}
return
false
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/util/WorkFlowUtil.java
0 → 100644
View file @
2430f82b
This diff is collapsed.
Click to expand it.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/word/CommonWord.java
0 → 100644
View file @
2430f82b
This diff is collapsed.
Click to expand it.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/word/DocFont.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
word
;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
/**
* @author xfchai
* @ClassName ImportWordService.java
* @Description 文本字体
* @createTime 2022/01/11 11:30:00
*/
@Data
public
class
DocFont
{
/**
* 是否加粗
*/
private
String
bold
;
/**
* 字体大小
*/
private
String
size
;
/**
* 字体名称
*/
private
String
name
;
public
boolean
notEqualsFont
(
String
bold
,
String
size
,
String
name
)
{
return
!
StringUtils
.
equals
(
this
.
bold
,
bold
)
||
!
StringUtils
.
equals
(
this
.
size
,
size
)
||
!
StringUtils
.
equals
(
this
.
name
,
name
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/word/DocumentDispatch.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
word
;
import
com.jacob.activeX.ActiveXComponent
;
import
com.jacob.com.ComThread
;
import
com.jacob.com.Dispatch
;
import
com.jacob.com.Variant
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.Objects
;
/**
* @author xfchai
* @ClassName ImportWordService.java
* @Description
* @createTime 2022/01/11 11:30:00
*/
@Slf4j
public
class
DocumentDispatch
{
@Getter
private
String
filepath
;
@Getter
private
String
path
;
@Getter
private
ActiveXComponent
wordApp
;
@Getter
private
Dispatch
document
;
Dispatch
documents
;
@Getter
private
Dispatch
table
;
/**
* word打开是否显示
*/
@Getter
final
boolean
Word_Visible
=
false
;
final
int
wdFormatPDF
=
17
;
// PDF 格式
public
void
init
(
String
fileAbsolutePath
)
throws
IOException
{
File
file
=
new
File
(
fileAbsolutePath
);
filepath
=
file
.
getParentFile
().
getPath
();
path
=
fileAbsolutePath
;
log
.
info
(
"[Word操作] >>>>> {}"
,
path
);
log
.
info
(
"[Word操作({})] >>>>>> 初始化COM"
);
ComThread
.
InitMTA
(
true
);
log
.
info
(
"[Word操作({})] >>>>>> 初始化ActiveX"
);
wordApp
=
new
ActiveXComponent
(
"Word.Application"
);
Dispatch
wordObject
=
wordApp
.
getObject
();
Dispatch
.
put
(
wordObject
,
"Visible"
,
new
Variant
(
Word_Visible
));
documents
=
wordApp
.
getProperty
(
"Documents"
).
toDispatch
();
log
.
info
(
"[Word操作({})] >>>>>> 打开文件"
,
path
);
document
=
Dispatch
.
call
(
documents
,
"Open"
,
path
).
toDispatch
();
}
private
void
filePathExist
(
String
filePath
)
{
File
file
=
new
File
(
filePath
);
if
(!
file
.
exists
())
{
file
.
mkdirs
();
}
}
private
void
copyAndCloseStream
(
InputStream
is
,
OutputStream
os
)
throws
IOException
{
try
{
IOUtils
.
copy
(
is
,
os
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"copyAndCloseStream error:"
,
e
);
}
finally
{
is
.
close
();
os
.
close
();
}
}
public
void
release
()
{
close
(
wordApp
,
document
);
deleteDocFile
(
path
,
filepath
,
null
);
}
public
String
getCellStr
(
int
x
,
int
y
)
{
Dispatch
cell
=
Dispatch
.
call
(
table
,
"cell"
,
x
,
y
).
toDispatch
();
Dispatch
range
=
Dispatch
.
get
(
cell
,
"Range"
).
toDispatch
();
return
Dispatch
.
get
(
range
,
"Text"
).
getString
();
}
public
DocFont
getFont
(
int
x
,
int
y
,
int
row
)
{
Dispatch
cell
=
Dispatch
.
call
(
table
,
"cell"
,
x
,
y
).
toDispatch
();
Dispatch
range
=
Dispatch
.
get
(
cell
,
"Range"
).
toDispatch
();
if
(
row
>
0
)
{
Dispatch
paragraphs
=
Dispatch
.
get
(
range
,
"Paragraphs"
).
toDispatch
();
Dispatch
item
=
Dispatch
.
call
(
paragraphs
,
"Item"
,
new
Variant
(
row
)).
toDispatch
();
range
=
Dispatch
.
get
(
item
,
"Range"
).
toDispatch
();
}
Dispatch
font
=
Dispatch
.
get
(
range
,
"Font"
).
toDispatch
();
DocFont
docFont
=
new
DocFont
();
docFont
.
setBold
(
Dispatch
.
get
(
font
,
"Bold"
).
toString
());
docFont
.
setSize
(
Dispatch
.
get
(
font
,
"Size"
).
toString
());
docFont
.
setName
(
Dispatch
.
get
(
font
,
"Name"
).
toString
());
return
docFont
;
}
public
DocFont
getFont
(
int
x
,
int
y
)
{
return
getFont
(
x
,
y
,
-
1
);
}
public
int
getPageCount
()
{
Dispatch
selection
=
Dispatch
.
get
(
wordApp
,
"Selection"
).
toDispatch
();
String
count
=
Dispatch
.
call
(
selection
,
"Information"
,
new
Variant
(
4
)).
toString
();
return
Integer
.
parseInt
(
count
);
}
private
void
close
(
ActiveXComponent
objWord
,
Dispatch
document
)
{
if
(
Objects
.
nonNull
(
document
))
{
Dispatch
.
call
(
document
,
"Close"
,
new
Variant
(
0
));
document
=
null
;
}
if
(
Objects
.
nonNull
(
objWord
))
{
log
.
info
(
"release->{}"
,
objWord
);
objWord
.
invoke
(
"Quit"
,
new
Variant
[]{});
objWord
=
null
;
}
}
public
void
close
()
{
if
(
Objects
.
nonNull
(
document
))
{
Dispatch
.
call
(
document
,
"Close"
,
new
Variant
(
0
));
document
=
null
;
}
if
(
Objects
.
nonNull
(
wordApp
))
{
log
.
info
(
"release->{}"
,
wordApp
);
wordApp
.
invoke
(
"Quit"
,
new
Variant
[]{});
wordApp
=
null
;
}
}
private
void
deleteDocFile
(
String
path
,
String
filePath
,
String
pathXml
)
{
File
file
;
if
(
StringUtils
.
isNotEmpty
(
path
))
{
file
=
new
File
(
path
);
file
.
delete
();
}
if
(
StringUtils
.
isNotEmpty
(
filePath
))
{
file
=
new
File
(
filePath
);
file
.
delete
();
}
if
(
StringUtils
.
isNotEmpty
(
pathXml
))
{
file
=
new
File
(
pathXml
);
file
.
delete
();
}
}
/**
* word转pdf
*
* @param toAddress 新文件地址
*/
public
void
wordToPdf
(
String
toAddress
)
{
long
start
=
System
.
currentTimeMillis
();
File
tofile
=
new
File
(
toAddress
);
if
(
tofile
.
exists
())
{
tofile
.
delete
();
}
//word文件另存为pdf文件
Dispatch
.
call
(
document
,
//
"SaveAs"
,
//
toAddress
,
// FileName
wdFormatPDF
);
long
end
=
System
.
currentTimeMillis
();
log
.
info
(
"转换完成..用时:"
+
(
end
-
start
)
+
"ms."
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
/* DocumentDispatch documentDispatch=new DocumentDispatch();
// documentDispatch.init("word源文件路径");
// documentDispatch.wordToPdf("目标pdf路径");
documentDispatch.init("C://Users//ASUS//Desktop//中航//施工图研究设计输入new.doc");
documentDispatch.wordToPdf("C://Users//ASUS//Desktop//中航//xxx.pdf");
documentDispatch.close();*/
wordToPDF
(
"D:/Demo/123.docx"
,
"D:/Demo/Demo.pdf"
);
}
public
static
void
wordToPDF
(
String
fileAbsolutePath
,
String
toAddress
)
throws
Exception
{
DocumentDispatch
documentDispatch
=
new
DocumentDispatch
();
documentDispatch
.
init
(
fileAbsolutePath
);
documentDispatch
.
wordToPdf
(
toAddress
);
documentDispatch
.
close
();
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/word/DownloadPictures.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
word
;
import
org.springframework.stereotype.Service
;
/**
* @author xfchai
* @ClassName DownloadPictures.java
* @Description 下载图片
* @createTime 2022/01/11 11:53:00
*/
@Service
public
class
DownloadPictures
{
public
static
final
String
tempPath
=
"D:/SignService/SignImages/"
;
/**
* 获取签名图片地址
*
* @param img
* @return
*/
public
String
GetAddress
(
String
img
)
{
//签名图片保存到指定目录下(D:/SignService/SignImages/)
StringBuffer
tempPathImgs
=
new
StringBuffer
();
boolean
contains
=
img
.
contains
(
","
);
if
((
contains
))
{
String
[]
split
=
img
.
split
(
","
);
for
(
String
s
:
split
)
{
if
(
tempPathImgs
.
length
()
>
0
)
{
tempPathImgs
.
append
(
","
);
}
tempPathImgs
.
append
(
tempPath
+
s
);
}
}
else
{
tempPathImgs
.
append
(
tempPath
+
img
);
}
return
tempPathImgs
.
toString
();
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/word/ImportWordService.java
0 → 100644
View file @
2430f82b
package
com
.
yonde
.
dcs
.
plan
.
core
.
word
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yonde.dcs.plan.core.util.Word2PdfJacobUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.xwpf.usermodel.XWPFDocument
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
/**
* @author xfchai
* @ClassName ImportWordService.java
* @Description 生成word服务
* @createTime 2022/01/11 11:30:00
*/
@Service
@Slf4j
public
class
ImportWordService
{
@Autowired
private
UpdateWordText
updateWordText
;
public
int
getWordAllTable
(
JSONObject
data
,
String
srcPath
,
String
outPath
)
{
XWPFDocument
document
=
null
;
FileInputStream
is
=
null
;
FileOutputStream
out
=
null
;
int
pages
=
0
;
try
{
is
=
new
FileInputStream
(
srcPath
);
document
=
new
XWPFDocument
(
is
);
updateWordText
.
changeTable
(
document
,
data
,
"all"
);
out
=
new
FileOutputStream
(
outPath
);
document
.
write
(
out
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
toString
());
}
finally
{
try
{
out
.
close
();
is
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
toString
());
}
}
log
.
info
(
"第一次替换word文件内容结束====文件目录:{}"
+
outPath
);
String
pdfPath
=
outPath
.
split
(
"\\."
)[
0
]
+
".pdf"
;
FileInputStream
isPDF
=
null
;
FileOutputStream
outPdf
=
null
;
FileInputStream
isWord
=
null
;
XWPFDocument
document2
=
null
;
try
{
log
.
info
(
"开始转换pdf获取页数====临时pdf模板:{}"
+
pdfPath
);
// DocumentDispatch.wordToPDF(outPath, pdfPath);
Word2PdfJacobUtil
.
word2PDF
(
outPath
,
pdfPath
);
isPDF
=
new
FileInputStream
(
pdfPath
);
pages
=
getPdfPages
(
isPDF
);
isWord
=
new
FileInputStream
(
outPath
);
document2
=
new
XWPFDocument
(
isWord
);
//获取Word总页数
// pages = document2.getProperties().getExtendedProperties().getUnderlyingProperties().getPages();
pages
=
updateWordText
.
changeTablePages
(
document2
,
data
,
"all"
,
pages
);
outPdf
=
new
FileOutputStream
(
outPath
);
document2
.
write
(
outPdf
);
log
.
info
(
"update pages: {}"
,
outPath
);
}
catch
(
Exception
e
)
{
log
.
error
(
"获取页数失败"
,
e
);
}
finally
{
try
{
if
(
isPDF
!=
null
)
{
isPDF
.
close
();
}
if
(
isWord
!=
null
)
{
isWord
.
close
();
}
if
(
outPdf
!=
null
)
{
outPdf
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"关闭文档失败"
,
e
);
}
}
return
pages
;
}
/**
* 获取pdf页数
*
* @param is
* @return
*/
public
int
getPdfPages
(
FileInputStream
is
)
{
int
page
=
0
;
//todo
// PDDocument pdDocument = null;
// try {
// pdDocument = PDDocument.load(is);
// int pdfPages = pdDocument.getNumberOfPages();
// page = page + pdfPages;
// } catch (Exception e) {
// log.error(e.toString());
// } finally {
// if (pdDocument != null) {
// try {
// pdDocument.close();
// } catch (IOException e) {
// log.error(e.toString());
// }
// }
// }
return
page
;
}
public
int
generateWord
(
JSONObject
data
,
String
srcPath
,
String
outPath
)
{
XWPFDocument
document
=
null
;
FileInputStream
is
=
null
;
FileOutputStream
out
=
null
;
int
pages
=
0
;
try
{
is
=
new
FileInputStream
(
srcPath
);
document
=
new
XWPFDocument
(
is
);
updateWordText
.
changeTable
(
document
,
data
,
"all"
);
out
=
new
FileOutputStream
(
outPath
);
document
.
write
(
out
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
toString
());
}
finally
{
try
{
out
.
close
();
is
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
toString
());
}
}
return
pages
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/word/UpdateWordText.java
0 → 100644
View file @
2430f82b
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment