解析数据删除接口
This commit is contained in:
parent
4f28855752
commit
440fc917a4
|
|
@ -16,4 +16,12 @@ public interface QualificationApplicationService {
|
|||
* @return
|
||||
*/
|
||||
Map<String, Object> parsingFiles(Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 删除已经解析的数据
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> deleteParsedData(Map<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,12 @@ public interface UnpackZipService {
|
|||
*/
|
||||
Map<String, Object> reviewResubmittedMaterials(ZipFile zipFile, String requestId, JsonNode rootNode, Map<String, FileHeader> imageFileMap);
|
||||
|
||||
/**
|
||||
* 删除文件解析数据
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> deleteParsedData(Map<String, Object> param);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.engine.secret.util.ConfigUtil;
|
|||
import com.engine.secret.util.FieldConvertUtil;
|
||||
import com.engine.secret.util.ModeUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.wbi.util.Util;
|
||||
import com.weaver.formmodel.data.model.Formfield;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.FileHeader;
|
||||
|
|
@ -79,6 +80,45 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer
|
|||
return returnMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> deleteParsedData(Map<String, Object> param) {
|
||||
String requestId = Util.null2String(param.get("requestId"));
|
||||
String isCorrection = Util.null2String(param.get("isCorrection"));
|
||||
|
||||
// 读取配置表
|
||||
RecordSet rs = new RecordSet();
|
||||
List<DataConfig> dataConfig = getDataConfig("0");
|
||||
|
||||
if ("true".equals(isCorrection)) {
|
||||
// 补正
|
||||
} else {
|
||||
// 非补正
|
||||
for (DataConfig config : dataConfig) {
|
||||
String mainTableName = config.getMainTableName();
|
||||
String relatedField = config.getRelatedField();
|
||||
List<DataConfig> childDataConfig = config.getChildDataConfig();
|
||||
|
||||
String sql = "select id from " + mainTableName + " where " + relatedField + " =?";
|
||||
rs.executeQuery(sql, requestId);
|
||||
if (rs.next()) {
|
||||
int billId = rs.getInt("id");
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
// 删除明细表数据
|
||||
for (DataConfig childConfig : childDataConfig) {
|
||||
String detailTableName = childConfig.getDetailTableName();
|
||||
rs.executeUpdate("delete from " + detailTableName + " where mainid = ?", billId);
|
||||
}
|
||||
// 删除主表数据
|
||||
rs.executeUpdate("delete from " + mainTableName + " where id = ?", billId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化全局变量数据
|
||||
*
|
||||
|
|
@ -185,7 +225,8 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer
|
|||
* @param childDataConfigList
|
||||
* @throws Exception
|
||||
*/
|
||||
private void processChildDataConfigForUpdate(int billId, List<DataConfig> childDataConfigList) throws Exception {
|
||||
private void processChildDataConfigForUpdate(int billId, List<DataConfig> childDataConfigList) throws
|
||||
Exception {
|
||||
for (DataConfig childDataConfig : childDataConfigList) {
|
||||
String detailTableName = childDataConfig.getDetailTableName();
|
||||
List<FileConfig> childFileList = childDataConfig.getFileList();
|
||||
|
|
@ -723,7 +764,8 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer
|
|||
* @param isDetail
|
||||
* @throws Exception
|
||||
*/
|
||||
private void dealFileList(int mainId, List<FileConfig> fileConfigList, String tableName, boolean isDetail) throws Exception {
|
||||
private void dealFileList(int mainId, List<FileConfig> fileConfigList, String tableName, boolean isDetail) throws
|
||||
Exception {
|
||||
Map<String, Object> dataMap = new IgnoreCaseHashMap<>();
|
||||
Map<String, Object> defaultDataMap = new IgnoreCaseHashMap<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> deleteParsedData(Map<String, Object> param) {
|
||||
return ServiceUtil.getService(OfflineZipUnpackServiceImpl.class, user).deleteParsedData(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压ZIP文件
|
||||
*
|
||||
|
|
@ -146,7 +151,10 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
|
||||
|
||||
// 获取数据文件,用于后续数据解析
|
||||
String jsonFileName="(database)data.json";
|
||||
String jsonFileName = "(database)data.json";
|
||||
if ("true".equals(isCorrection)) {
|
||||
jsonFileName = "(extra)data.json";
|
||||
}
|
||||
FileHeader fileHeader = fileHeaderMap.get(jsonFileName);
|
||||
int dataJsonImageId = generateImageFileId(zipFile, fileHeader, jsonFileName);
|
||||
|
||||
|
|
@ -155,9 +163,9 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
JsonNode rootNode = parseJsonContent(dataJsonImageId);
|
||||
OfflineZipUnpackServiceImpl offlineZipUnpackService = ServiceUtil.getService(OfflineZipUnpackServiceImpl.class, user);
|
||||
if ("true".equals(isCorrection)) {
|
||||
return offlineZipUnpackService.reviewResubmittedMaterials(zipFile,requestId, rootNode, fileHeaderMap);
|
||||
return offlineZipUnpackService.reviewResubmittedMaterials(zipFile, requestId, rootNode, fileHeaderMap);
|
||||
}
|
||||
return offlineZipUnpackService.registerAcceptance(zipFile,requestId, rootNode, fileHeaderMap);
|
||||
return offlineZipUnpackService.registerAcceptance(zipFile, requestId, rootNode, fileHeaderMap);
|
||||
}
|
||||
|
||||
// TODO 兼容其他方式
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import weaver.hrm.User;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
|
@ -27,7 +27,7 @@ public class QualificationApplicationController {
|
|||
return ServiceUtil.getService(QualificationApplicationServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@POST
|
||||
@Path("/parsingFiles")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String parsingFiles(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
|
|
@ -36,4 +36,14 @@ public class QualificationApplicationController {
|
|||
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::parsingFiles, params);
|
||||
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/deleteParsedData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String deleteParsedData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> params = ParamUtil.request2Map(request);
|
||||
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::deleteParsedData, params);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue