9f11d0b85bc135558300a04dce62609916d6e1a7.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by FernFlower decompiler)
  4. //
  5. package com.kingdee.shr.base.syssetting.app.io.fileImport;
  6. import com.kingdee.bos.BOSException;
  7. import com.kingdee.bos.BOSObjectFactory;
  8. import com.kingdee.bos.Context;
  9. import com.kingdee.bos.ICommonBOSType;
  10. import com.kingdee.bos.dao.IObjectValue;
  11. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  12. import com.kingdee.bos.metadata.IMetaDataLoader;
  13. import com.kingdee.bos.metadata.MetaDataLoaderFactory;
  14. import com.kingdee.bos.metadata.MetaDataPK;
  15. import com.kingdee.bos.metadata.entity.EntityObjectInfo;
  16. import com.kingdee.bos.metadata.entity.EntityViewInfo;
  17. import com.kingdee.bos.metadata.entity.FilterInfo;
  18. import com.kingdee.bos.metadata.entity.FilterItemInfo;
  19. import com.kingdee.bos.metadata.entity.SelectorItemCollection;
  20. import com.kingdee.bos.metadata.entity.SelectorItemInfo;
  21. import com.kingdee.eas.common.EASBizException;
  22. import com.kingdee.eas.ep.CoreBillBaseCustomInfo;
  23. import com.kingdee.eas.ep.DataBaseCustomInfo;
  24. import com.kingdee.eas.framework.CoreBaseCollection;
  25. import com.kingdee.eas.framework.CoreBaseInfo;
  26. import com.kingdee.eas.framework.ICoreBase;
  27. import com.kingdee.eas.hr.base.app.filter.StructureConfigConvertHelper;
  28. import com.kingdee.eas.hr.emp.PersonCredentialsTypeInfo;
  29. import com.kingdee.shr.base.syssetting.BaseItemCustomInfo;
  30. import com.kingdee.shr.base.syssetting.ml.SHRWebResource;
  31. import com.kingdee.shr.base.syssetting.util.LocaleUtils;
  32. import com.kingdee.shr.base.syssetting.web.dynamic.model.DynamicModelInfo;
  33. import com.kingdee.shr.baseconfig.QueryConfigFieldInfo;
  34. import com.kingdee.shr.baseconfig.StructureConfigFilterColumnCollection;
  35. import com.kingdee.shr.baseconfig.StructureConfigFilterColumnInfo;
  36. import com.kingdee.shr.baseconfig.StructureConfigInfo;
  37. import com.kingdee.shr.shrimport.SHRImportTypeEnum;
  38. import com.kingdee.util.StringUtils;
  39. import com.kingdee.util.enums.Enum;
  40. import com.kingdee.util.enums.IntEnum;
  41. import com.kingdee.util.enums.StringEnum;
  42. import java.lang.reflect.Constructor;
  43. import java.sql.Timestamp;
  44. import java.text.MessageFormat;
  45. import java.util.ArrayList;
  46. import java.util.Date;
  47. import java.util.HashMap;
  48. import java.util.Iterator;
  49. import java.util.LinkedHashMap;
  50. import java.util.List;
  51. import java.util.Map;
  52. import java.util.Map.Entry;
  53. import org.apache.log4j.Logger;
  54. public class DynamicModelHelper {
  55. private Context ctx = null;
  56. private String scheme = null;
  57. private SHRImportTypeEnum importTypeEnum = null;
  58. private static Logger logger = Logger.getLogger(DynamicModelHelper.class);
  59. private Map<String, String> importPropNameAndEntityPropMap = null;
  60. private Map<String, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo> entityInfoMap = null;
  61. private Map<String, ICoreBase> entityICoreBase = null;
  62. private String mainEntityFullName = null;
  63. private String mainEntityShortName = null;
  64. private boolean multiImport;
  65. private com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo currentRow = null;
  66. private String currentBillid = null;
  67. public DynamicModelHelper(String scheme, Context ctx, Map<String, com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> columnMap, SHRImportTypeEnum importType) throws BOSException, EASBizException {
  68. this.ctx = ctx;
  69. this.scheme = scheme;
  70. this.importPropNameAndEntityPropMap = new HashMap();
  71. this.importTypeEnum = importType;
  72. StructureConfigInfo main = StructureConfigConvertHelper.getMain(this.ctx, this.scheme);
  73. if (main == null) {
  74. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "unable_get_primary_entity", this.ctx));
  75. } else {
  76. this.mainEntityFullName = main.getEntityName();
  77. this.entityInfoMap = new HashMap();
  78. Iterator<Entry<String, com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo>> iter = columnMap.entrySet().iterator();
  79. this.multiImport = true;
  80. com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo = null;
  81. ArrayList temp = new ArrayList();
  82. while(iter.hasNext()) {
  83. columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)((Entry)iter.next()).getValue();
  84. if (!this.handleColumnInfo(columnInfo)) {
  85. temp.add(columnInfo);
  86. }
  87. }
  88. Iterator tempIter = temp.iterator();
  89. while(tempIter.hasNext()) {
  90. columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)tempIter.next();
  91. this.handleColumnInfo(columnInfo);
  92. }
  93. }
  94. }
  95. private boolean handleColumnInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo) throws EASBizException, BOSException {
  96. return this.handleColumnInfo(columnInfo, true);
  97. }
  98. public void setCurrentBillid(String billId) {
  99. this.currentBillid = billId;
  100. }
  101. private boolean handleColumnInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo, boolean convertColumn) throws EASBizException, BOSException {
  102. String shortName = this.getEntityShortNameByPropName(columnInfo.getPropName());
  103. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo importEntityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo)this.entityInfoMap.get(shortName);
  104. if (importEntityInfo == null) {
  105. if (convertColumn) {
  106. columnInfo = this.convertColumnInfo(columnInfo);
  107. return this.handleColumnInfo(columnInfo, false);
  108. }
  109. importEntityInfo = this.getImportEntityInfo(columnInfo.getPropName());
  110. if (importEntityInfo == null) {
  111. return false;
  112. }
  113. this.entityInfoMap.put(shortName, importEntityInfo);
  114. if (importEntityInfo.getEntityFullName().equals(this.mainEntityFullName)) {
  115. this.mainEntityShortName = shortName;
  116. importEntityInfo.setMainEntity(true);
  117. }
  118. if (this.multiImport && !importEntityInfo.isMainEntity() && !importEntityInfo.isMultiRow()) {
  119. this.multiImport = false;
  120. }
  121. }
  122. importEntityInfo.addImportColumn(columnInfo);
  123. return true;
  124. }
  125. private com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo convertColumnInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo) throws BOSException {
  126. String propName = columnInfo.getPropName();
  127. if (logger.isDebugEnabled()) {
  128. logger.debug("debugxg1" + propName);
  129. }
  130. QueryConfigFieldInfo fieldInfo = StructureConfigConvertHelper.getQueryFieldByKey(this.ctx, this.scheme, propName);
  131. if (fieldInfo == null) {
  132. return columnInfo;
  133. } else {
  134. StructureConfigInfo configInfo = fieldInfo.getFactField().getStructureConfig();
  135. if (!configInfo.isBaseData()) {
  136. return columnInfo;
  137. } else {
  138. StructureConfigInfo parentConfigInfo = configInfo.getParent();
  139. if (parentConfigInfo.isBaseData()) {
  140. return columnInfo;
  141. } else {
  142. if (logger.isDebugEnabled()) {
  143. logger.debug("debugxg2" + propName);
  144. }
  145. configInfo = StructureConfigConvertHelper.getStructureConfigByID(this.ctx, configInfo.getId().toString(), this.scheme);
  146. String tempRelationName = this.getRelationName(configInfo);
  147. if (logger.isDebugEnabled()) {
  148. logger.debug("debugxg3" + parentConfigInfo.getId() + "|" + parentConfigInfo.getName());
  149. }
  150. String parentShortName = parentConfigInfo.getClientNumber().toUpperCase();
  151. com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo tempColumnInfo = new com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo(parentShortName + "." + tempRelationName, columnInfo.getName(), columnInfo.isNecessary(), 0, (String)null);
  152. tempColumnInfo.setColumnIndex(columnInfo.getColumnIndex());
  153. return tempColumnInfo;
  154. }
  155. }
  156. }
  157. }
  158. private String getEntityShortNameByPropName(String propName) {
  159. String[] strs = propName.split("\\.");
  160. return strs.length > 0 ? strs[0].toUpperCase() : propName.toUpperCase();
  161. }
  162. private com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo getImportEntityInfo(String propName) throws BOSException, EASBizException {
  163. QueryConfigFieldInfo fieldInfo = StructureConfigConvertHelper.getQueryFieldByKey(this.ctx, this.scheme, propName);
  164. StructureConfigInfo configInfo = null;
  165. String tempRelationName;
  166. if (fieldInfo == null) {
  167. String[] split = propName.split("\\.");
  168. tempRelationName = "";
  169. if (split.length > 0) {
  170. tempRelationName = split[0];
  171. }
  172. configInfo = StructureConfigConvertHelper.getStructureConfigByNumber(this.ctx, tempRelationName, this.scheme);
  173. if (configInfo == null) {
  174. return null;
  175. }
  176. }
  177. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo();
  178. if (configInfo == null) {
  179. configInfo = fieldInfo.getFactField().getStructureConfig();
  180. configInfo = StructureConfigConvertHelper.getStructureConfigByID(this.ctx, configInfo.getId().toString(), configInfo.getScheme().getNumber());
  181. }
  182. entityInfo.setEntityAliasName(configInfo.getAlias());
  183. entityInfo.setConfigInfo(configInfo);
  184. entityInfo.setEntityFullName(configInfo.getEntityName());
  185. entityInfo.setMultiRow(configInfo.isMultiRow());
  186. if (configInfo.isMultiRow() && configInfo.isSupportSingleView()) {
  187. entityInfo.setSingleShowCondition(configInfo.getSingleCondition());
  188. }
  189. entityInfo.setSingleFields(configInfo.getSingleFields());
  190. if (configInfo.getParent() != null) {
  191. tempRelationName = this.getRelationName(configInfo);
  192. entityInfo.setRelationName(tempRelationName);
  193. }
  194. return entityInfo;
  195. }
  196. private String getRelationName(StructureConfigInfo configInfo) {
  197. String tempRelationName = null;
  198. StructureConfigFilterColumnCollection filterColumnList = configInfo.getFilterColumn();
  199. int i = 0;
  200. for(int size = filterColumnList.size(); i < size; ++i) {
  201. StructureConfigFilterColumnInfo filterColumn = filterColumnList.get(i);
  202. if (filterColumn.getParentColumn() != null && "id".equalsIgnoreCase(filterColumn.getClientColumn())) {
  203. tempRelationName = filterColumn.getParentColumn();
  204. break;
  205. }
  206. if (filterColumn.getParentColumn() != null && "id".equalsIgnoreCase(filterColumn.getParentColumn())) {
  207. tempRelationName = filterColumn.getClientColumn();
  208. break;
  209. }
  210. if (filterColumn.getParentColumn() != null && "person".equalsIgnoreCase(filterColumn.getParentColumn()) && "person".equalsIgnoreCase(filterColumn.getClientColumn())) {
  211. return filterColumn.getParentColumn();
  212. }
  213. }
  214. return tempRelationName;
  215. }
  216. public void setRow(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo row) {
  217. this.currentRow = row;
  218. }
  219. public ICoreBase getEntityInterface(String entityName) {
  220. if (this.entityICoreBase == null) {
  221. this.entityICoreBase = new HashMap();
  222. }
  223. ICoreBase coreBase = (ICoreBase)this.entityICoreBase.get(entityName);
  224. if (coreBase == null) {
  225. MetaDataPK entityPK = MetaDataPK.create(entityName);
  226. try {
  227. coreBase = (ICoreBase)BOSObjectFactory.createCommonBOSObject(this.ctx, entityPK);
  228. this.entityICoreBase.put(entityName, coreBase);
  229. } catch (BOSException var5) {
  230. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "get_api_instance_error", this.ctx), var5);
  231. }
  232. }
  233. return coreBase;
  234. }
  235. public DynamicModelInfo convertRowToDynamicModel(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo row) throws com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException {
  236. this.currentRow = row;
  237. return this.convertRowToDynamicModel();
  238. }
  239. public DynamicModelInfo convertRowToDynamicModel() {
  240. if (this.currentRow == null) {
  241. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "row_data_isempty", this.ctx));
  242. } else {
  243. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo mainEntityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo)this.entityInfoMap.get(this.mainEntityShortName);
  244. CoreBaseInfo mainCoreBaseInfo = this.loadMainEntityInfo(mainEntityInfo);
  245. if (mainCoreBaseInfo == null) {
  246. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "entity_not_found", this.ctx));
  247. } else {
  248. this.currentBillid = mainCoreBaseInfo.getId().toString();
  249. DynamicModelInfo dyModelInfo = new DynamicModelInfo();
  250. HashMap<String, IObjectValue> valueMap = new HashMap();
  251. HashMap<String, Boolean> hasData = new HashMap();
  252. valueMap.put(mainEntityInfo.getEntityFullName(), mainCoreBaseInfo);
  253. hasData.put(mainEntityInfo.getEntityFullName(), true);
  254. dyModelInfo.setValueMap(valueMap);
  255. Iterator<Entry<String, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
  256. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = null;
  257. while(iter.hasNext()) {
  258. entityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo)((Entry)iter.next()).getValue();
  259. if (!valueMap.containsKey(entityInfo.getEntityFullName())) {
  260. CoreBaseInfo baseInfo = this.loadEntityInfo(entityInfo);
  261. // start xiaoxin 员工证件信息新增导入时,不根据证件类型做唯一校验更新数据,进入新增操作
  262. if(baseInfo instanceof PersonCredentialsTypeInfo && importTypeEnum.getValue()==10){
  263. baseInfo = null;
  264. }
  265. // end xiaoxin
  266. if (baseInfo == null) {
  267. SelectorItemCollection coll = this.getLoadSelectorColl(entityInfo.getImportColumn());
  268. if (coll.size() == 0) {
  269. hasData.put(entityInfo.getEntityFullName(), false);
  270. }
  271. } else {
  272. valueMap.put(entityInfo.getEntityFullName(), baseInfo);
  273. hasData.put(entityInfo.getEntityFullName(), true);
  274. }
  275. }
  276. }
  277. this.verifyOrCreateBlankBaseInfo(dyModelInfo, hasData);
  278. this.assignInfoSaveValue(dyModelInfo, hasData);
  279. this.currentBillid = null;
  280. return dyModelInfo;
  281. }
  282. }
  283. }
  284. private void verifyOrCreateBlankBaseInfo(DynamicModelInfo dyModelInfo, HashMap<String, Boolean> hasData) {
  285. HashMap<String, IObjectValue> valueMap = dyModelInfo.getValueMap();
  286. StringBuffer errorMsg = new StringBuffer();
  287. Iterator<Entry<String, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
  288. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = null;
  289. IObjectValue baseInfo = null;
  290. String tempEntityFullName = null;
  291. while(true) {
  292. String emsg;
  293. do {
  294. do {
  295. if (!iter.hasNext()) {
  296. emsg = errorMsg.toString();
  297. if (!StringUtils.isEmpty(emsg)) {
  298. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(emsg);
  299. }
  300. return;
  301. }
  302. entityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo)((Entry)iter.next()).getValue();
  303. } while(entityInfo.isMainEntity());
  304. tempEntityFullName = entityInfo.getEntityFullName();
  305. } while(hasData.get(tempEntityFullName) != null && !(Boolean)hasData.get(tempEntityFullName));
  306. baseInfo = (IObjectValue)valueMap.get(tempEntityFullName);
  307. switch(this.importTypeEnum.getValue()) {
  308. case 10:
  309. if (baseInfo == null) {
  310. baseInfo = this.createInfo(tempEntityFullName);
  311. valueMap.put(tempEntityFullName, baseInfo);
  312. } else {
  313. // start xiaoxin 员工证件信息导入时不根据证件类型做唯一校验
  314. if(!(baseInfo instanceof PersonCredentialsTypeInfo)){
  315. emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "add_fails_already_exist", this.ctx), entityInfo.getEntityAliasName());
  316. errorMsg.append(emsg);
  317. }
  318. // emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "add_fails_already_exist", this.ctx), entityInfo.getEntityAliasName());
  319. // errorMsg.append(emsg);
  320. // end xioaxin
  321. }
  322. break;
  323. case 20:
  324. if (baseInfo == null) {
  325. emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "cover_fails_not_load", this.ctx), entityInfo.getEntityAliasName());
  326. errorMsg.append(emsg);
  327. } else {
  328. CoreBaseInfo coreBaseInfo = this.createInfo(tempEntityFullName);
  329. coreBaseInfo.setId(((CoreBaseInfo)baseInfo).getId());
  330. valueMap.put(tempEntityFullName, coreBaseInfo);
  331. }
  332. break;
  333. case 30:
  334. if (baseInfo == null) {
  335. emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "update_fails_not_load", this.ctx), entityInfo.getEntityAliasName());
  336. errorMsg.append(emsg);
  337. }
  338. break;
  339. case 40:
  340. if (baseInfo == null) {
  341. baseInfo = this.createInfo(tempEntityFullName);
  342. valueMap.put(tempEntityFullName, baseInfo);
  343. }
  344. }
  345. }
  346. }
  347. private void assignInfoSaveValue(DynamicModelInfo dyModelInfo, HashMap<String, Boolean> hasData) {
  348. HashMap<String, IObjectValue> tempObjMap = dyModelInfo.getValueMap();
  349. LinkedHashMap<String, IObjectValue> saveModelMap = new LinkedHashMap();
  350. Iterator<Entry<String, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
  351. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = null;
  352. IObjectValue coreBase = null;
  353. com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo tempColumnInfo = null;
  354. Object tempValue = null;
  355. boolean hasUpdate = this.importTypeEnum.getValue() == 40 || this.importTypeEnum.getValue() == 30;
  356. while(true) {
  357. Boolean has;
  358. do {
  359. if (!iter.hasNext()) {
  360. if (tempObjMap.containsKey(this.mainEntityFullName)) {
  361. saveModelMap.put(this.mainEntityFullName, tempObjMap.get(this.mainEntityFullName));
  362. tempObjMap.remove(this.mainEntityFullName);
  363. }
  364. saveModelMap.putAll(tempObjMap);
  365. dyModelInfo.setSaveModelMap(saveModelMap);
  366. return;
  367. }
  368. entityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo)((Entry)iter.next()).getValue();
  369. has = (Boolean)hasData.get(entityInfo.getEntityFullName());
  370. } while(has != null && !has);
  371. coreBase = (IObjectValue)tempObjMap.get(entityInfo.getEntityFullName());
  372. boolean tempBoolean = hasUpdate && coreBase.get(coreBase.getPKField()) != null;
  373. List<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> columnInfoList = entityInfo.getImportColumn();
  374. boolean isPersonEntity = this.isPersonEntity(entityInfo.getEntityFullName());
  375. int i = 0;
  376. for(int size = columnInfoList.size(); i < size; ++i) {
  377. tempColumnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)columnInfoList.get(i);
  378. if (!isPersonEntity || !"person.name".equals(tempColumnInfo.getPropName()) && !"person.number".equals(tempColumnInfo.getPropName())) {
  379. String valString;
  380. if (tempBoolean) {
  381. valString = this.currentRow.getValueOfStringByIndex(tempColumnInfo.getColumnIndex());
  382. if (StringUtils.isEmpty(valString)) {
  383. continue;
  384. }
  385. if (com.kingdee.shr.base.syssetting.app.io.fileImport.ValueCovertUtils.UPDATE_BLANK_FLAG.equals(valString)) {
  386. tempValue = null;
  387. }
  388. }
  389. tempValue = this.currentRow.getValueOfObjectByIndex(tempColumnInfo.getColumnIndex());
  390. valString = this.getEntityPropName(tempColumnInfo.getPropName());
  391. coreBase.put(valString, tempValue);
  392. if (1 == tempColumnInfo.getDataType()) {
  393. coreBase.put(valString + "_" + LocaleUtils.locale_l1.getDisplayName(), tempValue);
  394. coreBase.put(valString + "_" + LocaleUtils.locale_l2.getDisplayName(), tempValue);
  395. coreBase.put(valString + "_" + LocaleUtils.locale_l3.getDisplayName(), tempValue);
  396. }
  397. }
  398. }
  399. String tempRelate = entityInfo.getRelationName();
  400. if (!StringUtils.isEmpty(tempRelate)) {
  401. IObjectValue mainValue = (IObjectValue)tempObjMap.get(this.mainEntityFullName);
  402. if (mainValue != null) {
  403. coreBase.put(tempRelate, mainValue);
  404. }
  405. }
  406. }
  407. }
  408. private CoreBaseInfo loadEntityInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo) {
  409. FilterInfo filter = null;
  410. SelectorItemCollection coll = this.getLoadSelectorColl(entityInfo.getImportColumn());
  411. if (coll.size() == 0) {
  412. return null;
  413. } else {
  414. List<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> keyColumn = entityInfo.getKeyColumn();
  415. if (keyColumn != null && keyColumn.size() > 0) {
  416. filter = new FilterInfo();
  417. this.getLoadFilterInfo(filter, keyColumn);
  418. }
  419. if (!StringUtils.isEmpty(entityInfo.getRelationName())) {
  420. if (filter == null) {
  421. filter = new FilterInfo();
  422. }
  423. filter.getFilterItems().add(new FilterItemInfo(entityInfo.getRelationName(), this.currentBillid));
  424. }
  425. if (filter == null) {
  426. return null;
  427. } else {
  428. EntityViewInfo view = new EntityViewInfo();
  429. view.setFilter(filter);
  430. try {
  431. ICoreBase iCoreBase = this.getEntityInterface(entityInfo.getEntityFullName());
  432. CoreBaseCollection coreBaseColl = iCoreBase.getCollection(view);
  433. int size = coreBaseColl.size();
  434. if (size == 0) {
  435. return null;
  436. } else if (size == 1) {
  437. return coreBaseColl.get(0);
  438. } else {
  439. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_entity_fails_mult", this.ctx), entityInfo.entityAliasName));
  440. }
  441. } catch (BOSException var9) {
  442. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_fails", this.ctx), entityInfo.entityAliasName), var9);
  443. }
  444. }
  445. }
  446. }
  447. private CoreBaseInfo loadMainEntityInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo) {
  448. if (!StringUtils.isEmpty(this.currentBillid)) {
  449. try {
  450. ICoreBase iCoreBase = this.getEntityInterface(entityInfo.getEntityFullName());
  451. CoreBaseInfo coreBase = iCoreBase.getValue(new ObjectUuidPK(this.currentBillid));
  452. return coreBase;
  453. } catch (EASBizException var13) {
  454. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(var13.getMessage(), var13);
  455. } catch (BOSException var14) {
  456. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_error", this.ctx), var14);
  457. }
  458. } else {
  459. FilterInfo filter = null;
  460. if (this.isPersonEntity(entityInfo.getEntityFullName())) {
  461. filter = new FilterInfo();
  462. String number = this.currentRow.getValueOfString("person.number");
  463. String name = this.currentRow.getValueOfString("person.name");
  464. if (!StringUtils.isEmpty(name)) {
  465. filter.getFilterItems().add(new FilterItemInfo(this.getEntityPropName("person.name"), name));
  466. }
  467. if (!StringUtils.isEmpty(number)) {
  468. filter.getFilterItems().add(new FilterItemInfo(this.getEntityPropName("person.number"), number));
  469. }
  470. EntityViewInfo view = new EntityViewInfo();
  471. view.setFilter(filter);
  472. try {
  473. ICoreBase iCoreBase = this.getEntityInterface(entityInfo.getEntityFullName());
  474. CoreBaseCollection coreBaseColl = iCoreBase.getCollection(view);
  475. int size = coreBaseColl.size();
  476. if (size == 0) {
  477. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "unable_load_entity", this.ctx, new Object[]{entityInfo.getEntityAliasName()}));
  478. } else if (size == 1) {
  479. return coreBaseColl.get(0);
  480. } else {
  481. CoreBaseInfo base = null;
  482. int count = 0;
  483. for(int i = 0; i < size; ++i) {
  484. CoreBaseInfo baseInfo = coreBaseColl.get(i);
  485. if ((StringUtils.isEmpty(name) || name.equals(baseInfo.getString("name"))) && (StringUtils.isEmpty(number) || number.equals(baseInfo.getString("number")))) {
  486. base = baseInfo;
  487. ++count;
  488. }
  489. }
  490. if (count == 1) {
  491. return base;
  492. } else {
  493. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_mult_entity", this.ctx, new Object[]{entityInfo.getEntityAliasName()}));
  494. }
  495. }
  496. } catch (BOSException var15) {
  497. throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_fails", this.ctx, new Object[]{entityInfo.getEntityAliasName()}), var15);
  498. }
  499. } else {
  500. return this.loadEntityInfo(entityInfo);
  501. }
  502. }
  503. }
  504. private boolean isPersonEntity(String entityFullName) {
  505. return "com.kingdee.eas.basedata.person.app.Person".equals(entityFullName);
  506. }
  507. private FilterInfo getLoadFilterInfo(FilterInfo filter, List<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> keyColumn) {
  508. com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo = null;
  509. int i = 0;
  510. for(int size = keyColumn.size(); i < size; ++i) {
  511. columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)keyColumn.get(i);
  512. String key = columnInfo.getPropName();
  513. String entityPropName = this.getEntityPropName(key);
  514. Object value = this.currentRow.getValueOfObjectByIndex(columnInfo.getColumnIndex());
  515. if (value instanceof String) {
  516. filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
  517. } else if (value instanceof Timestamp) {
  518. filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
  519. } else if (value instanceof Date) {
  520. filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
  521. } else if (value instanceof Enum) {
  522. if (value instanceof StringEnum) {
  523. StringEnum en = (StringEnum)value;
  524. filter.getFilterItems().add(new FilterItemInfo(entityPropName, en.getValue()));
  525. } else if (value instanceof IntEnum) {
  526. IntEnum en = (IntEnum)value;
  527. filter.getFilterItems().add(new FilterItemInfo(entityPropName, en.getValue()));
  528. }
  529. } else if (value instanceof CoreBaseInfo) {
  530. CoreBaseInfo coreBaseInfo = (CoreBaseInfo)value;
  531. filter.getFilterItems().add(new FilterItemInfo(entityPropName, coreBaseInfo.getId()));
  532. } else {
  533. filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
  534. }
  535. }
  536. return filter;
  537. }
  538. private SelectorItemCollection getLoadSelectorColl(List<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> columnList) {
  539. com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo = null;
  540. SelectorItemCollection coll = new SelectorItemCollection();
  541. int i = 0;
  542. for(int size = columnList.size(); i < size; ++i) {
  543. columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)columnList.get(i);
  544. String key = columnInfo.getPropName();
  545. String entityPropName = this.getEntityPropName(key);
  546. String value = this.currentRow.getValueOfStringByIndex(columnInfo.getColumnIndex());
  547. if (!StringUtils.isEmpty(value)) {
  548. coll.add(new SelectorItemInfo(entityPropName));
  549. }
  550. }
  551. return coll;
  552. }
  553. private String getEntityPropName(String importPropName) {
  554. String entityPropName = (String)this.importPropNameAndEntityPropMap.get(importPropName);
  555. if (entityPropName == null) {
  556. String[] strs = importPropName.split("\\.");
  557. if (strs.length > 1) {
  558. entityPropName = strs[1];
  559. }
  560. this.importPropNameAndEntityPropMap.put(importPropName, entityPropName);
  561. }
  562. return entityPropName;
  563. }
  564. private CoreBaseInfo createInfo(String entityFullName) {
  565. IMetaDataLoader loader = MetaDataLoaderFactory.getMetaDataLoader(this.ctx);
  566. MetaDataPK metaDataPK = MetaDataPK.create(entityFullName);
  567. EntityObjectInfo eoInfo = loader.getEntity(metaDataPK);
  568. String valueClassName = eoInfo.getObjectValueClass();
  569. CoreBaseInfo info = null;
  570. try {
  571. Class<?> c = Class.forName(valueClassName);
  572. Constructor<?> cst = c.getConstructor();
  573. info = (CoreBaseInfo)cst.newInstance();
  574. if (info instanceof DataBaseCustomInfo) {
  575. ((DataBaseCustomInfo)info).setBOSType(eoInfo.getType());
  576. } else if (info instanceof BaseItemCustomInfo) {
  577. ((BaseItemCustomInfo)info).setBOSType(eoInfo.getType());
  578. } else if (info instanceof CoreBillBaseCustomInfo) {
  579. ((CoreBillBaseCustomInfo)info).setBOSType(eoInfo.getType());
  580. } else if (eoInfo.isDynamic() && info instanceof ICommonBOSType) {
  581. ICommonBOSType commonObject = (ICommonBOSType)info;
  582. commonObject.setBOSType(eoInfo.getType());
  583. commonObject.setPK(metaDataPK);
  584. }
  585. return info;
  586. } catch (Exception var10) {
  587. com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException importException = new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "creat_object_fails", this.ctx), var10);
  588. throw importException;
  589. }
  590. }
  591. }