use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class MakeCertController method makeSealBaiRun.
/**
* 百润制章
*
* @param billId
* 订单id
* @param csr
* 证书base64编码
* @param request
* @param response
* @return
* @throws EncDecException
* @throws Exception
*/
@RequestMapping(value = "/makeSealBaiRun", method = RequestMethod.POST)
public void makeSealBaiRun(@RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "sealpic", required = true) String sealpic, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "productId", required = false) Long productId, HttpServletRequest request, HttpServletResponse response) throws EncDecException, Exception {
// Map<String, Object> map = new HashMap<String, Object>();
// map.put("retCode", 0);
// 获取签章模版
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
// 查询项目产品
Product product = null;
// 如为组合产品productId不为空
if (null == productId) {
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
} else {
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId);
}
/*
* if (null == product.getMakeSealServer() ||
* product.getMakeSealServer() <= 0) { map.put("retMsg", "该产品未配置签章服务");
* return map; }
*/
MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
/*
* if (makeSealConfigs.isEmpty()) { map.put("retMsg", "没有找到签章服务配置");
* return map; }
*/
Map<String, Object> param = new HashMap<>();
param.put("id", bill.getId());
UserCertExample userc = new UserCertExample();
UserCertExample.Criteria us = userc.createCriteria();
us.andIdNotEqualTo(bill.getId());
userc.setOrderByClause("cert_start_time desc");
userc.setLimit(1);
UserCert usercert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userc);
CertBufExample certbuf = new CertBufExample();
CertBufExample.Criteria cert = certbuf.createCriteria();
cert.andIdEqualTo(usercert.getCertBuf());
CertBuf organ = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByExample", certbuf);
if (makeSealConfigs.get(1).getName().contains(makeSealServer.getFirm())) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
// 替换-印章名称
if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
makeSealServer.setSealName(uidutils.getUidInfo(billId, makeSealServer.getSealName()));
}
try {
log.error("request.getLocalAddr : " + request.getLocalAddr() + ",CSR:" + organ.getCertBuf());
boolean userbool = true;
if (usercert.getIsRegister() == null || !usercert.getIsRegister().equals(1)) {
usercert.setIsRegister(1);
sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKeySelective", usercert);
// 注册用户
userbool = UserSDK.addUser(null, makeSealConfig.getAddressKey(), organ.getCertBuf(), makeSealServer.getAccount(), Constant.APP, Constant.Token);
log.error("makeCertController userbool : " + userbool);
// log.info(makeSealConfig.getAddressKey());
// log.info(String.valueOf(userbool));
}
// 制作印章
Map<String, Object> result = SealSDK.makeSeal(makeSealServer.getSealName(), organ.getCertBuf(), sealpic, "公章", Constant.APP, Constant.Token);
if (userbool && (Boolean) result.get("state")) {
// 制章完成后的印章数据,返回到前台用作导章
log.error("SealSDK : context");
} else {
log.error("SealSDK : ");
// map.put("retMsg", "制章异常");
}
response.setCharacterEncoding("GBK");
response.setContentType("text/html");
OutputStream out = response.getOutputStream();
out.write(result.get("data").toString().getBytes("GBK"));
// map.put("bairun_ret",
// result.get("data").toString().getBytes("GBK"));
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
// map.put("retMsg", e.getMessage());
}
} else {
MakeSealConfig makeSealConfig = makeSealConfigs.get(1);
// 替换-印章名称
if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
makeSealServer.setSealName(uidutils.getUidInfo(billId, makeSealServer.getSealName()));
}
try {
log.error("request.getLocalAddr : " + request.getLocalAddr() + ",CSR:" + organ.getCertBuf());
boolean userbool = true;
if (usercert.getIsRegister() != null && !usercert.getIsRegister().equals(1)) {
usercert.setIsRegister(1);
sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKeySelective", usercert);
// 注册用户
userbool = UserSDK.addUser(null, makeSealConfig.getAddressKey(), organ.getCertBuf(), Constant.TianWeiChenXin, Constant.APP, Constant.Token);
}
// 制作印章
Map<String, Object> result = SealSDK.makeSeal(makeSealServer.getSealName(), organ.getCertBuf(), sealpic, "公章", Constant.APP, Constant.Token);
String s = Constant.IP;
if (userbool && (Boolean) result.get("state")) {
// 制章完成后的印章数据,返回到前台用作导章
log.error("SealSDK : " + result.get("data").toString());
} else {
log.error("SealSDK : ");
// map.put("retMsg", "制章异常");
}
response.setCharacterEncoding("GBK");
response.setContentType("text/html");
OutputStream out = response.getOutputStream();
out.write(result.get("data").toString().getBytes("GBK"));
// map.put("bairun_ret",
// result.get("data").toString().getBytes("GBK"));
out.flush();
out.close();
System.out.println(result.get("data").toString().getBytes("GBK").toString() + ":JS");
} catch (Exception e) {
e.printStackTrace();
// map.put("retMsg", e.getMessage());
}
}
// map.put("retCode", 1);
// return map;
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class MakeCertController method update.
// 显示制证详情
@RequestMapping(value = "/update/{id}", produces = "text/html")
public String update(@PathVariable("id") Long id, Model uiModel) throws EncDecException, Exception {
List<Map> makecerts = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillByMakecert", id);
uiModel.addAttribute("makecerts", makecerts);
uiModel.addAttribute("enterpriseSn", makecerts.get(0).get("enterprise_sn"));
DigitalCert digitalcert = null;
ProductSpec productSpec = null;
Product product = null;
Map<String, Object> params = new HashMap<String, Object>();
// 添加组合产品
if (makecerts.get(0).get("is_combined") != null && makecerts.get(0).get("is_combined").equals(1)) {
try {
uiModel.addAttribute("billStr", jsonTool.writeValueAsString(makecerts.get(0)));
} catch (Exception e) {
e.printStackTrace();
}
// 得到三条组合产品的产品信息
for (int i = 1; i < 4; i++) {
if (makecerts.get(0).get("product" + i) == null) {
uiModel.addAttribute("usercertallStr" + i, "{}");
continue;
}
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product" + i));
uiModel.addAttribute("product" + i, product);
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
uiModel.addAttribute("digitalcert" + i, digitalcert);
params.put("id", id);
params.put("pid", product.getId());
List<Map<String, Object>> makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillAndProductKey", params);
uiModel.addAttribute("makecertexall" + i, makecertexall);
// 获取产品规格
if (makecerts.get(0).containsKey("product_spec" + i) && !"0".equals(makecerts.get(0).get("product_spec" + i))) {
productSpec = productSpecService.getProductSpec((Long) makecerts.get(0).get("product_spec" + i));
}
uiModel.addAttribute("productSpec" + i, productSpec);
try {
uiModel.addAttribute("digitalcertStr" + i, jsonTool.writeValueAsString(digitalcert));
uiModel.addAttribute("productStr" + i, jsonTool.writeValueAsString(product));
uiModel.addAttribute("productSpecStr" + i, jsonTool.writeValueAsString(productSpec));
uiModel.addAttribute("usercertallStr" + i, jsonTool.writeValueAsString(makecertexall));
} catch (Exception e) {
e.printStackTrace();
}
// 解析项目产品中,certinfo配置信息
JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
for (int j = 0; certinfo != null && j < certinfo.size(); j++) {
JSONObject obj = certinfo.getJSONObject(j);
String autoid = obj.getString("autoid");
if (autoid == null)
continue;
String autoidType = obj.getString("autoidType");
String autoidPrev = obj.getString("autoidPrev");
String autoidPrevDate = obj.getString("autoidPrevDate");
String autoidLength = obj.getString("autoidLength");
// 从user_cert表查询,该autoidType的最大值,如果没有最大值,则设置为0
Map param = new HashMap();
String enterpriseId = makecerts.get(0).get("enterprise").toString();
param.put("enterpriseId", makecerts.get(0).get("enterprise"));
param.put("type", autoidType);
Integer autoidValue = null;
if (autoidPrevDate == null)
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditon", param);
else
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditonDate", param);
if (autoidValue == null)
autoidValue = 0;
uiModel.addAttribute("enterpriseId" + i, enterpriseId);
uiModel.addAttribute("autoidType" + i, autoidType);
uiModel.addAttribute("autoidPrev" + i, autoidPrev);
uiModel.addAttribute("autoidLength" + i, autoidLength);
uiModel.addAttribute("autoidValue" + i, autoidValue);
break;
}
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
if (null != makeSealServer) {
// 替换-印章名称
if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
makeSealServer.setSealName(uidutils.getUidInfo(id, makeSealServer.getSealName()));
}
uiModel.addAttribute("makeSealServer" + i, makeSealServer);
}
}
return "makecert/update1";
}
List<Map> makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillKey", id);
uiModel.addAttribute("makecertexall", makecertexall);
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", makecerts.get(0).get("cert"));
uiModel.addAttribute("digitalcert", digitalcert);
if (makecerts.get(0).containsKey("product_spec") && !"0".equals(makecerts.get(0).get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) makecerts.get(0).get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product"));
uiModel.addAttribute("product", product);
try {
uiModel.addAttribute("billStr", jsonTool.writeValueAsString(makecerts.get(0)));
uiModel.addAttribute("usercertallStr", jsonTool.writeValueAsString(makecertexall));
uiModel.addAttribute("digitalcertStr", jsonTool.writeValueAsString(digitalcert));
uiModel.addAttribute("productStr", jsonTool.writeValueAsString(product));
uiModel.addAttribute("productSpecStr", jsonTool.writeValueAsString(productSpec));
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println(makecerts.get(0).get("product_num"));
// 处理autoid自动编号信息
// 解析项目产品中,certinfo配置信息
JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
for (int i = 0; certinfo != null && i < certinfo.size(); i++) {
JSONObject obj = certinfo.getJSONObject(i);
String autoid = obj.getString("autoid");
if (autoid == null)
continue;
String autoidType = obj.getString("autoidType");
String autoidPrev = obj.getString("autoidPrev");
String autoidPrevDate = obj.getString("autoidPrevDate");
String autoidLength = obj.getString("autoidLength");
// 从user_cert表查询,该autoidType的最大值,如果没有最大值,则设置为0
Map param = new HashMap();
String enterpriseId = makecerts.get(0).get("enterprise").toString();
param.put("enterpriseId", makecerts.get(0).get("enterprise"));
param.put("type", autoidType);
Integer autoidValue = null;
if (autoidPrevDate == null)
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditon", param);
else
autoidValue = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByConditonDate", param);
if (autoidValue == null)
autoidValue = 0;
uiModel.addAttribute("enterpriseId", enterpriseId);
uiModel.addAttribute("autoidType", autoidType);
uiModel.addAttribute("autoidPrev", autoidPrev);
uiModel.addAttribute("autoidLength", autoidLength);
uiModel.addAttribute("autoidValue", autoidValue);
break;
}
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
if (null != makeSealServer) {
// 替换-印章名称
if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
makeSealServer.setSealName(uidutils.getUidInfo(id, makeSealServer.getSealName()));
}
uiModel.addAttribute("makeSealServer", makeSealServer);
}
return "makecert/update";
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class QueryBillController method show.
// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
Map param = new HashMap();
param.put("id", id);
// 管理员项目权限
Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
param.put("hasProjects", Arrays.asList(projectsOfAdmin));
Map bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByCondition2", param);
if (null == bill || bill.isEmpty()) {
uiModel.addAttribute("errorMsg", "未找到该订单");
return "status403";
}
uiModel.addAttribute("bill", bill);
// 得到纳税人识别号
if (bill.get("id") != null) {
String taxesCode = getTaxesCode(Long.valueOf(bill.get("id").toString()));
uiModel.addAttribute("taxesCode", taxesCode);
}
// 获取十环证书编号
if (null != bill.get("uid") && !"{}".equals(bill.get("uid"))) {
List<String> uidList = new ArrayList<String>();
JSONObject uid = JSONObject.parseObject(bill.get("uid").toString());
int countUid = StringUtils.countMatches(bill.get("uid").toString(), "ADDTIONAL_FIELD4");
for (int i = 0; i < countUid; i++) {
uidList.add(uid.get("ADDTIONAL_FIELD4_" + (i + 1)).toString());
}
uiModel.addAttribute("uidList", uidList);
}
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.get("product"));
uiModel.addAttribute("product", product);
Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
if (certification != null) {
uiModel.addAttribute("rank", certification.getRank());
}
PayInfo payinfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", bill.get("pay_info"));
uiModel.addAttribute("pi", payinfo);
if (product.getIsCombined() != null && product.getIsCombined().equals(1)) {
for (int i = 1; i < 4; i++) {
if (bill.get("product" + i) != null) {
Product product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.get("product" + i));
uiModel.addAttribute("product" + i, product1);
if (null != product1.getCert()) {
DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product1.getCert());
System.out.println(product1.getCert() + "-------------" + cert.getCertType());
uiModel.addAttribute("cert" + i, cert);
}
ProductSpec productSpec = null;
if (bill.containsKey("product_spec" + i) && !"0".equals(bill.get("product_spec" + i))) {
productSpec = productSpecService.getProductSpec((Long) bill.get("product_spec" + i));
}
uiModel.addAttribute("productSpec" + i, productSpec);
PreferentialRecord pr = preferentialRecordService.selectPreferentialRecordSByBillIdAndProductId(id, product1.getId());
if (null != pr) {
uiModel.addAttribute("preferentialrecord" + i, pr);
}
}
}
}
DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
uiModel.addAttribute("cert", cert);
// 获取产品规格
ProductSpec productSpec = null;
if (bill.containsKey("product_spec") && !"0".equals(bill.get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) bill.get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
PreferentialRecord pr = preferentialRecordService.selectPreferentialRecordSByBillId(id);
if (null != pr) {
uiModel.addAttribute("preferentialrecord", pr);
}
if (bill.get("on_pay_info") != null) {
OnPayInfo onpayinfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.get("on_pay_info"));
uiModel.addAttribute("onpayinfo", onpayinfo);
OnlinePay onlinepay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", bill.get("online_pay"));
uiModel.addAttribute("onlinepay", onlinepay);
}
// 证书信息
UserCertExample uce = new UserCertExample();
UserCertExample.Criteria ucc = uce.createCriteria();
ucc.andBillEqualTo(id);
List certs = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByExample", uce);
uiModel.addAttribute("certs", certs);
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.get("enterprise"));
uiModel.addAttribute("ent", enterprise);
BusinessLicenseExample ble = new BusinessLicenseExample();
BusinessLicenseExample.Criteria blc = ble.createCriteria();
blc.andEnterpriseEqualTo(enterprise.getId());
blc.andBillEqualTo(id);
BusinessLicense bl = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByExample", ble);
uiModel.addAttribute("bl", bl);
OrgCodeExample oce = new OrgCodeExample();
OrgCodeExample.Criteria occ = oce.createCriteria();
occ.andEnterpriseEqualTo(enterprise.getId());
occ.andBillEqualTo(id);
OrgCode oc = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByExample", oce);
uiModel.addAttribute("oc", oc);
TaxRegisterCertExample trce = new TaxRegisterCertExample();
TaxRegisterCertExample.Criteria trcc = trce.createCriteria();
trcc.andEnterpriseEqualTo(enterprise.getId());
trcc.andBillEqualTo(id);
TaxRegisterCert trc = sqlSession.selectOne("com.itrus.portal.db.TaxRegisterCertMapper.selectByExample", trce);
uiModel.addAttribute("trc", trc);
IdentityCardExample ice = new IdentityCardExample();
IdentityCardExample.Criteria icc = ice.createCriteria();
icc.andEnterpriseEqualTo(enterprise.getId());
icc.andBillEqualTo(id);
IdentityCard ic = sqlSession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByExample", ice);
uiModel.addAttribute("ic", ic);
AgentExample ate = new AgentExample();
AgentExample.Criteria aec = ate.createCriteria();
aec.andEnterpriseEqualTo(enterprise.getId());
aec.andBillEqualTo(id);
Agent at = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectByExample", ate);
uiModel.addAttribute("at", at);
ProxyExample pe = new ProxyExample();
ProxyExample.Criteria pc = pe.createCriteria();
pc.andEnterpriseEqualTo(enterprise.getId());
pc.andBillEqualTo(id);
Proxy proxy = sqlSession.selectOne("com.itrus.portal.db.ProxyMapper.selectByExample", pe);
uiModel.addAttribute("proxy", proxy);
uiModel.addAttribute("p", proxy);
PayInfo pi = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", bill.get("pay_info"));
uiModel.addAttribute("pi", pi);
Invoice invoice = sqlSession.selectOne("com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey", bill.get("invoice"));
uiModel.addAttribute("invoice", invoice);
if (invoice != null && invoice.getReceipt() != null) {
Receipt receipt = sqlSession.selectOne("com.itrus.portal.db.ReceiptMapper.selectByPrimaryKey", invoice.getReceipt());
uiModel.addAttribute("receipt", receipt);
}
// 判断是否选择电子发票
if (bill.get("e_invoice") != null && bill.get("e_invoice") != "") {
Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.get("e_invoice"));
uiModel.addAttribute("einvoice", einvoice);
Ereceipt ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", einvoice.geteReiceipt());
uiModel.addAttribute("ereceipt", ereceipt);
}
Delivery d = sqlSession.selectOne("com.itrus.portal.db.DeliveryMapper.selectByPrimaryKey", bill.get("delivery"));
uiModel.addAttribute("d", d);
if (d != null) {
String regionCodes = d.getRegionCodes();
String adds = d.getDetailAdds();
if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
String[] codes = regionCodes.split("@");
String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
adds = regionName + adds;
d.setDetailAdds(adds);
}
// Courier delivery =
// sqlSession.selectOne("com.itrus.portal.db.CourierMapper.selectByPrimaryKey",
// d.getCourier());
uiModel.addAttribute("delivery", d.getCourier());
}
CourierInfoExample cie = new CourierInfoExample();
CourierInfoExample.Criteria cic = cie.createCriteria();
cic.andBillEqualTo(id);
List couriers = sqlSession.selectList("com.itrus.portal.db.CourierInfoMapper.selectByExample", cie);
uiModel.addAttribute("couriers", couriers);
Map<Long, Courier> deliverys = sqlSession.selectMap("com.itrus.portal.db.CourierMapper.selectByExample", null, "id");
uiModel.addAttribute("deliverys", deliverys);
// 解锁相关证书信息
UserCertExample keyUnlockuce = new UserCertExample();
UserCertExample.Criteria keyUnlockuceucc = keyUnlockuce.createCriteria();
if (bill.get("unlock_user_cert") != null) {
keyUnlockuceucc.andIdEqualTo((Long) bill.get("unlock_user_cert"));
UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", keyUnlockuce);
uiModel.addAttribute("userCert", userCert);
}
KeyUnlockExample kue = new KeyUnlockExample();
KeyUnlockExample.Criteria keuc = kue.createCriteria();
keuc.andBillEqualTo(id);
KeyUnlock keyUnlock = sqlSession.selectOne("com.itrus.portal.db.KeyUnlockMapper.selectByExample", kue);
uiModel.addAttribute("keyUnlock", keyUnlock);
if (keyUnlock != null) {
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keyUnlock.getKeySn());
uiModel.addAttribute("projectKeyInfo", projectKeyInfo);
}
try {
makeSeal((Long) bill.get("id"), uiModel);
} catch (EncDecException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return "querybill/show";
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class AESencrp method decrypt.
// 解密
public static String decrypt(String encVal, String decKey) throws EncDecException, Exception {
if (StringUtils.isBlank(decKey) || decKey.length() < 32)
throw new EncDecException("秘钥为空或长度小于32位");
SecretKeySpec skeySpec = new SecretKeySpec(decKey.substring(0, 16).getBytes(), ENC_CIPHER);
IvParameterSpec ivSpec = new IvParameterSpec(decKey.substring(16, 32).getBytes());
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivSpec, null);
byte[] decVal = cipher.doFinal(Base64.decode(encVal.getBytes()));
return new String(decVal);
}
use of com.itrus.portal.exception.EncDecException in project portal by ixinportal.
the class AESencrp method encrypt.
// 加密
public static String encrypt(String plainText, String enckey) throws EncDecException, Exception {
if (StringUtils.isBlank(enckey) || enckey.length() < 32)
throw new EncDecException("秘钥为空或长度小于32位");
SecretKeySpec skeySpec = new SecretKeySpec(enckey.substring(0, 16).getBytes(), ENC_CIPHER);
IvParameterSpec ivSpec = new IvParameterSpec(enckey.substring(16, 32).getBytes());
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
byte[] encVal = cipher.doFinal(plainText.getBytes());
// 此处使用BASE64做转码功能,同时能起到2次加密的作用。
return new String(Base64.encode(encVal));
}
Aggregations