/** 获得系数列表; */ @SuppressWarnings("unchecked") public void showAll() { try { String barId = ServletActionContext.getRequest().getParameter("barId"); ExtLimit limit = (ExtLimit) EntityReflect.createObjectFromRequest( ServletActionContext.getRequest(), ExtLimit.class); BarProportion barProportion = (BarProportion) EntityReflect.createObjectFromRequest( ServletActionContext.getRequest(), BarProportion.class); barProportion.setExtLimit(limit); barProportion.setBarId(TypeConverterUtil.parseInt(barId)); int count = barProportionService.selectLimitCount(barProportion); List<Department> barProportionList = barProportionService.selectByLimit(barProportion); AjaxOut.responseJSonGrid( ServletActionContext.getResponse(), barProportionList, count, new SimpleDateFormat("yyyy-MM-dd")); } catch (Exception e) { logger.error("", e); } }
/** 新增系数; */ public void save() { JSONObject obj = new JSONObject(); obj.put("success", true); try { BarProportion barProportion = (BarProportion) EntityReflect.createObjectFromRequest( ServletActionContext.getRequest(), BarProportion.class); List<BarProportion> proportionList = barProportionService.selectProportionByDate(barProportion); UserInfoEty user = this.getLoginUser(); if (barProportion.getId() == null) { if (proportionList.isEmpty()) { barProportion.setStatus(START_STATUS); barProportion.setCreateTime(new Date()); barProportion.setCreator(user.getUsername()); barProportionService.insert(barProportion); obj.put("result", "success"); } else { obj.put("result", "use"); // use 表示要插入或更改的日期已经存在. } } else { if (proportionList.isEmpty()) { barProportionService.updateById(barProportion); obj.put("result", "success"); } else { obj.put("result", "use"); } } } catch (Exception e) { logger.error("", e); } AjaxOut.responseText(ServletActionContext.getResponse(), obj.toString()); }
public void search() { try { JSONObject retObj = new JSONObject(); retObj.put("action", true); StatisticsAAContextForm sf = (StatisticsAAContextForm) EntityReflect.createObjectFromRequest( ServletActionContext.getRequest(), StatisticsAAContextForm.class); List<StatisticsAAContext> dataList = statisticsAAContextDao.statistSearch(sf); retObj.put("size", dataList.size()); JSONArray columModleArray = new JSONArray(); JSONArray topGroup = new JSONArray(); JSONArray secondGroup = new JSONArray(); JSONObject jobj = new JSONObject(); jobj.put("header", ""); jobj.put("colspan", 2); jobj.put("align", "center"); topGroup.add(jobj); secondGroup.add(jobj); JSONArray dayColumArr = createDayColum(dataList, topGroup, secondGroup); columModleArray.addAll(GridColumModleInfo); columModleArray.addAll(dayColumArr); retObj.put("columns", columModleArray); retObj.put("topGroup", topGroup); retObj.put("secondGroup", secondGroup); retObj.put("data", getData(dataList)); retObj.put("fields", getFieldsNamesArray(dataList)); AjaxOut.responseText(ServletActionContext.getResponse(), retObj.toString()); } catch (Exception e) { e.printStackTrace(); } }