use of com.itrus.portal.db.ProductSpec in project portal by ixinportal.
the class MakeCertController method show.
// 显示查看详细
@RequestMapping(value = "show/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
List<Map> makecerts = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillByMakecert", id);
uiModel.addAttribute("makecerts", makecerts);
List makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryBillKey", id);
uiModel.addAttribute("makecertexall", makecertexall);
DigitalCert digitalcert = null;
ProductSpec productSpec = null;
if (makecerts.get(0).get("is_combined") != null && makecerts.get(0).get("is_combined").equals(1)) {
Product productSub = null;
// 得到三条组合产品的产品信息
for (int i = 1; i < 4; i++) {
if (makecerts.get(0).get("product" + i) == null) {
continue;
}
productSub = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product" + i));
uiModel.addAttribute("product" + i, productSub);
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", productSub.getCert());
uiModel.addAttribute("digitalcert" + i, digitalcert);
// 获取产品规格
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);
}
return "makecert/show";
}
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);
return "makecert/show";
}
use of com.itrus.portal.db.ProductSpec in project portal by ixinportal.
the class MakeCertController method showReNew.
// 显示待更新订单详细
@RequestMapping(value = "showrenew/{id}", produces = "text/html")
public String showReNew(@PathVariable("id") Long id, Model uiModel) {
List<Map> makecerts = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillByMakecert", id);
uiModel.addAttribute("makecerts", makecerts);
List makecertexall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectOldUserCertByBillId", id);
uiModel.addAttribute("makecertexall", makecertexall);
DigitalCert digitalcert = null;
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", makecerts.get(0).get("cert"));
uiModel.addAttribute("digitalcert", digitalcert);
ProductSpec productSpec = null;
if (makecerts.get(0).get("is_combined") != null && makecerts.get(0).get("is_combined").equals(1)) {
Product productSub = null;
// 得到三条组合产品的产品信息
for (int i = 1; i < 4; i++) {
if (makecerts.get(0).get("product" + i) == null) {
continue;
}
productSub = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", makecerts.get(0).get("product" + i));
uiModel.addAttribute("product" + i, productSub);
digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", productSub.getCert());
uiModel.addAttribute("digitalcert" + i, digitalcert);
// 获取产品规格
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);
}
return "makecert/show2";
}
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);
return "makecert/show2";
}
use of com.itrus.portal.db.ProductSpec 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.db.ProductSpec in project portal by ixinportal.
the class DownLoadCertServiceImpl method downLoadCert.
/**
* 下载证书
*
* @param product
* @param ra
* @param bill
* @param digitalcert
* @param uidIdx
* @param csr
* @return
* @throws Exception
*/
public CertInfo downLoadCert(Product product, RaAccount ra, Bill bill, DigitalCert digitalcert, Integer uidIdx, String csr, String autoidType, Integer autoidValue) throws Exception {
CertInfo racertinfo = null;
// 解析项目产品中,certinfo配置信息
JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
// 解析订单中uid信息{"ADDTIONAL_FIELD1_1":"","ADDTIONAL_FIELD3_1":"","ADDTIONAL_FIELD4_1":"G2016071301","inputName":"inputValue"}
JSONObject uid = JSONObject.parseObject(bill.getUid());
com.itrus.portal.utils.CertUtlis certutil = new com.itrus.portal.utils.CertUtlis();
// 组织RA参数
cn.topca.tca.ra.service.UserInfo rauserinfo = new cn.topca.tca.ra.service.UserInfo();
UIDInfoUtils uidutils = new UIDInfoUtils();
uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
for (int i = 0; i < certinfo.size(); i++) {
JSONObject obj = certinfo.getJSONObject(i);
String raParaName = obj.getString("raParaName");
if (raParaName == null)
continue;
// "autoid":"yes",
String autoid = obj.getString("autoid");
// "raParaName": "userName",
String constValue = obj.getString("constValue");
// "constValue": "test@itrus.com.cn"
String refName = obj.getString("refName");
String val = null;
if (constValue != null) {
val = constValue;
} else if (refName != null) {
if (refName.indexOf("?") == -1)
val = uidutils.getUidInfo(bill.getId(), refName);
else {
val = "";
String[] arr = refName.split("\\?", 2);
if (arr.length == 2) {
String condition = arr[0].trim();
String[] refarr = arr[1].split(":", 2);
if (refarr.length == 2) {
boolean bret = uidutils.checkCondition(bill.getId(), condition);
if (bret)
val = uidutils.getUidInfo(bill.getId(), refarr[0].trim());
else
val = uidutils.getUidInfo(bill.getId(), refarr[1].trim());
}
}
}
} else if (autoid != null) {
// "autoidPrev":"G",
String autoidPrev = obj.getString("autoidPrev");
// "autoidType":"mytestautoid",
autoidType = obj.getString("autoidType");
// "inputName": "ADDTIONAL_FIELD4",存在多个值
String uidval = uid.getString(obj.getString("inputName") + "_" + uidIdx.toString());
val = uidval;
if (StringUtils.isNotBlank(uidval) && uidval.indexOf(autoidPrev) == 0) {
// "autoidPrevDate":"yyyyMMdd",
String autoidPrevDate = obj.getString("autoidPrevDate");
try {
if (autoidPrevDate == null || autoidPrevDate.length() == 0)
autoidValue = Integer.parseInt(uidval.substring(autoidPrev.length()));
else
autoidValue = Integer.parseInt(uidval.substring(autoidPrev.length() + autoidPrevDate.length()));
} catch (Exception e) {
e.printStackTrace();
autoidValue = 0;
}
}
} else {
val = uid.getString(obj.getString("inputName") + "_" + uidIdx.toString());
}
certutil.setUserInfoVal(rauserinfo, raParaName, val);
}
// 证书有效期
// {"0":"1年","1":"2年","2":"3年","3":"5年","4":"10年"})
Integer certValidity = 5;
boolean hasProductSpec = false;
// 判断订单中是否配了产品规格且有期限
ProductSpec productSpec = null;
if (null != bill.getProductSpec() && 0 != bill.getProductSpec()) {
productSpec = productSpecService.getProductSpec(bill.getProductSpec());
if (StringUtils.isNotBlank(productSpec.getProductValid())) {
hasProductSpec = true;
}
}
if (hasProductSpec) {
Integer day = Integer.parseInt(productSpec.getProductValid());
if (day == 100) {
// TODO 测试时候,配置年限为100年,则有效期为10天
certValidity = 10;
} else {
certValidity = 365 * day + 1 + (day / 4);
}
} else {
if ("0".compareTo(digitalcert.getCertDeadline()) == 0) {
certValidity = 365 * 1 + 1;
} else if ("1".compareTo(digitalcert.getCertDeadline()) == 0) {
certValidity = 365 * 2 + 1;
} else if ("2".compareTo(digitalcert.getCertDeadline()) == 0) {
certValidity = 365 * 3 + 1;
} else if ("3".compareTo(digitalcert.getCertDeadline()) == 0) {
certValidity = 365 * 5 + 2;
} else if ("4".compareTo(digitalcert.getCertDeadline()) == 0) {
certValidity = 365 * 10 + 2;
}
}
if (ra.getAaPassword() != null)
ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
racertinfo = certutil.enrollCertByWS(csr, ra, rauserinfo, certValidity);
return racertinfo;
}
use of com.itrus.portal.db.ProductSpec in project portal by ixinportal.
the class BillWebController method reNewCertConfirm.
// 订单详情,待更新确认
@RequestMapping(value = "/reNewCertConfirm/{id}", produces = "text/html")
public String reNewCertConfirm(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == userInfo || null == enterprise) {
return "redirect:/userInfoWeb/denglu.html";
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
Map param = new HashMap();
// 设置查询条件,选择属于当前用户,当前企业的订单
param.put("id", id);
// param.put("userinfoid", userInfo.getId());
// param.put("enterpriseid", enterprise.getId());
List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProductBillCertById", param);
log.error("--------获取订单数量-------" + billAll.size() + "*****获取订单信息***" + billAll);
log.error("------获取订单id--------" + billAll.get(0).get("id"));
log.error("========获取订单编号=========" + billAll.get(0).get("bill_id"));
if (0 == billAll.size()) {
return "redirect:/userInfoWeb/denglu.html";
}
uiModel.addAttribute("bills", billAll.get(0));
// 获取数字证书
Product product = productService.getProduct((Long) billAll.get(0).get("product"));
log.error("****获取产品id*****" + product.getId());
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
// 获取产品规格
ProductSpec productSpec = null;
if (null != billAll.get(0).get("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
uiModel.addAttribute("digitalCert", digitalCert);
// 返回订单对应的老证书的base64
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectCertBufByBillId", id);
if (null != certBuf) {
uiModel.addAttribute("oldCertB64", certBuf.getCertBuf().replaceAll("\n", ""));
}
log.error("*********签章服务******" + product.getMakeSealServer());
// 判断是否有签章服务,有则显示授权
if (null != product.getMakeSealServer()) {
uiModel.addAttribute("makesealserver", product.getMakeSealServer());
uiModel.addAttribute("billId", billAll.get(0).get("id"));
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
try {
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
} catch (EncDecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
}
return "ixinweb/dingdanxiangqing_gengxinqueren";
}
Aggregations