|
@@ -19,8 +19,10 @@ import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.sec.user.utils.UserOperationUtils;
|
|
import kd.bos.sec.user.utils.UserOperationUtils;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
+import kd.epm.eb.common.model.DynamicInfoCollection;
|
|
import kd.imc.bdm.common.constant.BotpCallBackLogConstant;
|
|
import kd.imc.bdm.common.constant.BotpCallBackLogConstant;
|
|
|
|
|
|
|
|
|
|
@@ -162,10 +164,45 @@ public class TestPlugin extends AbstractListPlugin {
|
|
super.afterBindData(e);
|
|
super.afterBindData(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //根据基础资料数据生成dat文件,nckdentry基础资料标识,selector字段标识,filePath文件路径
|
|
|
|
+ public void creatDatFile(String nckdentry,List<String> selector,String filePath) {
|
|
|
|
+ try {
|
|
|
|
+ //基础资料数据
|
|
|
|
+ DynamicObjectType dynamicObjectType = EntityMetadataCache.getDataEntityType(nckdentry);
|
|
|
|
+ DynamicObject[] dataList = BusinessDataServiceHelper.load(dynamicObjectType.getName(), String.join(",", selector), null);
|
|
|
|
+ File file = new File(filePath);
|
|
|
|
+ //文件路径不存在则创建文件
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
+ File parentDir = file.getParentFile();
|
|
|
|
+ if (parentDir != null && !parentDir.exists()) {
|
|
|
|
+ parentDir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ file.createNewFile();
|
|
|
|
+ }
|
|
|
|
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), "GBK"))) {
|
|
|
|
+ for (DynamicObject data : dataList) {
|
|
|
|
+ StringBuilder line = new StringBuilder();
|
|
|
|
+ for (String field : selector) {
|
|
|
|
+ line.append(data.get(field) != null ? data.get(field).toString() : "").append("\u0001");
|
|
|
|
+ }
|
|
|
|
+ line.setLength(line.length() - 1);
|
|
|
|
+ line.append("|$|");
|
|
|
|
+ writer.write(line.toString());
|
|
|
|
+ writer.newLine();
|
|
|
|
+ }
|
|
|
|
+ this.getView().showMessage("数据文件已成功生成!");
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ this.getView().showMessage("生成数据文件时发生错误!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
|
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
|
super.afterDoOperation(e);
|
|
super.afterDoOperation(e);
|
|
String filePath = "D:/test.dat";
|
|
String filePath = "D:/test.dat";
|
|
|
|
+ //生成data文件
|
|
if ("scdatwj".equals(e.getOperateKey())) {//生成data文件
|
|
if ("scdatwj".equals(e.getOperateKey())) {//生成data文件
|
|
try {
|
|
try {
|
|
DynamicObjectType dynamicObjectType = EntityMetadataCache.getDataEntityType("nckd_basicdata");
|
|
DynamicObjectType dynamicObjectType = EntityMetadataCache.getDataEntityType("nckd_basicdata");
|
|
@@ -535,7 +572,7 @@ public class TestPlugin extends AbstractListPlugin {
|
|
throw new RuntimeException(ex);
|
|
throw new RuntimeException(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //减值数据
|
|
|
|
|
|
+ //减值数据,导入数据先删除旧的数据
|
|
if ("jzsj".equals(e.getOperateKey()))
|
|
if ("jzsj".equals(e.getOperateKey()))
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
@@ -549,15 +586,11 @@ public class TestPlugin extends AbstractListPlugin {
|
|
"nckd_stage_rslt", "nckd_ecl_ratio"
|
|
"nckd_stage_rslt", "nckd_ecl_ratio"
|
|
);
|
|
);
|
|
List<DynamicObject> createdataList = new ArrayList<>();
|
|
List<DynamicObject> createdataList = new ArrayList<>();
|
|
- List<DynamicObject> updatedataList = new ArrayList<>();
|
|
|
|
- //查出所有现有的数据
|
|
|
|
|
|
+ QFilter filter=new QFilter("nckd_isdelete",QCP.equals,false);
|
|
|
|
+ //查询已经存在的数据
|
|
DynamicObject[] existingData = BusinessDataServiceHelper
|
|
DynamicObject[] existingData = BusinessDataServiceHelper
|
|
- .load(dynamicObjectType.getName(), String.join(",", selector) + ",nckd_isdelete", null);
|
|
|
|
- Map<String, DynamicObject> existingDataMap = new HashMap<>();
|
|
|
|
- for (DynamicObject obj : existingData) {
|
|
|
|
- //单据号
|
|
|
|
- existingDataMap.put(obj.getString("nckd_dubil_id"), obj);
|
|
|
|
- }
|
|
|
|
|
|
+ .load(dynamicObjectType.getName(), String.join(",", selector) + ",nckd_isdelete", new QFilter[]{filter});
|
|
|
|
+
|
|
Set<String> processeddubilidSet = new HashSet<>();
|
|
Set<String> processeddubilidSet = new HashSet<>();
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(filelocation))) {
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(filelocation))) {
|
|
String line;
|
|
String line;
|
|
@@ -572,64 +605,38 @@ public class TestPlugin extends AbstractListPlugin {
|
|
}
|
|
}
|
|
//获取单据号
|
|
//获取单据号
|
|
String dubil_id = fields[0];
|
|
String dubil_id = fields[0];
|
|
- boolean isUpdated = false;
|
|
|
|
DynamicObject data;
|
|
DynamicObject data;
|
|
processeddubilidSet.add(dubil_id);
|
|
processeddubilidSet.add(dubil_id);
|
|
- if (existingDataMap.containsKey(dubil_id)) {
|
|
|
|
- //获取对应单据号的数据
|
|
|
|
- data = existingDataMap.get(dubil_id);
|
|
|
|
- for (int i = 0; i < selector.size(); i++) {
|
|
|
|
- String fieldName = selector.get(i);
|
|
|
|
- String newValue = fields[i];
|
|
|
|
- String existingValue = data.getString(fieldName);
|
|
|
|
- //判断数据是否与之前的数据相同,不相同则更新
|
|
|
|
- if (!Objects.equals(existingValue, newValue)) {
|
|
|
|
- data.set(fieldName, newValue);
|
|
|
|
- isUpdated = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-// //更新了数据则设置数据更新的时间
|
|
|
|
- if (isUpdated) {
|
|
|
|
-// data.set("nckd_updatedate", new Date());
|
|
|
|
- updatedataList.add(data);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //不存在这条数据则新增一条到data中
|
|
|
|
- data = new DynamicObject(dynamicObjectType);
|
|
|
|
- for (int i = 0; i < selector.size(); i++) {
|
|
|
|
- data.set(selector.get(i), fields[i]);
|
|
|
|
- }
|
|
|
|
-// Date now = new Date();
|
|
|
|
-// data.set("nckd_createdate", now);
|
|
|
|
-// data.set("nckd_updatedate", now);
|
|
|
|
- createdataList.add(data);
|
|
|
|
|
|
+ //新增数据
|
|
|
|
+ data = new DynamicObject(dynamicObjectType);
|
|
|
|
+ for (int i = 0; i < selector.size(); i++) {
|
|
|
|
+ data.set(selector.get(i), fields[i]);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
- //查找数据是否被删除
|
|
|
|
- for (Map.Entry<String, DynamicObject> entry : existingDataMap.entrySet()) {
|
|
|
|
- String dubil_id = entry.getKey();
|
|
|
|
- DynamicObject data = entry.getValue();
|
|
|
|
- if (!processeddubilidSet.contains(dubil_id)) {
|
|
|
|
- data.set("nckd_isdelete", true);
|
|
|
|
- updatedataList.add(data);
|
|
|
|
|
|
+ //设置创建时间
|
|
|
|
+ data.set("nckd_creatd",new Date());
|
|
|
|
+ data.set("nckd_isdelete",false);
|
|
|
|
+ createdataList.add(data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//新增数据不为空则更新到数据库中
|
|
//新增数据不为空则更新到数据库中
|
|
if (!createdataList.isEmpty()) {
|
|
if (!createdataList.isEmpty()) {
|
|
|
|
+ //转换list为DynamicObject类型
|
|
SaveServiceHelper.save(dynamicObjectType, createdataList.toArray(new DynamicObject[0]));
|
|
SaveServiceHelper.save(dynamicObjectType, createdataList.toArray(new DynamicObject[0]));
|
|
}
|
|
}
|
|
- //更新的数据不为空,则更新到数据库中
|
|
|
|
- if (!updatedataList.isEmpty()) {
|
|
|
|
- SaveServiceHelper.save(updatedataList.get(0).getDynamicObjectType(), updatedataList.toArray(new DynamicObject[0]));
|
|
|
|
|
|
+
|
|
|
|
+ //删除所有的数据,再新增
|
|
|
|
+ for (int i=0;i<existingData.length;i++) {
|
|
|
|
+ existingData[i].set("nckd_isdelete",true);
|
|
}
|
|
}
|
|
|
|
+ SaveServiceHelper.save(existingData);
|
|
|
|
+ QFilter qFilter=new QFilter("nckd_isdelete",QCP.equals,true);
|
|
|
|
+ DeleteServiceHelper.delete(dynamicObjectType.getName(),new QFilter[]{qFilter});
|
|
this.getView().showMessage("数据已成功保存!");
|
|
this.getView().showMessage("数据已成功保存!");
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
ex.printStackTrace();
|
|
ex.printStackTrace();
|
|
this.getView().showMessage("读取文件时发生错误:" + ex.getMessage());
|
|
this.getView().showMessage("读取文件时发生错误:" + ex.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//获取接口配置表中组织人员的数据,返回服务器中文件路径
|
|
//获取接口配置表中组织人员的数据,返回服务器中文件路径
|
|
if ("jkpz".equals(e.getOperateKey())) {
|
|
if ("jkpz".equals(e.getOperateKey())) {
|
|
try {
|
|
try {
|
|
@@ -641,16 +648,16 @@ public class TestPlugin extends AbstractListPlugin {
|
|
|
|
|
|
//读取行名行号,存入对应基础资料中
|
|
//读取行名行号,存入对应基础资料中
|
|
if("hmhh".equals(e.getOperateKey())) {
|
|
if("hmhh".equals(e.getOperateKey())) {
|
|
-// String fileurl=getFileUrl("hmhhurl");
|
|
|
|
//行名行号表字段
|
|
//行名行号表字段
|
|
List<String> selector = Arrays.asList(
|
|
List<String> selector = Arrays.asList(
|
|
"number", "name"
|
|
"number", "name"
|
|
);
|
|
);
|
|
//文件路径
|
|
//文件路径
|
|
- String fileurl="D:/hmhh.dat";
|
|
|
|
|
|
+// String fileurl="D:/hmhh.dat";
|
|
//行名行号表标识
|
|
//行名行号表标识
|
|
String bd_bebank="bd_bebank";
|
|
String bd_bebank="bd_bebank";
|
|
try {
|
|
try {
|
|
|
|
+ String fileurl = getFileUrl("hmhhurl");
|
|
//基础资料
|
|
//基础资料
|
|
DynamicObjectType dynamicObjectType = EntityMetadataCache.getDataEntityType(bd_bebank);
|
|
DynamicObjectType dynamicObjectType = EntityMetadataCache.getDataEntityType(bd_bebank);
|
|
//国家基础资料(中国)
|
|
//国家基础资料(中国)
|