parent
7405ceb954
commit
527be70f8b
|
@ -2,11 +2,19 @@ package shkd.repc.repmd.formplugin;
|
||||||
|
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
|
import kd.bos.form.control.AttachmentPanel;
|
||||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
|
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.web.actions.utils.FilePathUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ProjectBbFormPlugin extends AbstractFormPlugin {
|
public class ProjectBbFormPlugin extends AbstractFormPlugin {
|
||||||
|
|
||||||
|
@ -15,7 +23,7 @@ public class ProjectBbFormPlugin extends AbstractFormPlugin {
|
||||||
super.afterBindData(e);
|
super.afterBindData(e);
|
||||||
|
|
||||||
Long lastprojectid = (Long)this.getModel().getValue("lastprojectid");//上版本项目ID(修订使用)
|
Long lastprojectid = (Long)this.getModel().getValue("lastprojectid");//上版本项目ID(修订使用)
|
||||||
if (null != lastprojectid ) {
|
if (lastprojectid != 0 ) {
|
||||||
DynamicObject projectbill = BusinessDataServiceHelper.loadSingle(lastprojectid, "repmd_projectbill");
|
DynamicObject projectbill = BusinessDataServiceHelper.loadSingle(lastprojectid, "repmd_projectbill");
|
||||||
if (null != projectbill) {
|
if (null != projectbill) {
|
||||||
BigDecimal qeugDecimalfield5 = (BigDecimal)this.getModel().getValue("qeug_decimalfield5");//改建后可出租面积(㎡)
|
BigDecimal qeugDecimalfield5 = (BigDecimal)this.getModel().getValue("qeug_decimalfield5");//改建后可出租面积(㎡)
|
||||||
|
@ -26,12 +34,39 @@ public class ProjectBbFormPlugin extends AbstractFormPlugin {
|
||||||
if (qeugTextfield3.isEmpty()) {
|
if (qeugTextfield3.isEmpty()) {
|
||||||
this.getModel().setValue("qeug_textfield3", projectbill.getString("qeug_textfield3"));
|
this.getModel().setValue("qeug_textfield3", projectbill.getString("qeug_textfield3"));
|
||||||
}
|
}
|
||||||
// DynamicObjectCollection collection = this.getModel().getDataEntity().getDynamicObjectCollection("attachmentpanel");//附件
|
//附件
|
||||||
// if (collection.isEmpty()) {
|
AttachmentPanel qeug_attachmentpanelap = this.getView().getControl("attachmentpanel");
|
||||||
//
|
List<Map<String, Object>> attachments = qeug_attachmentpanelap.getAttachmentData();
|
||||||
// }
|
if (attachments.isEmpty()) {
|
||||||
}
|
List<Map<String, Object>> attachmentData = AttachmentServiceHelper.getAttachments("kded_sourcebill",
|
||||||
}
|
projectbill.getLong("id"), "attachmentpanel");
|
||||||
|
attachmentData.forEach(attach -> {
|
||||||
|
try {
|
||||||
|
//源附件数据的lastModified是timestamp,会出现强转long错误在此置null
|
||||||
|
attach.put("lastModified", null);
|
||||||
|
//源附件数据的url已经过URL编码,需要在此先解码获取原始下载路径,AttachmentServiceHelper.upload()会进行URL编码
|
||||||
|
attach.put("url", getPathfromDownloadUrl(URLDecoder.decode(String.valueOf(attach.get("url")), "UTF-8")));
|
||||||
|
//调用AttachmentServiceHelper.upload(formId, pkId, attachKey, attachments)将附件数据上传到目标附件面板
|
||||||
|
AttachmentServiceHelper.upload(getView().getEntityId(), getModel().getValue("id"), "attachmentpanel", attachmentData);
|
||||||
|
|
||||||
|
} catch (IOException ex) {
|
||||||
|
//do something with log.
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取文件服务器相对路径
|
||||||
|
* @param url
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private String getPathfromDownloadUrl(String url) throws IOException {
|
||||||
|
String path = StringUtils.substringAfter(url, "path=");
|
||||||
|
path = URLDecoder.decode(path, "UTF-8");
|
||||||
|
return FilePathUtil.dealPath(path, "attach");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue