丽知:1、钉钉附件下载,u8c附件上传。2、付款单新增。3、钉钉日志修改。4、钉钉修掉完善。
This commit is contained in:
parent
2fd90e74af
commit
962e43791a
|
@ -12,9 +12,15 @@ import com.hzya.frame.plugin.lets.dingtalk.callback.service.CallBackService;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
|
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity;
|
import com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.utils.DingTalkUtils;
|
import com.hzya.frame.plugin.lets.dingtalk.utils.DingTalkUtils;
|
||||||
|
import com.hzya.frame.plugin.lets.dingtalk.utils.FileUtil;
|
||||||
|
import com.hzya.frame.plugin.lets.dingtalk.utils.PushU8CFileUtil;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.vo.DingCallbackCrypto;
|
import com.hzya.frame.plugin.lets.dingtalk.vo.DingCallbackCrypto;
|
||||||
import com.hzya.frame.plugin.lets.u8cdto.ArapDjzb;
|
import com.hzya.frame.plugin.lets.dingtalk.vo.FileModuleVO;
|
||||||
import com.hzya.frame.plugin.lets.u8cdto.GeneralBillVO_4ADto;
|
import com.hzya.frame.plugin.lets.dingtalk.vo.SysFileVO;
|
||||||
|
import com.hzya.frame.plugin.lets.entity.BdCorpEntity;
|
||||||
|
import com.hzya.frame.plugin.lets.entity.BdDeptdocEntity;
|
||||||
|
import com.hzya.frame.plugin.lets.u8cdto.*;
|
||||||
|
import com.hzya.frame.plugin.lets.util.QueryU8CEntityUtil;
|
||||||
import com.hzya.frame.plugin.lets.util.pushData.Attribute;
|
import com.hzya.frame.plugin.lets.util.pushData.Attribute;
|
||||||
import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode;
|
import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode;
|
||||||
import com.hzya.frame.plugin.lets.util.pushData.ZTResult;
|
import com.hzya.frame.plugin.lets.util.pushData.ZTResult;
|
||||||
|
@ -24,10 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.time.LocalDate;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service("callBackService")
|
@Service("callBackService")
|
||||||
|
@ -88,7 +92,6 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
logger.info("采购付款申请(新) -> PROC-AC33FC85-FB44-49FC-B926-1D966AE3BBD2");
|
logger.info("采购付款申请(新) -> PROC-AC33FC85-FB44-49FC-B926-1D966AE3BBD2");
|
||||||
transferBill(eventJson);//特殊业务处理(新)
|
transferBill(eventJson);//特殊业务处理(新)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +240,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
public DingU8cBillEntity queryU8CDing(String ding_talk_process_id) {
|
public DingU8cBillEntity queryU8CDing(String ding_talk_process_id) {
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||||
dingU8cBillEntity.setDingTalkProcessId(ding_talk_process_id);
|
dingU8cBillEntity.setDingTalkProcessId(ding_talk_process_id);
|
||||||
|
dingU8cBillEntity.setSts("Y");
|
||||||
List<DingU8cBillEntity> query = dingU8cBillDao.query(dingU8cBillEntity);
|
List<DingU8cBillEntity> query = dingU8cBillDao.query(dingU8cBillEntity);
|
||||||
if (query.size() == 0) {
|
if (query.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -260,8 +264,8 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
String processInstanceId = eventJson.getString("processInstanceId");
|
String processInstanceId = eventJson.getString("processInstanceId");
|
||||||
DingU8cBillEntity dingU8cBillEntity = queryU8CDing(processInstanceId);
|
DingU8cBillEntity dingU8cBillEntity = queryU8CDing(processInstanceId);
|
||||||
if (dingU8cBillEntity == null) {
|
if (dingU8cBillEntity == null) {
|
||||||
//新增
|
//新增u8c付款单、保存日志、上传附件
|
||||||
addArapBill(processInstanceId);
|
addArapBill(processInstanceId,token);
|
||||||
} else {
|
} else {
|
||||||
//查询实例的具体信息
|
//查询实例的具体信息
|
||||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||||
|
@ -314,14 +318,19 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
private PushU8CByApiCode pushU8CByApiCode;
|
private PushU8CByApiCode pushU8CByApiCode;
|
||||||
/**
|
/**
|
||||||
* 审核付款单
|
* 审核付款单
|
||||||
|
*
|
||||||
* @param remark 处理意见
|
* @param remark 处理意见
|
||||||
*/
|
*/
|
||||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity, String remark) throws Exception {
|
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity, String remark) throws Exception {
|
||||||
|
//获取当前时间
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
|
||||||
Map bills = new HashMap();
|
Map bills = new HashMap();
|
||||||
bills.put("djbh", dingU8cBillEntity.getU8cBillCode());
|
bills.put("djbh", dingU8cBillEntity.getU8cBillCode());
|
||||||
bills.put("dwbm", dingU8cBillEntity.getU8cCodeCorp());
|
bills.put("dwbm", dingU8cBillEntity.getU8cCodeCorp());
|
||||||
bills.put("opinion", remark);
|
bills.put("opinion", remark);
|
||||||
bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||||
|
bills.put("operatedate", now);
|
||||||
String jsonStr = JSONUtil.toJsonStr(bills);
|
String jsonStr = JSONUtil.toJsonStr(bills);
|
||||||
jsonStr = "{\"bills\":[" + jsonStr + "]}";
|
jsonStr = "{\"bills\":[" + jsonStr + "]}";
|
||||||
System.out.println(jsonStr);
|
System.out.println(jsonStr);
|
||||||
|
@ -356,23 +365,187 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Autowired
|
||||||
|
private QueryU8CEntityUtil queryU8CEntityUtil;
|
||||||
|
@Autowired
|
||||||
|
private FileUtil fileUtil;
|
||||||
|
@Autowired
|
||||||
|
private PushU8CFileUtil pushU8CFileUtil;
|
||||||
/**
|
/**
|
||||||
* 付款单新增
|
* 付款单新增
|
||||||
|
* 1、付款单保存及审批
|
||||||
|
* 2、附件上传
|
||||||
*/
|
*/
|
||||||
public void addArapBill(String processInstanceId) throws Exception {
|
public void addArapBill(String processInstanceId,String token) throws Exception {
|
||||||
//查询实例的具体信息
|
//查询实例的具体信息
|
||||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||||
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||||
|
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues> formComponentValues = processInstanceResponseBodyResult.getFormComponentValues();
|
||||||
|
|
||||||
|
//需要的信息:公司、部门、项目所属类目、费用所属项目、申请理由、申请金额、备注、附件
|
||||||
|
String corpName = "";
|
||||||
|
String corpCode = "";
|
||||||
|
String deptName = "";
|
||||||
|
String deptCode = "";
|
||||||
|
String xmName = "";
|
||||||
|
String xmCode = "";
|
||||||
|
String fyName = "";
|
||||||
|
String fyCode = "";
|
||||||
|
String ly = "";
|
||||||
|
String je = "";
|
||||||
|
String bz = "";
|
||||||
|
String fjJson="";
|
||||||
|
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues formComponentValue : formComponentValues) {
|
||||||
|
if ("费用所属公司".equals(formComponentValue.getValue())) {
|
||||||
|
corpName = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if ("费用所属部门".equals(formComponentValue.getValue())) {
|
||||||
|
deptName = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if ("项目所属类目".equals(formComponentValue.getValue())) {
|
||||||
|
xmName = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if ("费用所属项目".equals(formComponentValue.getValue())) {
|
||||||
|
fyName = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if ("申请理由".equals(formComponentValue.getValue())) {
|
||||||
|
ly = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if ("申请金额(元)".equals(formComponentValue.getValue())) {
|
||||||
|
je = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if ("备注".equals(formComponentValue.getValue())) {
|
||||||
|
bz = formComponentValue.getName();
|
||||||
|
}
|
||||||
|
if("DDAttachment".equals(formComponentValue.getComponentType())){
|
||||||
|
fjJson = formComponentValue.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String mapStr="";
|
||||||
|
String response="";
|
||||||
|
|
||||||
|
try {
|
||||||
|
ArapDjzbVO billvo = new ArapDjzbVO();
|
||||||
|
ArapDjzbVO.Parentt parentvo = new ArapDjzbVO.Parentt();
|
||||||
|
//djrq 单据日期
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
parentvo.setDjrq(now.toString());
|
||||||
|
|
||||||
|
//dwbm 公司
|
||||||
|
BdCorpEntity bdCorpEntity = queryU8CEntityUtil.queryBdCorpByUnitName(corpName);
|
||||||
|
if (bdCorpEntity == null) {
|
||||||
|
Assert.state(false, "钉钉回调->付款单新增:根据表单【费用所属公司】:{},未查询到u8c对应公司,请检查名称。", corpName);
|
||||||
|
}
|
||||||
|
parentvo.setDwbm(bdCorpEntity.getUnitcode());
|
||||||
|
|
||||||
|
//wldx 往来对象标识(0 客户 1供应商 2部门 3业务员 )
|
||||||
|
parentvo.setWldx("2");
|
||||||
|
|
||||||
|
//deptid 部门
|
||||||
|
BdDeptdocEntity bdDeptdocEntity = queryU8CEntityUtil.queryBdDeptDocByPkCorpAndDeptName(bdCorpEntity.getPkCorp(), deptName);
|
||||||
|
if (bdDeptdocEntity == null) {
|
||||||
|
Assert.state(false, "钉钉回调->付款单新增:根据表单【费用所属部门】:{}。在公司:{},下未查询到u8c对应部门,请检查部门名称。", corpName, deptName);
|
||||||
|
}
|
||||||
|
parentvo.setDeptid(bdDeptdocEntity.getDeptcode());
|
||||||
|
|
||||||
|
//lrr 录入人
|
||||||
|
parentvo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||||
|
//shr 审核人
|
||||||
|
parentvo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||||
|
//shrq 审核日期
|
||||||
|
parentvo.setShrq(now.toString());
|
||||||
|
|
||||||
|
List<ArapDjzbVO.Childrenn> children = new ArrayList<>();
|
||||||
|
ArapDjzbVO.Childrenn childrenvo = new ArapDjzbVO.Childrenn();
|
||||||
|
//jfybje 借方原币金额
|
||||||
|
childrenvo.setJfybje(je);
|
||||||
|
children.add(childrenvo);
|
||||||
|
billvo.setParentvo(parentvo);
|
||||||
|
billvo.setChildren(children);
|
||||||
|
mapStr = JSONUtil.toJsonStr(billvo);
|
||||||
|
//推送u8c
|
||||||
|
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("otheroutqzCode"), mapStr);
|
||||||
|
if ("false".equals(ztResult.getFlag())) {
|
||||||
|
//转发失败
|
||||||
|
response = JSONUtil.toJsonStr(ztResult.getAttribute());
|
||||||
|
Assert.state(false, "付款单新增.中台转发失败,失败原因:{}", ztResult.getAttribute());
|
||||||
|
}
|
||||||
|
Attribute attribute = ztResult.getAttribute();
|
||||||
|
boolean isSuccess = false;
|
||||||
|
String vbillcode = "";
|
||||||
|
String vbillId = "";
|
||||||
|
if ("success".equals(attribute.getStatus())) {
|
||||||
|
isSuccess = true;
|
||||||
|
String data = attribute.getData();
|
||||||
|
ArapDjzbVO arapDjzbVO = resultDataHandle(data);
|
||||||
|
vbillcode = arapDjzbVO.getParentvo().getDjbh();
|
||||||
|
vbillId = arapDjzbVO.getParentvo().getVouchid();
|
||||||
|
}
|
||||||
|
if (!isSuccess) {
|
||||||
|
Assert.state(false, "推送U8C--> 付款单新增 失败 接口返回结果:{} 接口入参:{}", attribute.getErrormsg(), mapStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//成功
|
||||||
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||||
|
dingU8cBillEntity.setU8cPkCorp(bdCorpEntity.getPkCorp());//公司主键
|
||||||
|
dingU8cBillEntity.setU8cCodeCorp(bdCorpEntity.getUnitcode());//公司编码
|
||||||
|
dingU8cBillEntity.setU8cBillType(null);//单据类型
|
||||||
|
dingU8cBillEntity.setU8cBillCode(vbillcode);//单据号
|
||||||
|
dingU8cBillEntity.setU8cBillId(vbillId);//单据主键
|
||||||
|
dingU8cBillEntity.setPushStatus("Y");//推送成功
|
||||||
|
dingU8cBillEntity.setPushInfo("success");//推送成功
|
||||||
|
dingU8cBillEntity.setDingTalkProcessId(processInstanceId);//钉钉审批实例id
|
||||||
|
dingU8cBillEntity.setCreate_time(new Date());//创建时间
|
||||||
|
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
||||||
|
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
||||||
|
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
||||||
|
|
||||||
|
//上传附件,获取附件的表单,转base64,上传u8c
|
||||||
|
List<FileModuleVO> fileModuleVOList = JSONUtil.toList(fjJson, FileModuleVO.class);
|
||||||
|
List<SysFileVO> sysFileVOS = fileUtil.DingFileTransBase64(fileModuleVOList, processInstanceId, token);
|
||||||
|
|
||||||
|
for (SysFileVO sysFileVO : sysFileVOS) {
|
||||||
|
//上传u8c单据
|
||||||
|
pushU8CFileUtil.pushFile(vbillId,sysFileVO);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e);
|
||||||
|
//成功
|
||||||
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||||
|
dingU8cBillEntity.setU8cPkCorp(corpName);//公司主键
|
||||||
|
dingU8cBillEntity.setU8cCodeCorp(null);//公司编码
|
||||||
|
dingU8cBillEntity.setU8cBillType(null);//单据类型
|
||||||
|
dingU8cBillEntity.setU8cBillCode(null);//单据号
|
||||||
|
dingU8cBillEntity.setU8cBillId(null);//单据主键
|
||||||
|
dingU8cBillEntity.setPushStatus("N");//推送成功
|
||||||
|
dingU8cBillEntity.setPushInfo(e.getMessage());//推送成功
|
||||||
|
dingU8cBillEntity.setDingTalkProcessId(processInstanceId);//钉钉审批实例id
|
||||||
|
dingU8cBillEntity.setCreate_time(new Date());//创建时间
|
||||||
|
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
||||||
|
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
||||||
|
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArapDjzbVO resultDataHandle(String resultData) {
|
||||||
|
try {
|
||||||
|
if (resultData != null && !"".equals(resultData)) {
|
||||||
|
if (resultData.contains("[")) {
|
||||||
|
resultData = resultData.substring(1, resultData.length() - 1);
|
||||||
|
}
|
||||||
|
return JSON.parseObject(resultData, ArapDjzbVO.class);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("解析返回参数失败的错误", e);
|
||||||
|
//如果解析失败,记录原因,但是不能影响结果的记录
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Map bills=new HashMap();
|
// LocalDate now = LocalDate.now();
|
||||||
bills.put("djbh","FK2108160001");
|
// System.out.println(now.toString());
|
||||||
bills.put("dwbm","SHLZ");
|
|
||||||
bills.put("operatorid", "tbadmin");
|
|
||||||
String jsonStr = JSONUtil.toJsonStr(bills);
|
|
||||||
jsonStr="{\"bills\":["+jsonStr+"]}";
|
|
||||||
System.out.println(jsonStr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class DingU8cBillDaoImpl extends MybatisGenericDao<DingU8cBillEntity, Str
|
||||||
dingU8cBill.setId(dingU8cBillEntity.getId());
|
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||||
dingU8cBill.setModify_time(new Date());
|
dingU8cBill.setModify_time(new Date());
|
||||||
dingU8cBill.setDing_res(dingU8cBillEntityNew.getDing_res());
|
dingU8cBill.setDing_res(dingU8cBillEntityNew.getDing_res());
|
||||||
|
dingU8cBill.setApprove(dingU8cBillEntityNew.getApprove());
|
||||||
this.update(dingU8cBill);
|
this.update(dingU8cBill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class DingU8cBillEntity extends BaseEntity {
|
||||||
private String ding_res;
|
private String ding_res;
|
||||||
/** 是否审核 Y 、 N */
|
/** 是否审核 Y 、 N */
|
||||||
private String approve;
|
private String approve;
|
||||||
|
/** D钉钉发起,U u8c发起 */
|
||||||
|
private String initiate="U";
|
||||||
|
|
||||||
public DingU8cBillEntity(String u8cPkCorp, String u8cCodeCorp, String u8cBillType, String u8cBillCode, String u8cBillId, String pushStatus, String pushInfo, String dingTalkProcessId, String ding_res) {
|
public DingU8cBillEntity(String u8cPkCorp, String u8cCodeCorp, String u8cBillType, String u8cBillCode, String u8cBillId, String pushStatus, String pushInfo, String dingTalkProcessId, String ding_res) {
|
||||||
this.u8cPkCorp = u8cPkCorp;
|
this.u8cPkCorp = u8cPkCorp;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<result property="dingTalkProcessId" column="ding_talk_process_id" jdbcType="VARCHAR"/>
|
<result property="dingTalkProcessId" column="ding_talk_process_id" jdbcType="VARCHAR"/>
|
||||||
<result property="ding_res" column="ding_res" jdbcType="VARCHAR"/>
|
<result property="ding_res" column="ding_res" jdbcType="VARCHAR"/>
|
||||||
<result property="approve" column="approve" jdbcType="VARCHAR"/>
|
<result property="approve" column="approve" jdbcType="VARCHAR"/>
|
||||||
|
<result property="initiate" column="initiate" jdbcType="VARCHAR"/>
|
||||||
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
|
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="sts" column="sts" jdbcType="VARCHAR"/>
|
<result property="sts" column="sts" jdbcType="VARCHAR"/>
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
,ding_talk_process_id
|
,ding_talk_process_id
|
||||||
,ding_res
|
,ding_res
|
||||||
,approve
|
,approve
|
||||||
|
,initiate
|
||||||
,modify_time
|
,modify_time
|
||||||
,create_time
|
,create_time
|
||||||
,sts
|
,sts
|
||||||
|
@ -52,10 +54,10 @@
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id = #{dingTalkProcessId} </if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id = #{dingTalkProcessId} </if>
|
||||||
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
||||||
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
||||||
|
<if test="initiate != null and initiate != ''"> and initiate = #{initiate} </if>
|
||||||
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
|
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
|
||||||
<if test="create_time != null"> and create_time = #{create_time} </if>
|
<if test="create_time != null"> and create_time = #{create_time} </if>
|
||||||
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
||||||
and sts='Y'
|
|
||||||
</trim>
|
</trim>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -74,6 +76,7 @@
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id = #{dingTalkProcessId} </if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id = #{dingTalkProcessId} </if>
|
||||||
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
||||||
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
||||||
|
<if test="initiate != null and initiate != ''"> and initiate = #{initiate} </if>
|
||||||
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
|
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
|
||||||
<if test="create_time != null"> and create_time = #{create_time} </if>
|
<if test="create_time != null"> and create_time = #{create_time} </if>
|
||||||
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
||||||
|
@ -98,6 +101,7 @@
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id like concat('%',#{dingTalkProcessId},'%') </if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id like concat('%',#{dingTalkProcessId},'%') </if>
|
||||||
<if test="ding_res != null and ding_res != ''"> and ding_res like concat('%',#{ding_res},'%') </if>
|
<if test="ding_res != null and ding_res != ''"> and ding_res like concat('%',#{ding_res},'%') </if>
|
||||||
<if test="approve != null and approve != ''"> and approve like concat('%',#{approve},'%') </if>
|
<if test="approve != null and approve != ''"> and approve like concat('%',#{approve},'%') </if>
|
||||||
|
<if test="initiate != null and initiate != ''"> and initiate like concat('%',#{initiate},'%') </if>
|
||||||
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
|
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
|
||||||
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
|
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
|
||||||
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
|
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
|
||||||
|
@ -122,6 +126,7 @@
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> or ding_talk_process_id = #{dingTalkProcessId} </if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> or ding_talk_process_id = #{dingTalkProcessId} </if>
|
||||||
<if test="ding_res != null and ding_res != ''"> or ding_res = #{ding_res} </if>
|
<if test="ding_res != null and ding_res != ''"> or ding_res = #{ding_res} </if>
|
||||||
<if test="approve != null and approve != ''"> or approve = #{approve} </if>
|
<if test="approve != null and approve != ''"> or approve = #{approve} </if>
|
||||||
|
<if test="initiate != null and initiate != ''"> or initiate = #{initiate} </if>
|
||||||
<if test="modify_time != null"> or modify_time = #{modify_time} </if>
|
<if test="modify_time != null"> or modify_time = #{modify_time} </if>
|
||||||
<if test="create_time != null"> or create_time = #{create_time} </if>
|
<if test="create_time != null"> or create_time = #{create_time} </if>
|
||||||
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
|
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
|
||||||
|
@ -144,6 +149,7 @@
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> ding_talk_process_id , </if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> ding_talk_process_id , </if>
|
||||||
<if test="ding_res != null and ding_res != ''"> ding_res , </if>
|
<if test="ding_res != null and ding_res != ''"> ding_res , </if>
|
||||||
<if test="approve != null and approve != ''"> approve , </if>
|
<if test="approve != null and approve != ''"> approve , </if>
|
||||||
|
<if test="initiate != null and initiate != ''"> initiate , </if>
|
||||||
<if test="modify_time != null"> modify_time , </if>
|
<if test="modify_time != null"> modify_time , </if>
|
||||||
<if test="create_time != null"> create_time , </if>
|
<if test="create_time != null"> create_time , </if>
|
||||||
<if test="sts != null and sts != ''"> sts , </if>
|
<if test="sts != null and sts != ''"> sts , </if>
|
||||||
|
@ -162,6 +168,7 @@
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> #{dingTalkProcessId} ,</if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> #{dingTalkProcessId} ,</if>
|
||||||
<if test="ding_res != null and ding_res != ''"> #{ding_res} ,</if>
|
<if test="ding_res != null and ding_res != ''"> #{ding_res} ,</if>
|
||||||
<if test="approve != null and approve != ''"> #{approve} ,</if>
|
<if test="approve != null and approve != ''"> #{approve} ,</if>
|
||||||
|
<if test="initiate != null and initiate != ''"> #{initiate} ,</if>
|
||||||
<if test="modify_time != null"> #{modify_time} ,</if>
|
<if test="modify_time != null"> #{modify_time} ,</if>
|
||||||
<if test="create_time != null"> #{create_time} ,</if>
|
<if test="create_time != null"> #{create_time} ,</if>
|
||||||
<if test="sts != null and sts != ''"> #{sts} ,</if>
|
<if test="sts != null and sts != ''"> #{sts} ,</if>
|
||||||
|
@ -169,33 +176,6 @@
|
||||||
</trim>
|
</trim>
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<!-- 批量新增 -->
|
|
||||||
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
||||||
insert into ding_u8c_bill(u8c_pk_corp, u8c_code_corp, u8c_bill_type, u8c_bill_code, u8c_bill_id, push_status, push_info, ding_talk_process_id, modify_time, create_time, sts, sts)
|
|
||||||
values
|
|
||||||
<foreach collection="entities" item="entity" separator=",">
|
|
||||||
(#{entity.u8cPkCorp},#{entity.u8cCodeCorp},#{entity.u8cBillType},#{entity.u8cBillCode},#{entity.u8cBillId},#{entity.pushStatus},#{entity.pushInfo},#{entity.dingTalkProcessId},#{entity.modify_time},#{entity.create_time},#{entity.sts}, 'Y')
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
<!-- 批量新增或者修改-->
|
|
||||||
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
||||||
insert into ding_u8c_bill(u8c_pk_corp, u8c_code_corp, u8c_bill_type, u8c_bill_code, u8c_bill_id, push_status, push_info, ding_talk_process_id, modify_time, create_time, sts)
|
|
||||||
values
|
|
||||||
<foreach collection="entities" item="entity" separator=",">
|
|
||||||
(#{entity.u8cPkCorp},#{entity.u8cCodeCorp},#{entity.u8cBillType},#{entity.u8cBillCode},#{entity.u8cBillId},#{entity.pushStatus},#{entity.pushInfo},#{entity.dingTalkProcessId},#{entity.modify_time},#{entity.create_time},#{entity.sts})
|
|
||||||
</foreach>
|
|
||||||
on duplicate key update
|
|
||||||
u8c_pk_corp = values(u8c_pk_corp),
|
|
||||||
u8c_code_corp = values(u8c_code_corp),
|
|
||||||
u8c_bill_type = values(u8c_bill_type),
|
|
||||||
u8c_bill_code = values(u8c_bill_code),
|
|
||||||
u8c_bill_id = values(u8c_bill_id),
|
|
||||||
push_status = values(push_status),
|
|
||||||
push_info = values(push_info),
|
|
||||||
ding_talk_process_id = values(ding_talk_process_id),
|
|
||||||
modify_time = values(modify_time),
|
|
||||||
create_time = values(create_time),
|
|
||||||
sts = values(sts)</insert>
|
|
||||||
<!--通过主键修改方法-->
|
<!--通过主键修改方法-->
|
||||||
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity" >
|
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity" >
|
||||||
update ding_u8c_bill set
|
update ding_u8c_bill set
|
||||||
|
@ -210,6 +190,7 @@ update ding_u8c_bill set
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> ding_talk_process_id = #{dingTalkProcessId},</if>
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> ding_talk_process_id = #{dingTalkProcessId},</if>
|
||||||
<if test="ding_res != null and ding_res != ''"> ding_res = #{ding_res},</if>
|
<if test="ding_res != null and ding_res != ''"> ding_res = #{ding_res},</if>
|
||||||
<if test="approve != null and approve != ''"> approve = #{approve},</if>
|
<if test="approve != null and approve != ''"> approve = #{approve},</if>
|
||||||
|
<if test="initiate != null and initiate != ''"> initiate = #{initiate},</if>
|
||||||
<if test="modify_time != null"> modify_time = #{modify_time},</if>
|
<if test="modify_time != null"> modify_time = #{modify_time},</if>
|
||||||
<if test="create_time != null"> create_time = #{create_time},</if>
|
<if test="create_time != null"> create_time = #{create_time},</if>
|
||||||
<if test="sts != null and sts != ''"> sts = #{sts},</if>
|
<if test="sts != null and sts != ''"> sts = #{sts},</if>
|
||||||
|
@ -221,23 +202,6 @@ where id = #{id}
|
||||||
update ding_u8c_bill set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
|
update ding_u8c_bill set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
<!-- 多条件逻辑删除 -->
|
|
||||||
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity" >
|
|
||||||
update ding_u8c_bill set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
|
|
||||||
<trim prefix="where" prefixOverrides="and">
|
|
||||||
<if test="id != null"> and id = #{id} </if>
|
|
||||||
<if test="u8cPkCorp != null and u8cPkCorp != ''"> and u8c_pk_corp = #{u8cPkCorp} </if>
|
|
||||||
<if test="u8cCodeCorp != null and u8cCodeCorp != ''"> and u8c_code_corp = #{u8cCodeCorp} </if>
|
|
||||||
<if test="u8cBillType != null and u8cBillType != ''"> and u8c_bill_type = #{u8cBillType} </if>
|
|
||||||
<if test="u8cBillCode != null and u8cBillCode != ''"> and u8c_bill_code = #{u8cBillCode} </if>
|
|
||||||
<if test="u8cBillId != null and u8cBillId != ''"> and u8c_bill_id = #{u8cBillId} </if>
|
|
||||||
<if test="pushStatus != null and pushStatus != ''"> and push_status = #{pushStatus} </if>
|
|
||||||
<if test="pushInfo != null and pushInfo != ''"> and push_info = #{pushInfo} </if>
|
|
||||||
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> and ding_talk_process_id = #{dingTalkProcessId} </if>
|
|
||||||
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
|
||||||
and sts='Y'
|
|
||||||
</trim>
|
|
||||||
</update>
|
|
||||||
<!--通过主键删除-->
|
<!--通过主键删除-->
|
||||||
<delete id="entity_delete">
|
<delete id="entity_delete">
|
||||||
delete from ding_u8c_bill where id = #{id}
|
delete from ding_u8c_bill where id = #{id}
|
||||||
|
|
|
@ -595,4 +595,37 @@ public class DingTalkUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载审批实例实例附件
|
||||||
|
* @param token
|
||||||
|
* @param processInstanceId
|
||||||
|
* @param fileId
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static GrantProcessInstanceForDownloadFileResponse downloadProcessFile (String token,String processInstanceId,String fileId) throws Exception {
|
||||||
|
Client client = createClient();
|
||||||
|
com.aliyun.dingtalkworkflow_1_0.models.GrantProcessInstanceForDownloadFileHeaders grantProcessInstanceForDownloadFileHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GrantProcessInstanceForDownloadFileHeaders();
|
||||||
|
grantProcessInstanceForDownloadFileHeaders.xAcsDingtalkAccessToken = token;
|
||||||
|
com.aliyun.dingtalkworkflow_1_0.models.GrantProcessInstanceForDownloadFileRequest grantProcessInstanceForDownloadFileRequest = new com.aliyun.dingtalkworkflow_1_0.models.GrantProcessInstanceForDownloadFileRequest()
|
||||||
|
.setProcessInstanceId(processInstanceId)
|
||||||
|
.setFileId(fileId);
|
||||||
|
try {
|
||||||
|
GrantProcessInstanceForDownloadFileResponse grantProcessInstanceForDownloadFileResponse =
|
||||||
|
client.grantProcessInstanceForDownloadFileWithOptions(grantProcessInstanceForDownloadFileRequest, grantProcessInstanceForDownloadFileHeaders, new RuntimeOptions());
|
||||||
|
return grantProcessInstanceForDownloadFileResponse;
|
||||||
|
} catch (TeaException err) {
|
||||||
|
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||||
|
Assert.state(false, err.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception _err) {
|
||||||
|
TeaException err = new TeaException(_err.getMessage(), _err);
|
||||||
|
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
||||||
|
Assert.state(false, err.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.aliyun.dingtalkstorage_1_0.models.AddPermissionResponse;
|
||||||
import com.aliyun.dingtalkstorage_1_0.models.CommitFileRequest;
|
import com.aliyun.dingtalkstorage_1_0.models.CommitFileRequest;
|
||||||
import com.aliyun.dingtalkstorage_1_0.models.CommitFileResponse;
|
import com.aliyun.dingtalkstorage_1_0.models.CommitFileResponse;
|
||||||
import com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponse;
|
import com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponse;
|
||||||
|
import com.aliyun.dingtalkworkflow_1_0.models.GrantProcessInstanceForDownloadFileResponse;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.vo.FileModuleVO;
|
import com.hzya.frame.plugin.lets.dingtalk.vo.FileModuleVO;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.vo.SysFileVO;
|
import com.hzya.frame.plugin.lets.dingtalk.vo.SysFileVO;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -13,10 +14,13 @@ import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.*;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -110,4 +114,57 @@ public class FileUtil {
|
||||||
}
|
}
|
||||||
return fileModuleVO;
|
return fileModuleVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钉钉审批实例附件下载,转base64编码
|
||||||
|
* @Param fileModuleVOList 钉钉附件列表
|
||||||
|
* @Param token token
|
||||||
|
* @Param processInstanceId 审批实例id
|
||||||
|
*/
|
||||||
|
public List<SysFileVO> DingFileTransBase64(List<FileModuleVO> fileModuleVOList,String token,String processInstanceId) throws Exception {
|
||||||
|
List<SysFileVO> sysFileVOList=new ArrayList<>();
|
||||||
|
|
||||||
|
for (FileModuleVO fileModuleVO : fileModuleVOList) {
|
||||||
|
SysFileVO sysFileVO = new SysFileVO();
|
||||||
|
String targetPath = "D:\\ding-file\\download\\"+processInstanceId+"_"+fileModuleVO.getFileId()+"\\";
|
||||||
|
|
||||||
|
//附件下载
|
||||||
|
GrantProcessInstanceForDownloadFileResponse grantProcessInstanceForDownloadFileResponse = DingTalkUtils.downloadProcessFile(token, processInstanceId, fileModuleVO.getFileId());
|
||||||
|
String uri = grantProcessInstanceForDownloadFileResponse.getBody().getResult().getDownloadUri();
|
||||||
|
URL url = new URL(uri);
|
||||||
|
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
|
||||||
|
int responseCode = httpConn.getResponseCode();
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
InputStream inputStream = httpConn.getInputStream();
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(targetPath);
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
//转为base64编码
|
||||||
|
// 读取文件内容到字节数组
|
||||||
|
byte[] fileContent = Files.readAllBytes(Paths.get(targetPath));
|
||||||
|
// 将字节数组转换为 Base64 编码的字符串
|
||||||
|
String encodedString = Base64.getEncoder().encodeToString(fileContent);
|
||||||
|
|
||||||
|
sysFileVO.setFileName(fileModuleVO.getFileName());
|
||||||
|
sysFileVO.setType(fileModuleVO.getFileType());
|
||||||
|
sysFileVO.setBaseCode(encodedString);
|
||||||
|
System.out.println(sysFileVO);
|
||||||
|
sysFileVOList.add(sysFileVO);
|
||||||
|
|
||||||
|
//关闭资源
|
||||||
|
outputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
httpConn.disconnect();
|
||||||
|
} else {
|
||||||
|
throw new IOException("无法下载文件,HTTP响应码: " + responseCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysFileVOList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,67 @@
|
||||||
|
package com.hzya.frame.plugin.lets.dingtalk.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.hzya.frame.plugin.lets.constant.OverallConstant;
|
||||||
|
import com.hzya.frame.plugin.lets.dingtalk.callback.service.impl.CallBackServiceImpl;
|
||||||
|
import com.hzya.frame.plugin.lets.dingtalk.vo.SysFileVO;
|
||||||
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||||
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PushU8CFileUtil {
|
||||||
|
protected static Logger logger = LogManager.getLogger(PushU8CFileUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送u8c单据附件
|
||||||
|
* @Param vouchId 单据主键
|
||||||
|
* @Param sysFileVO 文件信息
|
||||||
|
*/
|
||||||
|
public static void pushFile(String vouchId, SysFileVO sysFileVO) throws Exception{
|
||||||
|
|
||||||
|
// 服务器访问地址及端口,例如 http://ip:port
|
||||||
|
String serviceUrl = OverallConstant.getOverAllValue("u8cApiUrl");
|
||||||
|
// 服务名,例如 /u8cloud/api/cmp/hj/insert
|
||||||
|
String serviceName = "/u8cloud/api/file/upload/base64";
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("trantype", OverallConstant.getOverAllValue("u8cApiTrantypeCode")); // 档案翻译方式,枚举值为:编码请录入 code, 名称请录入 name, 主键请录入 pk
|
||||||
|
map.put("system", OverallConstant.getOverAllValue("u8cApiSystemCode")); // 系统编码
|
||||||
|
map.put("usercode", OverallConstant.getOverAllValue("u8cApiUsercodeCode")); // 用户
|
||||||
|
map.put("password", OverallConstant.getOverAllValue("u8cApiPasswordCode")); // 密码,需要 MD5 加密后录入
|
||||||
|
|
||||||
|
Map<String,String> fileMap=new HashMap<>();
|
||||||
|
fileMap.put("content",sysFileVO.getBaseCode());
|
||||||
|
fileMap.put("creator","tbadmin");//制单人code
|
||||||
|
fileMap.put("file_name",sysFileVO.getFileName());
|
||||||
|
fileMap.put("upload_path",vouchId);//单据主键
|
||||||
|
String jsonFileMap = JSONUtil.toJsonStr(fileMap);
|
||||||
|
String json="{\"file\":["+jsonFileMap+"]}";
|
||||||
|
System.out.println(json);
|
||||||
|
|
||||||
|
//上传
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
PostMethod httpPost = new PostMethod(serviceUrl+serviceName);
|
||||||
|
httpPost.setRequestHeader("content-type","application/json;charset=utf-8");
|
||||||
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
|
httpPost.setRequestHeader(entry.getKey(), entry.getValue()
|
||||||
|
.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestEntity entity = new StringRequestEntity(json,"application/json", "UTF-8");
|
||||||
|
httpPost.setRequestEntity(entity);
|
||||||
|
httpClient.executeMethod(httpPost);
|
||||||
|
String responseBodyAsString = httpPost.getResponseBodyAsString();
|
||||||
|
logger.info("推送u8c单据附件,推送单据主键:{},u8c返回信息:{}",vouchId,responseBodyAsString);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,24 @@
|
||||||
package com.hzya.frame.plugin.lets.dingtalk.utils;
|
package com.hzya.frame.plugin.lets.dingtalk.utils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponseBody;
|
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponseBody;
|
||||||
import com.aliyun.dingtalkworkflow_1_0.models.GetAttachmentSpaceResponse;
|
import com.aliyun.dingtalkworkflow_1_0.models.*;
|
||||||
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessCodeByNameResponse;
|
|
||||||
import com.dingtalk.api.response.OapiUserListidResponse;
|
import com.dingtalk.api.response.OapiUserListidResponse;
|
||||||
import com.dingtalk.api.response.OapiV2UserGetResponse;
|
import com.dingtalk.api.response.OapiV2UserGetResponse;
|
||||||
import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
|
import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import com.hzya.frame.plugin.lets.dingtalk.vo.FileModuleVO;
|
||||||
|
import com.hzya.frame.plugin.lets.dingtalk.vo.SysFileVO;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,13 +29,13 @@ import java.util.UUID;
|
||||||
* 采购付款申请(店群专用) PROC-285CCF2B-524F-4055-BE62-FC31F490C654 25354973072
|
* 采购付款申请(店群专用) PROC-285CCF2B-524F-4055-BE62-FC31F490C654 25354973072
|
||||||
*/
|
*/
|
||||||
public class Test {
|
public class Test {
|
||||||
// public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
// String appKey="ding5qfifcktfqfjlem0";
|
String appKey="ding5qfifcktfqfjlem0";
|
||||||
// String appSecret="BVuLOy_K0F8f5np69VuBeKdb1zfwqhuPsAV49lNbYVbx5TnfSTHjwEcad9Vwzfq1";
|
String appSecret="BVuLOy_K0F8f5np69VuBeKdb1zfwqhuPsAV49lNbYVbx5TnfSTHjwEcad9Vwzfq1";
|
||||||
|
|
||||||
//获取token
|
//获取token
|
||||||
// GetAccessTokenResponseBody tokenBody = DingTalkUtils.getTokenBody(appKey, appSecret);
|
GetAccessTokenResponseBody tokenBody = DingTalkUtils.getTokenBody(appKey, appSecret);
|
||||||
// System.out.println(tokenBody.getAccessToken());
|
System.out.println(tokenBody.getAccessToken());
|
||||||
|
|
||||||
//获取用户列表
|
//获取用户列表
|
||||||
// OapiUserListidResponse userIdList = DingTalkUtils.getUserIdList(tokenBody.getAccessToken());
|
// OapiUserListidResponse userIdList = DingTalkUtils.getUserIdList(tokenBody.getAccessToken());
|
||||||
|
@ -49,11 +60,73 @@ public class Test {
|
||||||
// System.out.println(processCode1.getBody().getResult().getProcessCode());//PROC-EC6B5BD2-DE3C-456E-9591-6F7B377E39E4
|
// System.out.println(processCode1.getBody().getResult().getProcessCode());//PROC-EC6B5BD2-DE3C-456E-9591-6F7B377E39E4
|
||||||
// GetProcessCodeByNameResponse processCode2 = DingTalkUtils.getProcessCode(tokenBody.getAccessToken(), "采购付款申请(店群专用)");
|
// GetProcessCodeByNameResponse processCode2 = DingTalkUtils.getProcessCode(tokenBody.getAccessToken(), "采购付款申请(店群专用)");
|
||||||
// System.out.println(processCode2.getBody().getResult().getProcessCode());//PROC-285CCF2B-524F-4055-BE62-FC31F490C654
|
// System.out.println(processCode2.getBody().getResult().getProcessCode());//PROC-285CCF2B-524F-4055-BE62-FC31F490C654
|
||||||
|
|
||||||
|
|
||||||
|
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(tokenBody.getAccessToken(), "TkERtV0BRW6GeqXcA0sMQg05751730701542");
|
||||||
|
System.out.println(processInstanceDetails.getBody().getResult().getFormComponentValues());
|
||||||
|
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues> formComponentValues =
|
||||||
|
processInstanceDetails.getBody().getResult().getFormComponentValues();
|
||||||
|
//获取附件的表单
|
||||||
|
List<FileModuleVO> fileModuleVOList=new ArrayList<>();
|
||||||
|
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues formComponentValue : formComponentValues) {
|
||||||
|
if("DDAttachment".equals(formComponentValue.getComponentType())){
|
||||||
|
String value = formComponentValue.getValue();
|
||||||
|
System.out.println(value);
|
||||||
|
fileModuleVOList = JSONUtil.toList(value, FileModuleVO.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<SysFileVO> sysFileVOList=new ArrayList<>();
|
||||||
|
for (FileModuleVO fileModuleVO : fileModuleVOList) {
|
||||||
|
// String targetPath = "D:\\ding-file\\download\\"+fileModuleVO.getFileName()+fileModuleVO.getFileId()+"."+fileModuleVO.getFileType();
|
||||||
|
String targetPath = "D:\\ding-file\\download\\"+"TkERtV0BRW6GeqXcA0sMQg05751730701542\\";
|
||||||
|
SysFileVO sysFileVO = new SysFileVO();
|
||||||
|
GrantProcessInstanceForDownloadFileResponse grantProcessInstanceForDownloadFileResponse = DingTalkUtils.downloadProcessFile(tokenBody.getAccessToken(), "TkERtV0BRW6GeqXcA0sMQg05751730701542", fileModuleVO.getFileId());
|
||||||
|
System.out.println(grantProcessInstanceForDownloadFileResponse.getBody().getResult().getDownloadUri());
|
||||||
|
String uri = grantProcessInstanceForDownloadFileResponse.getBody().getResult().getDownloadUri();
|
||||||
|
URL url = new URL(uri);
|
||||||
|
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
|
||||||
|
int responseCode = httpConn.getResponseCode();
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
InputStream inputStream = httpConn.getInputStream();
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(targetPath);
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
//转为base64编码
|
||||||
|
// 读取文件内容到字节数组
|
||||||
|
byte[] fileContent = Files.readAllBytes(Paths.get(targetPath));
|
||||||
|
// 将字节数组转换为 Base64 编码的字符串
|
||||||
|
String encodedString = Base64.getEncoder().encodeToString(fileContent);
|
||||||
|
|
||||||
|
sysFileVO.setFileName(fileModuleVO.getFileName());
|
||||||
|
sysFileVO.setType(fileModuleVO.getFileType());
|
||||||
|
sysFileVO.setBaseCode(encodedString);
|
||||||
|
System.out.println(sysFileVO);
|
||||||
|
sysFileVOList.add(sysFileVO);
|
||||||
|
|
||||||
|
//关闭资源
|
||||||
|
outputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
httpConn.disconnect();
|
||||||
|
} else {
|
||||||
|
throw new IOException("无法下载文件,HTTP响应码: " + responseCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 生成回调key
|
||||||
|
// * @param args
|
||||||
|
// */
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// String key = Base64.encodeBase64String(UUID.randomUUID().toString().replaceAll("-","").getBytes());
|
||||||
|
// System.out.println(key);
|
||||||
|
//
|
||||||
// }
|
// }
|
||||||
public static void main(String[] args) {
|
|
||||||
String key = Base64.encodeBase64String(UUID.randomUUID().toString().replaceAll("-","").getBytes());
|
|
||||||
System.out.println(key);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,69 @@ public class QueryU8CEntityUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public BdCorpEntity queryBdCorpByUnitName(String unitName) {
|
||||||
|
BdCorpEntity entity = new BdCorpEntity();
|
||||||
|
entity.setDr(0);
|
||||||
|
entity.setUnitname(unitName);
|
||||||
|
entity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
|
||||||
|
List<BdCorpEntity> query = iBdCorpDao.query(entity);
|
||||||
|
if (query.size() >= 1) {
|
||||||
|
return query.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////公司
|
////////////////////////////////////////////////////////////////////////////////////////公司
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////部门
|
||||||
|
@Autowired
|
||||||
|
private IBdDeptdocDao bdDeptdocDao;
|
||||||
|
/**
|
||||||
|
* 根据公司主键查询全部部门
|
||||||
|
*/
|
||||||
|
public List<BdDeptdocEntity> queryBdDeptDocByPkCorp(String pkCorp){
|
||||||
|
BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity();
|
||||||
|
bdDeptdocEntity.setDr(0);
|
||||||
|
bdDeptdocEntity.setPkCorp(pkCorp);
|
||||||
|
List<BdDeptdocEntity> query = bdDeptdocDao.query(bdDeptdocEntity);
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据公司主键、部门编码查询部门
|
||||||
|
*/
|
||||||
|
public BdDeptdocEntity queryBdDeptDocByPkCorpAndDeptCode(String pkCorp,String deptCode){
|
||||||
|
BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity();
|
||||||
|
bdDeptdocEntity.setDr(0);
|
||||||
|
bdDeptdocEntity.setPkCorp(pkCorp);
|
||||||
|
bdDeptdocEntity.setDeptcode(deptCode);
|
||||||
|
List<BdDeptdocEntity> query = bdDeptdocDao.query(bdDeptdocEntity);
|
||||||
|
if (query.size() >= 1) {
|
||||||
|
return query.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据公司主键、部门名称查询部门
|
||||||
|
*/
|
||||||
|
public BdDeptdocEntity queryBdDeptDocByPkCorpAndDeptName(String pkCorp,String deptName) {
|
||||||
|
BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity();
|
||||||
|
bdDeptdocEntity.setDr(0);
|
||||||
|
bdDeptdocEntity.setPkCorp(pkCorp);
|
||||||
|
bdDeptdocEntity.setDeptname(deptName);
|
||||||
|
List<BdDeptdocEntity> query = bdDeptdocDao.query(bdDeptdocEntity);
|
||||||
|
if (query.size() >= 1) {
|
||||||
|
return query.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////部门
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////仓库
|
////////////////////////////////////////////////////////////////////////////////////////仓库
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBdStordocDao iBdStordocDao;
|
private IBdStordocDao iBdStordocDao;
|
||||||
|
|
Loading…
Reference in New Issue