public void getAddAwardList(){ model.setFisrtRow((model.getPage() - 1) * model.getRows()); model.setLastRow(model.getRows()); try { BaseDao dao=getDao(); List<YouthModel> list = dao.selectForList("youth.getAddAwardList", model); HashMap<String ,Object> hm = new HashMap<String ,Object>(); hm.put("total", dao.selectByCount("youth.getListCount", model)); hm.put("rows", list); hm.put("success", true); this.doResponseWithJson(hm); } catch (Exception e) { e.printStackTrace(); this.setData("操作失败"); this.setSuccess(false); this.send(); } } /** * * @param sqlString 传进来的是以逗号分隔的字符串如:1,2,3 * @param modelString 传进来是model中的单个字符串,如:4 * @return */ private String removeSameValue(String sqlString, String modelString) { if (StringUtil.isEmpty(sqlString)) { return modelString; } String[] t = sqlString.split(","); TreeSet<String> tSet = new TreeSet<String>(); for (int i = 0; i < t.length; i++) { tSet.add(t[i]); } tSet.add(modelString); String s = ""; for (Iterator<String> it = tSet.iterator(); it.hasNext();) { s += it.next().toString() + ","; } s = s.substring(0, s.length() - 1); return s; } public void addAwardConfig(){ try { BaseDao dao=getDao(); //从界面获得所有需要的青年id String id = model.getId(); //用in 查找出()所有id的信息 select * from ybc_youth where id in ($VALUE$) List<YouthModel> retModel = dao.selectForList("youth.getAddAward", id); //实例青年 YouthModel tModel = new YouthModel(); //创建青年list List<YouthModel> sqlModelList = new ArrayList<YouthModel>(); //遍历青年,得到去重后的奖项id for (int i=0; i<retModel.size(); i++) { //将数据库信息赋给实例 tModel = retModel.get(i); //数据库的奖项id和界面的到的奖项id去重 tModel.setYouthAward(this.removeSameValue(tModel.getYouthAward(), model.getYouthAward())); //将得到的奖项id放入list sqlModelList.add(tModel); } //批量更新 dao.updateSql("youth.upt_youth", sqlModelList); this.setData("青年奖增加项配置成功"); this.setSuccess(true); this.send(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); this.setData("青年奖项增加配置失败,错误信息:"+e.getMessage()); this.setSuccess(false); this.send(); } } //减掉重复项 private String removeList(String sqlString,String modelString){ String[] sqlStr = sqlString.split(","); String[] modelStr = modelString.split(","); List<String> listA= java.util.Arrays.asList(sqlStr); List<String> listB= java.util.Arrays.asList(modelStr); Set setA = new TreeSet(listA); setA.removeAll(listB); System.out.println(setA); String s = ""; for (Iterator<String> it = setA.iterator(); it.hasNext();) { s += it.next().toString() + ","; } s = s.substring(0, s.length() - 1); return s; } public void removeAwardConfig(){ try{ BaseDao dao=getDao(); String id =model.getId(); List<YouthModel> retModel = dao.selectForList("youth.getAddAward", id); System.out.println(retModel.size()); YouthModel tModel = new YouthModel(); List<YouthModel> sqlModelList = new ArrayList<YouthModel>(); for (int i=0; i<retModel.size(); i++) { //将数据库信息赋给实例 tModel = retModel.get(i); //数据库的奖项id和界面的到的奖项id去重 tModel.setYouthAward(this.removeList(tModel.getYouthAward(), model.getYouthAward())); //将得到的奖项id放入list sqlModelList.add(tModel); } dao.updateSql("youth.upt_youth", sqlModelList); this.setData("青年奖项删除配置成功"); this.setSuccess(true); this.send(); }catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); this.setData("青年奖项配置删除失败,错误信息:"+e.getMessage()); this.setSuccess(false); this.send(); } }
相关推荐
3.2.4NC65单据字段参照时多选开发分享.docx
SQL查询包含某个字段的所有表名 SQL查询包含某个字段的所有表名 在查询分析器中选中目标数据库,执行以下语句。
oracle某个字段多行记录转化为一行,oracle某个字段多行记录转化为一行。
完美解决distinct中使用多个字段的方法,完美解决distinct中使用多个字段的方法完美解决distinct中使用多个字段的方法完美解决distinct中使用多个字段的方法完美解决distinct中使用多个字段的方法
Delphi,判断记录是否存在,取某个特定字段值,取多个字段值 自己工作总结,逐步增加
表T2 删掉 C2字段 alter table T2 drop column C2; 表T1 增加 g字段,类型为number(10) alter table t1 add g number(10);
1、编写视图时遇到多选的字典编码需要转换多选的名称时,比如将‘1,2,3...’ 转换成‘是,否,未知’ 2、通过函数实现,传入值1)字段名,2)对应关系,返回翻译后的中文多选字符串。
一个list里面有多个对象,对象有几个字段,要求在对象里面不要有重复的数据的实现。
C# 修改list所有对象中的某字段 博客地址:https://blog.csdn.net/qq_36051316/article/details/83475372 的案例
1.表中有id和name 两个字段,查询出name重复的所有数据 select * from xi a where (a.username) in (select username from xi group by username having count(*) > 1) 2、查询出所有数据进行分组之后,和重复数据...
JS实现:数组中的json对象,按某个字段来进行字母排序
Visual C++源代码 118 如何显示数据表多个字段合并信息Visual C++源代码 118 如何显示数据表多个字段合并信息Visual C++源代码 118 如何显示数据表多个字段合并信息Visual C++源代码 118 如何显示数据表多个字段合并...
oracle 用SQL通过使用游标实现批量更新表中某个字段的值表名和字段名需要修改,字符串的截取的方法需要根据实际情况修改
查找数据某个字段在那张表.txt 查找数据某个字段在那张表.txt
按照指定字段查询出出现重复的数据 SELECT m.* FROM dbo.Sheet1$ m,( SELECT ZCMC,ZCFL,XH FROM dbo.Sheet1$ GROUP BY ZCMC,ZCFL,XH HAVING COUNT(1)>1 ) AS m1 WHERE m.ZCMC=m1.ZCMC AND m.ZCFL=m1.ZCFL ...
对象更改比较工具类,用于比较字段变化值,抛砖引玉,欢迎指正。
在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所有值。其原因是...
Oracle使用 alter 增加 修改 删除 字段, 可以同时添加多个字段 创建 修改 添加表的约束
shell脚本修改json中某个字段的值 - 思路:通过awk来找到旧数据,然后用sed来替换旧数据