⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workeffortservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        Security security = ctx.getSecurity();        Map resultMap = new HashMap();                String workEffortId = (String) context.get("workEffortId");            GenericValue workEffort = null;                try {            workEffort = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", workEffortId));        } catch (GenericEntityException e) {            Debug.logWarning(e, module);        }                Boolean canView = null;        Collection workEffortPartyAssignments = null;        Boolean tryEntity = null;        GenericValue currentStatus = null;                if (workEffort == null) {            tryEntity = new Boolean(false);            canView = new Boolean(true);                    String statusId = (String) context.get("currentStatusId");                    if (statusId != null && statusId.length() > 0) {                try {                    currentStatus = delegator.findByPrimaryKeyCache("StatusItem", UtilMisc.toMap("statusId", statusId));                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }            }        } else {            // get a collection of workEffortPartyAssignments, if empty then this user CANNOT view the event, unless they have permission to view all            if (userLogin != null && userLogin.get("partyId") != null && workEffortId != null) {                try {                    workEffortPartyAssignments = delegator.findByAnd("WorkEffortPartyAssignment", UtilMisc.toMap("workEffortId", workEffortId, "partyId", userLogin.get("partyId")));                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }            }            canView = (workEffortPartyAssignments != null && workEffortPartyAssignments.size() > 0) ? Boolean.TRUE : Boolean.FALSE;            if (!canView.booleanValue() && security.hasEntityPermission("WORKEFFORTMGR", "_VIEW", userLogin)) {                canView = new Boolean(true);            }                    tryEntity = new Boolean(true);                    if (workEffort.get("currentStatusId") != null) {                try {                    currentStatus = delegator.findByPrimaryKeyCache("StatusItem", UtilMisc.toMap("statusId", workEffort.get("currentStatusId")));                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }            }        }                if (workEffortId != null) resultMap.put("workEffortId", workEffortId);        if (workEffort != null) resultMap.put("workEffort", workEffort);        if (canView != null) resultMap.put("canView", canView);        if (workEffortPartyAssignments != null) resultMap.put("partyAssigns", workEffortPartyAssignments);        if (tryEntity != null) resultMap.put("tryEntity", tryEntity);        if (currentStatus != null) resultMap.put("currentStatusItem", currentStatus);        return resultMap;    }             private static List getWorkEffortEvents(DispatchContext ctx, Timestamp startStamp, Timestamp endStamp, String partyId, String facilityId, String fixedAssetId) {        GenericDelegator delegator = ctx.getDelegator();        List validWorkEfforts = new ArrayList();        try {            List entityExprList = UtilMisc.toList(                    new EntityExpr("estimatedCompletionDate", EntityOperator.GREATER_THAN_EQUAL_TO, startStamp),                    new EntityExpr("estimatedStartDate", EntityOperator.LESS_THAN, endStamp));            List typesList = UtilMisc.toList(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "EVENT"));            if (UtilValidate.isNotEmpty(partyId)) {                entityExprList.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId));            }            if (UtilValidate.isNotEmpty(facilityId)) {                entityExprList.add(new EntityExpr("facilityId", EntityOperator.EQUALS, facilityId));                typesList.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_HEADER"));            }            if (UtilValidate.isNotEmpty(fixedAssetId)) {                entityExprList.add(new EntityExpr("fixedAssetId", EntityOperator.EQUALS, fixedAssetId));                typesList.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK"));            }            EntityCondition typesCondition = null;            if (typesList.size() == 1) {                typesCondition = (EntityExpr)typesList.get(0);            } else {                typesCondition = new EntityConditionList(typesList, EntityJoinOperator.OR);            }            entityExprList.add(typesCondition);            List tempWorkEfforts = null;            if (UtilValidate.isNotEmpty(partyId)) {                tempWorkEfforts = delegator.findByAnd("WorkEffortAndPartyAssign", entityExprList, UtilMisc.toList("estimatedStartDate"));            } else {                tempWorkEfforts = delegator.findByAnd("WorkEffort", entityExprList, UtilMisc.toList("estimatedStartDate"));            }            // FIXME: I think that now the following code can be removed.            //        It was probably here to remove duplicated workeffort ids caused            //        by the query on the WorkEffortAndPartyAssign view when no party was            //        specified; now it is no more necessary since, when no party is specified,            //        the query is done on the WorkEffort entity.            Set tempWeKeys = new HashSet();            Iterator tempWorkEffortIter = tempWorkEfforts.iterator();            while (tempWorkEffortIter.hasNext()) {                GenericValue tempWorkEffort = (GenericValue) tempWorkEffortIter.next();                String tempWorkEffortId = tempWorkEffort.getString("workEffortId");                if (tempWeKeys.contains(tempWorkEffortId)) {                    tempWorkEffortIter.remove();                } else {                    tempWeKeys.add(tempWorkEffortId);                }            }                        validWorkEfforts = new ArrayList(tempWorkEfforts);        } catch (GenericEntityException e) {            Debug.logWarning(e, module);        }        return validWorkEfforts;            }    public static Map getWorkEffortEventsByPeriod(DispatchContext ctx, Map context) {        GenericDelegator delegator = ctx.getDelegator();        Security security = ctx.getSecurity();        GenericValue userLogin = (GenericValue) context.get("userLogin");            Map resultMap = new HashMap();                Timestamp startDay = (Timestamp) context.get("start");        Integer numPeriodsInteger = (Integer) context.get("numPeriods");        Integer periodInteger = (Integer) context.get("periodSeconds");        String partyId = (String) context.get("partyId");        String facilityId = (String) context.get("facilityId");        String fixedAssetId = (String) context.get("fixedAssetId");        Boolean filterOutCanceledEvents = (Boolean) context.get("filterOutCanceledEvents");        if (filterOutCanceledEvents == null) {        	filterOutCanceledEvents = Boolean.FALSE;        }                //To be returned, the max concurrent entries for a single period        int maxConcurrentEntries = 0;                        long period = periodInteger.intValue()*1000;                int numPeriods = 0;        if(numPeriodsInteger != null) numPeriods = numPeriodsInteger.intValue();                // get a timestamp (date) for the beginning of today and for beginning of numDays+1 days from now        Timestamp startStamp = UtilDateTime.getDayStart(startDay);                  Timestamp endStamp = new Timestamp(startStamp.getTime()+(period*(numPeriods+1)));                startStamp.setNanos(0);        // Get the WorkEfforts        List validWorkEfforts = null;        String partyIdToUse = null;                if (UtilValidate.isNotEmpty(partyId)) {            if (partyId.equals(userLogin.getString("partyId")) || security.hasEntityPermission("WORKEFFORTMGR", "_VIEW", userLogin)) {                partyIdToUse = partyId;            } else {                return ServiceUtil.returnError("You do not have permission to view information for party with ID [" + partyId + "], you must be logged in as a user associated with this party, or have the WORKEFFORTMGR_VIEW or WORKEFFORTMGR_ADMIN permissions.");            }        } else {            // if a facilityId or a fixedAssetId are not specified, don't set a default partyId...            if (UtilValidate.isEmpty(facilityId) && UtilValidate.isEmpty(fixedAssetId)) {                partyIdToUse = userLogin.getString("partyId");            }        }                        // Use the View Entity        if (UtilValidate.isNotEmpty(partyIdToUse) || UtilValidate.isNotEmpty(facilityId) || UtilValidate.isNotEmpty(fixedAssetId)) {            validWorkEfforts = getWorkEffortEvents(ctx, startStamp, endStamp, partyIdToUse, facilityId, fixedAssetId);        }        if (filterOutCanceledEvents.booleanValue()) {        	validWorkEfforts = EntityUtil.filterOutByCondition(validWorkEfforts, new EntityExpr("currentStatusId", EntityOperator.EQUALS, "EVENT_CANCELLED"));        }                // Split the WorkEffort list into a map with entries for each period, period start is the key        List periods = new ArrayList();        if (validWorkEfforts != null) {                    // For each day in the set we check all work efforts to see if they fall within range            for (int i = 0; i < numPeriods; i++) {                Timestamp curPeriodStart = new Timestamp(startStamp.getTime()+(i*period));                Timestamp curPeriodEnd = new Timestamp(curPeriodStart.getTime()+period);                List curWorkEfforts = new ArrayList();                Map entry = new HashMap();                for (int j = 0; j < validWorkEfforts.size(); j++) {                                        GenericValue workEffort = (GenericValue) validWorkEfforts.get(j);                    // Debug.log("Got workEffort: " + workEffort.toString(), module);            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -