成本中心同步插件遍历修改为倒序

This commit is contained in:
zengweihai 2024-06-28 17:22:05 +08:00
parent 2bd6700386
commit 3205530f81
1 changed files with 11 additions and 2 deletions

View File

@ -83,8 +83,14 @@ public class CostCenterTaskImpl extends AbstractTask {
for (String key : keys) { for (String key : keys) {
QFilter userQF = new QFilter("number", QCP.equals, key); QFilter userQF = new QFilter("number", QCP.equals, key);
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle("bos_user", userQF.toArray());//查找星瀚对应人员 DynamicObject bos_user = BusinessDataServiceHelper.loadSingle("bos_user", userQF.toArray());//查找星瀚对应人员
// if(bos_user.getString("name").equals("周思悦")){
// System.out.println("11");
// }
if (bos_user != null){//当人员数据不为空时 if (bos_user != null){//当人员数据不为空时
boolean changeFlag = false; boolean changeFlag = false;
if(bos_user.getString("name").equals("周思悦")){
System.out.println("11");
}
HashMap<String,String> valueMap = orgMap.get(key);//部门及成本中心数据集合 HashMap<String,String> valueMap = orgMap.get(key);//部门及成本中心数据集合
String departmentcode = valueMap.get("departmentcode");//部门编码 String departmentcode = valueMap.get("departmentcode");//部门编码
String costCenterNumber = valueMap.get("costCenterNumber");//成本中心编码 String costCenterNumber = valueMap.get("costCenterNumber");//成本中心编码
@ -95,8 +101,9 @@ public class CostCenterTaskImpl extends AbstractTask {
if (bos_costCenter != null){//当成本中心不为空时 if (bos_costCenter != null){//当成本中心不为空时
//获取用户的成本中心信息分录 //获取用户的成本中心信息分录
DynamicObjectCollection costEntity = bos_user.getDynamicObjectCollection("shkd_costentity"); DynamicObjectCollection costEntity = bos_user.getDynamicObjectCollection("shkd_costentity");
int costSize = costEntity.size();
//首先遍历移除已存在的来源为泛微的数据 //首先遍历移除已存在的来源为泛微的数据
for (int i = 0;i < costEntity.size();i++){ for (int i = costSize-1 ;i >= 0;i--){
DynamicObject dynamicObject = costEntity.get(i); DynamicObject dynamicObject = costEntity.get(i);
String shkd_e_source = dynamicObject.getString("shkd_e_source"); String shkd_e_source = dynamicObject.getString("shkd_e_source");
if ("B".equals(shkd_e_source)){ if ("B".equals(shkd_e_source)){
@ -104,6 +111,7 @@ public class CostCenterTaskImpl extends AbstractTask {
costEntity.remove(index); costEntity.remove(index);
} }
} }
DynamicObject newObject = costEntity.addNew(); DynamicObject newObject = costEntity.addNew();
newObject.set("shkd_e_cost",bos_costCenter); newObject.set("shkd_e_cost",bos_costCenter);
newObject.set("shkd_e_source","B"); newObject.set("shkd_e_source","B");
@ -118,8 +126,9 @@ public class CostCenterTaskImpl extends AbstractTask {
if (bos_adminorg != null){//当行政组织不为空时 if (bos_adminorg != null){//当行政组织不为空时
//获取人员的组织分录 //获取人员的组织分录
DynamicObjectCollection entryentity = bos_user.getDynamicObjectCollection("entryentity");//组织分录 DynamicObjectCollection entryentity = bos_user.getDynamicObjectCollection("entryentity");//组织分录
int deptSize = entryentity.size();
//首先遍历移除已存在的来源为泛微的数据 //首先遍历移除已存在的来源为泛微的数据
for (int i = 0;i < entryentity.size();i++){ for (int i = deptSize-1; i >= 0; i--){
DynamicObject dynamicObject = entryentity.get(i); DynamicObject dynamicObject = entryentity.get(i);
String shkd_deptsource = dynamicObject.getString("shkd_deptsource"); String shkd_deptsource = dynamicObject.getString("shkd_deptsource");
if ("2".equals(shkd_deptsource)){ if ("2".equals(shkd_deptsource)){