Commit d203eef4 by liuyang

2024-08-16 安全记录APP附件上传调整

parent 97999a1f
......@@ -18,11 +18,10 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.lang3.ArrayUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author LiuYang
......@@ -61,7 +60,21 @@ public class ServiceHPSB008 extends ServiceEPBase {
@Override
public EiInfo delete(EiInfo inInfo) {
return super.delete(inInfo, HPSB008.DELETE);
try {
int rowCount = inInfo.getBlock(EiConstant.resultBlock).getRowCount();
for (int i = 0; i < rowCount; i++) {
Map<?,?> rowMap = inInfo.getBlock(EiConstant.resultBlock).getRow(i);
HPSB008 hpsb008 = new HPSB008();
hpsb008.fromMap(rowMap);
this.deleteFile(hpsb008.getId().toString());
DaoUtils.update(HPSB008.DELETE, hpsb008);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + rowCount + "]条数据保存成功!");
}catch (Exception e){
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "安全记录",operType = "保存",operDesc = "操作")
......@@ -104,49 +117,97 @@ public class ServiceHPSB008 extends ServiceEPBase {
public EiInfo appSave(EiInfo inInfo) {
try{
Map resultMap = EiInfoUtils.getFirstRow(inInfo, EiConstant.resultBlock);
String docId = MapUtils.getString(resultMap, HPSB099.FIELD_DOC_ID);
String docVideoId = MapUtils.getString(resultMap, HPSB099.FIELD_DOC_VIDEO_ID);
String docId = MapUtils.getString(resultMap, HPSB099.FIELD_DOC_ID).trim();
String docVideoId = MapUtils.getString(resultMap, HPSB099.FIELD_DOC_VIDEO_ID).trim();
String[] docIds = {};
String [] docVideoIds = {};
if (StringUtils.isNotEmpty(docId)) {
docIds = docId.split(",");
}
if (StringUtils.isNotEmpty(docVideoId)) {
docVideoIds = docVideoId.split(",");
}
HPSB008 hpsb008 = new HPSB008();
hpsb008.fromMap(resultMap);
if (hpsb008.getId() == null || hpsb008.getId() == 0) {
hpsb008.setRecordCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.RECORD_CODE));
DaoUtils.insert(HPSB008.INSERT, hpsb008);
this.addFile(hpsb008, docIds, docVideoIds);
}else {
/*List<HPSB099> hpsb099List = HPSBTools.Hpsb099.getMatId(hpsb008.getId());
if (hpsb099List.size() > 0) {
for (HPSB099 hpsb099 : hpsb099List) {
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocId());
}
}*/
this.modify(hpsb008);
this.modifyFile(hpsb008, docIds, docVideoIds);
}
if (StringUtils.isNotEmpty(docId)) {
String [] docIds = docId.split(",");
for (String docIdStr : docIds){
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
public void deleteFile(String docId) {
List<HPSB099> hpsb099List = HPSBTools.Hpsb099.getMatId(Long.valueOf(docId));
if (hpsb099List.size() > 0) {
for (HPSB099 hpsb099 : hpsb099List) {
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocId());
}
}
}
public void addFile(HPSB008 hpsb008, String[] docIds, String[] docVideoIds) {
for (String docIdStr : docIds){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
for (String docIdStr : docVideoIds){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setDocVideoId(docIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
}
public void modifyFile(HPSB008 hpsb008, String[] docIds, String[] docVideoIds) {
List<HPSB099> hpsb099List = HPSBTools.Hpsb099.getMatId(hpsb008.getId());
for (String docIdStr : docIds){
List list = hpsb099List.stream().filter(hpsb099 -> hpsb099.getDocId().equals(docIdStr)).collect(Collectors.toList());
if (list.isEmpty()){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
}
if (StringUtils.isNotEmpty(docVideoId)){
String [] docVideoIds = docVideoId.split(",");
for (String docIdStr : docVideoIds){
}
for (String docVideoIdStr : docVideoIds){
List list = hpsb099List.stream().filter(hpsb099 -> hpsb099.getDocId().equals(docVideoIdStr)).collect(Collectors.toList());
if (list.isEmpty()){
HPSB099 hgsc099 = new HPSB099();
hgsc099.setBizType("SBJL");
hgsc099.setDocId(docIdStr);
hgsc099.setDocVideoId(docIdStr);
hgsc099.setDocId(docVideoIdStr);
hgsc099.setDocVideoId(docVideoIdStr);
hgsc099.setMatId(hpsb008.getId());
DaoUtils.insert(HPSB099.INSERT, hgsc099);
}
}
for (HPSB099 hpsb099 : hpsb099List) {
if (hpsb099.getDocId().trim().length() > 0 && hpsb099.getDocVideoId().trim().length() == 0 && !ArrayUtils.contains(docIds, hpsb099.getDocId())){
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocId());
}
if (hpsb099.getDocVideoId().trim().length() >0 && !ArrayUtils.contains(docVideoIds, hpsb099.getDocVideoId())){
DaoUtils.update(HPSB099.DELETE, hpsb099);
Iplat4jUtils.deleteFileByDocId(hpsb099.getDocVideoId());
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment