Commit a6fd19d4 by liuyang

2024-05-23 维保申请更改为多条附件上传

parent 4f1827f7
package com.baosight.hggp.hg.sb.service;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.ds.domain.HGDS002;
import com.baosight.hggp.hg.sb.domain.HGSB099;
import com.baosight.hggp.util.FileUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/5/23
*/
public class ServiceHGSB099 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGSB099().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
try {
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
if (CommonConstant.projectEnv.RUN.equalsIgnoreCase(projectEnv)) {
inInfo = super.query(inInfo, "HGSB099.queryRun", new HGSB099());
} else {
inInfo = super.query(inInfo, "HGSB099.queryDev", new HGSB099());
}
} catch (Throwable e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@Override
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HGSB099 hgsb099 = new HGSB099();
hgsb099.fromMap(resultRow);
DaoUtils.update(HGSB099.DELETE, hgsb099);
if (!hgsb099.getDocId().isEmpty()) {
this.delectDoc(hgsb099.getDocId());
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
@Override
public EiInfo insert(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (Map resultRow : resultRows) {
HGSB099 hgsb099 = new HGSB099();
hgsb099.fromMap(resultRow);
DaoUtils.insert(HGSB099.INSERT, hgsb099);
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据新增成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败");
}
return inInfo;
}
/**
* 删除文件
* @param docId 文件ID
*/
public void delectDoc(String docId){
Map<String,Object> map = new HashMap<>();
map.put("docId",docId);
List<HGDS002> list = this.dao.query(HGDS002.QUERY,map);
if (list.size() > 0) {
String realPath = list.get(0).getRealPath();
// 项目环境
String projectEnv = ProjectInfo.getProjectEnv();
if (projectEnv.equals(CommonConstant.projectEnv.RUN)) {
EiInfo queryInfo = new EiInfo();
queryInfo.set(HGSB099.FIELD_DOC_ID,list.get(0).getDocId());
//获取文档信息
queryInfo.set(EiConstant.serviceId,"S_EU_0102");
EiInfo docInfo = XServiceManager.call(queryInfo);
//数据库
Map docInfoMap = docInfo.getMap("docMap");
if (docInfoMap.size() > 0) {
EiInfo eiInfo = new EiInfo();
eiInfo.set("data",docInfoMap.get("url")+"-"+0);
eiInfo.set(EiConstant.serviceId,"S_EU_0105");
//调用接口
EiInfo outInfo = XServiceManager.call(eiInfo);
if(outInfo.getStatus() == EiConstant.STATUS_FAILURE){
LogUtils.setDetailMsg(outInfo, new Throwable(), "查询部件类型失败");
outInfo.setMsg("失败");
}
}
}else {
FileUtils.deleteFile(realPath);
}
this.dao.delete(HGDS002.DELETE,map);
}
}
}
...@@ -30,7 +30,7 @@ $(function () { ...@@ -30,7 +30,7 @@ $(function () {
let template = ''; let template = '';
if (item.id) { if (item.id) {
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" ' template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="uploadFile(' + item.id + ')" >附件上传</a>'; + 'onclick="uploadFile(' + item.id + ')" >附件详情</a>';
} }
if (item.id) { if (item.id) {
if (auditStatus == 0) { if (auditStatus == 0) {
...@@ -88,7 +88,7 @@ $(function () { ...@@ -88,7 +88,7 @@ $(function () {
} }
return dataItem["deviceCode"] return dataItem["deviceCode"]
} }
}, { }, /*{
field: "docId", field: "docId",
template: function (item) { template: function (item) {
let template = ''; let template = '';
...@@ -99,7 +99,7 @@ $(function () { ...@@ -99,7 +99,7 @@ $(function () {
} }
return template; return template;
} }
}, { },*/ {
field: "applyUserId", field: "applyUserId",
title: "申请人", title: "申请人",
template: function (dataItem) { template: function (dataItem) {
...@@ -276,11 +276,11 @@ function updateStatus(id,deviceStatus) { ...@@ -276,11 +276,11 @@ function updateStatus(id,deviceStatus) {
*/ */
function uploadFile(id) { function uploadFile(id) {
JSColorbox.open({ JSColorbox.open({
href: "HGSB003A?methodName=initLoad&inqu_status-0-id="+id, href: "HGSB099?methodName=initLoad&inqu_status-0-matId="+id+"&inqu_status-0-bizType=SB003",
title: "<div style='text-align: center;'>附件上传</div>", title: "<div style='text-align: center;'>附件上传</div>",
width: "60%", width: "60%",
height: "50%", height: "50%",
callbackName: uploadFileCallback //callbackName: uploadFileCallback
}); });
} }
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<EF:EFComboColumn ename="status" cname="审批状态" width="80" align="center" enable="false" required="true" defaultValue="0"> <EF:EFComboColumn ename="status" cname="审批状态" width="80" align="center" enable="false" required="true" defaultValue="0">
<EF:EFCodeOption codeName="hggp.hgsb.approveStatus"/> <EF:EFCodeOption codeName="hggp.hgsb.approveStatus"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="docId" cname="维修图片" width="100" enable="false" readonly="true" align="center"/> <%--<EF:EFColumn ename="docId" cname="维修图片" width="100" enable="false" readonly="true" align="center"/>--%>
<EF:EFColumn cname="创建人" ename="createdName" align="center" width="100" readonly="true" required="false" enable="false"/> <EF:EFColumn cname="创建人" ename="createdName" align="center" width="100" readonly="true" required="false" enable="false"/>
<EF:EFColumn cname="创建时间" ename="createdTime" parseFormats="['yyyyMMddHHmmss']" editType="datetime" <EF:EFColumn cname="创建时间" ename="createdTime" parseFormats="['yyyyMMddHHmmss']" editType="datetime"
dateFormat="yyyy-MM-dd HH:mm:ss" align="center" width="120" readonly="true" required="false" dateFormat="yyyy-MM-dd HH:mm:ss" align="center" width="120" readonly="true" required="false"
......
...@@ -6,15 +6,15 @@ $(function () { ...@@ -6,15 +6,15 @@ $(function () {
success: function(e) { success: function(e) {
let docId = e.response.docId; let docId = e.response.docId;
let docName = e.response.docName; let docName = e.response.docName;
let id = $("#inqu_status-0-id").val() let id = $("#inqu_status-0-matId").val()
if (isBlank(docId)) { if (isBlank(docId)) {
return; return;
} }
$("#fileDocId").val(docId); $("#fileDocId").val(docId);
NotificationUtil("附件上传成功"); NotificationUtil("附件上传成功");
//saveTemp(e); saveTemp(e);
try { try {
parent.JSColorbox.setValueCallback({"id":id,"docId":docId,"docName":docName}); parent.JSColorbox.setValueCallback(e.response);
parent.JSColorbox.close(); parent.JSColorbox.close();
} catch (e){ } catch (e){
} }
...@@ -36,7 +36,7 @@ $(function () { ...@@ -36,7 +36,7 @@ $(function () {
result.set("result-0-realPath",docUrl); result.set("result-0-realPath",docUrl);
result.set("result-0-bizType",$("#inqu_status-0-bizType").val()); result.set("result-0-bizType",$("#inqu_status-0-bizType").val());
result.set("result-0-matId",$("#inqu_status-0-matId").val()); result.set("result-0-matId",$("#inqu_status-0-matId").val());
EiCommunicator.send("HPDS002", "insert", result, { EiCommunicator.send("HGDS002", "insert", result, {
onSuccess: function (ei) { onSuccess: function (ei) {
if (ei.getStatus() >= 0) { if (ei.getStatus() >= 0) {
if (ei.getStatus() == 0) { if (ei.getStatus() == 0) {
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
<c:set var="ctx" value="${pageContext.request.contextPath}"/> <c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="附件上传"> <EF:EFPage title="附件上传">
<EF:EFInput blockId="inqu_status" row="0" ename="id" cname="ID" type="hidden"/> <EF:EFInput blockId="inqu_status" row="0" ename="matId" cname="ID" type="hidden"/>
<EF:EFInput cname="业务类型" ename="bizType" blockId="inqu_status" row="0" type="hidden"/>
<EF:EFRegion id="result"> <EF:EFRegion id="result">
<EF:EFUpload blockId="result" ename="uploadFile" docTag="hg_file003" path="A"/> <EF:EFUpload blockId="result" ename="uploadFile" docTag="hg_file003" path="HGSB"/>
</EF:EFRegion> </EF:EFRegion>
<EF:EFInput ename="fileDocId" cname="" hidden="true"/> <EF:EFInput ename="fileDocId" cname="" hidden="true"/>
</EF:EFPage> </EF:EFPage>
$(function () {
IPLATUI.EFGrid = {
"result": {
columns: [{
field: "operator",
template: function (item) {
let template = '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'href="' + downloadHref(item.docId) + '" target="_blank">附件下载</a>';
return template;
}
}],
loadComplete: function(grid){
// 附件上传
$("#UPLOAD_FILE").on("click", uploadFile);
// 删除
$("#BTN_DELETE").on("click", deleteFunc);
},
dataBound: function () {
}
}
};
$("#ef_form_head").hide();
// 查询
$("#QUERY").on("click", query);
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 初始化查询
query();
});
/**
* 查询
*/
var query = function (e) {
resultGrid.dataSource.page(1);
}
/**
* 文件上传
*
* @param id
*/
function uploadFile(id) {
JSColorbox.open({
href: "HGSB003A?methodName=initLoad&inqu_status-0-bizType="+$("#inqu_status-0-bizType").val()+"&inqu_status-0-matId="+$("#inqu_status-0-matId").val(),
title: "<div style='text-align: center;'>附件上传</div>",
width: "60%",
height: "50%",
callbackName: uploadFileCallback
});
}
/**
* 附件上传回调
*
* @param docId
*/
function uploadFileCallback(item) {
let inEiInfo = new EiInfo();
inEiInfo.set("result-0-matId", $("#inqu_status-0-matId").val());
inEiInfo.set("result-0-docId", item.docId);
inEiInfo.set("result-0-docName",item.docName);
inEiInfo.set("result-0-docSize",item.docSize);
inEiInfo.set("result-0-docTag",item.docTag);
inEiInfo.set("result-0-realPath",item.docUrl);
inEiInfo.set("result-0-bizType", $("#inqu_status-0-bizType").val());
EiCommunicator.send('HGSB099', 'insert', inEiInfo, {
onSuccess(response) {
resultGrid.dataSource.page(1);
},
onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error");
}
}, {
async: false
});
}
/**
* 删除
*/
function deleteFunc() {
var rows = resultGrid.getCheckedRows();
if (rows.length == 0) {
message("请先勾选数据!");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作?", {
ok: function () {
JSUtils.submitGridsData("result", "HGSB099", "delete", true);
}
})
}
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: 1
Date: 2024/5/23
Time: 19:53
To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="附件清单">
<EF:EFRegion id="inqu" title="查询区域" type="query">
<EF:EFInput cname="主表ID" ename="matId" blockId="inqu_status" row="0" type="hidden"/>
<EF:EFInput cname="业务类型" ename="bizType" blockId="inqu_status" row="0" type="hidden"/>
<div class="row">
<EF:EFInput cname="文件名称" ename="docName" blockId="inqu_status" row="0" colWidth="3" />
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override" checkMode="row" isFloat="true">
<EF:EFColumn ename="id" cname="ID" hidden="true"/>
<EF:EFColumn ename="docId" cname="文件ID" enable="false" width="150"/>
<EF:EFColumn ename="docName" cname="文件名称" enable="false" width="150"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
parseFormats="['yyyyMMddHHmmss']" editType="datetime" dateFormat="yyyy-MM-dd HH:mm:ss"/>
<EF:EFColumn ename="operator" cname="操作" enable="false" width="200" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
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