use of com.itrus.portal.db.ProjectKeyInfoExample in project portal by ixinportal.
the class ProjectKeyInfoController method listjson.
// 列表所有信息
@RequestMapping(value = "/listjson", method = RequestMethod.GET)
@ResponseBody
public Map listjson() {
ProjectKeyInfoExample projectkeyinfoex = new ProjectKeyInfoExample();
List<ProjectKeyInfo> projectkeyinfoall = sqlSession.selectList("com.itrus.portal.db.ProjectKeyInfoMapper.selectByExample", projectkeyinfoex);
ProjectExample projectex = new ProjectExample();
Map projectmap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectex, "id");
return projectmap;
}
use of com.itrus.portal.db.ProjectKeyInfoExample 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.ProjectKeyInfoExample 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.ProjectKeyInfoExample 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