/** 同步公司间调拨 */ public void synTransBtwCompany(Connection conn, SfUserDTO user) { long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { logDTO = new SynLogDTO(); logDTO.setSynType("BTWTRANSCOMPANY"); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS公司间调拨开始"); logUtil.synLog(logDTO, conn); SBFIFAAssetsTransBtwCompanyDAO commitDAO = new SBFIFAAssetsTransBtwCompanyDAO(user, new SBFIFAAssetsTransBtwCompanyDTO(), conn); commitDAO.autoSyschronizeAssets(); resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType("BTWTRANSCOMPANY"); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS公司间调拨结束。耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (Exception e) { Logger.logError(e); } }
/** 查询会计期间 */ public void synPeriodStatus(Connection conn, SfUserDTO user) { int trueCount = 0; int totalCount = 0; long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { InquiryAssetPeriodStatusSrv service = new InquiryAssetPeriodStatusSrv(); SrvAssetPeriodStatusDTO dtoParameter = new SrvAssetPeriodStatusDTO(); SrvAssetPeriodDAO srvAssetPeriodDAO = new SrvAssetPeriodDAO(user, dtoParameter, conn); String bookType[] = logUtil.getBookTypeCodeModel(conn, MIS_CONSTANT.SOURCE_MIS); SrvReturnMessage srm = new SrvReturnMessage(); for (int i = 0; i < bookType.length; i++) { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_PERIOD); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg(bookType[i] + ":同步MIS资产会计期间开始"); logUtil.synLog(logDTO, conn); service.setBookTypeCode(bookType[i]); service.execute(); srm = service.getReturnMessage(); if (srm.getErrorFlag().equals("Y")) { DTOSet ds = service.getDs(); totalCount += ds.getSize(); trueCount += srvAssetPeriodDAO.synAssetPeriod(ds); } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_PERIOD); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( bookType[i] + ":同步MIS资产会计期间结束。同步" + totalCount + "条记录,成功" + trueCount + ",失败" + (totalCount - trueCount) + ",耗时" + resumeTime + "毫秒"); if (srm.getErrorFlag().equals("N")) { logDTO.setSynMsg(logDTO.getSynMsg() + ".错误信息:" + srm.getErrorMessage()); } logUtil.synLog(logDTO, conn); } if (totalCount == trueCount) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_FA_PERIOD, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_FA_PERIOD, conn); } } catch (Exception e) { Logger.logError(e); } }
/** 查询资产财务信息服务(ODI) */ public void synAssetInfo(Connection conn, SfUserDTO user, String periodName) { long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); boolean hasError = false; try { truncateData("ZTE_FA_ASSET_INFO", conn); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_TRANS_ASSET); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS资产财务信息(ODI)开始"); logUtil.synLog(logDTO, conn); String bookTypeCodes[] = logUtil.getBookTypeCode(conn, MIS_CONSTANT.SOURCE_MIS); // 唐明胜修改,增加获取无形资产的账簿代码 String envCode = SynUpdateDateUtils.getEnvCode("TransFaAssetInfoSrv", conn); // String periodName = // SynUpdateDateUtils.getPeriodName(SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_FA_TRANS_ASSET, conn)); // 唐明胜注释,会计期间需要获取关闭的最大会计期间 TransFaAssetInfoSrv transAssetInfoSrv = new TransFaAssetInfoSrv(); for (int i = 0; i < bookTypeCodes.length; i++) { transAssetInfoSrv.setEnvCode(envCode); transAssetInfoSrv.setPeriodName(periodName); transAssetInfoSrv.setBookTypeCode(bookTypeCodes[i]); transAssetInfoSrv.excute(); SrvReturnMessage srvMessage = transAssetInfoSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_TRANS_ASSET); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS资产财务信息(ODI)成功。耗时" + resumeTime + "毫秒。"); logUtil.synLog(logDTO, conn); } else { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_TRANS_ASSET); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS资产财务信息(ODI)失败。耗时" + resumeTime + "毫秒。错误信息:" + srvMessage.getErrorMessage()); logUtil.synLog(logDTO, conn); } } } catch (Throwable e) { Logger.logError(e); hasError = true; } finally { if (!hasError) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_FA_TRANS_ASSET, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_FA_TRANS_ASSET, conn); } } }
/** 查询组织结构 */ public void synOrgstructure(Connection conn, SfUserDTO user) { int count = 0; long resumeTime = 0; int falsecount = 0; long start = System.currentTimeMillis(); SynLogDTO logDTO = null; try { SynLogUtil logUtil = new SynLogUtil(); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_ORG_STRUCTURE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS组织结构开始"); logUtil.synLog(logDTO, conn); SBHRHRInquiryOrgStructureSrv service = new SBHRHRInquiryOrgStructureSrv(); service.excute(); SrvReturnMessage srm = service.getReturnMessage(); SBHRHRInquiryOrgStructureDAO dao = new SBHRHRInquiryOrgStructureDAO(user, new SBHRHRInquiryOrgStructureDTO(), conn); if (srm.getErrorFlag().equalsIgnoreCase("Y")) { DTOSet ds = service.getDs(); if (ds.getSize() > 0) { ds = filterDtoSet(ds); count = dao.synOrgStructure(ds); } } falsecount = dao.getErrorCount(); if (falsecount == 0) { // 没有发生错误才记录同步类型的更新时间 SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_ORG_STRUCTURE, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_ORG_STRUCTURE, conn); } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_ORG_STRUCTURE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS组织结构结束。同步" + (count + falsecount) + "条记录,成功" + count + ",失败" + (falsecount) + ",耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (CalendarException e) { Logger.logError(e); } catch (DTOException e) { Logger.logError(e); } catch (DataHandleException e) { Logger.logError(e); } }
/** 查询资产类别 */ public void synAssetCategory(Connection conn, SfUserDTO user) { int count = 0; long resumeTime = 0; int errorCount = 0; long start = System.currentTimeMillis(); SynLogDTO logDTO = null; try { SynLogUtil logUtil = new SynLogUtil(); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_CATEGORY); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS资产类别开始"); logUtil.synLog(logDTO, conn); SBFIFAInquiryAssetCategorySrv service = new SBFIFAInquiryAssetCategorySrv(); String lastUpdateDate = logUtil.getLastUpdateDate(SrvType.SRV_FA_CATEGORY, conn); SBFIFASrvAssetCategoryDAO srvAssetCategoryDAO = new SBFIFASrvAssetCategoryDAO(user, new SBFIFASrvAssetCategoryDTO(), conn); service.setLastUpdateDate(lastUpdateDate); service.execute(); SrvReturnMessage srm = service.getReturnMessage(); if (srm.getErrorFlag().equals("Y")) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_FA_CATEGORY, conn); DTOSet ds = service.getDs(); if (ds.getSize() > 0) { count = srvAssetCategoryDAO.SavaAssetCategory(ds); } SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_FA_CATEGORY, conn); } errorCount = srvAssetCategoryDAO.getErrorCount(); resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_CATEGORY); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS资产类别结束,成功" + count + ",失败" + errorCount + ",耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (DatatypeConfigurationException e) { Logger.logError(e); } catch (PoolException e) { Logger.logError(e); } catch (QueryException e) { Logger.logError(e); } catch (ContainerException e) { Logger.logError(e); } catch (CalendarException e) { Logger.logError(e); } catch (DTOException e) { Logger.logError(e); } catch (DataHandleException e) { Logger.logError(e); } }
/** 查询供应商信息 */ public void synVendorInfo(Connection conn, SfUserDTO user) { int count = 0; int errorCount = 0; long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_VENDOR); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS供应商信息开始"); logUtil.synLog(logDTO, conn); InquiryVendorInfoSrv service = new InquiryVendorInfoSrv(); service.setLastUpdateDate(SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_VENDOR, conn)); service.excute(); SrvReturnMessage srvMessage = service.getReturnMessage(); SrvVendorInfoDAO srvVendorInfoDAO = new SrvVendorInfoDAO(user, new SrvVendorInfoDTO(), conn); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_VENDOR, conn); DTOSet ds = service.getDs(); if (ds.getSize() > 0) { count = srvVendorInfoDAO.synVendorInfo(ds); } SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_VENDOR, conn); } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_VENDOR); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS供应商信息结束。同步" + (count + errorCount) + "条记录,成功" + count + ",失败" + errorCount + ",耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (DataHandleException e) { Logger.logError(e); } catch (QueryException e) { Logger.logError(e); } catch (ContainerException e) { Logger.logError(e); } catch (Exception e) { Logger.logError(e); } }
/** 查询科目余额(ODI) */ public void synAccountBlance(Connection conn, SfUserDTO user, String periodName) { long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); boolean hasError = false; try { truncateData("ZTE_GL_ACCOUNT_BALANCE", conn); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_ACCOUNT_BALANCE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS科目余额(ODI)开始"); logUtil.synLog(logDTO, conn); SBFIGLTransAccountBalanceSrv transAccountBalanceSrv = new SBFIGLTransAccountBalanceSrv(); String envCode = SynUpdateDateUtils.getEnvCode("TransAccountBalanceSrv", conn); // String periodName = // SynUpdateDateUtils.getPeriodName(SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_ACCOUNT_BALANCE, conn)); // 唐明胜注释,会计期间需要获取最大已关闭会计期间 transAccountBalanceSrv.setEnvCode(envCode); transAccountBalanceSrv.setPeriodName(periodName); transAccountBalanceSrv.excute(); SrvReturnMessage srvMessage = transAccountBalanceSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_ACCOUNT_BALANCE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS科目余额(ODI)成功。耗时" + resumeTime + "毫秒。"); logUtil.synLog(logDTO, conn); } else { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_ACCOUNT_BALANCE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS科目余额(ODI)失败。耗时" + resumeTime + "毫秒。错误信息:" + srvMessage.getErrorMessage()); logUtil.synLog(logDTO, conn); hasError = true; } } catch (Throwable e) { Logger.logError(e); hasError = true; } finally { if (!hasError) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_ACCOUNT_BALANCE, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_ACCOUNT_BALANCE, conn); } } }
public SQLModel getDataUpdateModel() throws SQLModelException { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); AmsSpareCategoryDTO amsSpareCategory = (AmsSpareCategoryDTO) dtoParameter; String sqlStr = "UPDATE AMS_SPARE_CATEGORY" + " SET" + " ITEM_NAME = ?," + " ITEM_SPEC = ?," + " ITEM_CATEGORY = ?," + " SPARE_USAGE = ?," + " VENDOR_ID = ?," + " ITEM_UNIT = ?," + " REMARK = ?," + " LAST_UPDATE_DATE = GETDATE()," + " LAST_UPDATE_BY = ?" + " WHERE " + " BARCODE = ?"; sqlArgs.add(amsSpareCategory.getItemName()); sqlArgs.add(amsSpareCategory.getItemSpec()); sqlArgs.add(amsSpareCategory.getItemCategory()); sqlArgs.add(amsSpareCategory.getSpareUsage()); sqlArgs.add(amsSpareCategory.getVendorId()); sqlArgs.add(amsSpareCategory.getItemUnit()); sqlArgs.add(amsSpareCategory.getRemark()); sqlArgs.add(sfUser.getUserId()); sqlArgs.add(amsSpareCategory.getBarcode()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
public SQLModel getDataCreateModel() throws SQLModelException { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); AmsSpareCategoryDTO amsSpareCategory = (AmsSpareCategoryDTO) dtoParameter; String sqlStr = "INSERT INTO " + " AMS_SPARE_CATEGORY(" + " BARCODE," + " ITEM_NAME," + " ITEM_SPEC," + " ITEM_CATEGORY," + " SPARE_USAGE," + " VENDOR_ID," + " ITEM_UNIT," + " REMARK," + " CREATION_DATE," + " CREATED_BY" + ") VALUES (" + " ?, ?, ?, ?, ?, ?, ?, ?, GETDATE(), ?)"; sqlArgs.add(amsSpareCategory.getBarcode()); sqlArgs.add(amsSpareCategory.getItemName()); sqlArgs.add(amsSpareCategory.getItemSpec()); sqlArgs.add(amsSpareCategory.getItemCategory()); sqlArgs.add(amsSpareCategory.getSpareUsage()); sqlArgs.add(amsSpareCategory.getVendorId()); sqlArgs.add(amsSpareCategory.getItemUnit()); sqlArgs.add(amsSpareCategory.getRemark()); sqlArgs.add(sfUser.getUserId()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** 查询项目任务信息(ODI) */ public void synTransTaskInfo(Connection conn, SfUserDTO user) { long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_PA_TASK); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS项目任务信息(ODI)开始"); logUtil.synLog(logDTO, conn); TransTaskInfoSrv transTaskInfoSrv = new TransTaskInfoSrv(); String envCode = SynUpdateDateUtils.getEnvCode("TransTaskInfoSrv", conn); String lastUpdateDate = SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_PA_TASK, conn); transTaskInfoSrv.setEnvCode(envCode); transTaskInfoSrv.setStratLastUpdateDate(lastUpdateDate); transTaskInfoSrv.excute(); SrvReturnMessage srvMessage = transTaskInfoSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_PA_TASK, conn); resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_PA_TASK); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS项目任务信息(ODI)成功。耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_PA_TASK, conn); } else { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_PA_TASK); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS项目任务信息(ODI)失败。耗时" + resumeTime + "毫秒。错误信息:" + srvMessage.getErrorMessage()); logUtil.synLog(logDTO, conn); } } catch (QueryException e) { Logger.logError(e); } catch (ContainerException e) { Logger.logError(e); } catch (Exception e) { Logger.logError(e); } }
@SuppressWarnings("unchecked") public SQLModel getSyncErrorModel() { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); String sqlStr = "SELECT COUNT(1) SYNC_ERROR_COUNT FROM ETS_AUTO_SYN_LOG EASL WHERE EASL.SYN_TYPE = 'SYN_CUST_DETAIL' AND EASL.CREATED_BY = ?"; sqlArgs.add(sfUser.getUserId()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
@SuppressWarnings("unchecked") public SQLModel getDataLogDeleteModel() throws SQLModelException { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); String sqlStr = "DELETE FROM ETS_AUTO_SYN_LOG WHERE SYN_TYPE = 'SYN_CUST_DETAIL' AND CREATED_BY = ?"; sqlArgs.add(sfUser.getUserId()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
@SuppressWarnings("unchecked") public SQLModel getDataImpDeleteModel(String projectNum, String bookTypeCode) throws SQLModelException { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); String sqlStr = "DELETE FROM ETS_TD_CUST_DETAIL_IMP2 WHERE BOOK_TYPE_CODE=? AND CREATE_USER_ID = ? AND PROJRCT_NUMBER= ? "; sqlArgs.add(bookTypeCode); sqlArgs.add(sfUser.getUserId()); sqlArgs.add(projectNum); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** * 功能:失效 * * @return SQLModel 返回数据删除用SQLModel */ public SQLModel getDataDeleteModel() { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter; String sqlStr = "UPDATE AMS_YJ_ITEM\n" + "SET DISABLE_DATE=GETDATE()," + " LAST_UPDATE_DATE = GETDATE()," + " LAST_UPDATE_USER = ?" + " WHERE" + " ITEM_CODE = CONVERT(FLOAT,?)"; sqlArgs.add(sfUser.getUserId()); sqlArgs.add(amsYjItem.getItemCode()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
@SuppressWarnings("unchecked") public SQLModel getErrorRowModel() { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); String sqlStr = "SELECT EASL.SYN_TYPE,\n" + " EASL.SYN_DATE,\n" + " EASL.SYN_MSG\n" + " FROM ETS_AUTO_SYN_LOG EASL\n" + " WHERE EASL.SYN_TYPE = 'SYN_CUST_DETAIL'\n" + " AND CONVERT(INT, CONVERT(CHAR, EASL.SYN_DATE, 112)) = CONVERT(INT, CONVERT(CHAR, GETDATE(), 112))\n" + " AND EASL.CREATED_BY = ?"; sqlArgs.add(sfUser.getUserId()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** * 增加信息到(ETS_FA_NEW_LOC)网络资产新地点表(AMS) * * @param objectCode * @param batchId * @param userAccount * @return */ public SQLModel getInsertSynLogModel( String objectCode, String batchId, SfUserDTO userAccount, String priKey) { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); String sqlStr = "INSERT INTO ETS_FA_NEW_LOC\n" + " (LOCATION_ID,\n" + " CODE,\n" + " LOCATION,\n" + " STATUS,\n" + " ORGANIZATION_ID,\n" + " MSG,\n" + " BATCH_ID,\n" + " CREATED_BY,\n" + " CREATION_DATE)\n" + " (SELECT '" + priKey + "',\n" + " EOL.LOC2_CODE,\n" + " EOL.LOC2_DESC,\n" + // " 2,\n" +//唐明胜注释 " 0,\n" + // 唐明胜修改,1表示正在同步 // " EOCM.ORGANIZATION_ID,\n" + userAccount.getOrganizationId() + ",\n" + " '',\n" + " '" + batchId + "',\n" + " " + userAccount.getUserId() + ",\n" + " GETDATE()\n" + " FROM ETS_OBJECT_LOC2 EOL" + // " , ETS_OU_CITY_MAP EOCM\n" + // " WHERE EOL.COMPANY_CODE = EOCM.COMPANY_CODE\n" + " WHERE EOL.LOC2_CODE = ?)"; sqlArgs.add(objectCode); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** * 统计同步数量 * * @return */ @SuppressWarnings("unchecked") public SQLModel getSyncTotalCountModel(String projectNum) { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); String sqlStr = "SELECT COUNT(1) SYNC_TOTAL_COUNT \n" + "FROM ETS_TD_CUST_DETAIL_IMP2 EFCDI \n" + "WHERE EFCDI.CREATE_USER_ID = ? \n" + "AND PROJRCT_NUMBER= ? \n" + "AND EFCDI.TAG_NUMBER IS NOT NULL\n" + "AND NOT EXISTS \n" + " (SELECT NULL\n" + " FROM ETS_ITEM_INFO EII\n" + " WHERE EFCDI.TAG_NUMBER = EII.BARCODE)"; sqlArgs.add(sfUser.getUserId()); sqlArgs.add(projectNum); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** * 功能:框架自动生成应急保障设备名称字典表 AMS_YJ_ITEM数据插入SQLModel,请根据实际需要修改。 * * @return SQLModel 返回数据插入用SQLModel * @throws SQLModelException 发生日历异常时转化为该异常抛出 */ public SQLModel getDataCreateModel() throws SQLModelException { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter; String sqlStr = "INSERT INTO " + " AMS_YJ_ITEM(" + " ITEM_CODE," + " ITEM_NAME," + " ITEM_CATEGORY," + " CREATION_DATE," + " CREATE_USER" + ") VALUES (" + " CONVERT(FLOAT,?), ?, '装备', GETDATE(), ?)"; sqlArgs.add(amsYjItem.getItemCode()); sqlArgs.add(amsYjItem.getItemName()); sqlArgs.add(sfUser.getUserId()); sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** 查询员工信息 */ public void synEmployeeInfo(Connection conn, SfUserDTO user) { long resumeTime = 0; int baseErrorCount = 0; int baseTotalCount = 0; int assignErrorCount = 0; int assignTotalCount = 0; long start = System.currentTimeMillis(); SBHRHRInquiryEmpBaseInfoSrv employeeInfoSrv = new SBHRHRInquiryEmpBaseInfoSrv(); SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); try { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_EMPLOYEE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS员工信息开始"); logUtil.synLog(logDTO, conn); employeeInfoSrv.setStartLastUpdateDate( SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_EMPLOYEE, conn)); employeeInfoSrv.excute(); SrvReturnMessage srvMessage = employeeInfoSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { DTOSet ds = employeeInfoSrv.getDs(); SBHRHRSrvEmpInfoDAO srvEmployeeInfoDAO = new SBHRHRSrvEmpInfoDAO(user, null, conn); for (int i = 0; i < ds.getSize(); i++) { SBHRHRSrvEmployeeInfoDTO dto = (SBHRHRSrvEmployeeInfoDTO) ds.getDTO(i); srvEmployeeInfoDAO.setDTOParameter(dto); try { if (srvEmployeeInfoDAO.isServiceTypeExists(dto.getEmployeeNumber())) { srvEmployeeInfoDAO.updateData(); } else { srvEmployeeInfoDAO.createData(); } baseTotalCount++; } catch (Throwable e) { Logger.logError(e); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_EMPLOYEE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg(e.toString()); logUtil.synLog(logDTO, conn); baseErrorCount++; } } SBHRHRInquiryEmpAssignInfoSrv empAssignInfoSrv = new SBHRHRInquiryEmpAssignInfoSrv(); empAssignInfoSrv.setStartLastUpdateDate( SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_EMPLOYEE, conn)); empAssignInfoSrv.execute(); SrvReturnMessage empMessage = empAssignInfoSrv.getReturnMessage(); if (empMessage.getErrorFlag().equalsIgnoreCase("Y")) { DTOSet dtos = empAssignInfoSrv.getDs(); SBHRHRSrvEmpAssignDAO srvEmpAssignInfoDAO = new SBHRHRSrvEmpAssignDAO(user, null, conn); for (int i = 0; i < dtos.getSize(); i++) { SBHRHRSrvEmployeeInfoDTO dto = (SBHRHRSrvEmployeeInfoDTO) dtos.getDTO(i); srvEmpAssignInfoDAO.setDTOParameter(dto); try { if (srvEmpAssignInfoDAO.isEmployeeExists(dto.getEmployeeNumber())) { srvEmpAssignInfoDAO.updateData(); assignTotalCount++; } } catch (Throwable e) { Logger.logError(e); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_EMPLOYEE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg(e.toString()); logUtil.synLog(logDTO, conn); assignErrorCount++; } } } if (baseErrorCount + assignErrorCount == 0) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_EMPLOYEE, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_EMPLOYEE, conn); } } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_EMPLOYEE); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS员工信息结束。共同步" + (baseTotalCount + baseErrorCount + assignTotalCount + assignErrorCount) + "条记录," + "员工基本信息同步成功" + baseTotalCount + ",失败" + baseErrorCount + "," + "员工分配信息同步成功" + assignTotalCount + ",失败" + assignErrorCount + "," + "耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (Throwable e) { Logger.logError(e); } }
@SuppressWarnings("unchecked") public SQLModel getDataCreateModel() throws SQLModelException { SQLModel sqlModel = new SQLModel(); List sqlArgs = new ArrayList(); DealTdProjectDiversityCheckDTO srvAssetCategory = (DealTdProjectDiversityCheckDTO) dtoParameter; String sqlStr = "INSERT INTO " + " ETS_TD_CUST_DETAIL_IMP2(" + " TAG_NUMBER," + " ASSET_NAME," + " ASSET_DESCRIPTION," + " MODEL_NUMBER," + " ASSET_CATEGORY," + " ASSET_CATEGORY_DESC," + " UNIT_OF_MEASURE," + " EMPLOYEE_NUMBER," + " LOCATION_CODE," + " ASSET_LOCATION," + " MANUFACTORER_NAME," + " ATTRIBUTE4," + " ATTRIBUTE5," + " ATTRIBUTE6," + " ATTRIBUTE7," + " BOOK_TYPE_CODE," + " PROJRCT_NUMBER," + " ASSET_UNITS," // + " TASK_ID," + " PROJECT_ID," + " PROJECT_ASSET_ID," + " CREATE_USER_ID," + " CREATION_DATE," + " START_DATE , " // + " CUST_ID " + ") VALUES (" + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CONVERT(FLOAT, ?), CONVERT(FLOAT, ?), CONVERT(FLOAT, ?), CONVERT(FLOAT, ?), ?, GETDATE(), ? , NEWID())"; sqlArgs.add(srvAssetCategory.getTagNumber()); sqlArgs.add(srvAssetCategory.getAssetName()); sqlArgs.add(srvAssetCategory.getAssetDescription()); sqlArgs.add(srvAssetCategory.getModelNumber()); sqlArgs.add(srvAssetCategory.getAssetCategory()); sqlArgs.add(srvAssetCategory.getAssetCategoryDesc()); sqlArgs.add(srvAssetCategory.getUnitOfMeasure()); sqlArgs.add(srvAssetCategory.getEmployeeNumber()); sqlArgs.add(srvAssetCategory.getLocationCode()); sqlArgs.add(srvAssetCategory.getAssetLocation()); sqlArgs.add(srvAssetCategory.getManufactorerName()); sqlArgs.add(srvAssetCategory.getAttribute4()); sqlArgs.add(srvAssetCategory.getAttribute5()); sqlArgs.add(srvAssetCategory.getAttribute6()); sqlArgs.add(srvAssetCategory.getAttribute7()); sqlArgs.add(srvAssetCategory.getBookTypeCode()); sqlArgs.add(srvAssetCategory.getProjectNumber()); sqlArgs.add(srvAssetCategory.getAssetUnits()); // sqlArgs.add(srvAssetCategory.getTaskId()); sqlArgs.add(srvAssetCategory.getProjectId()); sqlArgs.add(srvAssetCategory.getProjectAssetId()); sqlArgs.add(sfUser.getUserId()); // 增加start_date sqlArgs.add(getHandleDateFromERP(srvAssetCategory.getDatePlacedInService())); // sqlModel.setSqlStr(sqlStr); sqlModel.setArgs(sqlArgs); return sqlModel; }
/** 查询资产分配行信息(ODI) */ public void synAssetDistribute(Connection conn, SfUserDTO user) { long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { truncateData("ZTE_FA_ASSET_DISTRIBUTION", conn); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_DISTRIBUTION); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS资产分配行信息(ODI)开始"); logUtil.synLog(logDTO, conn); TransAssetDistributionSrv transAssetDistributionSrv = new TransAssetDistributionSrv(); String envCode = SynUpdateDateUtils.getEnvCode("TransAssetDistributionSrv", conn); // String bookTypeCodes[] = logUtil.getBookTypeCodeModel(conn, // MIS_CONSTANT.SOURCE_MIS); String bookTypeCodes[] = logUtil.getBookTypeCode(conn, MIS_CONSTANT.SOURCE_MIS); // 唐明胜修改,增加获取无形资产的账簿代码 String lastUpdateDate = SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_FA_DISTRIBUTION, conn); boolean hasError = false; if (bookTypeCodes != null && bookTypeCodes.length > 0) { for (int i = 0; i < bookTypeCodes.length; i++) { transAssetDistributionSrv.setEnvCode(envCode); transAssetDistributionSrv.setBookTypeCode(bookTypeCodes[i]); transAssetDistributionSrv.setStratLastUpdateDate(lastUpdateDate); try { transAssetDistributionSrv.excute(); SrvReturnMessage srvMessage = transAssetDistributionSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_DISTRIBUTION); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS资产分配行信息(ODI)成功。耗时" + resumeTime + "毫秒,资产账簿:" + bookTypeCodes[i]); logUtil.synLog(logDTO, conn); } else { resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_DISTRIBUTION); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS资产分配行信息(ODI)失败。耗时" + resumeTime + "毫秒,资产账簿:" + bookTypeCodes[i] + "。错误信息:" + srvMessage.getErrorMessage()); logUtil.synLog(logDTO, conn); hasError = true; } } catch (Throwable ex) { hasError = true; } } if (!hasError) { // 记录日志位于最后,以免遗漏数据读取不过来 SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_FA_DISTRIBUTION, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_FA_DISTRIBUTION, conn); } } } catch (Throwable e) { Logger.logError(e); } }
/** * @param request ServletRequest * @param res ServletResponse * @param chain FilterChain * @throws IOException * @throws ServletException */ public void doFilter(ServletRequest request, ServletResponse res, FilterChain chain) throws IOException, ServletException { try { HttpServletRequest req = (HttpServletRequest) request; if (isStartLog && !req.getRemoteAddr().equals("127.0.0.1")) { SfUserDTO userAccount = (SfUserDTO) SessionUtil.getUserAccount(req); String reqUrl = req.getRequestURI(); if (userAccount != null) { if (reqUrl.indexOf(".jsp") > -1 || reqUrl.indexOf("/servlet") > -1) { String action = "查询"; String queryStr = req.getQueryString(); String[] paras = StrUtil.splitStr(queryStr, "&"); if (paras != null && paras.length > 0) { int index = -1; String singlePara = ""; String paraName = ""; for (int i = 0; i < paras.length; i++) { singlePara = paras[i]; if (singlePara == null) { continue; } index = singlePara.indexOf("="); if (index != -1) { paraName = singlePara.substring(0, index); if (paraName.equals("act")) { action = singlePara.substring(index + 1); break; } } } } if (!StrUtil.isEmpty(queryStr)) { reqUrl = reqUrl + "?" + queryStr; } FilterConfigDTO filterConfigDTO = SessionUtil.getFilterConfigDTO(req); if (reqUrl.equals(filterConfigDTO.getLoginSuccessURL())) { action = "登录"; } if (reqUrl.equals(filterConfigDTO.getLogOutServlet())) { action = "注销"; } SfUserLogDTO logData = new SfUserLogDTO(); logData.setUserId(userAccount.getUserId()); logData.setUserAccount(userAccount.getLoginName()); logData.setActionType(action); logData.setClientIp(req.getRemoteAddr()); logData.setReqUrl(reqUrl); logData.setServer(req.getServerName()); logData.setLogTime(CalendarUtil.getCurrCalendar()); logData(userAccount, logData); } } } if (chain != null) { chain.doFilter(req, res); } } catch (DataHandleException ex) { ex.printLog(); throw new ServletException(ex); } catch (CalendarException ex) { ex.printLog(); throw new ServletException(ex); } }
/** 查询资产地点 */ public void synFaLocation(Connection conn, SfUserDTO user) { int totalCount = 0; int count = 0; long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_LOCATION); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS资产地点开始"); logUtil.synLog(logDTO, conn); SrvAssetLocationSrv service = new SrvAssetLocationSrv(); SrvAssetLocationDTO dtoParameter = new SrvAssetLocationDTO(); SrvAssetLocationDAO srvAssetLocationDAO = new SrvAssetLocationDAO(user, dtoParameter, conn); service.setLastUpDate(SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_FA_LOCATION, conn)); SrvProcessModel spm = new SrvProcessModel(); SQLModel sqlModel = spm.getLocalCodeModel(MIS_CONSTANT.SOURCE_MIS, SinoConfig.getLoc1SetNameMis()); SimpleQuery simp = new SimpleQuery(sqlModel, conn); simp.executeQuery(); Row row = null; if (simp.hasResult()) { RowSet rs = simp.getSearchResult(); for (int i = 0; i < rs.getSize(); i++) { row = rs.getRow(i); String cc = row.getStrValue("FLEX_VALUE"); service.setSegment1(cc); service.excute(); SrvReturnMessage srm = service.getReturnMessage(); if (srm.getErrorFlag().equals("Y")) { DTOSet ds = service.getDs(); totalCount += ds.getSize(); if (ds.getSize() > 0) { count += srvAssetLocationDAO.synAssetLocation(ds, cc); } } } if (totalCount == count) { // 全部成功才更新同步类型日志,以免下次获取不到数据 SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_FA_LOCATION, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_FA_LOCATION, conn); } } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_FA_LOCATION); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS资产地点结束。同步" + totalCount + "条记录,成功" + count + ",失败" + (totalCount - count) + ",耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (Exception e) { Logger.logError(e); } }
/** 查询值集信息 */ public void synSetValue(Connection conn, SfUserDTO user, String source) { int totalCount = 0; long resumeTime = 0; int errorCount = 0; long start = System.currentTimeMillis(); SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); try { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_SET_VALUESET); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS值集值信息服务开始"); logUtil.synLog(logDTO, conn); SBSYSYInquiryVSetValueInfoDAO mFndFlexValuesDAO = new SBSYSYInquiryVSetValueInfoDAO(user, null, conn); List valuesList = mFndFlexValuesDAO.getAllFlexValues(source); if (valuesList != null && valuesList.size() > 0) { SBSYSYInquiryVSetValueInfoSrv setValueInfoSrv = new SBSYSYInquiryVSetValueInfoSrv(); setValueInfoSrv.setStartLastUpdateDate( SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_SET_VALUESET, conn)); for (int i = 0; i < valuesList.size(); i++) { String flexValueName = (String) valuesList.get(i); setValueInfoSrv.setFlexValueName(flexValueName); setValueInfoSrv.execute(); SrvReturnMessage srvMessage = setValueInfoSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { DTOSet ds = setValueInfoSrv.getDs(); for (int j = 0; j < ds.getSize(); j++) { SBSYSYInquiryVSetValueInfoDTO valueSetDTO = (SBSYSYInquiryVSetValueInfoDTO) ds.getDTO(j); mFndFlexValuesDAO.setDTOParameter(valueSetDTO); try { if (mFndFlexValuesDAO.isexistsSetValueModel( valueSetDTO.getFlexValue(), valueSetDTO.getFlexValueSetId())) { mFndFlexValuesDAO.updateData(); } else { mFndFlexValuesDAO.createData(); } totalCount++; } catch (Throwable e) { Logger.logError(e); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_SET_VALUESET); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg(e.toString()); logUtil.synLog(logDTO, conn); errorCount++; } } } } if (errorCount == 0) { SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_SET_VALUESET, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_SET_VALUESET, conn); } } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_SET_VALUESET); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS值集值信息服务结束。成功" + totalCount + ",失败" + errorCount + ",耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (Throwable e) { Logger.logError(e); } }
/** 查询项目信息 */ public void synProjectInfo(Connection conn, SfUserDTO user) { int totalCount = 0; int errorCount = 0; long resumeTime = 0; SynLogDTO logDTO = null; SynLogUtil logUtil = new SynLogUtil(); long start = System.currentTimeMillis(); try { logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_PA_PROJECT); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg("同步MIS项目信息开始"); logUtil.synLog(logDTO, conn); InquiryProjectInfoSrv projectInfoSrv = new InquiryProjectInfoSrv(); projectInfoSrv.execute(); SrvReturnMessage srvMessage = projectInfoSrv.getReturnMessage(); if (srvMessage.getErrorFlag().equalsIgnoreCase("Y")) { DTOSet ds = projectInfoSrv.getDs(); SrvProjectInfoDAO srvProjectInfoDAO = new SrvProjectInfoDAO(user, null, conn); for (int i = 0; i < ds.getSize(); i++) { SrvProjectInfoDTO dto = (SrvProjectInfoDTO) ds.getDTO(i); srvProjectInfoDAO.setDTOParameter(dto); try { if (SynUpdateDateUtils.getBetweenDays( SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_PA_PROJECT, conn), (dto.getLastUpdateDate().toString())) > 0) { if (srvProjectInfoDAO.isProjecdtExists(dto.getSegment1())) { srvProjectInfoDAO.updateData(); } else { srvProjectInfoDAO.createData(); } totalCount++; } } catch (Throwable e) { Logger.logError(e); logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_PA_PROJECT); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg(e.toString()); logUtil.synLog(logDTO, conn); errorCount++; } } if (errorCount == 0) { // 错误数为0时才能更新同步类型日志记录,否则可能造成数据遗漏 SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_PA_PROJECT, conn); SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_PA_PROJECT, conn); } } resumeTime = System.currentTimeMillis() - start; logDTO = new SynLogDTO(); logDTO.setSynType(SrvType.SRV_PA_PROJECT); logDTO.setCreatedBy(user.getUserId()); logDTO.setSynMsg( "同步MIS项目信息结束!成功" + totalCount + ",失败" + errorCount + ",耗时" + resumeTime + "毫秒"); logUtil.synLog(logDTO, conn); } catch (Throwable e) { Logger.logError(e); } }