use of com.itrus.portal.db.SignatureConfig in project portal by ixinportal.
the class MakeCertController method push.
/**
* 手动推送
*
* @param id
* @param uiModel
* @return
*/
@RequestMapping(value = "/{id}/{type}", method = RequestMethod.GET, produces = "text/html")
@ResponseBody
public String push(@PathVariable("id") Long id, @PathVariable("type") Long type, Model uiModel) {
SignatureConfig sc = null;
JSONObject data = null;
JSONObject org = null;
JSONObject result = null;
Bill bill = null;
/*if(type==1){
try {
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
log.error("bill.getMcstatus()="+bill.getMcstatus()+"bill="+bill);
if(null == bill) {
//log.error(bill.getMcstatus()+"---------------------------------------------"+bill);
//System.out.println(bill.getMcstatus()+"=******************************="+bill);
return "该订单无法推送";
}
Product product = productService.getProductById(bill.getProduct());
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey",
product.getSignature());
Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
BusinessLicense bl = businessService.getBusinessByBillId((id), null);
if (org == null) {
org = new JSONObject();
}
org.put("userType", 1);
org.put("fullName", bl.getEnterpriseName());
if (bl != null && bl.getBusinessType() == 1) {
org.put("orgCode", bl.getLicenseNo());
} else {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
org.put("orgCode", tc == null ? "" : tc.getCertNo());
}
org.put("papersType", "营业执照");
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey",
bill.getUniqueId());
org.put("businessNum", userInfo.getTelephone());
// IdentityCard ic =
// identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
// null);
org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
Agent agent = agentService.getAgentByBillId((id), null);
org.put("transactorName", agent == null ? enterprise.getEnterpriseName() : agent.getName());
if (agent != null && agent.getCardType() == 1) {
org.put("transactorIdCardNum", agent.getIdCode());
}
org.put("transactorMobile", userInfo.getmPhone());
org.put("realInfoOrder", bill.getBillId());
org.put("realInfoUid", bill.getUniqueId());
if (data == null) {
data = new JSONObject();
}
data.put("appId", sc.getAppId());
data.put("timestamp", System.currentTimeMillis());
data.put("user", org);
data.put("autoCert", true);
data.put("autoSeal", true);
// String content =
// "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
// bill =
// sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
// map.get("id"));
if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
// return "redirect:/makecert";
return null;
}
log.error("打印data="+data.toString());
log.error("----------接口地址**************"+sc.getAddress() + USER_URL+"***********服务密钥**********"+sc.getAddressKey());
result = JSONObject
.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
log.equals("MakeCert_push_result : " + result);
if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
// return "redirect:/makecert";
return null;
}
LogUtil.syslog(sqlSession, "手动推送用户",
bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
// uiModel.addAttribute("error", "错误:" +
// result.getString("message"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
// uiModel.addAttribute("error", "错误:" + e);
return "错误【" + e + "】";
}
}else */
if (type == 1) {
try {
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
if (null == bill) {
// System.out.println(bill.getMcstatus()+"=******************************="+bill);
return "该订单无法推送";
}
Product product = productService.getProductById(bill.getProduct());
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
BusinessLicense bl = businessService.getBusinessByBillId((id), null);
if (org == null) {
org = new JSONObject();
}
org.put("userType", 1);
org.put("fullName", bl.getEnterpriseName());
if (bl != null && bl.getBusinessType() == 1) {
org.put("orgCode", bl.getLicenseNo());
} else {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
org.put("orgCode", tc == null ? "orgCode" : tc.getCertNo());
}
org.put("papersType", "营业执照");
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
org.put("businessNum", userInfo.getTelephone() == null ? "businessNum" : userInfo.getTelephone());
// null);
if (bl != null) {
org.put("legalPersonName", bl.getLegalPerson() == null ? "legalPersonName" : bl.getLegalPerson());
} else {
org.put("legalPersonName", "legalPersonName");
}
Agent agent = agentService.getAgentByBillId((id), null);
org.put("transactorName", agent == null ? "transactorName" : agent.getName());
if (agent != null && agent.getCardType() == 1) {
org.put("transactorIdCardNum", agent.getIdCode());
} else {
org.put("transactorIdCardNum", "transactorIdCardNum");
}
org.put("transactorMobile", userInfo.getmPhone());
org.put("realInfoOrder", bill.getBillId());
org.put("realInfoUid", bill.getUniqueId());
if (data == null) {
data = getJSONRequest(sc.getAppId());
}
data.put("autoCert", true);
data.put("autoSeal", true);
// data.put("appId", sc.getAppId());
// data.put("timestamp", System.currentTimeMillis());
data.put("user", org);
// String content =
// "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
// bill =
// sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
// map.get("id"));
/*if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
// return "redirect:/makecert";
return null;
}*/
log.error("打印data=" + data.toString());
log.error("----------接口地址**************" + sc.getAddress() + USER_URL + "***********服务密钥**********" + sc.getAddressKey());
result = JSONObject.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
log.equals("MakeCert_push_result : " + result);
if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
// return "redirect:/makecert";
return null;
}
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
// uiModel.addAttribute("error", "错误:" +
// result.getString("message"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
// uiModel.addAttribute("error", "错误:" + e);
return "错误【" + e + "】";
}
} else {
try {
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
if (null == bill) {
// System.out.println(bill.getMcstatus()+"=******************************="+bill);
return "该订单无法推送";
}
Product product = productService.getProductById(bill.getProduct());
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
BusinessLicense bl = businessService.getBusinessByBillId((id), null);
/*if (org == null) {
org = new JSONObject();
}
org.put("userType", 1);
org.put("fullName", bl.getEnterpriseName());
if (bl != null && bl.getBusinessType() == 1) {
org.put("orgCode", bl.getLicenseNo());
} else {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
org.put("orgCode", tc == null ? "" : tc.getCertNo());
}
org.put("papersType", "营业执照");*/
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
// org.put("businessNum", userInfo.getTelephone());
// IdentityCard ic =
// identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
// null);
// org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
Agent agent = agentService.getAgentByBillId((id), null);
/*org.put("transactorName", agent == null ? "" : agent.getName());
if (agent != null && agent.getCardType() == 1) {
org.put("transactorIdCardNum", agent.getIdCode());
}
org.put("transactorMobile", userInfo.getmPhone());
org.put("realInfoOrder", bill.getBillId());
org.put("realInfoUid", bill.getUniqueId());*/
if (data == null) {
data = new JSONObject();
}
Map<String, Object> treeMap = Maps.newTreeMap();
treeMap.put("app_id", sc.getAppId());
treeMap.put("order_number", bill.getBillId());
treeMap.put("user_name", enterprise.getEnterpriseName());
treeMap.put("user_email", userInfo.getEmail());
treeMap.put("user_phone", userInfo.getmPhone());
treeMap.put("user_type", "organization");
/*String cardType = null;
if(agent!=null && agent.getCardType()!=null){
if(agent.getCardType()==1){
cardType = "IdentityCard";
}else if(agent.getCardType()==2){
cardType = "NationalPassport";
}else{
cardType = "Other";
}
treeMap.put("identification_number",agent.getIdCode());
}
*/
String cardType = null;
String sn = null;
BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
if (businessLicense != null && businessLicense.getBusinessType() == 1) {
sn = businessLicense.getLicenseNo();
cardType = "UniformSocialCreditCode";
}
if (businessLicense == null || businessLicense.getBusinessType() != 1) {
// 不是五证合一
OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
if (oc != null) {
sn = oc.getOrgCode();
cardType = "OrganizationCode";
}
}
treeMap.put("identification_number", sn);
treeMap.put("identity_type", cardType);
String jsondata = JSONObject.toJSONString(treeMap);
String data1 = mapToQueryString(treeMap);
log.error(data1);
result = JSONObject.parseObject(RequestUtils.post1(sc.getAddress(), jsondata.toString(), data1, sc.getAddressKey(), "HMAC-SHA256"));
log.equals("MakeCert_push_result : " + result);
if (result.getString("code") != null && "SUCCESS".equals(result.getString("code").toString())) {
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
// return "redirect:/makecert";
return null;
}
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
// uiModel.addAttribute("error", "错误:" +
// result.getString("message"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
// uiModel.addAttribute("error", "错误:" + e);
return "错误【" + e + "】";
}
}
return "错误【" + result.getString("message") + "】";
}
use of com.itrus.portal.db.SignatureConfig in project portal by ixinportal.
the class SignatureConfigController method updateForm.
// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) throws Exception {
SignatureConfig signatureconfig = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", id);
uiModel.addAttribute("signatureconfig", signatureconfig);
ProjectExample projectex = new ProjectExample();
List projectexall = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectByExample", projectex);
uiModel.addAttribute("projects", projectexall);
return "signatureconfig/update";
}
use of com.itrus.portal.db.SignatureConfig in project portal by ixinportal.
the class SignatureConfigController method delete.
// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) throws Exception {
SignatureConfig signatureconfig = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", id);
String message = null;
if (signatureconfig == null) {
message = "未找到要删除签名服务配置";
} else {
try {
sqlSession.delete("com.itrus.portal.db.SignatureConfigMapper.deleteByPrimaryKey", id);
String oper = "删除签名服务";
String info = "签名服务名称: " + signatureconfig.getName();
LogUtil.adminlog(sqlSession, oper, info);
} catch (Exception e) {
message = "要删除签名服务配置【" + signatureconfig.getName() + "】存在关联,无法删除";
}
}
return getReferer(request, "redirect:/signatureconfig" + (message == null ? "" : "?message=1"), true);
}
use of com.itrus.portal.db.SignatureConfig in project portal by ixinportal.
the class SignatureConfigController method show.
// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) throws Exception {
SignatureConfig signatureconfig = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", id);
uiModel.addAttribute("signatureconfig", signatureconfig);
Map project = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", null, "id");
uiModel.addAttribute("project", project);
return "signatureconfig/show";
}
use of com.itrus.portal.db.SignatureConfig in project portal by ixinportal.
the class UserBillServiceTask method run.
/**
* 用户信息推送
*/
@Override
public void run() {
/*if(!isRun()) {
return;
}*/
List<Map> makecertexall = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectAutoMakeCert");
SignatureConfig sc = null;
JSONObject data = null;
JSONObject result = null;
Bill bill = null;
Map param;
Map map;
try {
// for (Map<String,String> dataMap:makecertexall) {
if (makecertexall.isEmpty()) {
return;
}
int index = (int) (Math.random() * makecertexall.size());
Map dataMap = makecertexall.get(index);
param = new HashMap();
param.put("id", dataMap.get("id"));
map = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByAllMakeCert", param);
// sc = scs.get(map.get("signature"));
if (sc == null) {
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", map.get("signature"));
}
if (null == sc || sc.getPush() != 1 || null == sc.getSntTime()) {
// 未配置信息、未开启、未配置时间间隔
log.debug("未配置信息、未开启、未配置时间间隔");
return;
}
// 上次时间为空,或者上次时间大于当前时间,则重新设置上次时间为当前时间的毫秒数
if (null == sc.getCreateTime() || sc.getCreateTime().getTime() > System.currentTimeMillis()) {
sc.setCreateTime(new Date());
sqlSession.update("com.itrus.portal.db.SignatureConfigMapper.updateByPrimaryKeySelective", sc);
}
// 判断是否在时间间隔内(当前时间小于 上次时间加上时间间隔)
if (System.currentTimeMillis() < sc.getCreateTime().getTime() + (Integer.parseInt(sc.getSntTime()) * 1000)) {
log.debug("不在时间内");
sc = null;
return;
}
log.debug("任务开始");
// BusinessLicense bl = businessService.getBusinessByBillId(Long.parseLong(String.valueOf(map.get("id"))), null);
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", map.get("unique_id"));
Agent agent = agentService.getAgentByBillId(Long.parseLong(String.valueOf(map.get("id"))), null);
Map<String, Object> treeMap = Maps.newTreeMap();
/*if(data == null) {
data = new JSONObject();
}*/
treeMap.put("app_id", sc.getAppId());
treeMap.put("order_number", map.get("bill_id"));
treeMap.put("user_name", map.get("enterprise_name"));
treeMap.put("user_email", userInfo.getEmail());
treeMap.put("user_phone", userInfo.getmPhone());
treeMap.put("user_type", "organization");
String cardType = null;
String sn = null;
BusinessLicense businessLicense = businessService.getBusinessByBillId(Long.parseLong(String.valueOf(map.get("id"))), null);
if (businessLicense != null && businessLicense.getBusinessType() == 1) {
sn = businessLicense.getLicenseNo();
cardType = "UniformSocialCreditCode";
}
if (businessLicense == null || businessLicense.getBusinessType() != 1) {
// 不是五证合一
OrgCode oc = orgCodeService.getOrgCodeByBillId(Long.parseLong(String.valueOf(map.get("id"))), null);
if (oc != null) {
sn = oc.getOrgCode();
cardType = "OrganizationCode";
}
}
/*if(businessLicense == null || businessLicense.getBusinessType()!=1) {//不是五证合一
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId(Long.parseLong(String.valueOf(map.get("id"))), null);
if(tc != null){
sn = tc.getCertNo();
}
}*/
/*if(agent.getCardType()==1){
cardType = "IdentityCard";
}else if(agent.getCardType()==2){
cardType = "NationalPassport";
}else{
cardType = "Other";
}*/
treeMap.put("identity_type", cardType);
// agent.getIdCode()
treeMap.put("identification_number", sn);
String jsondata = JSONObject.toJSONString(treeMap);
String data1 = mapToQueryString(treeMap);
// String content = "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", map.get("id"));
if (bill.getBillStatus() >= 8) {
return;
}
if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
return;
}
result = JSONObject.parseObject(RequestUtils.post1(sc.getAddress(), jsondata.toString(), data1, sc.getAddressKey(), "HMAC-SHA256"));
log.error("SignServiceTask_user_result :" + result);
/*if(result.getBoolean("isOK") && result.getIntValue("code") == 101) {//用户已存在 改成已撤销
bill.setMcstatus(1);
bill.setBillStatus(9);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
return;
}*/
if (result.getString("code") != null && "SUCCESS".equals(result.getString("code").toString())) {
// temp.put(String.valueOf(dataMap.get("id")), "");
LogUtil.syslog(sqlSession, "推送华侨城", Thread.currentThread().getName() + bill.getBillId() + "企业名称:" + map.get("enterprise_name"));
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
return;
}
LogUtil.syslog(sqlSession, "推送华侨城", bill.getBillId() + "企业名称:" + map.get("enterprise_name") + "错误:" + result.getString("message"));
// }
if (null != sc) {
// 设置本次时间
sc.setCreateTime(new Date());
sqlSession.update("com.itrus.portal.db.SignatureConfigMapper.updateByPrimaryKeySelective", sc);
}
log.debug("任务结束");
} catch (Exception e) {
// log.error("ERRORLOG用户推送 {}", e.getMessage());
StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 1];
LogUtil.syslog(sqlSession, "推送华侨城", "错误:" + stackTraceElement.getLineNumber() + e.getMessage());
}
}
Aggregations