diff --git a/com/Client.java b/com/Client.java
index 2d7ac57..22e3cf2 100644
--- a/com/Client.java
+++ b/com/Client.java
@@ -18,8 +18,8 @@ public class Client {
// String str = "1010157060000081243025801570102311000120230905104426true500130004130157202309050600000812430todogetCountuserNum10913026任广鹏是个大刷币";
// String str = "0000066900000000000402580170951101017020230920195236true500120043010170202309200000000000040BTSQD-20230921001110110001测试审批人2驳回测试2";
// String str = "000005971010157000000001757025801570102311000120231018135840true500130004130157202310180000000017570todogetCount2userNum10110567";
- String str = "000005961010157000000001757025801570102311000120231018135840true500130004130157202310180000000017570todogetCountuserNum10110567";
- // ;
+ // String str = "000005961010157000000001757025801570102311000120231018135840true500130004130157202310180000000017570todogetCountuserNum10110567";
+ String str = "0000066400000000000302580170951101017020240329082246true500120043010170202403290000000000030FHBTSQD-20240325000111010036赵圣熙0驳回测试"; // ;
// System.out.println(XMLUtils.parseXMLToMap(str));
// Map stringStringMap = XMLUtils.parseXMLToMap(str);
// System.out.println(stringStringMap);
diff --git a/com/engine/custom/action/PushCWAction.java b/com/engine/custom/action/PushCWAction.java
new file mode 100644
index 0000000..b161c58
--- /dev/null
+++ b/com/engine/custom/action/PushCWAction.java
@@ -0,0 +1,368 @@
+package com.engine.custom.action;
+
+import com.dcfs.fts.common.error.FtpException;
+import com.engine.custom.hg.util.HgUtils;
+import com.engine.custom.sl.entity.*;
+import com.engine.util.SocketClientUtil;
+import com.engine.util.XMLUtils;
+import com.weaver.general.Util;
+import org.jsoup.Jsoup;
+import weaver.conn.RecordSet;
+import weaver.file.ImageFileManager;
+import weaver.general.BaseBean;
+import weaver.general.StringUtil;
+import weaver.hrm.User;
+import weaver.interfaces.workflow.action.Action;
+import weaver.soa.workflow.request.RequestInfo;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 推送商旅节点后附加操作(推送商旅节点后附加操作
+ * 测试环境
+ */
+public class PushCWAction extends BaseBean implements Action {
+ /**
+ * After selecting aciton after the process path node, this method will be executed after the node is submitted.
+ */
+ @Override
+ public String execute(RequestInfo request) {
+ writeLog("推送商旅节点后附加操作====>");
+ // if(error) {
+ // request.getRequestManager().setMessageid("90001");
+ // request.getRequestManager().setMessagecontent("System Abnormal Termination Process Submission!");
+ // }
+ String requestId = request.getRequestid();
+ String tablename = request.getRequestManager().getBillTableName();
+ TravelToEsbBean toEsbBean = new TravelToEsbBean();
+ //封装主表数据
+ RecordSet rs = new RecordSet();
+ String mainId = setMainForm(requestId, tablename, rs, toEsbBean);
+ writeLog("toEsbBean1====>"+toEsbBean);
+ writeLog("上传附件到ESB服务器====>");
+ try {
+ fileToEsb(toEsbBean,requestId);
+ } catch (Exception e) {
+ request.getRequestManager().setMessageid("10001");
+ request.getRequestManager().setMessagecontent(e.getMessage());
+ return Action.FAILURE_AND_CONTINUE;
+ }
+ setFormDt1(mainId,tablename,rs,toEsbBean);
+ writeLog("toEsbBean2====>"+toEsbBean);
+ setFormDt2(mainId,tablename,rs,toEsbBean);
+ writeLog("toEsbBean3====>"+toEsbBean);
+ String Service_Body = ""+ toEsbBean.toXMLString()+"" ;
+ writeLog("toEsbBean4====>"+Service_Body);
+ try{
+ EsbRequestHeader esbRequestHeader = new EsbRequestHeader(Util.getIntValue(mainId));
+ writeLog("esbRequestHeader====>"+esbRequestHeader);
+ String Service_Header = TravelToEsbBean.convertObjectToXml(esbRequestHeader,"Service_Header");
+ writeLog("esbRequestHeaderXML====>"+Service_Header);
+ String serviceXML = "";
+ serviceXML = serviceXML + Service_Header + Service_Body;
+ serviceXML = serviceXML + "";
+ writeLog("esbRequestHeaderXML====>"+serviceXML);
+ int byteArray = serviceXML.getBytes("UTF-8").length;
+
+ // Calculate the length of the byte array
+ // int bytelength = byteArray.length;
+ String length = String.format("%08d", byteArray);
+ writeLog("XMLlength"+ length);
+ serviceXML = length + serviceXML;
+ writeLog("serviceXML==="+ serviceXML);
+ // serviceXML = new String(serviceXML.getBytes(StandardCharsets.UTF_8));
+ writeLog("UTF_8_serviceXML==="+ serviceXML);
+ SocketClientUtil scketClient = new SocketClientUtil("14.1.78.197",10149);
+ String send = scketClient.send(serviceXML);
+ String substring = send.substring(0, 8);
+ String substring1 = send.substring(8);
+ Map map = XMLUtils.parseXMLToMap(substring1);
+ String retCd = map.get("retCd");
+ String retCdDsc = map.get("retCdDsc");
+ if ("9999".equals(retCd)){
+ request.getRequestManager().setMessageid("9999");
+ request.getRequestManager().setMessagecontent(retCdDsc);
+ return Action.FAILURE_AND_CONTINUE;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ writeLog("构建XML异常"+e.getMessage());
+ request.getRequestManager().setMessageid("10001");
+ request.getRequestManager().setMessagecontent(e.getMessage());
+ return Action.FAILURE_AND_CONTINUE;
+ }
+ // setFormDt1();
+ return Action.SUCCESS;
+ }
+
+ private void fileToEsb(TravelToEsbBean toEsbBean, String requestId) throws Exception {
+ // HashMap filePathMap = new HashMap<>();
+ List acsryArray = toEsbBean.getAcsryArray();
+ for (acsryItem acsryItem : acsryArray) {
+ String acsryNm = acsryItem.getAcsryNm();
+ writeLog("acsryNm"+acsryNm);
+ ImageFileManager ifm = new ImageFileManager();
+ ifm.getImageFileInfoById(Util.getIntValue(acsryNm,0));
+ InputStream inputStream = ifm.getInputStream();
+ String imageFileName = ifm.getImageFileName();
+ writeLog("imageFileName"+imageFileName);
+ String[] filename = imageFileName.split("\\.");
+ int lastIndex = imageFileName.lastIndexOf('.');
+ String part1 = "";
+ String part2 = "";
+ if (lastIndex != -1) {
+ part1 = imageFileName.substring(0, lastIndex);
+ part2 = imageFileName.substring(lastIndex + 1);
+ }else {
+ part1 = imageFileName;
+ }
+ String tempFilePath = "";
+ try {
+ File tempFile = File.createTempFile(part1,part2.length() == 0 ? "" :part2);
+
+ // 创建一个输出流,将数据写入临时文件
+ OutputStream outputStream = new FileOutputStream(tempFile);
+
+ // 将输入流中的数据复制到输出流(即临时文件)
+ byte[] buffer = new byte[2048];
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ }
+ tempFilePath = tempFile.getAbsolutePath();
+ writeLog( "临时文件位置"+tempFilePath);
+ // 关闭输入流和输出流
+ inputStream.close();
+ outputStream.close();
+ }catch (Exception e){
+ e.printStackTrace();
+ writeLog( "创建本地文件异常"+e.getMessage());
+ throw new Exception("创建"+imageFileName+"文件异常"+e.getMessage());
+ }
+ //推送ESB服务器
+ String ftpPath = "";
+ try {
+ ftpPath = HgUtils.putFile(tempFilePath, requestId + File.separator + imageFileName);
+
+ } catch (FtpException e) {
+ e.printStackTrace();
+ writeLog( "传输ESBftp异常"+e.getMessage());
+ throw new Exception("传输ESBftp异常");
+ } catch (IOException e) {
+ e.printStackTrace();
+ writeLog( "传输ESBIO异常"+e.getMessage());
+ throw new Exception("传输ESBftp异常");
+ }
+ acsryItem.setAcsryNm(imageFileName);
+ acsryItem.setSavePath(ftpPath);
+ }
+
+ }
+
+ private String setMainForm(String requestId, String tablename, RecordSet rs ,TravelToEsbBean toEsbBean) {
+ rs.execute("select * from " + tablename + " where requestid = " + requestId);
+ String mainid = "";
+ String fj = "";
+ String spdfj = "";
+ String spwhscpdfwj = "";
+ //表单数据
+ if (rs.next()) {
+ mainid = rs.getString("id");
+ //OA差旅报销单单据编号
+ toEsbBean.setOaTrvlBnsExpnsAcctNo(rs.getString(Util.null2String("djbh")));
+ //经办人工号
+ toEsbBean.setOperatorNo(processString(Util.null2String(rs.getString("jbrgh"))));
+ //经办人姓名 id
+ toEsbBean.setOperatorName(Util.null2String(rs.getString("jbrxm")));
+ String lastname = new User(Util.getIntValue(toEsbBean.getOperatorName())).getLastname();
+ toEsbBean.setOperatorName(lastname);
+
+ //附件张数
+ toEsbBean.setAcsryNums(Util.null2String(rs.getString("fjzs")));
+ //报销金额
+ toEsbBean.setExpnsAmt(multiply100(Util.null2String(rs.getString("bxjedwf"))));
+ toEsbBean.setCostDeptCode((Util.null2String(rs.getString("cbzxbm"))));
+ toEsbBean.setCostDeptName((Util.null2String(rs.getString("cbzxmc"))));
+ //报销事由 Jsoup.parse(htmlContent).text()
+ String expnsRsn = Util.null2String(rs.getString("bxsy"));
+ String text = Jsoup.parse(expnsRsn).text();
+ toEsbBean.setExpnsRsn(text);
+ //备注
+ toEsbBean.setRemark(Util.null2String(rs.getString("bz")));
+ fj = Util.null2String(rs.getString("fj"));
+ spdfj = Util.null2String(rs.getString("spdfj"));
+ // spwhscpdfwj = Util.null2String(rs.getString("clspdpdffj"));
+ spwhscpdfwj = Util.null2String(rs.getString("clspdpdffj"));
+ // String formData = rs.getString("formData");
+ }
+ // 封装文件数组
+ //现在是id
+ List fjids;
+ if(!StringUtil.isEmpty(fj)){
+ fjids = new ArrayList<>( Arrays.asList(fj.split(",")));
+ }else {
+ fjids = new ArrayList<>();
+ }
+ //
+ writeLog("fjids"+fjids);
+ try {
+ if (!StringUtil.isEmpty(spdfj)){
+ fjids.add(spdfj);
+ }
+ if (!StringUtil.isEmpty(spwhscpdfwj)){
+ fjids.add(spwhscpdfwj);
+ }
+ ArrayList acsryArray = new ArrayList<>();
+ for (String fjid : fjids) {
+ acsryItem acsryItem = new acsryItem();
+ acsryItem.setAcsryNm(getimgid(fjid,rs));
+ acsryArray.add(acsryItem);
+ }
+ toEsbBean.setAcsryArray(acsryArray);
+ //重新设置下附件张数为数组长度
+ toEsbBean.setAcsryNums(acsryArray.size()+"");
+ }catch (Exception e){
+ e.printStackTrace();
+ writeLog("fjidsException"+e);
+ }
+
+ return mainid;
+ }
+
+
+ private void setFormDt1(String mainid, String tablename, RecordSet rs , TravelToEsbBean toEsbBean) {
+ rs.execute("select * from " + tablename + "_dt1 where mainid = " + mainid);
+ List expenseArray = new ArrayList<>();
+ while (rs.next()) {
+ ExpenseItem expenseItem = new ExpenseItem();
+ // 支出类型
+ expenseItem.setExpndType(getpartyBuildCostCode(Util.getIntValue(rs.getString("zclx"),0)));
+ //不含税金额
+ expenseItem.setExclsvTaxAmt(multiply100(Util.null2String(rs.getString("bhsjedwf"))));
+ // //不含税金额
+ expenseItem.setTaxAmt(multiply100(Util.null2String(rs.getString("sedwf"))));
+ //价税合计金额
+ expenseItem.setPrcTotAmt(multiply100(Util.null2String(rs.getString("jshjjedwf"))));
+ //记账摘要 Jsoup.parse(expnsRsn).text()
+ String jzzy = Util.null2String(rs.getString("jzzy"));
+ String text = Jsoup.parse(jzzy).text();
+ expenseItem.setAcctingAbstct(text);
+ expenseArray.add(expenseItem);
+ }
+ toEsbBean.setExpndArray(expenseArray);
+ }
+
+
+ private void setFormDt2(String mainid, String tablename, RecordSet rs , TravelToEsbBean toEsbBean) {
+ rs.execute("select * from " + tablename + "_dt2 where mainid = " + mainid);
+ List jrnyInfoArray = new ArrayList<>();
+ while (rs.next()) {
+ JourneyInfo journeyInfo = new JourneyInfo();
+ // 开始日期
+ journeyInfo.setStartDate(formatDate(Util.null2String(rs.getString("ksrq"))));
+ // 结束日期
+ journeyInfo.setEndDate(formatDate(Util.null2String(rs.getString("jsrq"))));
+ // 出差天数
+ journeyInfo.setBsnTrpDays(Util.null2String(rs.getString("ccts")));
+ //行程路线
+ journeyInfo.setJrnyPath(Util.null2String(rs.getString("hclx")));
+ //行程说明
+ journeyInfo.setJrnyExpln(Util.null2String(rs.getString("hcsm")));
+ //记账摘要
+ journeyInfo.setRemark(Util.null2String(rs.getString("bz")));
+ jrnyInfoArray.add(journeyInfo);
+ }
+ toEsbBean.setJrnyInfoArray(jrnyInfoArray);
+ }
+
+ //获取支出类型
+ private String getpartyBuildCostCode(int index){
+ if(index == 0){
+ return "FEE_BUILD";
+ }else if(index == 1){
+ return "BIZ_FEE";
+ }else if(index == 2){
+ return "PARTY_BUILD_EXPENSE";
+ }
+ return "";
+ }
+
+ public String getimgid(String docid, RecordSet rs){
+ String sql = "select docid,df.imagefileid imgid from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID = ?";
+ writeLog("getimgidsql"+sql+"===="+docid);
+ rs.executeQuery(sql,docid);
+ if (rs.next()){
+ writeLog("imgid"+Util.null2String(rs.getString("imgid")));
+ return Util.null2String(rs.getString("imgid"));
+ }
+ return "";
+ };
+ //生成流水号
+ public static String generateTimestamp() {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+ Date currentDate = new Date();
+ return dateFormat.format(currentDate);
+ }
+
+ public static String multiply100(String s) {
+ s = s.replace(",", ""); // 移除逗号
+ if (StringUtil.isEmpty(s)){
+ return "0";
+ }
+ BigDecimal value = new BigDecimal(s);
+ BigDecimal multipliedValue = value.multiply(new BigDecimal("100"));
+ int result = multipliedValue.intValue();
+ System.out.println(result); // 输出:123456
+ return String.valueOf(result); // 输出:123456
+ }
+
+ public static String formatDate(String input) {
+ // String input = "2023-09-20 19:29";
+ try {
+ SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ // 使用SimpleDateFormat解析输入字符串
+ if (!input.contains(" ")){
+ datetimeFormat = new SimpleDateFormat("yyyy-MM-dd");
+ }
+
+ Date date = datetimeFormat.parse(input);
+ // 使用另一个SimpleDateFormat对象格式化Date为所需的输出格式
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ String output = dateFormat.format(date);
+
+ return output; // 输出: 2023-09-20
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ public static String processString(String input) {
+ // 检查字符串长度是否大于8
+ if (input.length() > 8) {
+ // 如果是,截取前八位
+ return input.substring(0, 8);
+ } else {
+ // 否则,返回原字符串
+ return input;
+ }
+ }
+
+
+ public static void main(String[] args) {
+ String imageFileName = "11.16天津-成都去程机票 (1).jpg";
+ int lastIndex = imageFileName.lastIndexOf('.');
+ String part1 = imageFileName.substring(0, lastIndex);
+ String part2 = imageFileName.substring(lastIndex + 1);
+ System.out.println(part1);
+ System.out.println(part2);
+ }
+
+
+
+
+
+}
diff --git a/com/engine/custom/archives/corn/PushArchivesCorn.java b/com/engine/custom/archives/corn/PushArchivesCorn.java
index 9e2fb57..70561e0 100644
--- a/com/engine/custom/archives/corn/PushArchivesCorn.java
+++ b/com/engine/custom/archives/corn/PushArchivesCorn.java
@@ -4,10 +4,14 @@ import com.engine.custom.archives.service.PushArchivesCornService;
import lombok.extern.slf4j.Slf4j;
import weaver.interfaces.schedule.BaseCronJob;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+
import java.util.HashMap;
+/***
+ * 推送档案系统定时任务
+ * @author rengp
+ * @date 2024/4/7
+ */
@Slf4j
public class PushArchivesCorn extends BaseCronJob {
public String filePath = "/opt/weaver/filesys/test";
diff --git a/com/engine/custom/archives/service/PushArchivesCornService.java b/com/engine/custom/archives/service/PushArchivesCornService.java
index 4074656..4615ba5 100644
--- a/com/engine/custom/archives/service/PushArchivesCornService.java
+++ b/com/engine/custom/archives/service/PushArchivesCornService.java
@@ -16,6 +16,7 @@ import java.nio.charset.StandardCharsets;
import java.io.*;
import java.util.*;
+import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.StringUtil;
import weaver.general.Util;
@@ -76,8 +77,10 @@ public class PushArchivesCornService {
public void pushArchives(Map param) {
log.info("PushArchivesCorn====Begin========{}", param);
try {
+
ZipUtil zipUtil = new ZipUtil();
Date date = getDate();
+
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String format = dateFormat.format(date);
SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@@ -215,13 +218,16 @@ public class PushArchivesCornService {
});
//开始承办单 先获取主流程的承办单
List requestDocid = generaRequestFormPdf(requestid);
- List subRequestDocid = generaSubRequestFormPdf(requestid);
+ // 1.去掉生成子流程承办单
+ // List subRequestDocid = generaSubRequestFormPdf(requestid);
Map reqDocMap = getFileIdByDocId(String.join(",", requestDocid));
- Map subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
+ // 2.去掉生成子流程承办单
+ // Map subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
- log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
+ //log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
docids.addAll(requestDocid);
- docids.addAll(subRequestDocid);
+ // 3.去掉生成子流程承办单
+ // docids.addAll(subRequestDocid);
//附件
reqDocMap.forEach((docid, imageid) -> {
ImageFileManager imageFileManager = new ImageFileManager();
@@ -249,34 +255,36 @@ public class PushArchivesCornService {
}
});
//正文
+
i[0] = 1;
- subReqDocMap.forEach((docid, imageid) -> {
- ImageFileManager imageFileManager = new ImageFileManager();
- imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
- InputStream inputStream = imageFileManager.getInputStream();
- //中文路径/中文文件名
- String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName());
- imageFileName = codeUtf8(imageFileName);
- log.info("子流程承办单路径:{}", imageFileName);
- try {
- File file = saveInputStreamToFile(inputStream, imageFileName);
- String jsonStr = callApi(Url, file);
- log.error("永中接口返回:{}", jsonStr);
- JSONObject result = JSONObject.parseObject(jsonStr);
- String errorcode = result.getString("errorcode");
- if ("0".equals(errorcode)) {
- JSONObject data = result.getJSONObject("data");
- String destFileName = data.getString("destFileName");
- String viewUrl = data.getString("viewUrl");
- downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf");
- }
- i[0]++;
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
+ // 4.去掉生成子流程承办单
+ // subReqDocMap.forEach((docid, imageid) -> {
+ // ImageFileManager imageFileManager = new ImageFileManager();
+ // imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
+ // InputStream inputStream = imageFileManager.getInputStream();
+ // //中文路径/中文文件名
+ // String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName());
+ // imageFileName = codeUtf8(imageFileName);
+ // log.info("子流程承办单路径:{}", imageFileName);
+ // try {
+ // File file = saveInputStreamToFile(inputStream, imageFileName);
+ // String jsonStr = callApi(Url, file);
+ // log.error("永中接口返回:{}", jsonStr);
+ // JSONObject result = JSONObject.parseObject(jsonStr);
+ // String errorcode = result.getString("errorcode");
+ // if ("0".equals(errorcode)) {
+ // JSONObject data = result.getJSONObject("data");
+ // String destFileName = data.getString("destFileName");
+ // String viewUrl = data.getString("viewUrl");
+ // downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf");
+ // }
+ // i[0]++;
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ // });
log.error(JSONObject.toJSONString(requestDocid));
- log.error(JSONObject.toJSONString(subRequestDocid));
+ // log.error(JSONObject.toJSONString(subRequestDocid));
for (String docid : docids) {
log.error("删除了" + docid);
deleteDocByid(docid);
@@ -474,7 +482,7 @@ public class PushArchivesCornService {
context.append(lwdwmc).append("|");
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
context.append(bgqx).append("|");
- String lwrq = Util.null2String(requesData.get("bgqx")); //7 日期 -> 原发文日期
+ String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期
context.append(lwrq).append("|");
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
context.append(ys).append("|");
@@ -857,11 +865,21 @@ public class PushArchivesCornService {
public static String getSignLog(String requestid, String dirName, String requestName) {
List subRequestIds = getSubRequestIds(requestid);
ArrayList