应付单跳转旗舰版按钮-后端代码2

This commit is contained in:
mzr 2025-11-30 18:00:52 +08:00
parent 4bd7bd2308
commit 653dd7cd99
2 changed files with 57 additions and 93 deletions

View File

@ -1,53 +1,78 @@
package nccloud.web.arap.arappub.action;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.itf.arap.pub.IArapBillService;
import nc.itf.scmpub.reference.uap.rbac.UserManageQuery;
import nc.itf.uif.pub.IUifService;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.arap.basebill.BaseAggVO;
import nc.vo.arap.basebill.BaseItemVO;
import nc.vo.bc.pub.util.SysParaInitQuery;
import nc.vo.bd.psn.PsndocVO;
import nc.vo.sm.UserVO;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.container.IRequest;
import nccloud.web.action.NCCAction;
import nccloud.web.uapbd.commons.web.ParamUtils;
import java.util.Map;
public class LinkBipAction extends NCCAction {
private IUifService uifservice = NCLocator.getInstance().lookup(IUifService.class);
// JwtUtil util = new JwtUtil();
@Override
public <T> Object execute(IRequest request, T para) throws Exception {
ParamUtils param = new ParamUtils(request);
String bip_pk = param.getString("bip_pk", null);
String bip_no = param.getString("bip_no", null);
// String pk_group = param.getString("pk_group", null);
String redirctCode = "purinv";
String pkBill = param.getString("pk_bill", null);
String billType = param.getString("billType", null);
String redirctCode = param.getString("redirctCode", null);
if (redirctCode == null || redirctCode.isEmpty()) {
throw new RuntimeException("redirctCode为空,请检查");
}
String userid = InvocationInfoProxy.getInstance().getUserId();
String psnid = UserManageQuery.queryPsndocByUserid(userid);
// String linkbipurl = SysParaInitQuery.getParaString("GLOBLE00000000000000", "LinkBIPUrl");
String linkbipurl = "";
linkbipurl = "https://www.tkkfbip.com/c-kk-lszz-znpt/commontthirdLogin";
// if (psnid == null || psnid.isEmpty()) {
// throw new RuntimeException("当前用户无人员信息,请检查");
// }
UserVO userVO = UserManageQuery.queryUserVOByUserid(userid);
if (userVO == null) {
throw new RuntimeException("当前用户查询不到信息,请检查");
}
String userCode = userVO.getUser_code();
String linkbipurl = SysParaInitQuery.getParaString("GLOBLE00000000000000", "LinkBIPUrl");
try {
// PsndocVO vo = (PsndocVO) uifservice.queryByPrimaryKey(PsndocVO.class, psnid);
// String key = SysParaInitQuery.getParaString("GLOBLE00000000000000", "LinkBIPKey");// 密钥
// String[] bipkey = key.split("/");
// if (bipkey == null || bipkey.length != 2) {
// throw new RuntimeException("LinkBIPKey格式不对请检查");
// }
// String userCode = util.encrypt(vo.getCode(), bipkey[0]);
// Map<String, Object> map = new HashMap<>();
// map.put("userCode", userCode);
// map.put("secretKey", bipkey[1]);
// map.put("ttlMillis", 60000 * 1);// 设置过期时间1分钟
// String token = util.createJWT(map);
// String url = "?token=" + token + "&redirctCode=" + redirctCode + "&billId=" + bip_pk;
// bip_pk = "2385789401874563081";// 测试环境
bip_pk = "2414583154678431746";//开发环境
String url = "?redirctCode=" + redirctCode + "&billId=" + bip_pk;
// =========根据应付单id查询采购发票的旗舰版id===========
// NCCForUAPLogger.debug("pkBill:" + pkBill + " billType:" + billType);
BaseAggVO[] vos = ServiceLocator.find(IArapBillService.class).queryArapBillByPKs(new String[]{pkBill}, billType);
if (MMValueCheck.isEmpty(vos)) {
ExceptionUtils.wrapBusinessException("未找到单据,查询参数:" + "pkBill:" + pkBill + " billType:" + billType);
}
BaseAggVO vo = vos[0];
BaseItemVO[] itemVOS = vo.getItems();
BaseItemVO itemVO = itemVOS[0];
String topBillid = itemVO.getTop_billid();
String topTradetype = itemVO.getTop_tradetype();
// NCCForUAPLogger.debug("topBillid:" + topBillid + " topTradetype:" + topTradetype);
String sql = "SELECT a.pk_invoice,a.vbillcode," +
" b.cextsrcbilltype, b.vextsrcbillcode, b.cextsrcid, b.cextsrcbid" +
" FROM po_invoice_b b" +
" LEFT JOIN po_invoice a ON a.pk_invoice = b.pk_invoice" +
" WHERE " +
" a.pk_invoice = '" + topBillid + "'";
NCCForUAPLogger.debug("sql:" + sql);
Map<String, Object> billMap = (Map<String, Object>) new BaseDAO().executeQuery(sql, new MapProcessor());
if (MMValueCheck.isEmpty(billMap)) {
ExceptionUtils.wrapBusinessException("未查询到采购发票查询sql:" + sql);
}
if (MMValueCheck.isEmpty(billMap.get("cextsrcid"))) {
ExceptionUtils.wrapBusinessException("该采购发票不来源于外部系统无法跳转查询sql:" + sql);
}
// =========根据应付单id查询采购发票的旗舰版id===========
// String bip_pk = "2385789401874563081";// 测试环境
String bip_pk = billMap.get("cextsrcid") + "";
bip_pk = "2414583154678431746";// 开发环境
NCCForUAPLogger.debug("LinkBipAction-userCode = " + userCode);
userCode = "yhtmanager";
String url = "?redirctCode=" + redirctCode + "&billId=" + bip_pk + "&userCode=" + userCode;
linkbipurl = linkbipurl + url;
NCCForUAPLogger.debug("LinkBipAction-linkbipurl = " + linkbipurl);
return linkbipurl;

View File

@ -1,61 +0,0 @@
package nccloud.web.arap.arappub.action;
import com.alibaba.fastjson.JSONObject;
import nc.bs.dao.BaseDAO;
import nc.itf.arap.pub.IArapBillService;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.arap.basebill.BaseAggVO;
import nc.vo.arap.basebill.BaseItemVO;
import nc.vo.pub.BusinessException;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory;
import nccloud.web.arap.arappub.info.CommonInfo;
import nccloud.web.arap.arappub.util.BillActionUtils;
import java.util.Map;
public class LinkOtherPurInvoiceAction implements ICommonAction {
public LinkOtherPurInvoiceAction() {
}
public Object doAction(IRequest request) {
String str = request.read();
(new BillActionUtils()).setBusiInfoParm(str);
IJson json = JsonFactory.create();
CommonInfo info = json.fromJson(str, CommonInfo.class);
try {
String pkBill = info.getPk_bill();
String billType = info.getBillType();
NCCForUAPLogger.debug("pkBill:" + pkBill + " billType:" + billType);
BaseAggVO[] vos = ServiceLocator.find(IArapBillService.class).queryArapBillByPKs(new String[]{pkBill}, billType);
if (MMValueCheck.isEmpty(vos)) {
ExceptionUtils.wrapBusinessException("δÕÒµ½µ¥¾Ý");
}
BaseAggVO vo = vos[0];
BaseItemVO[] itemVOS = vo.getItems();
BaseItemVO itemVO = itemVOS[0];
String topBillid = itemVO.getTop_billid();
String topTradetype = itemVO.getTop_tradetype();
NCCForUAPLogger.debug("topBillid:" + topBillid + " topTradetype:" + topTradetype);
String sql = "SELECT a.pk_invoice,a.vbillcode," +
" b.cextsrcbilltype, b.vextsrcbillcode, b.cextsrcid, b.cextsrcbid" +
" FROM po_invoice_b b" +
" LEFT JOIN po_invoice a ON a.pk_invoice = b.pk_invoice" +
" WHERE " +
" a.pk_invoice = '" + topBillid + "'";
Map<String, Object> map = (Map<String, Object>) new BaseDAO().executeQuery(sql, new MapProcessor());
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", map);
return jsonObject;
} catch (BusinessException e) {
ExceptionUtils.wrapException(e);
return null;
}
}
}