List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:com.gst.portfolio.loanaccount.domain.Loan.java
public void makeChargePayment(final Long chargeId, final LoanLifecycleStateMachine loanLifecycleStateMachine, final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds, final HolidayDetailDTO holidayDetailDTO, final LoanTransaction paymentTransaction, final Integer installmentNumber) { validateAccountStatus(LoanEvent.LOAN_CHARGE_PAYMENT); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_CHARGE_PAYMENT, paymentTransaction.getTransactionDate()); validateActivityNotBeforeLastTransactionDate(LoanEvent.LOAN_CHARGE_PAYMENT, paymentTransaction.getTransactionDate()); validateRepaymentDateIsOnHoliday(paymentTransaction.getTransactionDate(), holidayDetailDTO.isAllowTransactionsOnHoliday(), holidayDetailDTO.getHolidays()); validateRepaymentDateIsOnNonWorkingDay(paymentTransaction.getTransactionDate(), holidayDetailDTO.getWorkingDays(), holidayDetailDTO.isAllowTransactionsOnNonWorkingDay()); if (paymentTransaction.getTransactionDate().isAfter(new LocalDate())) { final String errorMessage = "The date on which a loan charge paid cannot be in the future."; throw new InvalidLoanStateTransitionException("charge.payment", "cannot.be.a.future.date", errorMessage, paymentTransaction.getTransactionDate()); }// w w w . ja v a2s.co m existingTransactionIds.addAll(findExistingTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); LoanCharge charge = null; for (final LoanCharge loanCharge : this.charges) { if (loanCharge.isActive() && chargeId.equals(loanCharge.getId())) { charge = loanCharge; } } handleChargePaidTransaction(charge, paymentTransaction, loanLifecycleStateMachine, installmentNumber); }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * 260214 doi chieu ho so -comparison -binhnt53 * * @param form/*from w ww . j a va 2 s . c o m*/ * @param deptId * @param deptName * @param userId * @param userName * @return */ public boolean onComparison(FilesForm form, Long deptId, String deptName, Long userId, String userName) {//db140425 boolean bReturn = true; try { Files file = findById(form.getFileId()); Date dateNow = getSysdate(); if (file == null) { bReturn = false; } else { Long isComparison = form.getIsComparison(); if (isComparison.equals(1L)) { file.setStatus(Constants.FILE_STATUS.COMPARED); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.COMPARED)); form.setStatus(Constants.FILE_STATUS.COMPARED); } else { file.setStatus(Constants.FILE_STATUS.COMPARED_FAIL); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.COMPARED_FAIL)); form.setStatus(Constants.FILE_STATUS.COMPARED_FAIL); } file.setModifyDate(dateNow); file.setComparisonContent(form.getComparisonContent()); file.setIsComparison(form.getIsComparison()); //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); rcbo.setContent(form.getComparisonContent()); rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TBDC);//-150120 rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE);//-150120 //u150119 binhnt53 RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //!u150119 binhnt53 //cap nhat noi dung thong bao - tao noi dung thong bao //update process cu ProcessDAOHE pdhe = new ProcessDAOHE(); if (isComparison.equals(1L)) { Process oldP = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.ALERT_COMPARISON, Constants.FILE_STATUS.NEW_CREATE); if (oldP != null) { oldP.setStatus(form.getStatus()); if (form.getRequestCommentForm() != null) { oldP.setLastestComment(form.getRequestCommentForm().getContent()); } getSession().update(oldP); } else { oldP = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.COMPARED_FAIL, Constants.FILE_STATUS.NEW_CREATE); if (oldP != null) { oldP.setStatus(form.getStatus()); if (form.getRequestCommentForm() != null) { oldP.setLastestComment(form.getRequestCommentForm().getContent()); } getSession().update(oldP); } } } else { Process oldP = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.COMPARED_FAIL, Constants.FILE_STATUS.NEW_CREATE); if (oldP != null) { oldP.setStatus(form.getStatus()); if (form.getRequestCommentForm() != null) { oldP.setLastestComment(form.getRequestCommentForm().getContent()); } getSession().update(oldP); } else { oldP = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.ALERT_COMPARISON, Constants.FILE_STATUS.NEW_CREATE); if (oldP != null) { oldP.setStatus(form.getStatus()); if (form.getRequestCommentForm() != null) { oldP.setLastestComment(form.getRequestCommentForm().getContent()); } getSession().update(oldP); } } } //tao process moi Process newP = new Process(); newP.setObjectId(form.getFileId()); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setSendDate(dateNow); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); newP.setReceiveDate(dateNow); newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setProcessStatus(form.getStatus()); // De xu ly newP.setStatus(0L); // Moi den chua xu ly newP.setIsActive(1l); //tim lanh dao phan cong de gui if (isComparison.equals(1L)) { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } else { //tim doanh nghiep Process pReceive = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.NEW, Constants.FILE_STATUS.RECEIVED); if (pReceive != null) { newP.setReceiveUser(pReceive.getSendUser()); newP.setReceiveUserId(pReceive.getSendUserId()); newP.setReceiveGroup(pReceive.getSendGroup()); newP.setReceiveGroupId(pReceive.getSendGroupId()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } } getSession().save(newP); getSession().update(file); } } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 bReturn = false; } return bReturn; }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * tiep nhan ho so - vai tro van thu binhnt53 * * @param form//from w ww.j av a2 s . c o m * @param deptId * @param deptName * @param userId * @param userName * @return */ public boolean onReceivedFile(FilesForm form, Long deptId, String deptName, Long userId, String userName) { boolean bReturn = true; try { Date dateNow = getSysdate(); Files file = findById(form.getFileId()); if (file == null) { bReturn = false; } else { //140404 Long processStatus = file.getStatus(); if (processStatus.equals(Constants.FILE_STATUS.NEW_TO_ADD) || processStatus.equals(Constants.FILE_STATUS.RECEIVED_REJECT_TO_ADD)) {//neu ho so la nop sdbs k tao so if (form.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { file.setStatus(Constants.FILE_STATUS.RECEIVED_REJECT_TO_ADD); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED_REJECT_TO_ADD)); file.setClericalRequest(form.getClericalRequest()); } else { file.setStatus(Constants.FILE_STATUS.RECEIVED_TO_ADD); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED_TO_ADD)); } //file.setReceiveNo(getNewReceiveNo(deptId)); } else if (form.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { file.setStatus(Constants.FILE_STATUS.RECEIVED_REJECT); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED_REJECT)); file.setClericalRequest(form.getClericalRequest()); } else { file.setStatus(Constants.FILE_STATUS.RECEIVED); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED)); if (file.getReceiveNo() == null || file.getReceiveNo().trim().length() == 0) { file.setReceiveNo(getNewReceiveNo(deptId)); } } file.setModifyDate(dateNow); // file.setIsFee(form.getIsFee()); file.setStaffSigningId(userId); file.setStaffSigningName(userName); if (form.getSignDate() == null) { file.setSignDate(dateNow); } else { file.setSignDate(form.getSignDate()); } //140627 UPDATE BO SUNG THOI GIAN HAN CONG BO, PHAN HOI HO SO if (!form.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { file.setReceivedDate(dateNow); ResourceBundle rb = ResourceBundle.getBundle("config"); ProcedureDAOHE procedureDAOHE = new ProcedureDAOHE(); Procedure procedurebo = procedureDAOHE.findById(file.getFileType()); if ("announcement4star".equalsIgnoreCase(procedurebo.getDescription())) { file.setDeadlineApprove(getDateWorkingTime(15)); file.setDeadlineComment(getDateWorkingTime(15)); } else { int CB = 0, PH = 0; try { CB = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_CB")); } catch (NumberFormatException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } try { PH = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_PH")); } catch (NumberFormatException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } if (CB > 0) { file.setDeadlineApprove(getDateWorkingTime(CB)); } if (PH > 0) { file.setDeadlineComment(getDateWorkingTime(PH)); } } } ProcessDAOHE psdhe = new ProcessDAOHE(); Process ptmp = psdhe.getProcessByAction(file.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); if (ptmp != null) { if (processStatus.equals(Constants.FILE_STATUS.NEW_TO_ADD)) { if (form.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { ptmp.setStatus(Constants.FILE_STATUS.RECEIVED_REJECT_TO_ADD); } else { ptmp.setStatus(Constants.FILE_STATUS.RECEIVED_TO_ADD); } } else if (form.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { ptmp.setStatus(form.getStatus()); } else { ptmp.setStatus(Constants.FILE_STATUS.RECEIVED); } ptmp.setLastestComment(form.getStaffRequest()); getSession().update(ptmp); } Process newP = new Process(); newP.setObjectId(form.getFileId()); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setSendDate(dateNow); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); // Neu khong co luong if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED)) { // Gui toi chinh don vi quan ly de tiep nhan newP.setReceiveDate(dateNow); if (form.getProcessDeptName() != null && form.getProcessDeptId() != null) { newP.setReceiveGroup(form.getProcessDeptName()); newP.setReceiveGroupId(form.getProcessDeptId()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); } else { if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED_TO_ADD)) { //gui cho chuyen vien tham dinh ho so newP.setReceiveDate(dateNow); //140407 ProcessDAOHE processDAOHE = new ProcessDAOHE(); Process userAction = processDAOHE.findProcessByActionEvaluate(file.getFileId()); if (userAction != null) { newP.setReceiveUser(userAction.getReceiveUser()); newP.setReceiveUserId(userAction.getReceiveUserId()); newP.setReceiveGroup(userAction.getReceiveGroup()); newP.setReceiveGroupId(userAction.getReceiveGroupId()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } // newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); } if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { //tu choi tiep nhan newP.setReceiveDate(dateNow); ProcessDAOHE processDAOHE = new ProcessDAOHE();//140407 //Process userAction = processDAOHE.findProcessByActionEvaluate(file.getFileId());//141217u binhnt update thay lai luong tra lai doanh nghiep khi tu choi tiep nhan ho so Process userAction = processDAOHE.getProcessByAction(file.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.NEW, Constants.FILE_STATUS.NEW_CREATE); if (userAction != null) { //141217u binhnt update thay lai luong tra lai doanh nghiep khi tu choi tiep nhan ho so newP.setReceiveUser(userAction.getSendUser()); newP.setReceiveUserId(userAction.getSendUserId()); newP.setReceiveGroup(userAction.getSendGroup()); newP.setReceiveGroupId(userAction.getSendGroupId()); /* newP.setReceiveUser(userAction.getReceiveUser()); newP.setReceiveUserId(userAction.getReceiveUserId()); newP.setReceiveGroup(userAction.getReceiveGroup()); newP.setReceiveGroupId(userAction.getReceiveGroupId()); */ } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } // newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); } if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT_TO_ADD)) {//tu choi tiep nhan sdbs newP.setReceiveDate(dateNow); if (ptmp != null) { //141217u binhnt update thay lai luong tra lai doanh nghiep khi tu choi tiep nhan ho so newP.setReceiveUser(ptmp.getSendUser()); newP.setReceiveUserId(ptmp.getSendUserId()); newP.setReceiveGroup(ptmp.getSendGroup()); newP.setReceiveGroupId(ptmp.getSendGroupId()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); } } getSession().save(newP); // } getSession().update(file); MessageSmsDAOHE msdhe = new MessageSmsDAOHE(); String msg = "Ho so ma: " + file.getFileCode() + " cua doanh nghiep: " + file.getBusinessName() + " dang trong trang thai: da tiep nhan"; msdhe.saveMessageSMS(userId, file.getUserCreateId(), msg); //email MessageEmailDAOHE msedhe = new MessageEmailDAOHE(); String msge = "H s m: " + file.getFileCode() + " ca doanh nghip: " + file.getBusinessName() + " ang trong trng thi: ? tip nhn"; msedhe.saveMessageEmail(userId, file.getUserCreateId(), msge); //send group leader of dept 140915 binhnt53 EmailSmsDAO emdao = new EmailSmsDAO(); emdao.alertLeaderOfStaffAssignFiles(deptId, file.getFileCode(), file.getBusinessName()); // bReturn = true; } } catch (Exception ex) { bReturn = false; LogUtil.addLog(ex);//binhnt sonar a160901 } return bReturn; }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
public boolean onReviewManyFiles(FilesForm form, Long deptId, String deptName, Long userId, String userName) { boolean bReturn = true; try {/*from w w w . j a v a 2s . c o m*/ Files file = findById(form.getFileId()); Date dateNow = getSysdate(); if (file == null) { bReturn = false; } else { Long processStatus = file.getStatus();//trang thai ho so truoc khi thay doi Long status = form.getStatus(); if (processStatus != null//141225 BINHNT update phan quyen ho so tham dinh && (processStatus.equals(Constants.FILE_STATUS.EVALUATED)//DA THAM DINH DAT || processStatus.equals(Constants.FILE_STATUS.FEDBACK_TO_REVIEW)//TRA LAI XEM XET LAI || processStatus.equals(Constants.FILE_STATUS.EVALUATE_TO_ADD)//TRA LAI XEM XET LAI || processStatus.equals(Constants.FILE_STATUS.FEDBACK_TO_ADD))) {//DA THAM DINH YEU CA SDBS // Cap nhat trang thai ho so file.setStatus(status); file.setDisplayStatus(getFileStatusName(status)); String dateTime = DateTimeUtils.convertDateToString(dateNow, "dd/MM/yyyy HH:mm"); if (!status.equals(Constants.FILE_STATUS.REVIEW_TO_ADD)) { file.setLeaderStaffRequest( userName + " " + dateTime + ":\n" + form.getLeaderStaffRequest()); file.setDisplayRequest(form.getLeaderStaffRequest()); } file.setModifyDate(dateNow); file.setEvaluateAddDate(dateNow); file.setLeaderApproveName(form.getLeaderApproveName()); file.setLeaderApproveId(form.getLeaderApproveId()); // Cap nhat process ProcessDAOHE pdhe = new ProcessDAOHE(); Process p = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); Process newP = new Process(); newP.setObjectId(form.getFileId()); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setSendDate(dateNow); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); newP.setProcessStatus(status); // De xu ly newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setStatus(Constants.FILE_STATUS.NEW_CREATE); // Moi den chua xu ly newP.setIsActive(Constants.ACTIVE_STATUS.ACTIVE); newP.setReceiveDate(dateNow); newP.setReceiveUser(form.getLeaderApproveName()); newP.setReceiveUserId(form.getLeaderApproveId()); newP.setReceiveGroup(file.getAgencyName()); newP.setReceiveGroupId(file.getAgencyId()); getSession().save(newP); if (p != null) { p.setStatus(status); p.setLastestComment(form.getLeaderStaffRequest()); getSession().update(p); } else { Process pFeedbacktoAdd = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.FEDBACK_TO_ADD, Constants.FILE_STATUS.NEW_CREATE); if (pFeedbacktoAdd != null) { pFeedbacktoAdd.setStatus(status); pFeedbacktoAdd.setLastestComment(form.getLeaderStaffRequest()); getSession().update(pFeedbacktoAdd); } } update(file); } else { return false; } } } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 bReturn = false; } return bReturn; }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * hieptq update 120114/* ww w.j a va 2 s . c o m*/ * * @param form * @param deptId * @param deptName * @param userId * @param userName * @param lstObjectId * @return */ public boolean onReceivedMoreFile(FilesForm form, Long deptId, String deptName, Long userId, String userName, String lstObjectId) { boolean bReturn = true; boolean bCheckCount = true; String[] lstObjectIdSplit = lstObjectId.split(","); int countObj = lstObjectIdSplit.length; try {//form.setStatus(Constants.FILE_STATUS.RECEIVED); for (int i = 0; i < countObj; i++) { Long fileId = Long.parseLong(lstObjectIdSplit[i]); Files file = findById(fileId); if (file == null) { bReturn = false; } else { Long processStatus = file.getStatus(); ProcedureDepartmentDAOHE prodepdaohe = new ProcedureDepartmentDAOHE(); List lstCQXL = prodepdaohe.getAllProcedureDepartmentByProcedureId(file.getFileType()); //binhnt update 150918 if ((lstCQXL == null || lstCQXL.size() > 1) && !processStatus.equals(Constants.FILE_STATUS.NEW_TO_ADD)) { bCheckCount = false; continue; } //140404 if (processStatus.equals(Constants.FILE_STATUS.NEW_TO_ADD)) {//neu ho so la nop sdbs k tao so file.setStatus(Constants.FILE_STATUS.RECEIVED_TO_ADD); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED_TO_ADD)); } else { file.setStatus(Constants.FILE_STATUS.RECEIVED); file.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.RECEIVED)); if (file.getReceiveNo() == null || file.getReceiveNo().trim().length() == 0) { file.setReceiveNo(getNewReceiveNo(deptId)); } } file.setReceivedDate(getSysdate()); file.setStaffSigningId(userId); file.setStaffSigningName(userName); file.setSignDate(getSysdate()); //140627 UPDATE BO SUNG THOI GIAN HAN CONG BO, PHAN HOI HO SO ResourceBundle rb = ResourceBundle.getBundle("config"); Procedure procedurebo; ProcedureDAOHE procedureDAOHE = new ProcedureDAOHE(); procedurebo = procedureDAOHE.findById(file.getFileType()); int CB = 0, PH = 0; try { CB = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_CB")); } catch (NumberFormatException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } try { PH = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_PH")); } catch (NumberFormatException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } if (CB > 0) { file.setDeadlineApprove(getDateWorkingTime(CB)); } if (PH > 0) { file.setDeadlineComment(getDateWorkingTime(PH)); } ProcessDAOHE psdhe = new ProcessDAOHE(); Process ptmp = psdhe.getProcessByAction(file.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); if (ptmp != null) { if (processStatus.equals(Constants.FILE_STATUS.NEW_TO_ADD)) { ptmp.setStatus(Constants.FILE_STATUS.RECEIVED_TO_ADD); } else { ptmp.setStatus(Constants.FILE_STATUS.RECEIVED); } getSession().update(ptmp); } Process newP = new Process(); newP.setObjectId(fileId); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setSendDate(getSysdate()); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED)) { // Gui toi chinh don vi quan ly de tiep nhan newP.setReceiveDate(getSysdate()); if (form != null && form.getProcessDeptName() != null && form.getProcessDeptId() != null) { newP.setReceiveGroup(form.getProcessDeptName()); newP.setReceiveGroupId(form.getProcessDeptId()); } else if (!lstCQXL.isEmpty()) { ProcedureDepartment prodept = (ProcedureDepartment) lstCQXL.get(0); if (prodept != null && prodept.getProcessDeptId() != null && prodept.getProcessDeptName() != null) { newP.setReceiveGroup(prodept.getProcessDeptName()); newP.setReceiveGroupId(prodept.getProcessDeptId()); } } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); } else {//neu la sdbs gui cho chuyen vien tham dinh ho so if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED_TO_ADD)) { newP.setReceiveDate(getSysdate()); //140407 ProcessDAOHE processDAOHE = new ProcessDAOHE(); Process userAction = processDAOHE.findProcessByActionEvaluate(file.getFileId()); if (userAction != null) { newP.setReceiveUser(userAction.getReceiveUser()); newP.setReceiveUserId(userAction.getReceiveUserId()); newP.setReceiveGroup(userAction.getReceiveGroup()); newP.setReceiveGroupId(userAction.getReceiveGroupId()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } // newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); getSession().save(newP); } if (file.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { //tu choi tiep nhan newP.setReceiveDate(getSysdate()); ProcessDAOHE processDAOHE = new ProcessDAOHE();//140407 Process userAction = processDAOHE.getProcessByAction(file.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.NEW, Constants.FILE_STATUS.NEW_CREATE); if (userAction != null) { newP.setReceiveUser(userAction.getSendUser()); newP.setReceiveUserId(userAction.getSendUserId()); newP.setReceiveGroup(userAction.getSendGroup()); newP.setReceiveGroupId(userAction.getSendGroupId()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } newP.setProcessStatus(file.getStatus()); // De xu ly newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); } // Tra lai cho doanh nghiep khong xu ly gi them } getSession().save(newP); getSession().update(file); MessageSmsDAOHE msdhe = new MessageSmsDAOHE(); String msg = "Ho so ma: " + file.getFileCode() + " cua doanh nghiep: " + file.getBusinessName() + " dang trong trang thai: da tiep nhan"; msdhe.saveMessageSMS(userId, file.getUserCreateId(), msg); //email MessageEmailDAOHE msedhe = new MessageEmailDAOHE(); String msge = "H s m: " + file.getFileCode() + " ca doanh nghip: " + file.getBusinessName() + " ang trong trng thi: ? tip nhn"; msedhe.saveMessageEmail(userId, file.getUserCreateId(), msge); //send group leader of dept 140915 binhnt53 EmailSmsDAO emdao = new EmailSmsDAO(); emdao.alertLeaderOfStaffAssignFiles(deptId, file.getFileCode(), file.getBusinessName()); bReturn = true; } } } catch (Exception ex) { bReturn = false; LogUtil.addLog(ex);//binhnt sonar a160901 } if (!bCheckCount) { return false; } return bReturn; }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * xem xt thm nh h s.//from w ww . j a v a 2 s.c o m * * @param form * @param deptId * @param deptName * @param userId * @param userName * @return */ public boolean onReviewEvaluate(FilesForm form, Long deptId, String deptName, Long userId, String userName) { boolean bReturn = true; try { Files file = findById(form.getFileId()); Date dateNow = getSysdate(); if (file == null) { bReturn = false; } else { Long processStatus = file.getStatus();//trang thai ho so truoc khi thay doi Long status = form.getStatus(); if (processStatus != null//141225 BINHNT update phan quyen ho so tham dinh && (processStatus.equals(Constants.FILE_STATUS.EVALUATED)//DA THAM DINH DAT || processStatus.equals(Constants.FILE_STATUS.FEDBACK_TO_REVIEW)//TRA LAI XEM XET LAI || processStatus.equals(Constants.FILE_STATUS.EVALUATE_TO_ADD)//TRA LAI XEM XET LAI || processStatus.equals(Constants.FILE_STATUS.FEDBACK_TO_ADD))) {//DA THAM DINH YEU CA SDBS // Cap nhat trang thai ho so file.setStatus(status); file.setDisplayStatus(getFileStatusName(status)); String dateTime = DateTimeUtils.convertDateToString(dateNow, "dd/MM/yyyy HH:mm"); if (!status.equals(Constants.FILE_STATUS.REVIEW_TO_ADD)) { file.setLeaderStaffRequest( userName + " " + dateTime + ":\n" + form.getLeaderStaffRequest()); file.setDisplayRequest(form.getLeaderStaffRequest()); } else { file.setLeaderStaffRequest("Trng phng xem xt cng vn S?BS"); file.setDisplayRequest("Trng phng xem xt cng vn S?BS"); } file.setModifyDate(dateNow); file.setEvaluateAddDate(dateNow); file.setLeaderApproveName(form.getLeaderApproveName()); file.setLeaderApproveId(form.getLeaderApproveId()); // Cap nhat process ProcessDAOHE pdhe = new ProcessDAOHE(); Process p = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); Process newP = new Process(); newP.setObjectId(form.getFileId()); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setSendDate(dateNow); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); newP.setProcessStatus(status); // De xu ly newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setStatus(Constants.FILE_STATUS.NEW_CREATE); // Moi den chua xu ly newP.setIsActive(Constants.ACTIVE_STATUS.ACTIVE); newP.setReceiveDate(dateNow); if (status.equals(Constants.FILE_STATUS.REVIEWED)) { // Phe duyet oke, chuyen ho so cho lanh dao phe duyet newP.setReceiveUser(form.getLeaderApproveName()); newP.setReceiveUserId(form.getLeaderApproveId()); newP.setReceiveGroup(file.getAgencyName()); newP.setReceiveGroupId(file.getAgencyId()); } else { if (status.equals(Constants.FILE_STATUS.EVALUATED_TO_ADD)) { //140722 - da thong bao yeu cau sdbs ProcessDAOHE psdhe = new ProcessDAOHE(); Process pold = psdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.NEW, Constants.FILE_STATUS.RECEIVED); if (pold != null) { newP.setReceiveGroupId(pold.getSendGroupId()); newP.setReceiveGroup(pold.getSendGroup()); newP.setReceiveUserId(pold.getSendUserId()); newP.setReceiveUser(pold.getSendUser()); } else { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } //xa b?n ghi temp tr?c n?u c (lu vo vng lu tr?) updateSetNotLastIsTemp(file.getFileId());// ProcessCommentDAOHE pcdaohe = new ProcessCommentDAOHE(); pcdaohe.updateSetNotLastIsTemp(file.getFileId()); try {//140627 THIET LAP HAN SDBS HO SO ResourceBundle rb = ResourceBundle.getBundle("config"); Procedure procedurebo; ProcedureDAOHE procedureDAOHE = new ProcedureDAOHE(); procedurebo = procedureDAOHE.findById(file.getFileType()); int SD = 0; try { SD = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_SD")); } catch (NumberFormatException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } if (SD > 0) { file.setDeadlineAddition(getDateWorkingTime(SD)); } } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } //!140627 THIET LAP HAN SDBS HO SO //sms MessageSmsDAOHE msdhe = new MessageSmsDAOHE(); String msg = "Ho so ma: " + file.getFileCode() + " cua doanh nghiep: " + file.getBusinessName() + " dang trong trang thai: da thong bao yeu cau sdbs"; msdhe.saveMessageSMS(userId, file.getUserCreateId(), msg); //email MessageEmailDAOHE msedhe = new MessageEmailDAOHE(); String msge = "H s m: " + file.getFileCode() + " ca doanh nghip: " + file.getBusinessName() + " ang trong trng thi: ? thng bo yu cu sa i b sung."; msedhe.saveMessageEmail(userId, file.getUserCreateId(), msge); // try { // if ("true".equals(ResourceBundleUtil.getString("send_service", "config"))) { // Helper h = new Helper(); // h.sendMs_330(file.getFileId(), msge); // } // } catch (UnsupportedEncodingException ex) { // Logger.getLogger(FilesDAOHE.class.getName()).log(Level.SEVERE, null, ex); // } } if (status.equals(Constants.FILE_STATUS.FEDBACK_TO_EVALUATE)) { // Tra lai cho chuyen vien tham dinh if (form.getLeaderStaffRequest() != null) { file.setLeaderStaffRequest( userName + " " + dateTime + ":\n" + form.getLeaderStaffRequest()); } if (p != null) { //lay process tham dinh ho so ProcessDAOHE psdhe = new ProcessDAOHE(); Process pold = psdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.EVALUATED, Constants.FILE_STATUS.NEW_CREATE); if (pold != null) { newP.setReceiveGroup(pold.getSendGroup()); newP.setReceiveGroupId(pold.getSendGroupId()); if (file != null && file.getStaffProcess() != null && file.getNameStaffProcess() != null) { newP.setReceiveUser(file.getNameStaffProcess()); newP.setReceiveUserId(file.getStaffProcess()); } else { newP.setReceiveUser(pold.getSendUser()); newP.setReceiveUserId(pold.getSendUserId()); } } else {//141218u binhnt53 fix loi ho so lanh dao phong tra lai voi pold = psdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.FEDBACK_TO_ADD, Constants.FILE_STATUS.NEW_CREATE); if (pold != null) { newP.setReceiveGroup(pold.getSendGroup()); newP.setReceiveGroupId(pold.getSendGroupId()); if (file != null && file.getStaffProcess() != null && file.getNameStaffProcess() != null) { newP.setReceiveUser(file.getNameStaffProcess()); newP.setReceiveUserId(file.getStaffProcess()); } else { newP.setReceiveUser(pold.getSendUser()); newP.setReceiveUserId(pold.getSendUserId()); } } else { pold = psdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.ASSIGNED, null); if (pold != null) { newP.setReceiveGroup(pold.getReceiveGroup()); newP.setReceiveGroupId(pold.getReceiveGroupId()); newP.setReceiveUser(pold.getReceiveUser()); newP.setReceiveUserId(pold.getReceiveUserId()); } else if (p != null) {// Gui lai cho chinh nguoi gui newP.setReceiveGroup(p.getSendGroup()); newP.setReceiveGroupId(p.getSendGroupId()); newP.setReceiveUser(p.getSendUser()); newP.setReceiveUserId(p.getSendUserId()); } } } } //hieptq update 080515 // xoa ban ghi lanh dao comment khi bi tra lai RequestCommentDAOHE rcdhe = new RequestCommentDAOHE(); RequestComment rc = rcdhe.findLeaderComment(form.getFileId(), 1l); if (rc != null && !"".equals(rc.getContent())) { rc.setIsActive(0l); getSession().update(rc); } } /* if (form.getStatus().equals(Constants.FILE_STATUS.REVIEWED_TO_ADD)) {//da xem xet yc sdbs newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); newP.setReceiveUser(file.getNameStaffProcess()); newP.setReceiveUserId(file.getStaffProcess()); }*/ if (status.equals(Constants.FILE_STATUS.REVIEW_TO_ADD)) { /* lanh dao phong vao xem xet noi dung thong bao sua doi bo sung chinh sua noi dung luu va gui len lanh dao cuc */ if (form.getIsTypeChange() != null) { file.setIsTypeChange(form.getIsTypeChange());//chuyen loai ho so hay khong } newP.setReceiveUser(form.getLeaderApproveName()); newP.setReceiveUserId(form.getLeaderApproveId()); newP.setReceiveGroup(file.getAgencyName()); newP.setReceiveGroupId(file.getAgencyId()); //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); if (form.getEvaluationRecordsForm() != null) { String content = ""; if (form.getLeaderStaffRequest() != null && !"null".equals(form.getLeaderStaffRequest())) { content += "* ? kin chung:" + "\n"; content += form.getLeaderStaffRequest() + "\n"; } if (form.getEvaluationRecordsForm().getLegalContentL() != null && !"null".equals(form.getEvaluationRecordsForm().getLegalContentL())) { content += "* V? php ch:" + "\n"; content += form.getEvaluationRecordsForm().getLegalContentL() + "\n"; } if (form.getEvaluationRecordsForm().getFoodSafetyQualityContentL() != null && !"null".equals( form.getEvaluationRecordsForm().getFoodSafetyQualityContentL())) { content += "* V? ch tiu cht lng an ton thc phm:" + "\n"; content += form.getEvaluationRecordsForm().getFoodSafetyQualityContentL() + "\n"; } if (form.getEvaluationRecordsForm().getEffectUtilityContentL() != null && !"null" .equals(form.getEvaluationRecordsForm().getEffectUtilityContentL())) { content += "* V? c ch tc dng, cng dng v hng dn s dng:" + "\n"; content += form.getEvaluationRecordsForm().getEffectUtilityContentL() + "\n"; } if (content != null && !"null".equals(content)) { rcbo.setContent(content); } else { rcbo.setContent("Khng c ni dung."); } } else if (file.getLeaderStaffRequest() != null) { rcbo.setContent(form.getLeaderStaffRequest()); } else { rcbo.setContent("Lnh o phng cha c ni dung."); } rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TBSDBS); //-150120 RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //!cap nhat noi dung thong bao - tao noi dung thong bao //-150120 //!luu noi dung du thao } } getSession().save(newP); //insert noi dung tham dinh if (form.getEvaluationRecordsForm() != null) { EvaluationRecordsDAOHE evaluationRecordsDAOHE = new EvaluationRecordsDAOHE(); EvaluationRecords evaluationRecords = evaluationRecordsDAOHE.findFilesByFileId(file); if (evaluationRecords != null) { evaluationRecords.setSendDate(file.getSendDate()); evaluationRecords.setLegalL(form.getEvaluationRecordsForm().getLegalL()); evaluationRecords.setLegalContentL(form.getEvaluationRecordsForm().getLegalContentL()); evaluationRecords .setFoodSafetyQualityL(form.getEvaluationRecordsForm().getFoodSafetyQualityL()); evaluationRecords.setFoodSafetyQualityContentL( form.getEvaluationRecordsForm().getFoodSafetyQualityContentL()); evaluationRecords .setEffectUtilityL(form.getEvaluationRecordsForm().getEffectUtilityL()); evaluationRecords.setEffectUtilityContentL( form.getEvaluationRecordsForm().getEffectUtilityContentL()); evaluationRecords.setFilesStatusL(status); evaluationRecords.setMainContentL(form.getLeaderStaffRequest()); getSession().update(evaluationRecords); } insertRequestCommentLeader(file.getFileId(), form, userId, userName, deptId, deptName, dateNow);//binhnt53 150130 } if (p != null) { p.setStatus(status); p.setLastestComment(form.getLeaderStaffRequest()); getSession().update(p); } else { ProcessDAOHE psdhe = new ProcessDAOHE(); Process pFeedbacktoAdd = psdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.FEDBACK_TO_ADD, Constants.FILE_STATUS.NEW_CREATE); if (pFeedbacktoAdd != null) { pFeedbacktoAdd.setStatus(status); pFeedbacktoAdd.setLastestComment(form.getLeaderStaffRequest()); getSession().update(pFeedbacktoAdd); } } // Hiepvv_Home Update Title And Content of File SDBS after announced if (form.getContentsEditATTP() != null && form.getTitleEditATTP() != null && (!"".equals(form.getContentsEditATTP().trim()) || !"".equals(form.getTitleEditATTP().trim())) && (file.getFilesSourceID() != null && file.getFilesSourceID() > 0 && file.getFileSourceCode() != null)) { if (form.getTitleEditATTP() != null) { file.setTitleEditATTP(form.getTitleEditATTP()); } if (form.getContentsEditATTP() != null) { file.setContentsEditATTP(form.getContentsEditATTP()); } } //End Hiepvv update(file); } else { return false; } } } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 bReturn = false; } return bReturn; }
From source file:jp.primecloud.auto.service.impl.InstanceServiceImpl.java
/** * {@inheritDoc}/*from w w w . j a v a2s. co m*/ */ @Override public void updateAwsInstance(Long instanceNo, String instanceName, String comment, String keyName, String instanceType, String securityGroupName, String availabilityZoneName, Long addressNo, String subnetId, String privateIpAddress) { // ? updateInstance(instanceNo, instanceName, comment); // ? if (instanceNo == null) { throw new AutoApplicationException("ECOMMON-000003", "instanceNo"); } if (keyName == null || keyName.length() == 0) { throw new AutoApplicationException("ECOMMON-000003", "keyName"); } try { InstanceType.fromValue(instanceType); } catch (IllegalArgumentException e) { throw new AutoApplicationException("ECOMMON-000001", "instanceType"); } // ?? Instance instance = instanceDao.read(instanceNo); if (instance == null) { throw new AutoApplicationException("ESERVICE-000403", instanceNo); } // ?? Platform platform = platformDao.read(instance.getPlatformNo()); if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType()) == false) { throw new AutoApplicationException("ESERVICE-000404", instance.getInstanceName()); } //? Farm farm = farmDao.read(instance.getFarmNo()); // ?????? AwsInstance awsInstance = awsInstanceDao.read(instanceNo); if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.STOPPED) { // ?????????????????? if (!StringUtils.equals(awsInstance.getKeyName(), keyName)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (!StringUtils.equals(awsInstance.getInstanceType(), instanceType)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (StringUtils.isEmpty(awsInstance.getSecurityGroups()) ? StringUtils.isNotEmpty(securityGroupName) : !StringUtils.equals(awsInstance.getSecurityGroups(), securityGroupName)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (StringUtils.isEmpty(awsInstance.getAvailabilityZone()) ? StringUtils.isNotEmpty(availabilityZoneName) : !StringUtils.equals(awsInstance.getAvailabilityZone(), availabilityZoneName)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (StringUtils.isEmpty(awsInstance.getSubnetId()) ? StringUtils.isNotEmpty(subnetId) : !StringUtils.equals(awsInstance.getSubnetId(), subnetId)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } if (StringUtils.isEmpty(awsInstance.getPrivateIpAddress()) ? StringUtils.isNotEmpty(privateIpAddress) : !StringUtils.equals(awsInstance.getPrivateIpAddress(), privateIpAddress)) { throw new AutoApplicationException("ESERVICE-000407", instance.getInstanceName()); } } // ?? if (StringUtils.isEmpty(awsInstance.getSubnetId()) && StringUtils.isEmpty(securityGroupName)) { throw new AutoApplicationException("ECOMMON-000003", "securityGroupName"); } // ?? PlatformAws platformAws = platformAwsDao.read(instance.getPlatformNo()); if (platformAws.getEuca() == false && platformAws.getVpc()) { if (StringUtils.equals(awsInstance.getSubnetId(), subnetId) == false) { //VPC???????????? if (awsVolumeDao.countByInstanceNo(instanceNo) > 0) { // EBS???()????? throw new AutoApplicationException("ESERVICE-000421"); } } } else { if (StringUtils.isEmpty(awsInstance.getAvailabilityZone()) ? StringUtils.isNotEmpty(availabilityZoneName) : !StringUtils.equals(awsInstance.getAvailabilityZone(), availabilityZoneName)) { if (awsVolumeDao.countByInstanceNo(instanceNo) > 0) { // EBS??????? throw new AutoApplicationException("ESERVICE-000412"); } } } //??? if (StringUtils.isNotEmpty(subnetId) && StringUtils.isNotEmpty(privateIpAddress)) { //AWS_INSTANCE?subnet?? List<Instance> instances = instanceDao.readByFarmNo(farm.getFarmNo()); List<Long> instanceNos = new ArrayList<Long>(); for (Instance tmpInstance : instances) { if (instanceNo.equals(tmpInstance.getInstanceNo()) == false) { instanceNos.add(tmpInstance.getInstanceNo()); } } List<AwsInstance> awsInstances = awsInstanceDao.readInInstanceNos(instanceNos); for (AwsInstance tmpAwsInstance : awsInstances) { if (subnetId.equals(tmpAwsInstance.getSubnetId()) && privateIpAddress.equals(tmpAwsInstance.getPrivateIpAddress())) { //??subnetId???privateIpAddress??AWS_INSTANCE??? throw new AutoApplicationException("ESERVICE-000420", privateIpAddress); } } } // AWS?? AwsAddress awsAddress = null; if (addressNo != null) { // AWS?? awsAddress = awsAddressDao.read(addressNo); if (awsAddress == null) { throw new AutoApplicationException("ESERVICE-000415", addressNo); } // ???????????? if (awsAddress.getInstanceNo() != null && !instanceNo.equals(awsAddress.getInstanceNo())) { // ?????? throw new AutoApplicationException("ESERVICE-000416", awsAddress.getPublicIp()); } } // AWS? awsInstance.setKeyName(keyName); awsInstance.setInstanceType(instanceType); awsInstance.setSecurityGroups(securityGroupName); awsInstance.setAvailabilityZone(availabilityZoneName); awsInstance.setSubnetId(subnetId); awsInstance.setPrivateIpAddress(privateIpAddress); awsInstanceDao.update(awsInstance); // ?AWS???????? List<AwsAddress> awsAddresses = awsAddressDao.readByInstanceNo(instanceNo); for (AwsAddress address : awsAddresses) { if (address.getAddressNo().equals(addressNo)) { continue; } address.setInstanceNo(null); awsAddressDao.update(address); } // AWS?? if (addressNo != null && !instanceNo.equals(awsAddress.getInstanceNo())) { awsAddress.setInstanceNo(instanceNo); awsAddressDao.update(awsAddress); } // eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), null, null, instanceNo, instanceName, "InstanceUpdate", instanceType, instance.getPlatformNo(), null); }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * Gi h s cho c quan x l K ton xc nhn h s * * @param fileId//from w w w. ja v a2 s . c o m * @param deptId * @param userId * @param userName * @param businessId * @param businessName * @return */ public boolean assignFileToDept(Long fileId, Long deptId, Long userId, String userName, Long businessId, String businessName) { boolean bReturn = true; try { Files bo = findById(fileId); DepartmentDAOHE ddhe = new DepartmentDAOHE(); Date dateNow = getSysdate(); Department dept = ddhe.findById(deptId); Long processStatus = bo.getStatus(); bo.setAgencyId(dept.getDeptId()); bo.setAgencyName(dept.getDeptName()); bo.setModifyDate(dateNow); ProcedureDAOHE pdhe = new ProcedureDAOHE(); Procedure pro = pdhe.findById(bo.getFileType()); if (pro != null && pro.getDeadline() != null) { Date dt = DateTimeUtils.getAddDate(dateNow, 0, pro.getDeadline().intValue()); bo.setDeadline(dt); } if (bo.getStatus().equals(Constants.FILE_STATUS.NEW_CREATE) || bo.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { bo.setStatus(Constants.FILE_STATUS.NEW); bo.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.NEW)); if (processStatus.equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { ProcessDAOHE psdhe = new ProcessDAOHE(); Process p = psdhe.getProcessByAction(fileId, Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); if (p != null) { p.setStatus(bo.getStatus()); p.setLastestComment("Doanh nghip gi Sa i b sung"); getSession().update(p); } } } if (processStatus.equals(Constants.FILE_STATUS.EVALUATED_TO_ADD) || processStatus.equals(Constants.FILE_STATUS.RECEIVED_REJECT_TO_ADD)) { bo.setStatus(Constants.FILE_STATUS.NEW_TO_ADD); bo.setDisplayStatus(getFileStatusName(Constants.FILE_STATUS.NEW_TO_ADD)); //update process ProcessDAOHE psdhe = new ProcessDAOHE(); Process p = psdhe.getProcessByAction(fileId, Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); if (p != null) { p.setStatus(bo.getStatus()); p.setLastestComment("Doanh nghip gi Sa i b sung"); getSession().update(p); } } bo.setSendDate(dateNow); //140623 THIET LAP HAN TIEP NHAN HO SO ResourceBundle rb = ResourceBundle.getBundle("config"); Procedure procedurebo; ProcedureDAOHE procedureDAOHE = new ProcedureDAOHE(); procedurebo = procedureDAOHE.findById(bo.getFileType()); int TN = 0; try { TN = Integer.parseInt(rb.getString(procedurebo.getDescription() + "_TN")); } catch (NumberFormatException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 } if (TN > 0) { bo.setDeadlineReceived(getDateWorkingTime(TN)); } //Hiepvv Set defalt TitleEditATTP = TitleEdit AND ContentsEditATTP = ContentsEdit if (bo.getTitleEdit() != null) { bo.setTitleEditATTP(bo.getTitleEdit()); } if (bo.getContentsEdit() != null) { bo.setContentsEditATTP(bo.getContentsEdit()); } //140623 THIET LAP HAN TIEP NHAN HO SO getSession().update(bo); // gui den cho co quan truoc Process p = new Process(); p.setObjectId(fileId); p.setObjectType(Constants.OBJECT_TYPE.FILES); p.setSendDate(dateNow); p.setSendGroup(businessName); p.setSendGroupId(businessId); p.setSendUserId(userId); p.setSendUser(userName); p.setReceiveDate(dateNow); // String deptCode = rb.getString("deptCode"); if (deptCode == null) { deptCode = "ATTP"; } DepartmentDAOHE dphe = new DepartmentDAOHE(); Department dep = dphe.findByDeptCode(deptCode); if (dep != null) { p.setReceiveGroup(dep.getDeptName()); p.setReceiveGroupId(dep.getDeptId()); } else { p.setReceiveGroup(dept.getDeptName()); p.setReceiveGroupId(dept.getDeptId()); } p.setProcessType(Constants.PROCESS_TYPE.MAIN); //140404 binhnt53 if (bo.getStatus().equals(Constants.FILE_STATUS.NEW) || bo.getStatus().equals(Constants.FILE_STATUS.RECEIVED_REJECT)) { p.setProcessStatus(Constants.FILE_STATUS.NEW); // De xu ly } else { p.setProcessStatus(Constants.FILE_STATUS.NEW_TO_ADD); // De xu ly } // p.setProcessStatus(Constants.FILE_STATUS.NEW); // De xu ly //!140404 binhnt53 // if (lst != null && lst.size() > 0) { //140405 if (bo.getStatus().equals(Constants.FILE_STATUS.EVALUATED_TO_ADD) == true) { p.setStatus(Constants.FILE_STATUS.ASSIGNED); } else { p.setStatus(Constants.FILE_STATUS.NEW_CREATE); } p.setIsActive(Constants.ACTIVE_STATUS.ACTIVE); getSession().save(p); } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 bReturn = false; // log.error(en.getMessage()); } return bReturn; }
From source file:de.innovationgate.wgpublisher.WGACore.java
public WGDatabase connectPlugin(WGAPlugin plugin, Map domainConfigs, Set connectedPlugins) throws Problem, InvalidPluginException, WGIllegalArgumentException, FileSystemException, IOException { // Look if already connected to the correct file String dbKey = plugin.buildDatabaseKey(); WGDatabase db = contentdbs.get(dbKey); if (db != null) { try {// w ww . j av a 2s .c o m Long pluginFileTime = (Long) db.getAttribute(DBATTRIB_PLUGIN_FILETIME); Version pluginVersion = (Version) db.getAttribute(DBATTRIB_PLUGIN_VERSION); if (pluginVersion.equals(plugin.getPluginID().getVersion()) && (pluginFileTime != null && pluginFileTime.equals(new Long(plugin.getFileLastModified())))) { if (!db.isSessionOpen()) { db.openSession(); } return null; } else { removeContentDB(dbKey); db = null; } } catch (Exception e) { throw new InvalidPluginException(plugin, "Error checking existent plugin database " + dbKey, e); } } if (!plugin.isActive()) { throw new InvalidPluginException(plugin, "Plugin is deactivated"); } if (!plugin.isValid()) { throw new InvalidPluginException(plugin, "Plugin is invalid"); } // First connect all mandatory plugins try { Iterator mandatoryPlugins = plugin.getMandatoryPlugins().values().iterator(); while (mandatoryPlugins.hasNext()) { WGAPlugin mandatoryPlugin = (WGAPlugin) mandatoryPlugins.next(); connectPlugin(mandatoryPlugin, domainConfigs, connectedPlugins); } } // A mandatory plugin is invalid. Cancel connect. catch (InvalidPluginException e) { throw e; } logCategoryInfo("Plugin " + plugin.getInstallationKey(), 2); // Mandatory db options (for plugins) Map<String, String> dbOptions = new HashMap<String, String>(); dbOptions.put(WGDatabase.COPTION_DBREFERENCE, dbKey.toLowerCase()); dbOptions.put(WGDatabase.COPTION_READERPROFILECREATION, "true"); putDefaultDbOptions(dbOptions); dbOptions.put(WGDatabase.COPTION_CLUSTERED, "false"); // We try to automatically migrate plugin content stores to CS5 format dbOptions.put(WGDatabase.COPTION_CONTENT_STORE_VERSION, String.valueOf(WGDatabase.CSVERSION_WGA5)); dbOptions.put(Database.OPTION_PATH, plugin.getInstallationKey()); // Ugly hack to insert DB options for plugin debugging File optionsFile = getWGAFile(plugin.getPluginID().getUniqueName() + ".dboptions.properties"); if (optionsFile != null && optionsFile.exists()) { Properties props = new Properties(); FileInputStream in = new FileInputStream(optionsFile); props.load(in); in.close(); for (Map.Entry<Object, Object> option : props.entrySet()) { dbOptions.put(String.valueOf(option.getKey()), String.valueOf(option.getValue())); } } // Clear the plugin database before connecting if the plugin is updated and should clear the db on update if (plugin.getRuntimeContext().isUpdated()) { if (plugin.getCsConfig() .getPluginConfig() instanceof de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig) { de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig v3Config = (de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig) plugin .getCsConfig().getPluginConfig(); if (v3Config.isClearDatabaseOnUpdate()) { getLog().info("Clearing plugin database for installation key " + plugin.getInstallationKey()); plugin.getParent().deletePluginDatabase(plugin); } } plugin.getRuntimeContext().setUpdated(false); } // Optionally add hotpatches path String hotPatchesPath = System.getProperty(SYSPROPERTY_JDBC_HOTPATCHES); if (hotPatchesPath != null) { File hotPatchesFile = getWGAFile(hotPatchesPath); if (hotPatchesFile != null) { dbOptions.put(WGDatabaseImpl.COPTION_HOTPATCH, hotPatchesFile.getAbsolutePath()); } } // Determine WGAPI implementation boolean usesDatabase = true; if (plugin.getCsConfig() .getPluginConfig() instanceof de.innovationgate.wga.common.beans.csconfig.v5.PluginConfig) { de.innovationgate.wga.common.beans.csconfig.v5.PluginConfig v5PluginConfig = (de.innovationgate.wga.common.beans.csconfig.v5.PluginConfig) plugin .getCsConfig().getPluginConfig(); if ("true".equals(v5PluginConfig.getOptions() .get(de.innovationgate.wga.common.beans.csconfig.v5.PluginConfig.OPTION_NO_DATABASE))) { usesDatabase = false; } } Class<? extends WGDatabaseCore> implClass; if (usesDatabase) { if (!"false".equals(System.getProperty("de.innovationgate.wga.plugin.lazydbs"))) { implClass = de.innovationgate.webgate.api.hsql.WGLazyDatabaseImpl.class; } else { implClass = de.innovationgate.webgate.api.hsql.WGDatabaseImpl.class; } } else { implClass = WGFakeContentStore.class; } // Connect getLog().info("Connecting plugin " + plugin.getPluginID().getUniqueName() + " Version " + plugin.getPluginID().getVersion().toString()); try { db = getPluginSet().getDbServer().openDatabase(implClass, dbOptions); } catch (Throwable e1) { throw new InvalidPluginException(plugin, "Could not connect plugin \"" + plugin.getPluginID().getUniqueName() + "\"", e1); } if (db == null || !db.isSessionOpen()) { throw new InvalidPluginException(plugin, "Could not connect plugin \"" + plugin.getPluginID().getUniqueName() + "\" - Check logged messages above for error details"); } try { db.getSessionContext().setTask("Initializing database in WGA"); // Plugin dbs are always CS5 since they are automatically migrated //getLog().info("Database of plugin " + plugin.getPluginID().getUniqueName() + " is content store version " + db.getContentStoreVersion()); PluginConfig pc = plugin.getCsConfig().getPluginConfig(); String auth = pc.getAuthentication(); db.setTitle(pc.getTitle()); // Set mandatory database attributes initializeDBAttributes(db, dbKey, dbKey, new HashSet()); // Create authentication if (auth != null) { String authImplClass = null; Map<String, String> authOptions = new HashMap<String, String>(); // Delegate authentication to the default domain if (auth.equals(PluginConfig.AUTHSOURCE_DEFAULT_DOMAIN)) { authImplClass = WGAAuthModuleFactory.AUTHMODULE_DELEGATE; authOptions.put(DelegatingAuthModule.COPTION_DOMAIN, "default"); } // Use some plugin for authentication else { WGAPlugin authPlugin = plugin.getParent().getPluginByUniqueName(auth); if (authPlugin != null) { authImplClass = CSAuthModule.class.getName(); authOptions.put(CSAuthModule.COPTION_DBKEY, authPlugin.buildDatabaseKey()); } else { getLog().error("Unable to find authentication plugin " + auth); } } if (authImplClass != null) { AuthenticationModule authModule = WGFactory.getAuthModuleFactory().getAuthModule(authImplClass, authOptions, db); db.setAuthenticationModule(authModule); } } // Enforce some plugin settings via db attributes if (usesDatabase) { db.setAttribute(DBATTRIB_PERSMODE, String.valueOf(pc.getPersonalisationMode())); } else { db.setAttribute(DBATTRIB_PERSMODE, String.valueOf(Constants.PERSMODE_SESSION)); } db.setAttribute(DBATTRIB_PERSSTATMODE, String.valueOf(Constants.PERSSTATMODE_SESSION)); db.setAttribute(DBATTRIB_PLUGIN_FILETIME, new Long(plugin.getFileLastModified())); db.setAttribute(DBATTRIB_PLUGIN_ID, plugin.getPluginID()); db.setAttribute(DBATTRIB_PLUGIN_VERSION, plugin.getPluginID().getVersion()); if (!pc.isUsageAsContentStore()) { db.setAttribute(DBATTRIB_ALLOW_PUBLISHING, "false"); } if (!pc.isShowOnStartPage()) { db.setAttribute(DBATTRIB_STARTPAGE, "false"); } // Configure design provider DesignReference ref = new DesignReference(Constants.DESIGNCOL_PLUGIN, plugin.getInstallationKey(), null); Map<String, String> options = new HashMap<String, String>(); db.setDesignProvider( new FileSystemDesignProvider(ref, this, db, plugin.getDesignURL().toString(), options)); db.setAllowDesignModification(false); getDesignFileCache().flushGroup(ref.toString()); // Determine if ACL is empty boolean aclEmpty = false; try { if (db.isConnected() && db.hasFeature(WGDatabase.FEATURE_ACL_MANAGEABLE) && db.getACL().getAllEntries().size() == 0) { aclEmpty = true; } } catch (WGBackendException e1) { getLog().error("Error retrieving ACL state of db '" + db.getDbReference() + "'", e1); } // Process system container SystemContainerManager.SystemContainerContext scContext = null; try { scContext = _systemContainerManager.addDatabase(db, plugin, aclEmpty); } catch (Problem p) { throw p; } catch (Exception e) { throw new InvalidPluginException(plugin, "Exception processing system file container for plugin '" + plugin.getPluginID().getUniqueName() + "'", e); } // Build map of publisher options from wga.xml. We only use gobal options here since plugins have no own options in wga.xml // and csconfig.xml options are processed via system container Map<String, String> publisherOptions = new HashMap<String, String>(); // publisherOptions.putAll(_globalPublisherOptions); Plugins should not be influenced by global options of the current configuration if (scContext != null) { scContext.putPublisherOptions(publisherOptions); } // Publisher options initialisation which is equal for content dbs and plugins processPublisherOptions(db, publisherOptions); // Set plugin homepage. The method chooses either the plugin-specific homepage or the publisher option // Must be after publisher option initialisation to be able to react on them db.setAttribute(DBATTRIB_HOME_PAGE, plugin.getPluginHomepage()); // check if db is empty before hdb script runs boolean isEmptyDB = db.isContentEmpty(); // Validate default language definition if (!isEmptyDB) { db.determineDefaultLanguage(); } // Add listeners for events and register embedded event scripts db.addDatabaseEventListener(_eventManager); db.addContentEventListener(_eventManager); db.addWorkflowEventListener(_eventManager); if (db.isConnected()) { _eventManager.updateDatabaseEvents(db); } // Add file annotators updateFileAnnotators(db); // add File Converter db.setFileConverter(_fileConverter); // System container initialisations if (scContext != null) { scContext.performInitialisation(new Boolean(isEmptyDB)); if (isEmptyDB) { db.onConnect(new ValidateDefaultLanguageAction()); } } // Registering connection this.contentdbs.put(db.getDbReference(), db); performNewDBOperations(db); // Mark this database as fully connected db.setAttribute(DBATTRIB_FULLY_CONNECTED, "true"); // Initially create field mappings. These can only come from csconfig.xml for plugins updateFieldMappings(db, null); // Add to connected plugins connectedPlugins.add(db.getDbReference()); return db; } catch (Throwable e) { try { db.close(); } catch (WGAPIException e2) { // Silent failure of closing an uninitialized plugin bc. the connection failure is more important } plugin.setValid(false); if (e instanceof Problem) { throw (Problem) e; } else { throw new InvalidPluginException(plugin, "Error connecting plugin", e); } } }
From source file:com.viettel.hqmc.DAOHE.FilesDAOHE.java
/** * Ph duyt h s/*ww w . ja v a 2s.c om*/ * * @param form * @param deptId * @param deptName * @param userId * @param userName * @return */ public boolean onApprove(FilesForm form, Long deptId, String deptName, Long userId, String userName) { boolean bReturn = true; try { Files file = findById(form.getFileId()); Date dateNow = getSysdate(); if (file == null) { bReturn = false; } else { Long processStatus = file.getStatus(); /* REVIEWED = 5L;//? xem xt kt qu REVIEW_TO_ADD = 26L;// xem xt ni dung cv sbs REVIEW_TO_BOSS = 29L;//H s trnh cc trng xem xt APPROVE_TO_LEADER = 30L;//H s cc trng quyt nh APPROVE_TO_ADD ph duyt cng vn sa i b sung. EVALUATE_TO_ADD //Da soan du thao sua doi bo sung */ if (processStatus != null//141225 BINHNT update phan quyen ho so tham dinh && (processStatus.equals(Constants.FILE_STATUS.REVIEWED)//? xem xt kt qu || processStatus.equals(Constants.FILE_STATUS.REVIEW_TO_ADD)//? xem xt ni dung cv sbs || processStatus.equals(Constants.FILE_STATUS.APPROVE_TO_ADD)//? ph duyt ni dung thng bo VT || processStatus.equals(Constants.FILE_STATUS.REVIEW_TO_BOSS)//H s trnh cc trng xem xt || processStatus.equals(Constants.FILE_STATUS.APPROVE_TO_LEADER)//H s cc trng quyt nh || processStatus.equals(Constants.FILE_STATUS.EVALUATE_TO_ADD) //? son d tho sa i b sung || processStatus.equals(Constants.FILE_STATUS.FEDBACK_TO_ADD) //? tr li b sung h s || processStatus.equals(Constants.FILE_STATUS.EVALUATED) //? tr li b sung h s )) { file.setStatus(form.getStatus()); file.setDisplayStatus(getFileStatusName(form.getStatus())); String dateTime = DateTimeUtils.convertDateToString(dateNow, "dd/MM/yyyy HH:mm"); if (!form.getStatus().equals(Constants.FILE_STATUS.APPROVE_TO_ADD)) { file.setLeaderRequest(userName + " " + dateTime + ":\n" + form.getLeaderRequest()); file.setDisplayRequest(form.getLeaderRequest()); } else { file.setLeaderRequest(userName + " " + dateTime + ":\n" + "? ph duyt ni dung cng vn yu cu S?BS"); file.setDisplayRequest("? ph duyt ni dung cng vn yu cu S?BS"); } file.setModifyDate(dateNow); file.setLeaderStaffSignId(userId); file.setLeaderStaffSignName(userName); // Cap nhat process ProcessDAOHE pdhe = new ProcessDAOHE(); Process oldP = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, processStatus, Constants.FILE_STATUS.NEW_CREATE); if (oldP != null) { oldP.setStatus(form.getStatus()); oldP.setLastestComment(form.getLeaderRequest()); getSession().update(oldP); } //to process mi vi x l hin ti Process newP = new Process(); newP.setObjectId(form.getFileId()); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setSendDate(dateNow); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); newP.setProcessStatus(form.getStatus()); // De xu ly newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); newP.setReceiveDate(dateNow); if (form.getStatus().equals(Constants.FILE_STATUS.APPROVED)) {//tr v? cho vn th thng bo i chiu newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); rcbo.setContent(form.getLeaderStaffRequest()); file.setComparisonContent(form.getLeaderStaffRequest()); rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TBDC); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); //150119 binhnt53 update bo sung last change RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //!binhnt53 update bo sung last change ProcedureDAOHE pdheNew = new ProcedureDAOHE(); Procedure pro = pdheNew.findById(file.getFileType()); //Hiepvv 0803 Khong xet lai phi cho SDBS sau cong bo if (!"01".equals(pro.getCode()) && !"02".equals(pro.getCode()) && !"announcementFile05".equals(pro.getDescription())) { file.setIsFee(0l); //update binhnt // if ("true".equals(ResourceBundleUtil.getString("send_service", "config"))) { // Helper h = new Helper(); // h.sendMs_340(file.getFileId(), "Ho so ma: " + file.getFileCode() + " Da duoc phe duyet yeu cau nop phi ho so."); // } } /* i lung binhnt53 140914 // Phe duyet oke, chuyen ho so xuong cho van thu tra ho so Process newP = new Process(); newP.setObjectId(form.getFileId()); newP.setObjectType(Constants.OBJECT_TYPE.FILES); newP.setSendDate(dateNow); newP.setSendGroup(deptName); newP.setSendGroupId(deptId); newP.setSendUserId(userId); newP.setSendUser(userName); newP.setProcessStatus(form.getStatus()); // De xu ly newP.setProcessType(Constants.PROCESS_TYPE.MAIN); newP.setStatus(0l); // Moi den chua xu ly newP.setIsActive(1l); newP.setReceiveDate(dateNow); //lay process cua VT tiep nhan Process pold = pdhe.getProcessByAction(form.getFileId(), Constants.Status.ACTIVE, Constants.OBJECT_TYPE.FILES, Constants.FILE_STATUS.RECEIVED, Constants.FILE_STATUS.ASSIGNED); if (pold != null) { newP.setReceiveGroup(pold.getSendGroup()); newP.setReceiveGroupId(pold.getSendGroupId()); newP.setReceiveUser(pold.getSendUser()); newP.setReceiveUserId(pold.getSendUserId()); } else { newP.setReceiveUser(deptName); newP.setReceiveUserId(deptId); } RequestComment rcbo = new RequestComment(); rcbo.setContent(form.getLeaderRequest()); file.setComparisonContent(form.getLeaderRequest()); file.setIsFee(0L);//bay gio tinh phi giay cong bo rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType("YKPD"); getSession().save(rcbo); getSession().save(newP); */ } else { if (form.getStatus().equals(Constants.FILE_STATUS.REVIEWED_TO_ADD)) {//da xem xet yc sdbs //lay process tham dinh ho so tra ve cho chuyen vien tham dinh chinh //gui den chuyen vien xu ly if (oldP != null) { newP.setReceiveGroup(oldP.getSendGroup()); newP.setReceiveGroupId(oldP.getSendGroupId()); } newP.setReceiveUser(file.getNameStaffProcess()); newP.setReceiveUserId(file.getStaffProcess()); //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); rcbo.setContent(file.getLeaderRequest()); rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TBSDBS); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //cap nhat noi dung thong bao - tao noi dung thong bao } if (form.getStatus().equals(Constants.FILE_STATUS.APPROVE_TO_ADD)) {//ldc phe duyet noi dung chuyen cho vt gui cong van sdbs if (deptId.equals(file.getAgencyId())) { newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); } else { newP.setReceiveGroup(file.getAgencyName()); newP.setReceiveGroupId(file.getAgencyId()); } //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); if (file.getLeaderRequest() != null) { rcbo.setContent(form.getLeaderRequest()); } else { rcbo.setContent("Lnh o phng cha c ni dung."); } rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TBSDBS); //u150119 binhnt53 RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //!cap nhat noi dung thong bao - tao noi dung thong bao //tang so ho so di CountNoDAOHE cndaohe = new CountNoDAOHE(); CountNo cnbo = cndaohe.returnCountNoByDeptId(deptId); if (cnbo != null && cnbo.getSendNo() > 0L) { Long nCount = cnbo.getSendNo(); cnbo.setSendNo(nCount + 1); getSession().update(cnbo); } else if (file != null && file.getAgencyId() > 0L) { cnbo = cndaohe.returnCountNoByDeptId(file.getAgencyId()); Long nCount = cnbo.getSendNo(); cnbo.setSendNo(nCount + 1); getSession().update(cnbo); } } if (form.getStatus().equals(Constants.FILE_STATUS.FEDBACK_TO_REVIEW)) {//160406 //lanh dao cuc tu choi phe duyet cong van thong bao sdbs chuyen cho lanh dao phong xem xet lai if (oldP != null) { newP.setReceiveGroup(oldP.getSendGroup()); newP.setReceiveGroupId(oldP.getSendGroupId()); newP.setReceiveUser(oldP.getSendUser()); newP.setReceiveUserId(oldP.getSendUserId()); } //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); if (file.getLeaderRequest() != null) { rcbo.setContent(form.getLeaderRequest()); } else { rcbo.setContent("Lnh o phng cha c ni dung."); } rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TBSDBS); RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //!cap nhat noi dung thong bao - tao noi dung thong bao } if (form.getStatus().equals(Constants.FILE_STATUS.REVIEW_TO_BOSS)) {//- luong pho cuc truong gui trinh len lanh dao cuc //- tim cuc truong de gui UsersDAOHE udaohe = new UsersDAOHE(); Users ubo = udaohe.findUserByPosition(deptId, Constants.POSITION.LEADER_CT); if (ubo != null) { newP.setReceiveUser(ubo.getFullName()); newP.setReceiveUserId(ubo.getUserId()); } newP.setReceiveGroup(deptName); newP.setReceiveGroupId(deptId); //cap nhat noi dung thong bao - tao noi dung thong bao RequestComment rcbo = new RequestComment(); if (file.getLeaderRequest() != null) { rcbo.setContent(form.getLeaderRequest()); } else { rcbo.setContent("Lnh o phng cha c ni dung."); } rcbo.setCreateBy(userId); rcbo.setCreateDate(dateNow); rcbo.setUserId(userId); rcbo.setUserName(userName); rcbo.setStatus(1L); rcbo.setIsActive(1L); rcbo.setGroupId(deptId); rcbo.setGroupName(deptName); rcbo.setIsLastChange(Constants.ACTIVE_STATUS.ACTIVE); rcbo.setObjectId(form.getFileId()); rcbo.setRequestType(Constants.REQUEST_COMMENT_TYPE.TCT);//trinh cuc truong RequestCommentDAOHE rqdaohe = new RequestCommentDAOHE(); RequestComment lastRQBo = rqdaohe.findLastRequestComment(file.getFileId(), Constants.ACTIVE_STATUS.ACTIVE); if (lastRQBo != null) { rcbo.setLastContent(lastRQBo.getContent()); lastRQBo.setIsLastChange(Constants.ACTIVE_STATUS.DEACTIVE); getSession().update(lastRQBo); } getSession().save(rcbo); //!cap nhat noi dung thong bao - tao noi dung thong bao } } getSession().save(newP); update(file); //onCreatePaper(form, deptId, deptName, userId, userName); if (form.getStatus().equals(Constants.FILE_STATUS.APPROVED)) { ProcedureDAOHE pcdaohe = new ProcedureDAOHE(); Procedure procedure = pcdaohe.findById(file.getFileType()); if (procedure != null && procedure.getProcedureId() > 0) { if (!procedure.getDescription().equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE01) && !procedure.getDescription() .equals(Constants.FILE_DESCRIPTION.ANNOUNCEMENT_FILE03)) { //sms MessageSmsDAOHE msdhe = new MessageSmsDAOHE(); String msg = "Ho so ma: " + file.getFileCode() + " cua doanh nghiep: " + file.getBusinessName() + " dang trong trang thai: da phe duyet, doanh nghiep luu y dong le phi cap so de duoc cap ban cong bo"; msdhe.saveMessageSMS(userId, file.getUserCreateId(), msg); //email MessageEmailDAOHE msedhe = new MessageEmailDAOHE(); String msge = "H s m: " + file.getFileCode() + " ca doanh nghip: " + file.getBusinessName() + " ang trong trng thi: ph duyt, doanh nghip lu ng l ph cp s c cp bn cng b"; msedhe.saveMessageEmail(userId, file.getUserCreateId(), msge); } } //update binhnt // try { // if ("true".equals(ResourceBundleUtil.getString("send_service", "config"))) { // Helper h = new Helper(); // h.sendMs_340(file.getFileId(), "Ho so ma: " + file.getFileCode() + " Da duoc phe duyet yeu cau nop phi ho so."); // } // } catch (UnsupportedEncodingException ex) { // Logger.getLogger(FilesDAOHE.class.getName()).log(Level.SEVERE, null, ex); // } } } else { return false; } } } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 bReturn = false; } return bReturn; }