use of com.itrus.portal.db.ProjectKeyInfo in project portal by ixinportal.
the class UnlockKeyBillController method sendCodeJSSQYZ.
/**
* 获取:解锁申请验证码
* 需要先判断用户输入的手机号是否已经存在了,如果已经存在了,则只需要验证验证码即可然后跳转首页, 如果不存在,则需要输入密码
* retMap.put("hasUserInfo", 1);// 0表示没有用户,1表示有用户
* @param mPhone
* @param project
* @param certBase64
* @return
*/
@RequestMapping("/sendCode")
@ResponseBody
public Map<String, Object> sendCodeJSSQYZ(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam(value = "keySn", required = true) String keySn, HttpSession session) {
Map<String, Object> retMap = new HashMap<String, Object>();
// 0标识发送验证码失败,1标识成功
retMap.put("retCode", 0);
// 根据key序列号,获取证书
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
retMap.put("retMsg", "无法识别该序列号:" + keySn + ", 请联系系统管理进行配置");
return retMap;
}
Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
try {
// 判断该证书是否已经绑定有用户
UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
// 0表示没有用户,1表示有用户
retMap.put("has_userInfo", 0);
if (null != userInfo) {
retMap.put("has_userInfo", 1);
retMap.put("eMail", userInfo.getEmail());
}
// 发送验证码,JSSQYZ
dynamicCodeService.sendCodeJSSQYZ(mPhone, project.getId(), "JSSQYZ");
retMap.put("retCode", 1);
} catch (UserInfoServiceException e) {
retMap.put("retMsg", e.getMessage());
return retMap;
}
return retMap;
}
use of com.itrus.portal.db.ProjectKeyInfo in project portal by ixinportal.
the class ProjectKeyInfoController method update.
// 修改处理
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid ProjectKeyInfo projectkeyinfo, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("projectkeyinfo", projectkeyinfo);
return "projectkeyinfos/update";
}
ProjectKeyInfo projectkeyinfo0 = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.selectByPrimaryKey", projectkeyinfo.getId());
// 检查是否有权限操作
Long[] projects = getProjectLongIdsOfAdmin();
List<Long> list = Arrays.asList(projects);
if (list != null && !list.contains(projectkeyinfo.getProject())) {
return "status403";
}
// 加密adminPinValue信息
if (projectkeyinfo.getAdminPinValue() != null && !projectkeyinfo.getAdminPinValue().equals("")) {
String unlockCipher = "AES";
SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
byte[] encadminpin = cipher.doFinal(projectkeyinfo.getAdminPinValue().getBytes());
String sencadminpin = new String(Base64.encode(encadminpin));
projectkeyinfo.setAdminPinValue(sencadminpin);
}
// 加密adminPinValue信息
if (projectkeyinfo.getAdminPinValue2() != null && !projectkeyinfo.getAdminPinValue2().equals("")) {
String unlockCipher = "AES";
SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec, null);
byte[] encadminpin = cipher.doFinal(projectkeyinfo.getAdminPinValue2().getBytes());
String sencadminpin = new String(Base64.encode(encadminpin));
projectkeyinfo.setAdminPinValue2(sencadminpin);
}
projectkeyinfo.setCreateTime(projectkeyinfo0.getCreateTime());
sqlSession.update("com.itrus.portal.db.ProjectKeyInfoMapper.updateByPrimaryKey", projectkeyinfo);
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectkeyinfo.getProject());
String oper = "修改序列号";
String info = "项目名称: " + project.getName() + ", 序列号1: " + projectkeyinfo.getSn1() + ", 序列号2: " + projectkeyinfo.getSn2();
LogUtil.adminlog(sqlSession, oper, info);
cacheCustomer.initProjectKeyInfos();
return "redirect:/projectkeyinfos";
}
use of com.itrus.portal.db.ProjectKeyInfo in project portal by ixinportal.
the class ProjectKeyInfoController method list.
// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@Valid ProjectKeyInfo projectkeyinfo, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
uiModel.addAttribute("project", projectkeyinfo.getProject());
uiModel.addAttribute("sn1", projectkeyinfo.getSn1());
// page,size
if (page == null || page < 1)
page = 1;
if (size == null || size < 1)
size = 10;
ProjectKeyInfoExample projectkeyinfoex = new ProjectKeyInfoExample();
ProjectKeyInfoExample.Criteria criteria = projectkeyinfoex.or();
if (projectkeyinfo.getProject() != null && projectkeyinfo.getProject() > 0L)
criteria.andProjectEqualTo(projectkeyinfo.getProject());
if (projectkeyinfo.getSn1() != null && projectkeyinfo.getSn1().length() > 0)
criteria.andSn1Like("%" + projectkeyinfo.getSn1() + "%");
// 检查是否有权限操作
Long[] projects = getProjectLongIdsOfAdmin();
List<Long> list = Arrays.asList(projects);
if (list != null) {
criteria.andProjectIn(list);
}
// count,pages
Integer count = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.countByExample", projectkeyinfoex);
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
// page, size
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
// query data
Integer offset = size * (page - 1);
RowBounds rowBounds = new RowBounds(offset, size);
List<ProjectKeyInfo> projectkeyinfoall = sqlSession.selectList("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectkeyinfoex, rowBounds);
uiModel.addAttribute("projectkeyinfos", projectkeyinfoall);
// itemcount
uiModel.addAttribute("itemcount", projectkeyinfoall.size());
Map<Long, ProjectKeyInfo> projectkeyinfomap = sqlSession.selectMap("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectkeyinfoex, "id");
uiModel.addAttribute("projectkeyinfomap", projectkeyinfomap);
Map<Long, Project> projectmap = getProjectMapOfAdmin();
uiModel.addAttribute("projectmap", projectmap);
uiModel.addAttribute("projects", projectmap.values());
return "projectkeyinfos/list";
}
use of com.itrus.portal.db.ProjectKeyInfo in project portal by ixinportal.
the class ProjectKeyInfoController method updateSnProject.
// 修正序列号项目归属
@RequestMapping("/updateSnProject")
@ResponseBody
public Map<String, Object> updateSnProject(@RequestParam(value = "projectId", required = true) Long projectId) {
Map<String, Object> map = new HashMap<String, Object>();
// 10000代表处理成功
map.put("retCode", "10000");
// 检查是否有权限操作
Long[] projects = getProjectLongIdsOfAdmin();
List<Long> list = Arrays.asList(projects);
Long adminProject = getProjectOfAdmin();
if (list != null && !list.contains(projectId)) {
map.put("retCode", "10001");
map.put("retMsg", "您不能进行该操作");
return map;
}
if (projectId.toString().equals("0")) {
map.put("retCode", "10002");
map.put("retMsg", "请先选择一个项目进行修正");
return map;
}
// 1、查询对应项目下的 所有 序列号配置;
ProjectKeyInfoExample projectKeyInfoExample = new ProjectKeyInfoExample();
ProjectKeyInfoExample.Criteria projectKeyInfoCriteria = projectKeyInfoExample.or();
projectKeyInfoCriteria.andProjectEqualTo(projectId);
List<ProjectKeyInfo> projectKeyInfos = sqlSession.selectList("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectKeyInfoExample);
int updateNum = 0;
if (!projectKeyInfos.isEmpty()) {
// 2、基于所有序列号配置,组织查询语句,将该项目的软件更新记录全部查询处理
for (ProjectKeyInfo projectKeyInfo : projectKeyInfos) {
if (StringUtils.isBlank(projectKeyInfo.getSn1())) {
// sn1为空 不进行处理
continue;
}
VersionChange versionChange = new VersionChange();
// 设置正确的projet
versionChange.setProject(projectKeyInfo.getProject());
VersionChangeExample example = new VersionChangeExample();
VersionChangeExample.Criteria criteria = example.or();
// 非该项目的软件更新记录
criteria.andProjectNotEqualTo(projectKeyInfo.getProject());
if (!projectKeyInfo.getSn1().endsWith("$")) {
if (StringUtils.isNotBlank(projectKeyInfo.getSn2())) {
// 范围匹配 sn1和sn2都存在
criteria.andKeySnBetween(projectKeyInfo.getSn1(), projectKeyInfo.getSn2());
} else {
// 前缀匹配 只有sn1
criteria.andKeySnLike(projectKeyInfo.getSn1() + "%");
}
} else if (projectKeyInfo.getSn1().endsWith("$")) {
// 后缀匹配 sn1以$结尾
String sn1 = projectKeyInfo.getSn1().substring(0, projectKeyInfo.getSn1().length() - 1);
criteria.andKeySnLike("%" + sn1);
} else {
continue;
}
// 查询需要修改的总数
Integer num = sqlSession.selectOne("com.itrus.portal.db.VersionChangeMapper.countByExample", example);
updateNum += num;
// 3、逐条处理查询出来的记录,如果记录的项目不是当前项目,则进行修正
// 执行批量修改
Map<String, Object> retmap = new HashMap<String, Object>();
retmap.put("record", versionChange);
retmap.put("example", example);
sqlSession.update("com.itrus.portal.db.VersionChangeMapper.updateByExampleSelective", retmap);
}
}
VersionChangeExample vexample = new VersionChangeExample();
VersionChangeExample.Criteria vcriteria = vexample.or();
vcriteria.andProjectEqualTo(projectId);
Integer projectAllNum = sqlSession.selectOne("com.itrus.portal.db.VersionChangeMapper.countByExample", vexample);
// 4、修正完成后显示结果:a 修正记录数 b 项目当前 软件更新记录 数
// 修改的总记录数
map.put("updateNum", updateNum);
// 该项目软件更新总记录数
map.put("projectAllNum", projectAllNum);
return map;
}
use of com.itrus.portal.db.ProjectKeyInfo in project portal by ixinportal.
the class ProjectKeyInfoController method acsn1.
@RequestMapping(value = "/acsn1", method = RequestMethod.GET)
@ResponseBody
public List acsn1(@RequestParam(value = "term", required = false) String term) {
String term1 = "%" + term + "%";
ProjectKeyInfoExample projectkeyinfoex = new ProjectKeyInfoExample();
projectkeyinfoex.or().andSn1Like(term1);
projectkeyinfoex.setOrderByClause("sn1");
List<ProjectKeyInfo> projectkeyinfos = sqlSession.selectList("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectkeyinfoex);
List<String> sn1s = new ArrayList<String>();
for (ProjectKeyInfo projectkeyinfo : projectkeyinfos) sn1s.add(projectkeyinfo.getSn1());
return sn1s;
}
Aggregations