/** * @描述 如果attr,如description的长度超过30(随机,由Random决定),则后面用...代替。 * * @param page * @param paras */ public void format(Page<Record> page, String... paras) { for (Record record : page.getList()) { for (String attr : paras) { record.set( attr, StringUtils.abbreviate(record.getStr(attr), (new Random().nextInt(2) + 35))); } } }
public static final List<OrderInfo> list(OrderInfo order, int offset, int limit) { StringBuffer where = new StringBuffer("from orderinfo where deleted=0"); List<Object> params = new ArrayList<Object>(); if (order.getStr("createUser") != null && !"".equals(order.getStr("createUser").trim())) { where.append(" and createUser=?"); params.add(order.getStr("createUser").trim()); } if (order.getStr("shopCode") != null && !"".equals(order.getStr("shopCode").trim())) { where.append(" and shopCode=?"); params.add(order.getStr("shopCode").trim()); } where.append(" order by createTime desc"); Page<OrderInfo> orders = null; if (params.size() == 0) { orders = OrderInfo.dao.paginate(offset, limit, "select *", where.toString()); } else { orders = OrderInfo.dao.paginate(offset, limit, "select *", where.toString(), params.toArray()); } return orders.getList(); }
protected void setJsonData(Page page) { if (page != null) { json.setData("list", page.getList()); json.setData("total", page.getTotalRow()); } else json.code = serviceError; }
public void add() { Ckjhcheck ckjhcheck = new Ckjhcheck(); Jbsupplier jbsupplier = new Jbsupplier(); Jbstore jbstore = new Jbstore(); // 采购入库单号 String ordCdNw = null; // 不是采购订单导入 Long id = getParaToLong(0, 0L); List<Object> param = new ArrayList<Object>(); StringBuffer whee = new StringBuffer(); whee.append(" and a.OrderCode = ?"); if (id != 0) { // 修改 ckjhcheck = Ckjhcheck.dao.findById(id); jbsupplier = Jbsupplier.dao.findFirst( "select * from jbsupplier where supplierCode = ?", ckjhcheck.getStr("SupplierCode")); jbstore = Jbstore.dao.findFirst( "select * from jbstore where StoreCode = ?", ckjhcheck.getStr("StoreCode")); param.add(ckjhcheck.get("orderCode")); } else { synchronized (lock) { ordCdNw = BsUtil.getMaxOrdNo("OrderCode", "PK", "ckjhcheck"); } ckjhcheck.set("OrderCode", ordCdNw); param.add(ordCdNw); // 赋值当前时间 Date dt = new Date(); SimpleDateFormat ckDate = new SimpleDateFormat("yyyy-MM-dd"); ckjhcheck.set("orderdate", ckDate.format(dt)); // 赋值制单人 Record m = getCurrentUser(); ckjhcheck.set("operator", m.getStr("usr_name")); } String sql = "select a.id,b.GoodsCode 商品编号,b.GoodsName 商品名称,b.Model 商品规格,b.BaseUnit 基本单位,b.BRefPrice 原价,a.Discount 折扣, a.Quantity 数量,"; sql += " a.TaxRate 税率,a.TaxAmount 税额,a.Amount 金额"; String sqlSelect = " from ckjhcheckdetail a"; sqlSelect += " left join jbgoods b on a.GoodsCode = b.GoodsCode where 1=1 "; Page<Record> redLst = Db.paginate( getParaToInt("pageNum", 1), getParaToInt("numPerPage", 20), sql, sqlSelect + whee.toString(), param.toArray()); int size = redLst.getList().size(); // 不足10条,补足10条显示 if (size < 10) { for (int i = 0; i < 10 - size; i++) { redLst.getList().add(new Record()); } } setAttr("page", redLst); setAttr( "collist", new String[] {"商品编号", "商品名称", "商品规格", "单位", "原价", "折扣%", "数量", "订单金额", "税率%", "税额", "金额"}); setAttr("ckjhcheck", ckjhcheck); setAttr("store", jbstore); setAttr("supplier", jbsupplier); setAttr(InOutTypeNoSelectTarget.targetName, new InOutTypeNoSelectTarget()); setAttr(PartmentSelectTarget.targetName, new PartmentSelectTarget()); setAttr(EmployeeSelectTarget.targetName, new EmployeeSelectTarget()); render("add.html"); }
// 采购入库 public void cgInStore() { Ckjhcheck ckjhcheck = new Ckjhcheck(); Jbsupplier jbsupplier = new Jbsupplier(); Jbstore jbstore = new Jbstore(); List<Object> param = new ArrayList<Object>(); // 采购入库单号 String ordCdNw = null; synchronized (lock) { ordCdNw = BsUtil.getMaxOrdNo("OrderCode", "PK", "ckjhcheck"); } ckjhcheck.set("OrderCode", ordCdNw); String obj = getPara(); Cgorder cgOrd = new Cgorder(); cgOrd = Cgorder.dao.findFirst("select * from cgorder where orderCode = ?", new Object[] {obj}); jbsupplier = Jbsupplier.dao.findFirst( "select * from jbsupplier where supplierCode = ?", cgOrd.getStr("supplierCode")); jbstore = Jbstore.dao.findFirst( "select * from jbstore where StoreCode = ?", cgOrd.getStr("StoreCode")); // ckjhcheck.set("OrderCode", ordCdNw); ckjhcheck.set("OrderDate", cgOrd.getDate("DeliveryDate")); ckjhcheck.set("supplierCode", cgOrd.getStr("supplierCode")); ckjhcheck.set("StoreCode", cgOrd.getStr("StoreCode")); // ckjhcheck.set("InOutTypeNo", "52"); ckjhcheck.set("BillOrderNo", cgOrd.getStr("orderCode")); ckjhcheck.set("deptCode", cgOrd.getStr("deptcode")); ckjhcheck.set("Empcode", cgOrd.getStr("Empcode")); ckjhcheck.set("Operator", cgOrd.getStr("Operator")); ckjhcheck.set("CheckFlag", 0); ckjhcheck.set("SettleTypeFlag", 0); StringBuffer whee = new StringBuffer(); whee.append(" and a.orderCode = ?"); param.add(obj); String sql = "select a.id,b.GoodsCode 商品编号,b.GoodsName 商品名称,b.Model 商品规格,b.BaseUnit 基本单位,b.BRefPrice 原价,a.Discount 折扣, a.Quantity 数量,"; sql += " a.TaxRate 税率,a.TaxAmount 税额,a.Amount 税后金额"; String sqlSelect = " from cgorderdetail a"; sqlSelect += " left join jbgoods b on a.GoodsCode = b.GoodsCode where 1=1 "; Page<Record> redLst = Db.paginate( getParaToInt("pageNum", 1), getParaToInt("numPerPage", 20), sql, sqlSelect + whee.toString(), param.toArray()); int size = redLst.getList().size(); // 不足10条,补足10条显示 if (size < 10) { for (int i = 0; i < 10 - size; i++) { redLst.getList().add(new Record()); } } setAttr("page", redLst); setAttr( "collist", new String[] { "商品编号", "商品名称", "商品规格", "基本单位", "原价", "折扣%", "单价", "数量", "税率%", "折后金额", "税后金额" }); setAttr("ckjhcheck", ckjhcheck); setAttr("store", jbstore); setAttr("supplier", jbsupplier); setAttr(InOutTypeNoSelectTarget.targetName, new InOutTypeNoSelectTarget()); setAttr(PartmentSelectTarget.targetName, new PartmentSelectTarget()); setAttr(EmployeeSelectTarget.targetName, new EmployeeSelectTarget()); render("add.html"); }
@CacheName(AppConstants.DEFAULT_CACHENAME) public void user() { User user = SubjectUtils.me().getUser(); keepPara("user_search"); // 查询当前用户的角色 UserRole userRole = UserRole.dao.findFirstBy("`userRole`.user_id=" + user.get("id")); // 当前用户的子集角色 List<Role> roles = Role.dao.findChildrenById("`role`.deleted_at is null", userRole.get("role_id")); String roleIds = ""; if (roles != null) { int size = roles.size(); int i = 0; for (Role role : roles) { roleIds += role.get("id"); if (i < size - 1) { roleIds += ","; } i++; } } // 只能查询当前用户以下的角色 String where = " `user`.id <> " + user.get("id") + " AND `userRole`.role_id in (" + roleIds + ")"; String user_search = getPara("user_search"); if (!ValidateUtils.me().isNullOrEmpty(user_search)) { where += " AND (INSTR(`user`.username,'" + user_search + "')>0 OR INSTR(`user`.full_name,'" + user_search + "')>0 " + "OR INSTR(`user`.mobile,'" + user_search + "')>0 OR INSTR(`province`.name,'" + user_search + "')>0 " + "OR INSTR(`city`.name,'" + user_search + "')>0 OR INSTR(`county`.name,'" + user_search + "')>0 " + "OR INSTR(`userInfo`.street,'" + user_search + "')>0 OR INSTR(`userInfo`.zip_code,'" + user_search + "')>0 " + "OR INSTR(`user`.created_at,'" + user_search + "')>0 OR INSTR(`user`.email,'" + user_search + "')>0) "; } // String start_at = getPara("start_at"); // if (ValidateUtils.me().isDateTime(start_at)) { // where += " AND `user`.created_at >= '" + start_at + "'"; // } // // String end_at = getPara("end_time"); // if (ValidateUtils.me().isDateTime(end_at)) { // where += " AND `user`.created_at <= '" + end_at + "'"; // } // // Boolean deleted = getParaToBoolean("deleted"); // if (!ValidateUtils.me().isNullOrEmpty(deleted) && deleted) { // where += " AND `user`.deleted_at is not null"; // } else { // where += " AND `user`.deleted_at is null"; // } Page<User> users = User.dao.paginateInfoBy(getParaToInt(0, 1), getParaToInt("pageSize", 15), where); Map userGroup = SortUtils.me().sort(users.getList(), "last_name"); setAttr("roles", roles); setAttr("users", users); setAttr("userGroup", userGroup); setAttr("userStates", State.dao.findBy("`state`.type='user.state'")); dynaRender("/view/admin/user.ftl"); }