|
@@ -18,6 +18,7 @@ import kd.bos.sec.user.utils.UserOperationUtils;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
import sys.sc.formplugin.ABillServiceHelper;
|
|
|
+import sys.sc.opplugin.utils.InterFaceImgUtils;
|
|
|
import sys.sc.opplugin.utils.SftpClient;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -32,10 +33,18 @@ import java.util.*;
|
|
|
public class UpdateDataDailyTask extends AbstractTask {
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(UpdateDataDailyTask.class);
|
|
|
- public static String host="192.168.10.69";//服务器ip地址
|
|
|
- public static String username="root";//用户名
|
|
|
- public static int port = 22;//端口号
|
|
|
- public static String password="Kd@86262007";//用户密码
|
|
|
+ public InterFaceImgUtils interFaceImgUtils=new InterFaceImgUtils("produceurl"); //服务器ip
|
|
|
+ public String host=interFaceImgUtils.getServerName();
|
|
|
+ //用户名
|
|
|
+ public String username=interFaceImgUtils.getServerUser();
|
|
|
+ //用户密码
|
|
|
+ public String password=interFaceImgUtils.getServerPassword();
|
|
|
+ //分割符
|
|
|
+ public String splitsign=interFaceImgUtils.getServerSplit();
|
|
|
+ //结尾符
|
|
|
+ public String endsign=interFaceImgUtils.getServerEndsign();
|
|
|
+ public int port= interFaceImgUtils.getProt();
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -93,13 +102,9 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
String line;
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
//去掉换行符|$|
|
|
|
- line = line.replace("|$|", "");
|
|
|
+ line = line.replace(endsign, "");
|
|
|
//空格符号,根据这个符号分割
|
|
|
- String[] fields = line.split("\u0001");
|
|
|
- //如果获取的数据行不等于预设字段的行,则跳过这行数据
|
|
|
- if (fields.length != selector.size()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ String[] fields = line.split(splitsign,-1);
|
|
|
//获取工号
|
|
|
String gonghao = fields[0];
|
|
|
boolean isUpdated = false;
|
|
@@ -112,10 +117,17 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
String fieldName = selector.get(i);
|
|
|
String newValue = fields[i];
|
|
|
String existingValue = data.getString(fieldName);
|
|
|
+ //如果等于行政编码,则去掉第一个字符1
|
|
|
+ if (i==7||i==9||i==11) {
|
|
|
+ existingValue=existingValue.substring(1);
|
|
|
+ }
|
|
|
//判断数据是否与之前的数据相同,不相同则更新
|
|
|
if (!Objects.equals(existingValue, newValue)) {
|
|
|
- data.set(fieldName, newValue);
|
|
|
- isUpdated = true;
|
|
|
+ if (!newValue.isEmpty()) {
|
|
|
+ data.set(fieldName, newValue);
|
|
|
+ isUpdated = true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//更新了数据则设置数据更新的时间
|
|
@@ -126,6 +138,16 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
} else {
|
|
|
//不存在这条数据则新增一条到data中
|
|
|
data = new DynamicObject(dynamicObjectType);
|
|
|
+ //行政编码不为空则在前面加1
|
|
|
+ if(!fields[7].isEmpty()) {
|
|
|
+ fields[7]="1"+fields[7];
|
|
|
+ }
|
|
|
+ if (!fields[9].isEmpty()) {
|
|
|
+ fields[9]="1"+fields[9];
|
|
|
+ }
|
|
|
+ if (!fields[11].isEmpty()) {
|
|
|
+ fields[11]="1"+fields[11];
|
|
|
+ }
|
|
|
for (int i = 0; i < selector.size(); i++) {
|
|
|
data.set(selector.get(i), fields[i]);
|
|
|
}
|
|
@@ -139,7 +161,6 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
for (Map.Entry<String, DynamicObject> entry : existingDataMap.entrySet()) {
|
|
|
String gonghao = entry.getKey();
|
|
|
DynamicObject data = entry.getValue();
|
|
|
-
|
|
|
if (!processedGonghaoSet.contains(gonghao)) {
|
|
|
data.set("nckd_isdelete", true);
|
|
|
updatedataList.add(data);
|
|
@@ -184,11 +205,13 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
log.info("指定的上级组织 'jxyh' 未找到!");
|
|
|
return;
|
|
|
}
|
|
|
- IFormView orgview = ABillServiceHelper.createAddView("bos_adminorg");
|
|
|
for (DynamicObject record : nckdData) {
|
|
|
// 判断并创建或更新所在单位
|
|
|
//所在单位编码
|
|
|
String szdwbm = record.getString("nckd_szdwcode");
|
|
|
+ if (!szdwbm.isEmpty()) {
|
|
|
+ szdwbm=szdwbm.substring(1);
|
|
|
+ }
|
|
|
//所在单位名称
|
|
|
String szdwmc = record.getString("nckd_szdwname");
|
|
|
DynamicObject org = BusinessDataServiceHelper.loadSingle(
|
|
@@ -196,8 +219,9 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
);
|
|
|
//没有单位则创建
|
|
|
if (org == null) {
|
|
|
+ IFormView orgview = ABillServiceHelper.createAddView("bos_adminorg");
|
|
|
//组织编码
|
|
|
- orgview.getModel().setValue("number", szdwbm);
|
|
|
+ orgview.getModel().setValue("number", "1"+szdwbm);
|
|
|
//组织名称
|
|
|
orgview.getModel().setValue("name", szdwmc);
|
|
|
//上级组织
|
|
@@ -211,7 +235,6 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
OperationResult operationResult = ABillServiceHelper.saveOperate(orgview);
|
|
|
//保存不成功
|
|
|
if (!operationResult.isSuccess()) {
|
|
|
-
|
|
|
}
|
|
|
org = orgview.getModel().getDataEntity();
|
|
|
//如果存在单位则检查单位名是否一致,不一致则更新
|
|
@@ -228,12 +251,15 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
}
|
|
|
// 判断一级机构编码 在行政组织中是否存在,不存在则新增
|
|
|
String yjjgbm = record.getString("nckd_yjbmcode");
|
|
|
+ if (!yjjgbm.isEmpty()) {
|
|
|
+ yjjgbm=yjjgbm.substring(1);
|
|
|
+ }
|
|
|
String yjjgmc = record.getString("nckd_yjbmname");
|
|
|
//一级机构
|
|
|
DynamicObject yjjg = BusinessDataServiceHelper.loadSingle("bos_adminorg", new QFilter[]{new QFilter("number", "=", yjjgbm)});
|
|
|
if (yjjg == null) {
|
|
|
- IFormView yjjgView=orgview;
|
|
|
- yjjgView.getModel().setValue("number", yjjgbm);
|
|
|
+ IFormView yjjgView=ABillServiceHelper.createAddView("bos_adminorg");
|
|
|
+ yjjgView.getModel().setValue("number","1"+yjjgbm);
|
|
|
yjjgView.getModel().setValue("name", yjjgmc);
|
|
|
yjjgView.getModel().setValue("parent", org); // 父级组织为 org
|
|
|
yjjgView.getModel().setValue("orgpattern", xingtaiinfo);
|
|
@@ -241,7 +267,7 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
yjjgView.getModel().setValue("enable", "1");
|
|
|
OperationResult yjjgOperationResult = ABillServiceHelper.saveOperate(yjjgView);
|
|
|
if (!yjjgOperationResult.isSuccess()) {
|
|
|
- // Handle the failure case here
|
|
|
+
|
|
|
}
|
|
|
yjjg = yjjgView.getModel().getDataEntity();
|
|
|
} else if (!yjjg.getString("name").equals(yjjgmc)) {
|
|
@@ -254,12 +280,15 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
}
|
|
|
// 判断所在部门编码 在行政组织中是否存在,不存在则新增
|
|
|
String szbmbm = record.getString("nckd_orgidcode");
|
|
|
+ if (!szbmbm.isEmpty()) {
|
|
|
+ szbmbm=szdwbm.substring(1);
|
|
|
+ }
|
|
|
String szbmmc = record.getString("nckd_orgidname");
|
|
|
//所在部门
|
|
|
DynamicObject szbm = BusinessDataServiceHelper.loadSingle("bos_adminorg", new QFilter[]{new QFilter("number", "=", szbmbm)});
|
|
|
if (szbm == null) {
|
|
|
- IFormView szbmView=orgview;
|
|
|
- szbmView.getModel().setValue("number", szbmbm);
|
|
|
+ IFormView szbmView=ABillServiceHelper.createAddView("bos_adminorg");
|
|
|
+ szbmView.getModel().setValue("number", "1"+szbmbm);
|
|
|
szbmView.getModel().setValue("name", szbmmc);
|
|
|
szbmView.getModel().setValue("parent", yjjg); // 设置父级为 yjjg
|
|
|
szbmView.getModel().setValue("orgpattern", xingtaiinfo);
|
|
@@ -354,15 +383,20 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
// 更新组织结构
|
|
|
DynamicObjectCollection structureInfoCollection = newOrgInfo.getDynamicObjectCollection("structure");
|
|
|
if (structureInfoCollection != null && !structureInfoCollection.isEmpty()) {
|
|
|
- DynamicObject structureInfo = structureInfoCollection.get(0);
|
|
|
- if(existingDeptEntry.getDynamicObject("orgstructure")!=null){
|
|
|
- if (!structureInfo.getPkValue().equals(existingDeptEntry.getDynamicObject("orgstructure").getPkValue())) {
|
|
|
- existingDeptEntry.set("orgstructure", structureInfo.getPkValue());
|
|
|
- deptUpdated = true;
|
|
|
+ for (DynamicObject item:structureInfoCollection) {
|
|
|
+ //不为兼职则更新
|
|
|
+ if (!item.getBoolean("ispartjob")) {
|
|
|
+ DynamicObject structureInfo=item;//获取结构信息
|
|
|
+ if(existingDeptEntry.getDynamicObject("orgstructure")!=null){
|
|
|
+ if (!structureInfo.getPkValue().equals(existingDeptEntry.getDynamicObject("orgstructure").getPkValue())) {
|
|
|
+ existingDeptEntry.set("orgstructure", structureInfo.getPkValue());
|
|
|
+ deptUpdated = true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ existingDeptEntry.set("orgstructure", structureInfo.getPkValue());
|
|
|
+ deptUpdated = true;
|
|
|
+ }
|
|
|
}
|
|
|
- }else{
|
|
|
- existingDeptEntry.set("orgstructure", structureInfo.getPkValue());
|
|
|
- deptUpdated = true;
|
|
|
}
|
|
|
}
|
|
|
// 标记是否需要保存
|
|
@@ -433,8 +467,13 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
// 获取组织的分录集合 structure 的第一条数据
|
|
|
DynamicObjectCollection structureInfoCollection = orginfo.getDynamicObjectCollection("structure");
|
|
|
if (structureInfoCollection != null && !structureInfoCollection.isEmpty()) {
|
|
|
- DynamicObject structureInfo = structureInfoCollection.get(0); // 获取第一条结构信息
|
|
|
- bumeninfo.set("orgstructure", structureInfo.getPkValue());
|
|
|
+ for (DynamicObject item:structureInfoCollection) {
|
|
|
+ //不为兼职则更新
|
|
|
+ if (!item.getBoolean("ispartjob")) {
|
|
|
+ DynamicObject structureInfo=item;//获取结构信息
|
|
|
+ bumeninfo.set("orgstructure",structureInfo.getPkValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
log.info("部门编码为 " + deptCode + " 的部门缺少组织结构信息,跳过该记录。");
|
|
|
}
|
|
@@ -477,9 +516,6 @@ public class UpdateDataDailyTask extends AbstractTask {
|
|
|
String datestr=sf.format(newDate);
|
|
|
//文件路径拼接
|
|
|
//真实路径
|
|
|
- if (nckd_url.equals("/var/appstatic/")) {
|
|
|
- nckd_url="/home/kingdee/cosmic/nginx-appstatic/store/appstatic/";
|
|
|
- }
|
|
|
String realPath = nckd_url+datestr+"/"+nckd_filename;
|
|
|
return realPath;
|
|
|
}
|