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

📄 productionrunservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);            result.put(ModelService.ERROR_MESSAGE, "You do not have permission to perform this operation for this party");            return partyId;        }         */        String productionRunId = (String) context.get("productionRunId");        if (!UtilValidate.isEmpty(productionRunId)) {            ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher);            if (productionRun.exist()){                                if (!productionRun.getGenericValue().getString("currentStatusId").equals("PRUN_CREATED")) {                    return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale));                }                Double quantity = (Double) context.get("quantity");                if (quantity != null &&  ! quantity.equals(productionRun.getQuantity()))                    productionRun.setQuantity(quantity);                                Timestamp  estimatedStartDate =  (Timestamp) context.get("estimatedStartDate");                if (estimatedStartDate != null && ! estimatedStartDate.equals(productionRun.getEstimatedStartDate()))                    productionRun.setEstimatedStartDate(estimatedStartDate);                                String  workEffortName = (String) context.get("workEffortName");                if (workEffortName != null) productionRun.setProductionRunName(workEffortName);                                String  description = (String) context.get("description");                if (description != null) productionRun.setDescription(description);                                String  facilityId = (String) context.get("facilityId");                if (facilityId != null) productionRun.getGenericValue().set("facilityId", facilityId);                if (productionRun.store()) return ServiceUtil.returnSuccess();                else {                    Debug.logError("productionRun.store() fail for productionRunId ="+productionRunId,module);                    return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotUpdated", locale));                }            }            Debug.logError("no productionRun for productionRunId ="+productionRunId,module);            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotUpdated", locale));        }        Debug.logError("service updateProductionRun call with productionRunId empty",module);        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotUpdated", locale));    }        public static Map changeProductionRunStatus(DispatchContext ctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = ctx.getDelegator();        LocalDispatcher dispatcher = ctx.getDispatcher();        Security security = ctx.getSecurity();        Locale locale = (Locale) context.get("locale");        GenericValue userLogin = (GenericValue) context.get("userLogin");                String productionRunId = (String) context.get("productionRunId");        String statusId = (String) context.get("statusId");                ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher);        if (!productionRun.exist()){            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotExists", locale));        }        String currentStatusId = productionRun.getGenericValue().getString("currentStatusId");                if (statusId != null && currentStatusId.equals(statusId)) {            result.put("newStatusId", currentStatusId);            result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", currentStatusId), locale));            return result;        }                // PRUN_CREATED --> PRUN_DOC_PRINTED        if (currentStatusId.equals("PRUN_CREATED") && (statusId == null || statusId.equals("PRUN_DOC_PRINTED"))) {            // change only the production run (header) status to PRUN_DOC_PRINTED            Map serviceContext = new HashMap();            serviceContext.clear();            serviceContext.put("workEffortId", productionRunId);            serviceContext.put("currentStatusId", "PRUN_DOC_PRINTED");            serviceContext.put("userLogin", userLogin);            Map resultService = null;            try {                resultService = dispatcher.runSync("updateWorkEffort", serviceContext);            } catch (GenericServiceException e) {                Debug.logError(e, "Problem calling the updateWorkEffort service", module);                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));            }            result.put("newStatusId", "PRUN_DOC_PRINTED");            result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale));            return result;        }                // PRUN_DOC_PRINTED --> PRUN_RUNNING        // this should be called only when the first task is started        if (currentStatusId.equals("PRUN_DOC_PRINTED") && (statusId == null || statusId.equals("PRUN_RUNNING"))) {            // change only the production run (header) status to PRUN_RUNNING            // First check if there are production runs with precedence not still completed            try {                List mandatoryWorkEfforts = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortAssoc", UtilMisc.toMap("workEffortIdTo", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY")));                for (int i = 0; i < mandatoryWorkEfforts.size(); i++) {                    GenericValue mandatoryWorkEffortAssoc = (GenericValue)mandatoryWorkEfforts.get(i);                    GenericValue mandatoryWorkEffort = mandatoryWorkEffortAssoc.getRelatedOne("FromWorkEffort");                    if (!(mandatoryWorkEffort.getString("currentStatusId").equals("PRUN_COMPLETED") ||                         mandatoryWorkEffort.getString("currentStatusId").equals("PRUN_CLOSED"))) {                        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChangedMandatoryProductionRunNotCompleted", locale));                    }                }            } catch(GenericEntityException gee) {                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));            }            Map serviceContext = new HashMap();            serviceContext.clear();            serviceContext.put("workEffortId", productionRunId);            serviceContext.put("currentStatusId", "PRUN_RUNNING");            serviceContext.put("actualStartDate", UtilDateTime.nowTimestamp());            serviceContext.put("userLogin", userLogin);            Map resultService = null;            try {                resultService = dispatcher.runSync("updateWorkEffort", serviceContext);            } catch (GenericServiceException e) {                Debug.logError(e, "Problem calling the updateWorkEffort service", module);                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));            }            result.put("newStatusId", "PRUN_RUNNING");            result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale));            return result;        }                // PRUN_RUNNING --> PRUN_COMPLETED        // this should be called only when the last task is completed        if (currentStatusId.equals("PRUN_RUNNING") && (statusId == null || statusId.equals("PRUN_COMPLETED"))) {            // change only the production run (header) status to PRUN_COMPLETED            Map serviceContext = new HashMap();            serviceContext.clear();            serviceContext.put("workEffortId", productionRunId);            serviceContext.put("currentStatusId", "PRUN_COMPLETED");            serviceContext.put("actualCompletionDate", UtilDateTime.nowTimestamp());            serviceContext.put("userLogin", userLogin);            Map resultService = null;            try {                resultService = dispatcher.runSync("updateWorkEffort", serviceContext);            } catch (GenericServiceException e) {                Debug.logError(e, "Problem calling the updateWorkEffort service", module);                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));            }            result.put("newStatusId", "PRUN_COMPLETED");            result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale));            return result;        }                // PRUN_COMPLETED --> PRUN_CLOSED        if (currentStatusId.equals("PRUN_COMPLETED") && (statusId == null || statusId.equals("PRUN_CLOSED"))) {            // change the production run status to PRUN_CLOSED            Map serviceContext = new HashMap();            serviceContext.clear();            serviceContext.put("workEffortId", productionRunId);            serviceContext.put("currentStatusId", "PRUN_CLOSED");            serviceContext.put("userLogin", userLogin);            Map resultService = null;            try {                resultService = dispatcher.runSync("updateWorkEffort", serviceContext);            } catch (GenericServiceException e) {                Debug.logError(e, "Problem calling the updateWorkEffort service", module);                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));            }            // change the production run tasks status to PRUN_CLOSED            Iterator tasks = productionRun.getProductionRunRoutingTasks().iterator();            while (tasks.hasNext()) {                GenericValue task = (GenericValue)tasks.next();                serviceContext.clear();                serviceContext.put("workEffortId", task.getString("workEffortId"));                serviceContext.put("currentStatusId", "PRUN_CLOSED");                serviceContext.put("userLogin", userLogin);                resultService = null;                try {                    resultService = dispatcher.runSync("updateWorkEffort", serviceContext);                } catch (GenericServiceException e) {                    Debug.logError(e, "Problem calling the updateWorkEffort service", module);                    return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));                }            }            result.put("newStatusId", "PRUN_CLOSED");            result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_CLOSED"), locale));            return result;        }        result.put("newStatusId", currentStatusId);        result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", currentStatusId), locale));        return result;    }    public static Map changeProductionRunTaskStatus(DispatchContext ctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = ctx.getDelegator();        LocalDispatcher dispatcher = ctx.getDispatcher();        Security security = ctx.getSecurity();        Locale locale = (Locale) context.get("locale");        GenericValue userLogin = (GenericValue) context.get("userLogin");                String productionRunId = (String) context.get("productionRunId");        String taskId = (String) context.get("workEffortId");        String statusId = (String) context.get("statusId");        Boolean issueAllComponents = (Boolean) context.get("issueAllComponents");        if (issueAllComponents == null) {            issueAllComponents = new Boolean(false);        }                ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher);        if (!productionRun.exist()){            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotExists", locale));        }        List tasks = productionRun.getProductionRunRoutingTasks();        GenericValue theTask = null;        GenericValue oneTask = null;        boolean allTaskCompleted = true;        boolean allPrecTaskCompleted = true;        for (int i = 0; i < tasks.size(); i++) {            oneTask = (GenericValue)tasks.get(i);            if (oneTask.getString("workEffortId").equals(taskId)) {                theTask = oneTask;            } else {                if (theTask == null && allPrecTaskCompleted && !oneTask.getString("currentStatusId").equals("PRUN_COMPLETED")) {                    allPrecTaskCompleted = false;                }                if (allTaskCompleted && !oneTask.getString("currentStatusId").equals("PRUN_COMPLETED")) {                    allTaskCompleted = false;                }

⌨️ 快捷键说明

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