|
@@ -7,15 +7,15 @@ import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
|
|
|
import com.kingdee.bos.metadata.entity.*;
|
|
|
import com.kingdee.bos.metadata.query.util.CompareType;
|
|
|
import com.kingdee.bos.sql.ParserException;
|
|
|
+import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
|
|
|
import com.kingdee.eas.common.EASBizException;
|
|
|
import com.kingdee.eas.custom.performancenew.*;
|
|
|
import com.kingdee.eas.framework.CoreBaseInfo;
|
|
|
import com.kingdee.eas.util.app.ContextUtil;
|
|
|
-import com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo;
|
|
|
-import com.kingdee.shr.base.syssetting.app.io.fileImport.BaseImportService;
|
|
|
-import com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo;
|
|
|
-import com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException;
|
|
|
+import com.kingdee.shr.base.syssetting.app.io.fileImport.*;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
|
|
|
import com.kingdee.shr.ml.util.SHRServerResource;
|
|
|
+import com.kingdee.shr.shrimport.SHRFileTemplateInfo;
|
|
|
import com.kingdee.util.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
@@ -23,10 +23,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author qingwu
|
|
@@ -34,25 +31,115 @@ import java.util.Map;
|
|
|
* @apiNote 周期季度(专员导入)人员考核等级评分
|
|
|
*/
|
|
|
public class ExamineGradeImportPFRService extends BaseImportService {
|
|
|
- //@Override
|
|
|
- //protected String getPKSelectString(BaseRowInfo row) {
|
|
|
- // String pkSelectString = super.getPKSelectString(row);
|
|
|
- // String parentId = getCustomParam("parentId");
|
|
|
- // if (StringUtils.isEmpty(parentId)) {
|
|
|
- // throw new RuntimeException("绩效考核周期表ID不可为空!!");
|
|
|
- // }
|
|
|
- // return pkSelectString + " and parent.id ='" + parentId + "'";
|
|
|
- //}
|
|
|
+ private static final SelectorItemCollection SIC = new SelectorItemCollection();
|
|
|
+ private static final SelectorItemCollection UPDATESIC = new SelectorItemCollection();
|
|
|
+
|
|
|
+ static {
|
|
|
+ SIC.add("adminOrg.name");
|
|
|
+ SIC.add("adminOrg.number");
|
|
|
+ SIC.add("auditor.name");
|
|
|
+ SIC.add("index");
|
|
|
+
|
|
|
+ UPDATESIC.add("index");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启用 批量导入
|
|
|
+ * com.kingdee.shr.base.syssetting.app.io.fileImport.ImportTaskExecutor#run() 135
|
|
|
+ *
|
|
|
+ * @param templateInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean isBatch(SHRFileTemplateInfo templateInfo) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始执行批量导入
|
|
|
+ *
|
|
|
+ * @param rowIterator
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean startBatchImport(Iterator<BaseRowInfo> rowIterator) {
|
|
|
+ List<BaseResultInfo> resultInfoList = null;
|
|
|
+ List<ExamineGradePersonEntryInfo> entryListData = new ArrayList<>();
|
|
|
+ Map<String, BaseResultInfo> map = new HashMap();
|
|
|
+
|
|
|
+ try {
|
|
|
+ //循环拿出数据
|
|
|
+ IExamineGradePersonEntry iExamineGradePersonEntry = ExamineGradePersonEntryFactory.getLocalInstance(this.getContext());
|
|
|
+ while (rowIterator.hasNext()) {
|
|
|
+ BaseRowInfo row = rowIterator.next();
|
|
|
+ BaseResultInfo baseResultInfo = new BaseResultInfo(row);
|
|
|
+ String fid = row.getValueOfString("id");
|
|
|
+ String index = row.getValueOfString("index");
|
|
|
+ ExamineGradePersonEntryInfo entryInfo = iExamineGradePersonEntry.getExamineGradePersonEntryInfo(new ObjectUuidPK(fid), SIC);
|
|
|
+ entryInfo.setIndex(Integer.parseInt(index));
|
|
|
+ entryListData.add(entryInfo);
|
|
|
+ map.put(entryInfo.getId().toString(), baseResultInfo);
|
|
|
+ }
|
|
|
+ //先排序list数据 按照部门和顺序排序
|
|
|
+ Collections.sort(entryListData, new Comparator<ExamineGradePersonEntryInfo>() {
|
|
|
+ @Override
|
|
|
+ public int compare(ExamineGradePersonEntryInfo o1, ExamineGradePersonEntryInfo o2) {
|
|
|
+ // 首先按照名称排序
|
|
|
+ int nameComparison = o1.getAdminOrg().getId().toString().compareTo(o2.getAdminOrg().getId().toString());
|
|
|
+ if (nameComparison != 0) {
|
|
|
+ return nameComparison;
|
|
|
+ }
|
|
|
+ // 如果名称相同,则按照编号排序
|
|
|
+ return o1.getIndex() - o2.getIndex();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 使用Map存储每个分类的最大编号
|
|
|
+ Map<String, Integer> maxNumberMap = new HashMap<>();
|
|
|
+ ExamineGradePersonEntryCollection entryCollection = new ExamineGradePersonEntryCollection();
|
|
|
+ //排序后的数据校验顺序是否断层
|
|
|
+ for (int i = 0; i < entryListData.size(); i++) {
|
|
|
+ ExamineGradePersonEntryInfo entryInfo = entryListData.get(i);
|
|
|
+ AdminOrgUnitInfo adminOrg = entryInfo.getAdminOrg();
|
|
|
+ String adminId = adminOrg.getId().toString();
|
|
|
+ int order = entryInfo.getIndex();
|
|
|
+ Integer maxNumber = maxNumberMap.getOrDefault(adminId, 0);
|
|
|
+ BaseResultInfo baseResultInfo = map.get(entryInfo.getId().toString());
|
|
|
+ // 检查编号是否按顺序且没有断层
|
|
|
+ if (order == maxNumber + 1) {
|
|
|
+ maxNumberMap.put(adminId, order);
|
|
|
+ resultInfoList = new ArrayList();
|
|
|
+ resultInfoList.add(baseResultInfo);
|
|
|
+ for (BaseResultInfo resultInfo : resultInfoList) {
|
|
|
+ resultInfo.setMessage("导入成功!");
|
|
|
+ getMonitor().completeRow(resultInfo);
|
|
|
+ }
|
|
|
+ entryCollection.add(entryInfo);
|
|
|
+ iExamineGradePersonEntry.updatePartial(entryInfo, UPDATESIC);
|
|
|
+ } else {
|
|
|
+ resultInfoList = new ArrayList();
|
|
|
+ resultInfoList.add(baseResultInfo);
|
|
|
+ for (BaseResultInfo resultInfo : resultInfoList) {
|
|
|
+ if (resultInfo.isSuccess()) {
|
|
|
+ resultInfo.setSuccess(false);
|
|
|
+ resultInfo.setState(0);
|
|
|
+ resultInfo.setMessage("部门[" + adminOrg.getName() + "] 中的顺序不符合规则!!");
|
|
|
+ resultInfo.setLog("部门[" + adminOrg.getName() + "] 中的顺序不符合规则!!");
|
|
|
+ resultInfo.setE(new ImportException("部门[" + adminOrg.getName() + "] 中的顺序不符合规则!!"));
|
|
|
+ }
|
|
|
+ getMonitor().completeRow(resultInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (BOSException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (EASBizException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- //@Override
|
|
|
- //public void completeGenerateExcel(Map<String, BaseColumnInfo> columnInfoMap, XSSFWorkbook wb, XSSFSheet sheet) {
|
|
|
- // String parentId = getCustomParam("parentId");
|
|
|
- // if (StringUtils.isEmpty(parentId)) {
|
|
|
- // throw new RuntimeException("绩效考核周期表ID不可为空!!");
|
|
|
- // }
|
|
|
- // super.completeGenerateExcel(columnInfoMap, wb, sheet);
|
|
|
- //}
|
|
|
@Override
|
|
|
public void completeGenerateExcel(Map<String, BaseColumnInfo> columnInfoMap, XSSFWorkbook wb, XSSFSheet sheet) {
|
|
|
Context ctx = getContext();
|
|
@@ -74,10 +161,11 @@ public class ExamineGradeImportPFRService extends BaseImportService {
|
|
|
filterItems.add(new FilterItemInfo("parent.id", parentId));
|
|
|
filterItems.add(new FilterItemInfo("orderStatuc", "2", CompareType.NOTEQUALS));
|
|
|
filterItems.add(new FilterItemInfo("scorer.id", currentPersonId));
|
|
|
- SorterItemCollection sorterItemCollection = new SorterItemCollection("adminOrg.id,index");
|
|
|
+ SorterItemCollection sorterItemCollection = new SorterItemCollection();
|
|
|
+ sorterItemCollection.add(new SorterItemInfo("adminOrg.id"));
|
|
|
+ sorterItemCollection.add(new SorterItemInfo("index"));
|
|
|
EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, sorterItemCollection);
|
|
|
IExamineGradePersonEntry iExamineGradePersonEntry = ExamineGradePersonEntryFactory.getLocalInstance(ctx);
|
|
|
-
|
|
|
ExamineGradePersonEntryCollection entryCollection = iExamineGradePersonEntry.getExamineGradePersonEntryCollection(entityViewInfo);
|
|
|
Map<Integer, String> columnIndexMap = getColumnIndexFn(columnInfoMap);
|
|
|
int fillColumnCount = columnInfoMap.size();
|
|
@@ -107,9 +195,6 @@ public class ExamineGradeImportPFRService extends BaseImportService {
|
|
|
} catch (BOSException e) {
|
|
|
e.printStackTrace();
|
|
|
throw new RuntimeException(e);
|
|
|
- } catch (ParserException e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -151,6 +236,6 @@ public class ExamineGradeImportPFRService extends BaseImportService {
|
|
|
BaseColumnInfo keyColumn = keyColumnList.get(i);
|
|
|
keyColumn.setCustomField(false);
|
|
|
}
|
|
|
- return super.getPKSelectString(row) + " and parent.id ='" + parentId + "'";
|
|
|
+ return super.getPKSelectString(row) + " and parent.id ='" + parentId + "' and orderstatuc <>'2'";
|
|
|
}
|
|
|
}
|