|
@ -36,9 +36,9 @@ public class MasterResourceDao {
|
|
|
|
|
|
public void saveOrUpdate(ResourceBucket resourceBucket, OriginalPackage originalPackage) throws Exception {
|
|
|
//如果是非结构化档案, 或者是 影像档案, 通过rowkey 判断结构化档案 是否有数据
|
|
|
if(originalPackage instanceof FilePackage || originalPackage instanceof LinkPackage){
|
|
|
if (originalPackage instanceof FilePackage || originalPackage instanceof LinkPackage){
|
|
|
String profileId = originalPackage.getProfileId().toString();
|
|
|
String rowkey = profileId.substring(2,profileId.length());
|
|
|
String rowkey = profileId.substring(2, profileId.length());
|
|
|
Map<String, String> originResult = hbaseDao.get(ResourceCore.MasterTable, rowkey, resourceBucket.getdFamily());
|
|
|
if (!originResult.isEmpty()) {
|
|
|
throw new IllegalJsonFileException("Please upload the struct package(" + rowkey + ") first !");
|
|
@ -46,7 +46,8 @@ public class MasterResourceDao {
|
|
|
}
|
|
|
String rowKey = resourceBucket.getId();
|
|
|
TableBundle bundle = new TableBundle();
|
|
|
if (originalPackage.isReUploadFlg()) { //补传处理
|
|
|
//补传处理
|
|
|
if (originalPackage.isReUploadFlg()) {
|
|
|
Map<String, String> originResult = hbaseDao.get(resourceBucket.getMaster(), rowKey, resourceBucket.getdFamily());
|
|
|
if (!originResult.isEmpty()) {
|
|
|
MasterRecord masterRecord = resourceBucket.getMasterRecord();
|
|
@ -55,10 +56,11 @@ public class MasterResourceDao {
|
|
|
bundle.addValues(rowKey, resourceBucket.getdFamily(), originResult);
|
|
|
hbaseDao.save(resourceBucket.getMaster(), bundle);
|
|
|
Map<String, String> basicResult = hbaseDao.get(resourceBucket.getMaster(), rowKey, resourceBucket.getBasicFamily());
|
|
|
updateFile(resourceBucket,originalPackage,basicResult);
|
|
|
updateFile(resourceBucket, originalPackage, basicResult);
|
|
|
if (StringUtils.isNotEmpty(basicResult.get(ResourceCells.EVENT_TYPE))) {
|
|
|
EventType eventType = EventType.create(basicResult.get(ResourceCells.EVENT_TYPE));
|
|
|
originalPackage.setEventType(eventType);
|
|
|
resourceBucket.insertBasicRecord(ResourceCells.EVENT_TYPE, Integer.toString(eventType.ordinal()));
|
|
|
}
|
|
|
resourceBucket.insertBasicRecord(ResourceCells.DEMOGRAPHIC_ID, basicResult.get(ResourceCells.DEMOGRAPHIC_ID));
|
|
|
} else {
|
|
@ -94,7 +96,7 @@ public class MasterResourceDao {
|
|
|
* @param basicResult
|
|
|
*/
|
|
|
private void updateFile(ResourceBucket resourceBucket, OriginalPackage originalPackage,Map<String, String> basicResult){
|
|
|
if(originalPackage instanceof FilePackage){
|
|
|
if (originalPackage instanceof FilePackage) {
|
|
|
String file_list = basicResult.get("file_list");
|
|
|
JsonArray oldFileArray = new JsonParser().parse(file_list).getAsJsonArray();
|
|
|
JsonArray newFileArray = new JsonArray();
|
|
@ -103,28 +105,28 @@ public class MasterResourceDao {
|
|
|
String file_list1 = resourceBucket.getBasicRecord("file_list");
|
|
|
JsonArray waitAddFileArray = new JsonParser().parse(file_list1).getAsJsonArray();
|
|
|
|
|
|
for(JsonElement waitAdd :waitAddFileArray){
|
|
|
for (JsonElement waitAdd :waitAddFileArray){
|
|
|
String cdaId = ((JsonObject) waitAdd).get("cda_document_id").getAsString();
|
|
|
for(JsonElement oldFile :oldFileArray){
|
|
|
for (JsonElement oldFile :oldFileArray){
|
|
|
String oldCdaId = ((JsonObject) oldFile).get("cda_document_id").getAsString();
|
|
|
if(cdaId.equalsIgnoreCase(oldCdaId)){
|
|
|
if (cdaId.equalsIgnoreCase(oldCdaId)){
|
|
|
newFileArray.remove(oldFile);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
newFileArray.addAll(waitAddFileArray);
|
|
|
basicResult.put("file_list",newFileArray.toString());
|
|
|
basicResult.put("file_list", newFileArray.toString());
|
|
|
TableBundle bundle = new TableBundle();
|
|
|
bundle.addValues(resourceBucket.getId(), resourceBucket.getBasicFamily(), basicResult);
|
|
|
hbaseDao.save(resourceBucket.getMaster(), bundle);
|
|
|
}else if (originalPackage instanceof LinkPackage){
|
|
|
} else if (originalPackage instanceof LinkPackage) {
|
|
|
String file_list = basicResult.get("file_list");
|
|
|
JsonArray oldFileArray = new JsonParser().parse(file_list).getAsJsonArray();
|
|
|
//新上报的数据
|
|
|
String file_list1 = resourceBucket.getBasicRecord("file_list");
|
|
|
JsonArray waitAddFileArray = new JsonParser().parse(file_list1).getAsJsonArray();
|
|
|
oldFileArray.addAll(waitAddFileArray);
|
|
|
basicResult.put("file_list",oldFileArray.toString());
|
|
|
basicResult.put("file_list", oldFileArray.toString());
|
|
|
TableBundle bundle = new TableBundle();
|
|
|
bundle.addValues(resourceBucket.getId(), resourceBucket.getBasicFamily(), basicResult);
|
|
|
hbaseDao.save(resourceBucket.getMaster(), bundle);
|