/** 对一个入库单实体添加基础数据 */ private void fillEntity(Context context, Instorage entity, String type) { Login login = context.find(Login.class); Employee emp = context.find(Employee.class, login.getEmployeeId()); entity.setRECID(context.newRECID()); entity.setSheetType(type); entity.setCreateDate(new Date().getTime()); if (CheckIsNull.isNotEmpty(entity.getPartnerId())) { Partner partner = context.find(Partner.class, entity.getPartnerId()); if (null != partner) { entity.setPartnerName(partner.getName()); entity.setPartnerShortName(partner.getShortName()); entity.setPartnerCode(partner.getCode()); } } Store store = context.find(Store.class, entity.getStoreId()); if (null != store) { entity.setStoreName(store.getName()); entity.setStoreNamePY(PinyinHelper.getLetter(store.getName())); } if (CheckingInType.Irregular.getCode().equals(type) || CheckingInType.Kit.getCode().equals(type)) { entity.setCreatorId(login.getEmployeeId()); entity.setCreator(emp.getName()); } }
/** * @param context * @param key * @param list */ private static void inventoryProvider( Context context, ReportCommonKey key, List<ReportResult> list) { List<InventoryInfo> glist = context.getList(InventoryInfo.class, new GetExceptionInventoryKey()); Set<GUID> set = new HashSet<GUID>(); for (InventoryInfo gi : glist) { set.add(gi.getGoodsItemId()); } for (GUID id : set) { GoodsInventorySumKey sumkey = new GoodsInventorySumKey(); sumkey.setGoodsItemId(id); GoodsInventorySum gi = context.find(GoodsInventorySum.class, sumkey); ReportResult rr = new ReportResult(); GoodsItem item = context.find(GoodsItem.class, id); rr.setTargetValue(GoodsItemEnum.GoodsName, item.getGoodsName()); rr.setTargetValue(GoodsItemEnum.GoodsAttr, item.getPropertiesWithoutUnit()); rr.setTargetValue(GoodsItemEnum.GoodsUnit, item.getGoodsUnit()); double inventoryAmount = gi.getTotalAmount(); double deliveryingCount = gi.getTotalToDeliverCount(); double iventoryCount = gi.getTotalCount(); double iventoryDifference = iventoryCount - deliveryingCount; rr.setTargetValue(GoodsItemEnum.InventoryCount, iventoryCount); rr.setTargetValue(GoodsItemEnum.InventoryDifference, iventoryDifference); rr.setTargetValue(GoodsItemEnum.InventoryAmount, inventoryAmount); rr.setOrderObj(GoodsItemEnum.InventoryCount); list.add(rr); } ComparatorUtils.sort(list, "orderObj", false); }
/* * 获取对象列表 */ public Object[] getElements(Context context, STableStatus tablestatus) { GetGoodsSplitBillListKey key = new GetGoodsSplitBillListKey(tablestatus.getBeginIndex(), tablestatus.getPageSize(), false); if (CheckIsNull.isNotEmpty(tablestatus.getSortColumn())) { key.setSortField(getSortField(tablestatus.getSortColumn())); key.setSortType(getSortType(tablestatus.getSortDirection())); } key.setStatus(new GoodsSplitStatus[] {GoodsSplitStatus.Approvaling}); key.setSearchText(searchText.getText()); key.setBeginTime(context.find(QueryTerm.class, queryTermList.getText()).getStartTime()); key.setEndTime(context.find(QueryTerm.class, queryTermList.getText()).getEndTime()); ListEntity<GoodsSplitItem> entity = context.find(ListEntity.class, key); List<GoodsSplitItem> itemList = entity.getItemList(); // if (CheckIsNull.isEmpty(itemList)) { // countLabel.setText("0"); // return null; // } GoodsSplitItem[] items = new GoodsSplitItem[itemList.size()]; for (int i = 0; i < itemList.size(); i++) { items[i] = itemList.get(i); itemMap.put(items[i].getRECID().toString(), items[i]); } int size = items.length; if (tablestatus.getPageNo() != STableStatus.FIRSTPAGE) { String preSize = countLabel.getText(); if (StringHelper.isNotEmpty(preSize)) { size += Integer.parseInt(preSize); } } countLabel.setText(String.valueOf(size)); // countLabel.setText("" + items.length); countLabel.getParent().getParent().layout(); return items; }
@Override protected void handle(Context context, CheckinSheetTask task) throws Throwable { InsertSqlBuilder ib = new InsertSqlBuilder(context); ib.setTable(ERPTableNames.Inventory.CheckinSheet.getTableName()); ib.addColumn("RECID", ib.guid, task.getEntity().getRECID()); ib.addColumn("sheetNo", ib.STRING, task.getEntity().getSheetNo()); ib.addColumn("sheetType", ib.STRING, task.getEntity().getSheetType()); ib.addColumn("partnerId", ib.guid, task.getEntity().getPartnerId()); ib.addColumn("partnerName", ib.STRING, task.getEntity().getPartnerName()); ib.addColumn("namePY", ib.STRING, task.getEntity().getNamePY()); ib.addColumn("partnerShortName", ib.STRING, task.getEntity().getPartnerShortName()); ib.addColumn("relaBillsId", ib.guid, task.getEntity().getRelaBillsId()); ib.addColumn("relaBillsNo", ib.STRING, task.getEntity().getRelaBillsNo()); ib.addColumn("storeId", ib.guid, task.getEntity().getStoreId()); ib.addColumn("storeName", ib.STRING, task.getEntity().getStoreName()); ib.addColumn("storeNamePY", ib.STRING, task.getEntity().getStoreNamePY()); ib.addColumn("goodsFrom", ib.STRING, task.getEntity().getGoodsFrom()); ib.addColumn("remark", ib.STRING, task.getEntity().getRemark()); ib.addColumn("buyPerson", ib.STRING, task.getEntity().getBuyPerson()); ib.addColumn("buyDate", ib.DATE, task.getEntity().getBuyDate()); ib.addColumn("amount", ib.DOUBLE, task.getEntity().getAmount()); ib.addColumn("askedAmount", ib.DOUBLE, task.getEntity().getAskedAmount()); ib.addColumn("paidAmount", ib.DOUBLE, task.getEntity().getPaidAmount()); ib.addColumn("disAmount", ib.DOUBLE, task.getEntity().getDisAmount()); ib.addColumn("checkinDate", ib.DATE, task.getEntity().getCheckinDate()); ib.addColumn("checkinPerson", ib.guid, task.getEntity().getCheckinPerson()); ib.addColumn("checkinPersonName", ib.STRING, task.getEntity().getCheckinPersonName()); ib.addColumn("deptId", ib.guid, task.getEntity().getDeptId()); ib.addColumn("creatorId", ib.guid, task.getEntity().getCreatorId()); ib.addColumn("creator", ib.STRING, task.getEntity().getCreator()); if (null != task.getEntity().getDeptId()) { Department depart = context.find(Department.class, task.getEntity().getDeptId()); if (null != depart) { ib.addColumn("deptName", ib.STRING, depart.getName()); } else { throw new Exception("获取用户部门信息出错!"); } } if (null != task.getEntity().getPartnerId()) { Partner p = context.find(Partner.class, task.getEntity().getPartnerId()); ib.addColumn("partnerCode", ib.STRING, p.getCode()); } if (ib.execute() == 1) { doSaveDetails(context, task); task.setSuccess(true); } if (task.getEntity().getSheetType().equals(CheckingInType.Joint.getCode()) || task.getEntity().getSheetType().equals(CheckingInType.RealGoods.getCode()) || task.getEntity().getSheetType().equals(CheckingInType.Kit.getCode())) { return; } writeJointRecord(context, task); }
@Override protected void occur(Context context, CheckInEvent event) throws Throwable { if (CheckIsNull.isEmpty(event.getRelaOrderId()) || CheckIsNull.isEmpty(event.getType())) { throw new Throwable("相关单据编号和入库类型不能为空"); } OrderInfo info = null; BillsEnum billsEnum = null; switch (event.getType()) { // Purchase("01", "采购入库"), // // Irregular("02", "零星采购"), // // Return("03", "销售退货"), // // RetailReturn("04","零售退货"), // Other("05", "其他入库"); case Purchase: info = context.find(PurchaseOrderInfo.class, event.getRelaOrderId()); billsEnum = BillsEnum.PURCHASE; break; case Return: info = context.find(SaleCancel.class, event.getRelaOrderId()); billsEnum = BillsEnum.SALE_CANCEL; break; // case DirectSupply: // info = context.find(PurchaseOrderInfo.class, event.getRelaOrderId()); // billsEnum = BillsEnum.PURCHASE; // break; default: return; } if (CheckIsNull.isEmpty(info)) { throw new Throwable("相关单据编号在订单中不存在"); } StatusEnum newstatus = InventoryDataUtil.getOrderStatusByIn(context, event.getRelaOrderId()); if (!newstatus.isThis(info.getStatus())) { OrderUtil.modifystatus( billsEnum, context, info.getRECID(), newstatus, StatusEnum.getstatus(info.getStatus())); // 全部出库完成出库 if (newstatus == StatusEnum.Store_All) { if (BillsEnum.PURCHASE == billsEnum) { context.dispatch( new PurchaseOrderChangedEvent(info.getRECID(), ChangedType.StoreFinish)); } else { context.dispatch(new SalesReturnChangedEvent(info.getRECID(), ChangedType.StoreFinish)); } } } }
@Override protected void occur(Context context, CheckOutEvent event) throws Throwable { if (CheckIsNull.isEmpty(event.getRelaOrderId()) || CheckIsNull.isEmpty(event.getType())) { throw new Throwable("相关单据编号和出库类型不能为空"); } OrderInfo info = null; BillsEnum billsEnum = null; switch (event.getType()) { // Sales("01", "销售出库"), // // Return("02", "采购退货"), // // Retail("03", "零售出库"), // // Kit("04", "其他出库"); case Sales: info = context.find(SaleOrderInfo.class, event.getRelaOrderId()); billsEnum = BillsEnum.SALE; break; case Return: info = context.find(PurchaseCancel.class, event.getRelaOrderId()); billsEnum = BillsEnum.PURCHASE_CANCEL; break; default: return; } if (CheckIsNull.isEmpty(info)) { throw new Throwable("相关单据编号在订单中不存在"); } StatusEnum newstatus = InventoryDataUtil.getOrderStatusByOut(context, event.getRelaOrderId()); if (!newstatus.isThis(info.getStatus())) { OrderUtil.modifystatus( billsEnum, context, info.getRECID(), newstatus, StatusEnum.getstatus(info.getStatus())); // 全部出库完成出库 if (newstatus == StatusEnum.Store_All) { if (BillsEnum.SALE == billsEnum) { context.dispatch(new SalesOrderChangedEvent(info.getRECID(), ChangedType.StoreFinish)); } else { context.dispatch( new PurchaseReturnChangedEvent(info.getRECID(), ChangedType.StoreFinish)); } } } }
@Override protected void occur(Context context, GoodsStatusChangeEvent event) throws Throwable { this.event = event; GoodsItem gi = context.find(GoodsItem.class, event.goodsItemId); if (GoodsStatus.STOP_SALE == gi.getStatus()) { new PromotionStopSql(context).executeUpdate(); new PromotionDelSql(context).executeUpdate(); } else if (GoodsStatus.ON_SALE == gi.getStatus()) { new PromotionIssueSql(context).executeUpdate(); new PromotionOutOfDateSql(context).executeUpdate(); } }
@SuppressWarnings("deprecation") @Override protected void occur(Context context, DealingAmountChanageEvent event) throws Throwable { DealingItem di = context.find(DealingItem.class, event.getDealingItemId()); double amount = di.getRealAmount(); DealingsType type = DealingsType.getEnum(di.getBillsType()); if (amount == 0 && (DealingsType.CUS_TZYS == type || DealingsType.CUS_INIT == type)) { // || DealingsType.CUS_THRK == type)){ amount = -di.getPlanAmount(); } if (0 != amount) { OrderUtil.subAlreadyUseCredit(context, di.getPartnerId(), amount); } }
@SuppressWarnings("unchecked") public Object[] getElements(Context context, STableStatus tablestatus) { // GetCustomerListKey key = new // GetCustomerListKey(PartnerStatus.Potential); if (!StringUtils.isEmpty(tablestatus.getSortColumn())) { key.setSortField(SortField.valueOf(tablestatus.getSortColumn())); if (tablestatus.getSortDirection() == SSortDirection.ASC) { key.setSortType(SortType.Asc); } else { key.setSortType(SortType.Desc); } } ListEntity<CustomerItem> listEntity = context.find(ListEntity.class, key); if (listEntity != null) { countLabel.setText(String.valueOf(listEntity.getItemList().size())); return listEntity.getItemList().toArray(); } countLabel.setText("0"); return null; }
@Override protected void handle(Context context, ChangeCheckinRealAmount task) throws Throwable { UpdateSqlBuilder ub = new UpdateSqlBuilder(context); double amount = task.getAmount(); if (amount < 0) { amount = DoubleUtil.sub(0, amount); } ub.setTable(ERPTableNames.Inventory.CheckinSheet.getTableName()); ub.addExpression("value", ub.DOUBLE, amount, "paidAmount = t.paidAmount+@value"); ub.addCondition("id", ub.guid, task.getId(), "t.RECID=@id"); ub.addCondition("xxx", ub.STRING, "a", "t.amount-t.paidAmount>=@value"); int count = ub.execute(); if (0 == count) { throw new Exception("付款金额超出入库金额,请核对!"); } CheckInBaseInfo info = context.find(CheckInBaseInfo.class, task.getId()); if (info.getAmount() == info.getPaidAmount()) { context.dispatch( new CheckInSheetAmountBalanceCompleteEvent(info.getRelaBillsId(), info.getSheetType())); } }
@SuppressWarnings("unchecked") @Override public Object[] getElements(Context context, STableStatus tablestatus) { GetOnlineReturnListKey key = new GetOnlineReturnListKey( tablestatus.getBeginIndex(), tablestatus.getPageSize(), true, OnlineReturnTab.Approving); key.setSearchText(search.getText()); OnlineReturnListEntity listEntity = context.find(OnlineReturnListEntity.class, key); if (null == listEntity) return null; // int size = listEntity.getItemList().size(); // if (tablestatus.getPageNo() != STableStatus.FIRSTPAGE) { // String preSize = countLabel.getText(); // if (StringHelper.isNotEmpty(preSize)) { // size += Integer.parseInt(preSize); // } // } countLabel.setText(listEntity.getTotalCount() + ""); return listEntity.getItemList().toArray(); }
/** * @param context * @param key * @param list */ @SuppressWarnings("unchecked") private static void purchaseProvider( Context context, ReportCommonKey key, List<ReportResult> list) { Tenant tenant = context.find(Tenant.class); QuerySqlBuilder qb = new QuerySqlBuilder(context); qb.addTable("SA_REPORT_GOODS_BUY_DATE", "t2"); qb.addArgs("comNo", qb.guid, tenant.getId()); qb.addEquals("t2.tenantId", "@comNo"); List<Enum> targets = key.getTargets(); qb.addColumn("t2.goodsItemId", "goodsItemId"); if (targets.indexOf(GoodsItemEnum.PurchaseAmount) >= 0) { qb.addColumn("sum(t2.ordAmount)", "ordAmounts"); } if (targets.indexOf(GoodsItemEnum.PurchaseCount) >= 0) { qb.addColumn("sum(t2.ordCount)", "ordCount2"); } if (targets.indexOf(GoodsItemEnum.PurchaseReturnAmount) >= 0) { qb.addColumn("sum(t2.rtnAmount)", "rtnAmounts"); } if (targets.indexOf(GoodsItemEnum.InStoreCount) >= 0) { qb.addColumn("sum(t2.outstoAmount)", "outstoAmount2"); } if (targets.indexOf(GoodsItemEnum.PayAmount) >= 0) { qb.addColumn("sum(t2.receiptAmount)", "receiptAmount2"); } Map<GUID, ReportResult> ymap = null; if (targets.indexOf(GoodsItemEnum.PurchaseAmount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.PurchaseCount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.PurchaseReturnAmount_OfYear) >= 0) { ymap = getYearDoubleMapPurchase(context, key, tenant); } for (Condition con : key.getConditions()) { if ("month".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("month", qb.INT, con.getValue()); qb.addEquals("t2.monthNo", "@month"); } else if ("season".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("season", qb.INT, con.getValue()); qb.addEquals("t2.quarter", "@season"); } else { } } qb.addGroupBy("t2.goodsItemId"); if (CheckIsNull.isNotEmpty(key.getOrderTarget()) && GoodsItemEnum.getTarget(key.getOrderTarget()) == GoodsItemEnum.PurchaseAmount) { String column = "ordAmounts"; if (key.isOrderDesc()) { column = column + " desc"; } qb.addOrderBy(column); } else if (CheckIsNull.isNotEmpty(key.getOrderTarget()) && GoodsItemEnum.getTarget(key.getOrderTarget()) == GoodsItemEnum.PurchaseReturnAmount) { String column = "rtnAmounts"; if (key.isOrderDesc()) { column = column + " desc"; } qb.addOrderBy(column); } RecordSet rs = null; if (key.getMaxCount() == 0) { rs = qb.getRecord(); } else { rs = qb.getRecordLimit(0, key.getMaxCount()); } while (rs.next()) { ReportResult rr = new ReportResult(); int index = 0; GUID goodsItemId = rs.getFields().get(index++).getGUID(); rr.setTargetValue(GoodsItemEnum.Id, goodsItemId); GoodsItem item = context.find(GoodsItem.class, goodsItemId); rr.setTargetValue(GoodsItemEnum.GoodsName, item.getGoodsName()); rr.setTargetValue(GoodsItemEnum.GoodsAttr, item.getPropertiesWithoutUnit()); rr.setTargetValue(GoodsItemEnum.GoodsUnit, item.getGoodsUnit()); if (targets.indexOf(GoodsItemEnum.PurchaseAmount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.PurchaseAmount, value); } if (targets.indexOf(GoodsItemEnum.PurchaseCount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.PurchaseCount, value); } if (targets.indexOf(GoodsItemEnum.PurchaseReturnAmount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.PurchaseReturnAmount, value); } if (targets.indexOf(GoodsItemEnum.InStoreCount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.InStoreCount, value); } if (targets.indexOf(GoodsItemEnum.PayAmount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.PayAmount, value); } if (targets.indexOf(GoodsItemEnum.PurchaseAmount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.PurchaseCount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.PurchaseReturnAmount_OfYear) >= 0) { ReportResult tt = ymap.get(goodsItemId); if (tt != null) { rr.setTargetValue( GoodsItemEnum.PurchaseAmount_OfYear, tt.getTargetValue(GoodsItemEnum.PurchaseAmount_OfYear)); rr.setTargetValue( GoodsItemEnum.PurchaseCount_OfYear, tt.getTargetValue(GoodsItemEnum.PurchaseCount_OfYear)); rr.setTargetValue( GoodsItemEnum.PurchaseReturnAmount_OfYear, tt.getTargetValue(GoodsItemEnum.PurchaseReturnAmount_OfYear)); } } list.add(rr); } }
/** * @param context * @param key * @param login * @return */ private static Map<GUID, ReportResult> getYearDoubleMap_Sales( Context context, ReportCommonKey key, Login login) { QuerySqlBuilder qb = new QuerySqlBuilder(context); qb.addTable("SA_REPORT_GOODS_SALE_DATE", "t"); qb.addArgs("comNo", qb.guid, login.getTenantId()); qb.addEquals("t.tenantId", "@comNo"); String dateKey = null, dateValue = null; int year = 0; for (Condition con : key.getConditions()) { if ("month".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("month", qb.INT, con.getValue()); year = Integer.parseInt((con.getValue() + "").substring(0, 4)); dateKey = "t.monthNo"; dateValue = "@month"; } else if ("season".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("season", qb.INT, con.getValue()); year = Integer.parseInt((con.getValue() + "").substring(0, 4)); dateKey = "t.quarter"; dateValue = "@season"; } } qb.addLessThanOrEquals(dateKey, dateValue); qb.addArgs("year", qb.INT, year); qb.addEquals("t.yearNo", "@year"); qb.addColumn("t.goodsItemId", "id"); qb.addColumn("sum(t.ordAmount)", "ordAmount"); qb.addColumn("sum(t.ordCount)", "receiptAmount"); qb.addColumn("sum(t.rtnAmount)", "rtnAmount"); qb.addGroupBy("t.goodsItemId"); Condition depCon = ReportUtils.findCondition("DepartmentId", key.getConditions()); if (AuthUtils.isBoss(context, login.getEmployeeId()) && null == depCon) { } else if (AuthUtils.isManager(context, login.getEmployeeId()) || null != depCon) { GUID deptId = null; if (null == depCon) { Employee emp = context.find(Employee.class, login.getEmployeeId()); deptId = emp.getDepartmentId(); } else { deptId = (GUID) depCon.getValue(); } Department dep = context.find(Department.class, deptId); List<String> argslist = new ArrayList<String>(); int i = 0; for (Department d : dep.getDescendants(context)) { argslist.add("@" + "deptId" + i); qb.addArgs("deptId" + i, qb.guid, d.getId()); i++; } qb.addIn("t.deptGuid", argslist); } else if (AuthUtils.isSales(context, login.getEmployeeId())) { qb.addArgs("userId", qb.guid, login.getEmployeeId()); qb.addEquals("t.orderPerson", "@userId"); } RecordSet rs = qb.getRecord(); Map<GUID, ReportResult> map = new HashMap<GUID, ReportResult>(); while (rs.next()) { GUID id = rs.getFields().get(0).getGUID(); ReportResult rr = new ReportResult(); rr.setTargetValue(GoodsItemEnum.SalesAmount_OfYear, rs.getFields().get(1).getDouble()); rr.setTargetValue(GoodsItemEnum.SalesCount_OfYear, rs.getFields().get(2).getDouble()); rr.setTargetValue(GoodsItemEnum.SalesReturnAmount_OfYear, rs.getFields().get(3).getDouble()); map.put(id, rr); } return map; }
/** * @param context * @param key * @param list */ @SuppressWarnings("unchecked") private static void salesProvider(Context context, ReportCommonKey key, List<ReportResult> list) { Login login = context.find(Login.class); QuerySqlBuilder qb = new QuerySqlBuilder(context); qb.addTable("SA_REPORT_GOODS_SALE_DATE", "t1"); qb.addArgs("comNo", qb.guid, login.getTenantId()); qb.addEquals("t1.tenantId", "@comNo"); List<Enum> targets = key.getTargets(); qb.addColumn("t1.goodsItemId", "goodsItemId"); if (targets.indexOf(GoodsItemEnum.SalesAmount) >= 0) { qb.addColumn("sum(t1.ordAmount)", "ordAmounts"); } if (targets.indexOf(GoodsItemEnum.SalesCount) >= 0) { qb.addColumn("sum(t1.ordCount)", "ordCount1"); } if (targets.indexOf(GoodsItemEnum.SalesReturnAmount) >= 0) { if (targets.indexOf(GoodsItemEnum.SalesAmount) < 0) { qb.addArgs("zero", qb.INT, 0); qb.addGreaterThan("t1.rtnAmount", "@zero"); } qb.addColumn("sum(t1.rtnAmount)", "rtnAmounts"); } if (targets.indexOf(GoodsItemEnum.OutStoreCount) >= 0) { qb.addColumn("sum(t1.outstoAmount)", "outstoAmount1"); } if (targets.indexOf(GoodsItemEnum.ReceiptAmount) >= 0) { qb.addColumn("sum(t1.receiptAmount)", "receiptAmount1"); } Map<GUID, ReportResult> ymap = null; if (targets.indexOf(GoodsItemEnum.SalesAmount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.SalesCount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.SalesReturnAmount_HuanBi) >= 0) { ymap = getYearDoubleMap_Sales(context, key, login); } for (Condition con : key.getConditions()) { if ("month".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("month", qb.INT, con.getValue()); qb.addEquals("t1.monthNo", "@month"); } else if ("thismonth".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("month", qb.INT, ReportDateUtils.getMonthNo(new Date())); qb.addEquals("t1.monthNo", "@month"); } else if ("season".toUpperCase().equals(con.getConditionColumn().toUpperCase())) { qb.addArgs("season", qb.INT, con.getValue()); qb.addEquals("t1.quarter", "@season"); } else { } } qb.addGroupBy("t1.goodsItemId"); if (CheckIsNull.isNotEmpty(key.getOrderTarget()) && GoodsItemEnum.getTarget(key.getOrderTarget()) == GoodsItemEnum.SalesAmount) { String column = "ordAmounts"; if (key.isOrderDesc()) { column = column + " desc"; } qb.addOrderBy(column); } else if (CheckIsNull.isNotEmpty(key.getOrderTarget()) && GoodsItemEnum.getTarget(key.getOrderTarget()) == GoodsItemEnum.SalesReturnAmount) { String column = "rtnAmounts"; if (key.isOrderDesc()) { column = column + " desc"; } qb.addOrderBy(column); } Condition depCon = ReportUtils.findCondition("DepartmentId", key.getConditions()); if (AuthUtils.isBoss(context, login.getEmployeeId()) && null == depCon) { } else if (AuthUtils.isManager(context, login.getEmployeeId()) || null != depCon) { GUID deptId = null; if (null == depCon) { Employee emp = context.find(Employee.class, login.getEmployeeId()); deptId = emp.getDepartmentId(); } else { deptId = (GUID) depCon.getValue(); } Department dep = context.find(Department.class, deptId); List<String> argslist = new ArrayList<String>(); int i = 0; for (Department d : dep.getDescendants(context)) { argslist.add("@" + "deptId" + i); qb.addArgs("deptId" + i, qb.guid, d.getId()); i++; } qb.addIn("t1.deptGuid", argslist); } else if (AuthUtils.isSales(context, login.getEmployeeId())) { qb.addArgs("userId", qb.guid, login.getEmployeeId()); qb.addEquals("t1.orderPerson", "@userId"); } RecordSet rs = null; if (key.getMaxCount() == 0) { rs = qb.getRecord(); } else { rs = qb.getRecordLimit(0, key.getMaxCount()); } while (rs.next()) { ReportResult rr = new ReportResult(); int index = 0; GUID goodsItemId = rs.getFields().get(index++).getGUID(); rr.setTargetValue(GoodsItemEnum.Id, goodsItemId); GoodsItem item = context.find(GoodsItem.class, goodsItemId); rr.setTargetValue(GoodsItemEnum.GoodsName, item.getGoodsName()); rr.setTargetValue(GoodsItemEnum.GoodsAttr, item.getPropertiesWithoutUnit()); rr.setTargetValue(GoodsItemEnum.GoodsUnit, item.getGoodsUnit()); if (targets.indexOf(GoodsItemEnum.SalesAmount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.SalesAmount, value); } if (targets.indexOf(GoodsItemEnum.SalesCount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.SalesCount, value); } if (targets.indexOf(GoodsItemEnum.SalesReturnAmount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.SalesReturnAmount, value); } if (targets.indexOf(GoodsItemEnum.OutStoreCount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.OutStoreCount, value); } if (targets.indexOf(GoodsItemEnum.ReceiptAmount) >= 0) { Object value = rs.getFields().get(index++).getObject(); rr.setTargetValue(GoodsItemEnum.ReceiptAmount, value); } if (targets.indexOf(GoodsItemEnum.SalesAmount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.SalesCount_OfYear) >= 0 || targets.indexOf(GoodsItemEnum.SalesReturnAmount_OfYear) >= 0) { ReportResult tt = ymap.get(goodsItemId); if (tt != null) { rr.setTargetValue( GoodsItemEnum.SalesAmount_OfYear, tt.getTargetValue(GoodsItemEnum.SalesAmount_OfYear)); rr.setTargetValue( GoodsItemEnum.SalesCount_OfYear, tt.getTargetValue(GoodsItemEnum.SalesCount_OfYear)); rr.setTargetValue( GoodsItemEnum.SalesReturnAmount_OfYear, tt.getTargetValue(GoodsItemEnum.SalesReturnAmount_OfYear)); } } list.add(rr); } }