1.修改增加费用登记识别发票后保存发票登记同时把发票带到发票登记中
This commit is contained in:
parent
8a8326653f
commit
cb2341c462
|
@ -13,6 +13,8 @@ import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
|||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.fileservice.FileItem;
|
||||
import kd.bos.fileservice.FileService;
|
||||
import kd.bos.fileservice.FileServiceFactory;
|
||||
import kd.bos.form.*;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
|
@ -44,7 +46,9 @@ import org.agrona.Strings;
|
|||
import shkd.repc.recon.formplugin.ReconPayreqFormPlugin;
|
||||
import shkd.utils.DobeDWUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -439,6 +443,8 @@ public class ReconPayreqNewFormPlugin extends AbstractFormPlugin implements Befo
|
|||
OperationResult operationResult1 = OperationServiceHelper.executeOperate("save", "recon_invoicebill", new DynamicObject[]{recon_invoicebill}, operateOption1);
|
||||
if (!operationResult1.isSuccess()){
|
||||
logger.error(operationResult1.getMessage());
|
||||
} else{
|
||||
saveAttachmentToInvoicebill( attachment, operationResult1.getSuccessPkIds().get(0).toString());
|
||||
}
|
||||
//提交
|
||||
OperateOption operateOption2 = OperateOption.create();
|
||||
|
@ -558,6 +564,47 @@ public class ReconPayreqNewFormPlugin extends AbstractFormPlugin implements Befo
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**将费用登记发票附件保存至对应发票登记*
|
||||
* pkid:发票登记ID
|
||||
*
|
||||
* **/
|
||||
private void saveAttachmentToInvoicebill(Map<String, Object> attachment,String pkid) {
|
||||
Object attPKId = attachment.get("attPkId");
|
||||
AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(attPKId);
|
||||
String resourcePath = attachmentDto.getResourcePath();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
FileServiceFactory.getAttachmentFileService().download(resourcePath,out,null);
|
||||
byte[] bytes = out.toByteArray();
|
||||
String type = attachment.get("type").toString();//附件类型
|
||||
String fileName = attachment.get("name").toString();//附件名称
|
||||
InputStream input = new ByteArrayInputStream(bytes);
|
||||
String uploadPath = "dbjt/" + fileName;
|
||||
StringBuffer uid = new StringBuffer();
|
||||
uid.append("rc-upload-").append(new Date().getTime()).append("-");
|
||||
int index = (int) (1 + Math.random() * 10);
|
||||
String uid1 = uid.toString() + index++;
|
||||
/****上传****/
|
||||
FileService fs = FileServiceFactory.getAttachmentFileService();
|
||||
// 构造FileItem
|
||||
FileItem fi = new FileItem(fileName, uploadPath, input);
|
||||
String path = fs.upload(fi);
|
||||
/****绑定****/
|
||||
Map uploadFileMap = new HashMap();
|
||||
uploadFileMap.put("uid", uid1);
|
||||
uploadFileMap.put("entityNum", "recon_invoicebill");
|
||||
uploadFileMap.put("billPkId", pkid);
|
||||
uploadFileMap.put("lastModified", new Date().getTime());
|
||||
uploadFileMap.put("name", fileName);
|
||||
uploadFileMap.put("url", path);
|
||||
uploadFileMap.put("size", bytes.length);
|
||||
uploadFileMap.put("status", "success");
|
||||
List<Map<String, Object>> attachments = new ArrayList<>( );
|
||||
attachments.add(uploadFileMap);
|
||||
AttachmentServiceHelper.upload("recon_invoicebill", pkid, "attachmentpanel", attachments);
|
||||
}
|
||||
|
||||
private void updateAmt(){
|
||||
DynamicObject dataEntity = this.getModel().getDataEntity();
|
||||
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||
|
|
Loading…
Reference in New Issue