销售合同附件上传
This commit is contained in:
parent
45aaec8cfb
commit
cea5489383
|
@ -26,4 +26,24 @@ public interface ISalesContractDao extends IBaseDao<SalesContractEntity,String>
|
|||
* @Date 2025-04-03 11:09
|
||||
* **/
|
||||
Integer updateSalesContract(SalesContractEntity entity);
|
||||
|
||||
/**
|
||||
*
|
||||
* @content 查询未上传文件的销售合同
|
||||
* @Param
|
||||
* @Return
|
||||
* @Author hecan
|
||||
* @Date 2025-04-16 14:40
|
||||
* **/
|
||||
List<SalesContractEntity> queryContractAnnexFile(SalesContractEntity salesContractEntity);
|
||||
|
||||
/**
|
||||
*
|
||||
* @content 更新销售合同附件和ipo附件上传标识
|
||||
* @Param
|
||||
* @Return
|
||||
* @Author hecan
|
||||
* @Date 2025-04-16 16:48
|
||||
* **/
|
||||
Integer updateAnnexFile(SalesContractEntity entity);
|
||||
}
|
||||
|
|
|
@ -19,4 +19,16 @@ public class SalesContractDaoImpl extends MybatisGenericDao<SalesContractEntity,
|
|||
public Integer updateSalesContract(SalesContractEntity entity) {
|
||||
return super.update("updateSalesContract",entity);
|
||||
}
|
||||
|
||||
@DS("#entity.dataSourceCode")
|
||||
@Override
|
||||
public List<SalesContractEntity> queryContractAnnexFile(SalesContractEntity entity) {
|
||||
return (List<SalesContractEntity>) super.selectList("queryContractAnnexFile",entity);
|
||||
}
|
||||
|
||||
@DS("#entity.dataSourceCode")
|
||||
@Override
|
||||
public Integer updateAnnexFile(SalesContractEntity entity) {
|
||||
return super.update("updateAnnexFile",entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,87 @@ public class SalesContractEntity extends BaseEntity {
|
|||
private String def9;//合同类型
|
||||
private String def2;//合同性质
|
||||
private String def41;//单据归属区域
|
||||
private String billid;//单据主键
|
||||
private String billtype;//单据类型
|
||||
private String billcode;//单据号
|
||||
private String ipofilename;//ipo附件 文件名称
|
||||
private String htnrfilename;//合同内容附件 文件名称
|
||||
private String htnrid;//合同内容附件id
|
||||
private String ipoid;//IPO附件id
|
||||
private String htnrpush;//合同附件上传标识
|
||||
private String ipopush;//ipo附件上传标识
|
||||
|
||||
public String getHtnrpush() {
|
||||
return htnrpush;
|
||||
}
|
||||
|
||||
public void setHtnrpush(String htnrpush) {
|
||||
this.htnrpush = htnrpush;
|
||||
}
|
||||
|
||||
public String getIpopush() {
|
||||
return ipopush;
|
||||
}
|
||||
|
||||
public void setIpopush(String ipopush) {
|
||||
this.ipopush = ipopush;
|
||||
}
|
||||
|
||||
public String getHtnrid() {
|
||||
return htnrid;
|
||||
}
|
||||
|
||||
public void setHtnrid(String htnrid) {
|
||||
this.htnrid = htnrid;
|
||||
}
|
||||
|
||||
public String getIpoid() {
|
||||
return ipoid;
|
||||
}
|
||||
|
||||
public void setIpoid(String ipoid) {
|
||||
this.ipoid = ipoid;
|
||||
}
|
||||
|
||||
public String getBillid() {
|
||||
return billid;
|
||||
}
|
||||
|
||||
public void setBillid(String billid) {
|
||||
this.billid = billid;
|
||||
}
|
||||
|
||||
public String getBilltype() {
|
||||
return billtype;
|
||||
}
|
||||
|
||||
public void setBilltype(String billtype) {
|
||||
this.billtype = billtype;
|
||||
}
|
||||
|
||||
public String getBillcode() {
|
||||
return billcode;
|
||||
}
|
||||
|
||||
public void setBillcode(String billcode) {
|
||||
this.billcode = billcode;
|
||||
}
|
||||
|
||||
public String getIpofilename() {
|
||||
return ipofilename;
|
||||
}
|
||||
|
||||
public void setIpofilename(String ipofilename) {
|
||||
this.ipofilename = ipofilename;
|
||||
}
|
||||
|
||||
public String getHtnrfilename() {
|
||||
return htnrfilename;
|
||||
}
|
||||
|
||||
public void setHtnrfilename(String htnrfilename) {
|
||||
this.htnrfilename = htnrfilename;
|
||||
}
|
||||
|
||||
public String getCustbillno() {
|
||||
return custbillno;
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
djgsqy.SORTNUMBER as def41 -- 单据归属区域
|
||||
</sql>
|
||||
|
||||
<!--查询审计完成的数据,推送BIP新增-->
|
||||
<!--查询未推送的数据,推送BIP新增-->
|
||||
<select id="querySalesContract" resultMap="get-SalesContractEntity-result" parameterType = "com.hzya.frame.plugin.salesContract.entity.SalesContractEntity">
|
||||
select
|
||||
<include refid="SalesContractEntity_Base_Column_List" />
|
||||
|
@ -66,7 +66,36 @@
|
|||
left join CTP_ENUM_ITEM djgsqy on djgsqy.id=field0135
|
||||
where field0146 is null and to_char(field0007,'yyyy-MM-dd HH24:mi:ss')>'2025-01-01'
|
||||
-- and summary.state in ('1','3')
|
||||
and field0132 is not null and field0001='SW15-004-2025003509'
|
||||
and field0132 is not null and field0001='SW15-004-2025003467'
|
||||
<trim prefix="where" prefixOverrides="and">
|
||||
<if test="id != null and id != ''"> and id = #{id} </if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<!--查询未上传的数据,推送BIP新增-->
|
||||
<select id="queryContractAnnexFile" resultMap="get-SalesContractEntity-result" parameterType = "com.hzya.frame.plugin.salesContract.entity.SalesContractEntity">
|
||||
select
|
||||
formmain_8694.id as id,
|
||||
formmain_8694.id as billid, -- 单据主键
|
||||
'HHHX0201' as billtype, -- 单据类型
|
||||
field0009 as billcode, -- 单据号 合同订单可以传合同号
|
||||
field0132 as pkOrg, -- 公司编码
|
||||
ipo_file.filename as ipofilename, -- ipo附件 文件名称
|
||||
htnr_file.filename as htnrfilename, --合同内容附件 文件名称
|
||||
htnr_file.id as htnrid, -- 合同内容附件id
|
||||
ipo_file.id as ipoid, -- IPO附件id
|
||||
field0153 as htnrpush, -- 合同附件上传标识
|
||||
field0154 as ipopush -- ipo附件上传标识
|
||||
from
|
||||
formmain_8694
|
||||
LEFT JOIN COL_SUMMARY summary ON summary.FORM_RECORDID = formmain_8694.id
|
||||
left join CTP_ATTACHMENT htnr on htnr.sub_reference=field0020
|
||||
left join CTP_ATTACHMENT ipo on ipo.sub_reference=field0139
|
||||
left join ctp_file htnr_file on htnr_file.id=htnr.file_url
|
||||
left join ctp_file ipo_file on ipo_file.id=ipo.file_url
|
||||
where field0146 is not null and to_char(field0007,'yyyy-MM-dd HH24:mi:ss')>'2025-01-01'
|
||||
-- and summary.state in ('1','3')
|
||||
and field0132 is not null and (field0153 is null or field0154 is null) and field0001='SW15-004-2025003467'
|
||||
<trim prefix="where" prefixOverrides="and">
|
||||
<if test="id != null and id != ''"> and id = #{id} </if>
|
||||
</trim>
|
||||
|
@ -77,6 +106,15 @@
|
|||
update formmain_8694 set field0146 = #{pushStatus} where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateAnnexFile" parameterType="com.hzya.frame.plugin.salesContract.entity.SalesContractEntity">
|
||||
update formmain_8694 set
|
||||
<trim suffix="" suffixOverrides=",">
|
||||
<if test="ipopush != null and ipopush !='' "> field0154 = #{ipopush},</if>
|
||||
<if test="htnrpush != null and htnrpush != ''"> field0153 = #{htnrpush}</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
package com.hzya.frame.plugin.salesContract.plugin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.dateutil.DateUtil;
|
||||
import com.hzya.frame.plugin.salesContract.dao.ISalesContractDao;
|
||||
import com.hzya.frame.plugin.salesContract.entity.SalesContractEntity;
|
||||
import com.hzya.frame.seeyon.util.OARestUtil;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
||||
import com.hzya.frame.uuid.UUIDUtils;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ContractAnnexFileUploadPluginInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(ContractAnnexFileUploadPluginInitializer.class);
|
||||
|
||||
@Autowired
|
||||
private ISalesContractDao salesContractDao;
|
||||
|
||||
@Autowired
|
||||
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||
|
||||
@Value("${zt.url}")
|
||||
private String url;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "ContractAnnexFileUploadPluginInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "销售合同附件上传";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "ContractAnnexFileUploadPluginInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||
try {
|
||||
logger.info("======开始执行销售合同附件上传BIP========");
|
||||
//重试方法
|
||||
if (null != requestJson) {
|
||||
//如果这个id不为空,说明是重试的
|
||||
String id = requestJson.getString("integration_task_living_details_id");
|
||||
//执行重新发送
|
||||
SalesContractEntity salesContractEntity = new SalesContractEntity();
|
||||
salesContractEntity.setDataSourceCode("SW-OA");
|
||||
if (StrUtil.isNotEmpty(id)) {
|
||||
salesContractEntity.setId(id);
|
||||
}
|
||||
//查询未上传的数据
|
||||
List<SalesContractEntity> salesContractEntities = salesContractDao.queryContractAnnexFile(salesContractEntity);
|
||||
if(salesContractEntities == null || salesContractEntities.size() == 0){
|
||||
logger.info("=====没有需要上传BIP的销售合同附件==========");
|
||||
return BaseResult.getSuccessMessageEntity("查询成功");
|
||||
}
|
||||
for (SalesContractEntity contractEntity : salesContractEntities) {
|
||||
if(null !=contractEntity.getHtnrfilename()){
|
||||
contractEntity.setDataSourceCode("SW-OA");
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("filename",contractEntity.getHtnrfilename());
|
||||
jsonObject.put("billtype",contractEntity.getBilltype());
|
||||
jsonObject.put("billid",contractEntity.getBillid());
|
||||
jsonObject.put("billcode",contractEntity.getBillcode());
|
||||
jsonObject.put("pk_org",contractEntity.getPkOrg());
|
||||
String file_url = contractEntity.getHtnrid();
|
||||
String newPath = "E:\\yongansystem\\upload\\reuce\\"+contractEntity.getHtnrfilename();
|
||||
downOaFile(file_url,contractEntity.getHtnrfilename(),newPath);
|
||||
//本地文件转为base64
|
||||
String base64 = getBase64(newPath);
|
||||
jsonObject.put("file",base64);
|
||||
JSONObject resultJson = send(jsonObject, contractEntity);
|
||||
if(!resultJson.getBoolean("flag")){
|
||||
logger.info("=========销售合同附件上传bip返回结果错误,开始修改销售合同附件上传推送标识为失败==========");
|
||||
contractEntity.setHtnrpush("0");
|
||||
salesContractDao.updateAnnexFile(contractEntity);
|
||||
logger.info("=========销售合同附件上传获取bip返回结果错误,修改销售合同附件上传推送标识为失败完毕==========");
|
||||
// saveTaskLivingDetails(contractEntity.getId(),contractEntity.getBillcode(),jsonObject.toString(),resultJson.toJSONString(),false);
|
||||
}else {
|
||||
logger.info("=========销售合同附件上传bip返回结果成功,开始修改销售合同附件上传推送标识为成功==========");
|
||||
contractEntity.setHtnrpush("1");
|
||||
salesContractDao.updateSalesContract(contractEntity);
|
||||
logger.info("=========销售合同附件上传bip返回结果成功,修改销售合同附件上传推送标识为成功完毕==========");
|
||||
// saveTaskLivingDetails(contractEntity.getId(),contractEntity.getBillcode(),jsonObject.toString(),resultJson.toJSONString(),true);
|
||||
}
|
||||
}
|
||||
if(null !=contractEntity.getIpofilename()){
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("filename",contractEntity.getIpofilename());
|
||||
jsonObject.put("billtype",contractEntity.getBilltype());
|
||||
jsonObject.put("billid",contractEntity.getBillid());
|
||||
jsonObject.put("billcode",contractEntity.getBillcode());
|
||||
jsonObject.put("pk_org",contractEntity.getPkOrg());
|
||||
String file_url = contractEntity.getIpoid();
|
||||
String newPath = "E:\\yongansystem\\upload\\reuce\\"+contractEntity.getIpofilename();
|
||||
downOaFile(file_url,contractEntity.getIpofilename(),newPath);
|
||||
//本地文件转为base64
|
||||
String base64 = getBase64(newPath);
|
||||
jsonObject.put("file",base64);
|
||||
JSONObject resultJson = send(jsonObject, contractEntity);
|
||||
if(!resultJson.getBoolean("flag")){
|
||||
logger.info("=========销售合同ipo附件上传bip返回结果错误,开始修改销售合同ipo附件上传推送标识为失败==========");
|
||||
contractEntity.setIpopush("0");
|
||||
salesContractDao.updateSalesContract(contractEntity);
|
||||
logger.info("=========销售合同ipo附件上传获取bip返回结果错误,修改销售合同ipo附件上传推送标识为失败完毕==========");
|
||||
//saveTaskLivingDetails(contractEntity.getId(),contractEntity.getBillcode(),jsonObject.toString(),resultJson.toJSONString(),false);
|
||||
}else {
|
||||
logger.info("=========销售合同ipo附件上传bip返回结果成功,开始修改销售合同ipo附件上传推送标识为成功==========");
|
||||
contractEntity.setIpopush("1");
|
||||
salesContractDao.updateSalesContract(contractEntity);
|
||||
logger.info("=========销售合同ipo附件上传bip返回结果成功,修改销售合同ipo附件上传推送标识为成功完毕==========");
|
||||
// saveTaskLivingDetails(contractEntity.getId(),contractEntity.getBillcode(),jsonObject.toString(),resultJson.toJSONString(),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("=======销售合同附件上传BIP执行成功=======");
|
||||
return BaseResult.getSuccessMessageEntity("销售合同附件上传执行成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.info("======执行销售合同附件上传BIP失败:{}========", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void downOaFile(String fileUrl, String fileName,String newPath) {
|
||||
logger.info("开始下载附件"+newPath);
|
||||
String token = getToken();
|
||||
logger.info("获取的token信息");
|
||||
String baseUrl = "https://swoa.sunwave.com.cn:9999/seeyon/rest/attachment/file/"+fileUrl+"?fileName="+fileName+"&token="+token;
|
||||
logger.info("要下载附件的URL"+baseUrl);
|
||||
HttpResponse response = HttpRequest.get(baseUrl).timeout(20000).execute();
|
||||
File uploadFile = new File(newPath);
|
||||
response.writeBody(uploadFile);
|
||||
}
|
||||
|
||||
private String getToken() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
HashMap<String,String> hashMap = new HashMap<>();
|
||||
hashMap.put("userName","hzyaRestUser");
|
||||
hashMap.put("password","hzya1314");
|
||||
hashMap.put("loginName","fkmanager");
|
||||
String result = HttpUtil.post("https://swoa.sunwave.com.cn:9999/seeyon/rest/token", JSON.toJSONString(hashMap));
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
if("".equals(result) || result == null){
|
||||
logger.info("获取token失败!");
|
||||
throw new RuntimeException("获取token失败!");
|
||||
}else{
|
||||
String token = jsonObject.get("id").toString();
|
||||
return token ;
|
||||
}
|
||||
}
|
||||
|
||||
//将本地文件转为base64编码
|
||||
private String getBase64(String filePath) {
|
||||
File file = new File(filePath);
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
byte[] bytes = new byte[(int) file.length()];
|
||||
fileInputStream.read(bytes);
|
||||
return Base64.getEncoder().encodeToString(bytes);
|
||||
}catch (Exception e){
|
||||
logger.info("========文件转base64失败:{}=====",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONObject send(JSONObject jsonObject,SalesContractEntity contractEntity){
|
||||
JSONObject token=new JSONObject();
|
||||
//获取TOKEN
|
||||
String tokenResult = HttpRequest.post(url).
|
||||
header("appId", "800050").
|
||||
header("apiCode", "8000500003").
|
||||
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
|
||||
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||
body(token.toString()).
|
||||
execute().
|
||||
body();
|
||||
logger.error("销售合同附件上传BIPtoken返回结果:"+tokenResult);
|
||||
JSONObject tokenResultJson = JSONObject.parseObject(tokenResult);
|
||||
if(!tokenResultJson.getBoolean("flag")){
|
||||
logger.info("=========销售合同上传附件获取biptoken错误,开始修改销售合同附件上传推送标识为失败==========");
|
||||
contractEntity.setIpopush("0");
|
||||
contractEntity.setHtnrpush("0");
|
||||
salesContractDao.updateAnnexFile(contractEntity);
|
||||
logger.info("=========销售合同附件上传获取biptoken错误,修改销售合同附件上传推送标识完毕==========");
|
||||
return null;
|
||||
}
|
||||
String tokenBody = tokenResultJson.getJSONObject("attribute").getJSONObject("data").getString("access_token");
|
||||
logger.error("销售合同附件上传推送BIP请求参数:"+jsonObject.toJSONString());
|
||||
//发送数据
|
||||
String result = HttpRequest.post(url).
|
||||
header("appId", "800050").
|
||||
header("apiCode", "8000500022").
|
||||
header("access_token", tokenBody).
|
||||
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
|
||||
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||
body(jsonObject.toString()).
|
||||
execute().
|
||||
body();
|
||||
logger.error("销售合同附件上传BIP返回结果:"+result);
|
||||
JSONObject resultJson = JSONObject.parseObject(result);
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
|
||||
try {
|
||||
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
|
||||
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
|
||||
integrationTaskLivingDetailsEntity.setSts("Y");
|
||||
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
|
||||
integrationTaskLivingDetailsEntity.setModify_user_id("1");
|
||||
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
|
||||
integrationTaskLivingDetailsEntity.setModify_time(new Date());
|
||||
integrationTaskLivingDetailsEntity.setOrg_id("0");
|
||||
integrationTaskLivingDetailsEntity.setCompanyId("0");
|
||||
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
|
||||
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
|
||||
integrationTaskLivingDetailsEntity.setPluginId("SalesContractPluginInitializer");
|
||||
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
|
||||
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
|
||||
if (flag) {
|
||||
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
|
||||
} else {
|
||||
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("保存日志到集成任务日志明细中失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue