/** * 功能:获得MIS的员工信息 * * @throws QueryException * @throws ContainerException */ private void appendUserData(EtsItemInfoDTO itemDTO, EtsFaAssetsDTO faDTO) throws QueryException { try { SQLModel sqlModel = modelProducer.getMISemployee(faDTO.getAssignedToNumber()); SimpleQuery sq = new SimpleQuery(sqlModel, conn); sq.executeQuery(); if (sq.hasResult()) { Row row = sq.getFirstRow(); itemDTO.setResponsibilityDept(row.getStrValue("DEPT_CODE")); itemDTO.setResponsibilityUser(row.getStrValue("EMPLOYEE_ID")); } } catch (ContainerException ex) { ex.printLog(); throw new QueryException(ex); } }
/** * 功能:获得ProjectId * * @throws QueryException * @throws ContainerException */ private void appendProjIdData(EtsItemInfoDTO itemDTO, EtsFaAssetsDTO faDTO) throws QueryException { try { SQLModel sqlModel = modelProducer.getProId(faDTO.getProjectid()); SimpleQuery sq = new SimpleQuery(sqlModel, conn); sq.executeQuery(); if (sq.hasResult()) { Row row = sq.getFirstRow(); itemDTO.setProjectid((String) row.getValue("PROJECT_ID")); } } catch (ContainerException ex) { ex.printLog(); throw new QueryException(ex); } }
/** * 功能:获得MIS的员工信息 * * @throws QueryException * @throws ContainerException */ private void appendAddressData(EtsItemInfoDTO itemDTO, EtsFaAssetsDTO faDTO) throws QueryException { try { SQLModel sqlModel = modelProducer.getLocId(faDTO.getAssetsLocationCode(), faDTO.getOrganizationId()); SimpleQuery sq = new SimpleQuery(sqlModel, conn); sq.executeQuery(); if (sq.hasResult()) { Row row = sq.getFirstRow(); itemDTO.setAddressId((String) row.getValue("ADDRESS_ID")); } } catch (ContainerException ex) { ex.printLog(); throw new QueryException(ex); } }
/** * 功能:插入地点信息 * * @throws DataHandleException */ private void matchData(EtsItemInfoDTO itemDTO, EtsFaAssetsDTO faDTO) throws DataHandleException { String[] systemids = new String[] {itemDTO.getSystemId() + "@@@" + faDTO.getAssetId()}; BarcodeMatchDTO baDTO = new BarcodeMatchDTO(); BarcodeMatchDAO barcodeMatchDAO = new BarcodeMatchDAO(userAccount, baDTO, conn); barcodeMatchDAO.doMatch(systemids); }
/** * 功能:插入租赁土地资产(EAM)表“AMS_LAND_INFO”数据。 * * @return boolean */ public boolean createData(EtsItemInfoDTO itemInfoDTO, String[] filePaths) throws DataHandleException { boolean operateResult = false; boolean autoCommit = false; boolean hasError = true; try { autoCommit = conn.getAutoCommit(); conn.setAutoCommit(false); AmsHouseInfoDTO landDTO = (AmsHouseInfoDTO) dtoParameter; String barcode = landDTO.getBarcode(); itemInfoDTO.setItemCode(landDTO.getItemCode()); // 分类编码 itemInfoDTO.setBarcode(landDTO.getBarcode()); // 获得Barcode EtsItemInfoDAO itemInfoDAO = new EtsItemInfoDAO(userAccount, itemInfoDTO, conn); boolean hasBarcode = hasBarcode(landDTO.getBarcode()); if (hasBarcode) { // 如果在表ETS_ITEM_INFO存在Barcode即对其进行修改,否则进行插入操作 itemInfoDAO.updateAttribute1( landDTO.getBarcode()); // 跟据Barcode对表ETS_ITEM_INFO进行修改操作,即对 ‘ATTRIBUTE1’的值改为"RENT" 改用 // Barcode } else { itemInfoDAO.createData(); // 对表 ETS_ITEM_INFO 进行插入操作 } super.createData(); // 对表 AMS_LAND_INFO 进行插入操作 if (landDTO .getIsRent() .equals("Y")) { // 判断表 AMS_LAND_INFO 中的字段 ‘IS_RENT’的值 ;1,若=‘Y’对表 AMS_RENT_INFO 进行插入操作 creatRentData(); // 插入表AMS_RENT_INFO字段 barcode 对其主键 RENT_ID 自动生成 } // ---对表AMS_ITEM_FILES进行操作 if (!StrUtil.isEmpty(filePaths)) { for (int i = 0; i < filePaths.length; i++) { AmsItemFilesDTO fileDTO = new AmsItemFilesDTO(); fileDTO.setBarcode(barcode); String filedp[] = StrUtil.splitStr(filePaths[i], "$"); fileDTO.setFileDesc(filedp[0]); fileDTO.setFilePath(filedp[1]); AmsItemFilesDAO amsItemFilesDAO = new AmsItemFilesDAO(userAccount, fileDTO, conn); amsItemFilesDAO.setDTOClassName(AmsItemFilesDTO.class.getName()); amsItemFilesDAO.createData(); } } operateResult = true; conn.commit(); hasError = false; prodMessage(MsgKeyConstant.CREATE_DATA_SUCCESS); getMessage().addParameterValue("土地数据"); } catch (SQLException ex) { Logger.logError(ex); prodMessage(MsgKeyConstant.SQL_ERROR); } catch (SQLModelException ex) { Logger.logError(ex); prodMessage(MsgKeyConstant.SQL_ERROR); } catch (QueryException ex) { Logger.logError(ex); prodMessage(MsgKeyConstant.SQL_ERROR); try { if (hasError) { conn.rollback(); // 回滚 } conn.setAutoCommit(autoCommit); // 恢复以前状态 } catch (SQLException e) { Logger.logError(e); prodMessage(MsgKeyConstant.ROLL_BACK_ERROR); } } return operateResult; }
/** * 提交工单 * * @param dtoSet * @return * @throws QueryException * @throws DataHandleException */ private boolean importEAMhouse(DTOSet dtoSet) throws DataHandleException { boolean operatorResult = false; try { if (dtoSet != null && dtoSet.getSize() > 0) { EtsFaAssetsDTO faDTO = null; EtsItemInfoDTO itemDTO = null; AmsHouseInfoDTO houseDTO = null; SystemItemHouse systemItemUtil = new SystemItemHouse(); for (int i = 0; i < dtoSet.getSize(); i++) { faDTO = (EtsFaAssetsDTO) dtoSet.getDTO(i); itemDTO = new EtsItemInfoDTO(); itemDTO.setBarcode(faDTO.getTagNumber()); itemDTO.setItemName(faDTO.getAssetsDescription()); itemDTO.setItemSpec(faDTO.getModelNumber()); itemDTO.setItemQty(StrUtil.nullToString(faDTO.getCurrentUnits())); itemDTO.setStartDate(faDTO.getDatePlacedInService().toString()); itemDTO.setItemCategory("HOUSE"); itemDTO.setAssetId(faDTO.getAssetId()); itemDTO.setOrganizationId(faDTO.getOrganizationId()); itemDTO.setFinanceProp("ASSETS"); itemDTO = systemItemUtil.checkSysItem(conn, itemDTO); appendProjIdData(itemDTO, faDTO); appendUserData(itemDTO, faDTO); appendAddressData(itemDTO, faDTO); if (StrUtil.isEmpty(itemDTO.getAddressId())) { addAddressData(faDTO); appendAddressData(itemDTO, faDTO); } if (StrUtil.isEmpty(itemDTO.getAddressId())) { continue; } houseDTO = new AmsHouseInfoDTO(); houseDTO.setBarcode(faDTO.getTagNumber()); houseDTO.setHouseAddress(faDTO.getAssetsLocation()); houseDTO.setHremark("house信息导入"); itemDTO.setSystemId(getNextSystemId()); itemDTO.setRemark("house信息导入"); if (!isExist(faDTO)) { insertEtsItemInfo(itemDTO); // IN ams_item_info } insertHouesInfo(houseDTO); // IN ams_house_info matchData(itemDTO, faDTO); // 进行匹配操作 } } operatorResult = true; } catch (DataHandleException ex) { ex.printLog(); throw new DataHandleException(ex); } catch (SQLException ex) { Logger.logError(ex); throw new DataHandleException(ex); } catch (ContainerException ex) { ex.printLog(); throw new DataHandleException(ex); } catch (QueryException ex) { ex.printLog(); throw new DataHandleException(ex); } catch (CalendarException ex) { ex.printLog(); throw new DataHandleException(ex); } return operatorResult; }
/** * 功能:修改数据。 * * @return boolean */ public boolean updateData( EtsItemInfoDTO itemInfoDTO, AmsItemFilesDTO fileDTO, String[] filePaths, DTOSet lineSet) throws DataHandleException { boolean operateResult = false; boolean autoCommit = false; boolean hasError = true; try { autoCommit = conn.getAutoCommit(); conn.setAutoCommit(false); AmsHouseInfoDTO HLDTO = (AmsHouseInfoDTO) dtoParameter; AmsHouseInfoModel model = new AmsHouseInfoModel(userAccount, HLDTO); SQLModel sqlModel1 = model.deleteUsesInfo(); DBOperator.updateRecord(sqlModel1, conn); String barcode = HLDTO.getBarcode(); super.updateData(); // 对表AMS_house_INFO进行修改操作 itemInfoDTO.setBarcode(HLDTO.getBarcode()); // 标签号 itemInfoDTO.setItemCode(HLDTO.getItemCode()); // 分类编码 itemInfoDTO.setSystemid(HLDTO.getSystemId()); // 根据SYSTEMID进行修改; if (!HLDTO.getTemp().equals("Y")) { GetMisHousInfoModel updateEII = new GetMisHousInfoModel(userAccount, HLDTO); SQLModel eiiSqlModel = updateEII.getEiiData(HLDTO.getBarcode()); DBOperator.updateRecord(eiiSqlModel, conn); } // EtsItemInfoDAO itemInfoDAO = new EtsItemInfoDAO(userAccount,itemInfoDTO,conn); // itemInfoDAO.updateData(); //对表ETS_ITEM_INFO进行修改操作 // if (landDTO.getIsRent().equals("Y")) { //表 AMS_RENT_INFO (RENT_ID ) 修改 // 先删除 再增加 // deleteRentData(); // creatRentData(); // } else { // deleteRentData(); //对表 AMS_RENT_INFO 进行删除操作 // } saveUses(lineSet); // --------------对表 AMS_ITEM_FILES 进行修改操作 先删除再增加 AmsItemFilesModel sqlModel = new AmsItemFilesModel(userAccount, fileDTO); DBOperator.updateRecord(sqlModel.getDeleteModel(barcode), conn); if (!StrUtil.isEmpty(filePaths)) { SeqProducer seq = new SeqProducer(conn); for (int i = 0; i < filePaths.length; i++) { fileDTO.setBarcode(barcode); String filedp[] = StrUtil.splitStr(filePaths[i], "$"); fileDTO.setFileDesc(filedp[0]); fileDTO.setFilePath(filedp[1]); fileDTO.setSystemId(seq.getGUID()); DBOperator.updateRecord(sqlModel.getCreateModel(), conn); } } operateResult = true; conn.commit(); hasError = false; prodMessage(MsgKeyConstant.UPDATE_DATA_SUCCESS); getMessage().addParameterValue("未处置信息"); } catch (SQLException ex) { Logger.logError(ex); prodMessage(MsgKeyConstant.SQL_ERROR); // } catch (SQLModelException ex) { // Logger.logError(ex); // prodMessage(MsgKeyConstant.SQL_ERROR); } catch (QueryException e) { Logger.logError(e); // prodMessage(MsgKeyConstant.SQL_ERROR); } finally { try { if (hasError) { conn.rollback(); // 回滚 } conn.setAutoCommit(autoCommit); // 恢复以前状态 } catch (SQLException ex) { Logger.logError(ex); prodMessage(MsgKeyConstant.ROLL_BACK_ERROR); } } return operateResult; }