全量提交
This commit is contained in:
parent
7c2a9ed2cf
commit
4fad9b294e
|
@ -0,0 +1,45 @@
|
|||
package q79l.pur.cosmic.plugin.demo;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
public class EmailSender {
|
||||
private String fromEmail;
|
||||
private String password;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
public EmailSender(String fromEmail, String password, String host, int port) {
|
||||
this.fromEmail = fromEmail;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void sendEmail(String toEmail, String subject, String content) throws MessagingException {
|
||||
Properties properties = new Properties();
|
||||
properties.put("mail.smtp.auth", "true");
|
||||
properties.put("mail.smtp.starttls.enable", "true");
|
||||
properties.put("mail.smtp.host", host);
|
||||
properties.put("mail.smtp.port", port);
|
||||
|
||||
Session session = Session.getInstance(properties, new javax.mail.Authenticator() {
|
||||
protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
|
||||
return new javax.mail.PasswordAuthentication(fromEmail, password);
|
||||
}
|
||||
});
|
||||
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(fromEmail));
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail));
|
||||
message.setSubject(subject);
|
||||
message.setText(content);
|
||||
|
||||
Transport.send(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package q79l.pur.cosmic.plugin.demo;
|
||||
|
||||
import q79l.pur.cosmic.plugin.form.SignHelper;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class TestSignXK {
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
// String url = SignHelper.JumpPurchaseOrderList("伍平");
|
||||
String fromEmail = "srm.service@xingqikeji.com"; // 你的阿里云邮箱地址
|
||||
String password = "SRM@xq123"; // 你的阿里云邮箱密码
|
||||
String host = "smtp.xingqikeji.com"; // 阿里云SMTP服务器地址
|
||||
int port = 465; // 阿里云SMTP服务器端口
|
||||
|
||||
EmailSender emailSender = new EmailSender(fromEmail, password, host, port);
|
||||
String toEmail = "1542470468@qq.com"; // 收件人邮箱地址
|
||||
String subject = "Test Email"; // 邮件主题
|
||||
String content = "Hello, this is a test email sent from Java using Aliyun email service."; // 邮件内容
|
||||
|
||||
try {
|
||||
emailSender.sendEmail(toEmail, subject, content);
|
||||
System.out.println("Email sent successfully!");
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Failed to send email.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import kd.bos.form.ConfirmCallBackListener;
|
||||
import kd.bos.form.MessageBoxOptions;
|
||||
import kd.bos.form.control.events.ItemClickEvent;
|
||||
import kd.bos.list.BillList;
|
||||
import kd.bos.list.IListView;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
public class ShkdListPlugin extends AbstractListPlugin {
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
// TODO 自动生成的方法存根
|
||||
super.registerListener(e);
|
||||
this.addItemClickListeners("toolbarap");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent evt) {
|
||||
|
||||
String key = evt.getItemKey();
|
||||
String entityName = ((IListView) this.getView()).getBillFormId();
|
||||
BillList billList = this.getControl("billlistap");
|
||||
//获取选中的ids
|
||||
Object[] ids = billList.getSelectedRows().getPrimaryKeyValues();//选中行单据id集合
|
||||
JSONObject js = new JSONObject();
|
||||
/**
|
||||
* {"dbid":"61cd78fbc6aa78","username":"zhangsan",
|
||||
* "appid":"BMMailApprovalApp","signeddata":"230bff1feb781****3458d30f37f17c824a8a5f30417608ca2ccfe1140bec9f2",
|
||||
* "timestamp":"1649726187","lcid":"2052","origintype":"SimPas",
|
||||
* "entryrole":"","formid":"","formtype":"","pkid":"","openmode":null}
|
||||
*/
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
js.put("dbid","");//数据中心的ID
|
||||
js.put("username","");//用户名称
|
||||
js.put("appid","");//应用程序ID
|
||||
js.put("signeddata","");//
|
||||
js.put("timestamp",String.valueOf(timeMillis));//时间戳
|
||||
js.put("lcid","2052");//语言ID,中文2052(默认),英文1033,繁体3076
|
||||
js.put("origintype","SimPas");//XT=云之家集成(同时要求entryrole=XT);SimPas=简单通行证集成
|
||||
js.put("entryrole","");//验证权限的入口角色
|
||||
js.put("formid","");//登录后默认打开功能的表单id
|
||||
js.put("formtype","bill");//单据:bill或空, 列表:list, 万能报表:wnreport, 直接sql报表:sqlreport, 系统报表:sysreport, 树形报表:treereport, 移动报表:movereport, 动态表单:dynamicform
|
||||
js.put("pkid","");//formid对应表单的主键;formtype为list时忽略,formtype为bill时起作用,如果为空表示新增状态
|
||||
js.put("openmode","");//登陆后打开指定功能单据的模式,空白=原有主控模式,Single=单独打开指定单据(没有主控功能,仅HTML5端支持
|
||||
if ("shkd_url".equals(key)) {
|
||||
// for (Object id : ids) {
|
||||
// String result = ListPluginImpl.impl(key, billList, id, entityName);
|
||||
// if (StringUtils.isNotBlank(null)) {
|
||||
// this.getView().openUrl(result);
|
||||
// } else {
|
||||
ConfirmCallBackListener confirmCallBackListener = new ConfirmCallBackListener("shkd_url", this);
|
||||
this.getView().showConfirm("不允许跳转", MessageBoxOptions.OK, confirmCallBackListener);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.IBillModel;
|
||||
import kd.bos.fileservice.FileServiceFactory;
|
||||
import kd.bos.form.ConfirmCallBackListener;
|
||||
import kd.bos.form.MessageBoxOptions;
|
||||
import kd.bos.form.control.events.ItemClickEvent;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.web.actions.utils.FilePathUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.mail.util.ByteArrayDataSource;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.Security;
|
||||
import java.util.*;
|
||||
|
||||
public class ShkdXQBillPlugin extends AbstractBillPlugIn {
|
||||
|
||||
private static Log log = LogFactory.getLog(ShkdXQBillPlugin.class);
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
// TODO 自动生成的方法存根
|
||||
super.registerListener(e);
|
||||
this.addItemClickListeners("tbmain");
|
||||
this.addItemClickListeners("toolbarap");
|
||||
}
|
||||
|
||||
static String emailText = "你好:\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"1. 附件是《采购合同》,请确认无误后务必盖章回传电子版(后续银行付款需要查看审核),并将合同盖章原件寄给我(需要说明一下,以后单笔订单总金额大于3000元的,请将盖章原件每个月汇总一次邮寄过来,邮寄地址见下方签名;小于3000元的,只要求盖章回传即可)。\n" +
|
||||
"\n" +
|
||||
"2. 产品交付日期:期望交期2024年7月13日,请邮件回复是否可在此日期交付。\n" +
|
||||
"\n" +
|
||||
"3. 交货需要您提供:《产品合格证》、《材质证明》、《出厂检验报告》,包装发货前拍视频及照片留存,发货后提供物流单号【我司建议发货物流选择顺丰/跨越/德邦,以免造成不必要的货物丢失事故,因物流而导致的物料丢失问题,我司将不会负责】。\n" +
|
||||
"\n" +
|
||||
"4. 供应商发票规格,数量,单位均需按我司合同内容开票,如不一致,我司有权要求供应商重开发票。\n" +
|
||||
"\n" +
|
||||
"5. 包装及外观要求: 附件为激光打标内容(序列号会在发货前提供),需要按照此模板来打印。包装需要双层抽真空包装,针对激光件和球阀。\n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
"注意:\n" +
|
||||
"\n" +
|
||||
"1、订单收到后请在2个工作日内回传。\n" +
|
||||
"\n" +
|
||||
"2、发货前请以邮件形式提前告知运单号和发货清单,方便采购通知仓库收货,到货超过一周未通知采购,仓库会进行退货处理。\n" +
|
||||
"\n" +
|
||||
"3、开票前一定要提前对账,电子发票请发采购员邮箱,纸质发票请邮寄给采购员,地址见签名。\n" +
|
||||
"\n" +
|
||||
"4、付款前请提供发票。\n" +
|
||||
"\n" +
|
||||
"请关注以上规定,以免影响财务结算导致延期付款。\n" +
|
||||
"\n" +
|
||||
"谢谢配合。\n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
"需要图纸加工的零件,请务必严格核对订单图纸版本号和图纸内版本号一致;如不一致,请即刻联系星奇要正确版本号图纸。";
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent evt) {
|
||||
|
||||
String key = evt.getItemKey();
|
||||
IBillModel model = (IBillModel) this.getModel();
|
||||
String entityName = model.getDataEntityType().toString();
|
||||
DynamicObject entity = model.getDataEntity();
|
||||
Object id = entity.getPkValue();
|
||||
|
||||
//发送邮件二开
|
||||
if ("shkd_sendemail".equals(key)) {
|
||||
List<Map<String, Object>> attachmentpanel = AttachmentServiceHelper.getAttachments(entityName, id, "attachmentpanel");
|
||||
// Object receivingsupplierid = this.getModel().getValue("supplier");
|
||||
// if(receivingsupplierid != null){
|
||||
// DynamicObject supplier = (DynamicObject)receivingsupplierid;
|
||||
// //电子邮箱
|
||||
// Object postal_code = supplier.get("postal_code");
|
||||
// //联系人分录
|
||||
// DynamicObjectCollection entry_linkman = supplier.getDynamicObjectCollection("entry_linkman");
|
||||
// //联系人分录-邮箱
|
||||
// Object email = entry_linkman.get(0).get("email");
|
||||
// }
|
||||
Multipart multipart = new MimeMultipart();
|
||||
int i = 0;
|
||||
if(attachmentpanel.size()>0){
|
||||
for (Map<String, Object> stringObjectMap : attachmentpanel) {
|
||||
String url = stringObjectMap.get("url").toString();
|
||||
String[] split = url.split("path=");
|
||||
String path = split[1];
|
||||
Object type = stringObjectMap.get("type");
|
||||
Object name = stringObjectMap.get("name");
|
||||
String nametype = name+"."+type;
|
||||
System.out.println("path:"+path+"type:"+type);
|
||||
try {
|
||||
String downLoadUrl = kd.bos.login.utils.StringUtils.getStringValue(url);
|
||||
String pathurl = downLoadUrl.substring(downLoadUrl.indexOf("path=") + "path=".length());
|
||||
pathurl = URLDecoder.decode(pathurl, "UTF-8");
|
||||
if(path.indexOf('&')>0){
|
||||
pathurl = pathurl.substring(0,pathurl.indexOf('&'));
|
||||
}
|
||||
downLoadUrl = FilePathUtil.dealPath(pathurl, "attach");
|
||||
InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(downLoadUrl);
|
||||
// //将附件转换成byte数组
|
||||
// file = urltobyte(path);
|
||||
// bytelist.add(file);
|
||||
// //附件名的list
|
||||
// attachmentNames.add(nametype);
|
||||
// 创建多部分内容
|
||||
// 添加邮件正文
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
if(i == 0){
|
||||
messageBodyPart.setText(emailText);
|
||||
++i;
|
||||
}
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
// 添加附件
|
||||
messageBodyPart = new MimeBodyPart();
|
||||
DataSource dataSource=new ByteArrayDataSource(inputStream, "application/octet-stream");
|
||||
messageBodyPart.setDataHandler(new DataHandler(dataSource));
|
||||
messageBodyPart.setFileName(nametype);
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
messageBodyPart.setText(emailText);
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
} catch (MessagingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
sendMail(multipart);
|
||||
this.getView().showTipNotification("发送成功!");
|
||||
}
|
||||
super.itemClick(evt);
|
||||
}
|
||||
|
||||
public static void sendMail(Multipart multipart){
|
||||
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
||||
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||
// 设置邮件服务器属性
|
||||
Map<String, String> emailMap = getEmailMap();
|
||||
String host = emailMap.get("host");
|
||||
String port = emailMap.get("port");
|
||||
String auth = emailMap.get("auth");
|
||||
String enable = emailMap.get("enable");
|
||||
String username = emailMap.get("username");
|
||||
String password = emailMap.get("password");
|
||||
String toemail = emailMap.get("toemail");
|
||||
log.info("emailMap"+emailMap);
|
||||
Properties properties = new Properties();
|
||||
|
||||
|
||||
properties.setProperty("mail.smtp.host", host);//smtp服务器地址
|
||||
//props.setProperty("mail.smtp.port", "25");//非加密端口
|
||||
// 使用ssl加密方式,进行如下配置:
|
||||
properties.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
|
||||
properties.setProperty("mail.smtp.socketFactory.fallback", "false");
|
||||
properties.setProperty("mail.smtp.socketFactory.port", port);
|
||||
|
||||
properties.setProperty("mail.smtp.auth", "true");//表示SMTP发送邮件,需要进行身份验证
|
||||
properties.setProperty("mail.smtp.from", username);//mailfrom 参数
|
||||
properties.setProperty("mail.user",username);//发件人的账号
|
||||
properties.setProperty("mail.password",password);// 发件人的账号的密码,如果开启三方客户端安全密码请使用新生产的密码
|
||||
|
||||
// 创建认证对象
|
||||
Authenticator authenticator = new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取邮件会话对象
|
||||
Session session = Session.getDefaultInstance(properties, authenticator);
|
||||
log.info("获取邮件会话对象Properties"+session.getProperties());
|
||||
try {
|
||||
// 创建邮件对象
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(username));
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toemail));
|
||||
message.setSubject("带附件的邮件");
|
||||
|
||||
message.setContent(multipart);
|
||||
log.info("发送邮件前");
|
||||
// 发送邮件
|
||||
Transport transport = session.getTransport("smtp");
|
||||
transport.connect(host,username,password);
|
||||
log.info("发送邮件中");
|
||||
transport.sendMessage(message,message.getRecipients(Message.RecipientType.TO));
|
||||
transport.close();
|
||||
// Transport.send(message);
|
||||
|
||||
log.info("发送邮件后");
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
log.info("发送失败",e);
|
||||
log.info(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String,String> getEmailMap(){
|
||||
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
DynamicObject[] shkd_image = BusinessDataServiceHelper.load("shkd_email", "shkd_value,name", new QFilter[]{});
|
||||
for (DynamicObject str:shkd_image) {
|
||||
String name = str.getString("name");
|
||||
String shkd_textfield = str.getString("shkd_value");
|
||||
map.put(name,shkd_textfield);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.form.ConfirmCallBackListener;
|
||||
import kd.bos.form.MessageBoxOptions;
|
||||
import kd.bos.form.control.IFrame;
|
||||
import kd.bos.form.events.PreOpenFormEventArgs;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* 点击苍穹应用菜单单点登录第三方系统并打开页面
|
||||
* @author kingdee
|
||||
*
|
||||
*/
|
||||
public class ToTrdSysPageFormPlugin extends AbstractFormPlugin {
|
||||
|
||||
// 展示第三方系统页面的IFrame控件
|
||||
private static final String KEY_IFRAME_TRDSYSPAGE = "shkd_iframeap";
|
||||
|
||||
@Override
|
||||
public void preOpenForm(PreOpenFormEventArgs e) {
|
||||
|
||||
// 取消打开页面
|
||||
e.setCancel(true);
|
||||
super.preOpenForm(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBindData(EventObject e) {
|
||||
super.afterBindData(e);
|
||||
// 为IFrame控件设置URL
|
||||
IFrame iFrame = this.getView().getControl(KEY_IFRAME_TRDSYSPAGE);
|
||||
String userId = RequestContext.get().getUserId();
|
||||
long l = Long.parseLong(userId);
|
||||
// QFilter qFilter = new QFilter("id", QCP.equals,l);
|
||||
// DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user","name",qFilter.toArray());
|
||||
// String name = user.getString("name");
|
||||
try {
|
||||
String url = XQSignHelper.JumpPurchaseOrderList("系统实施");
|
||||
iFrame.setSrc(url);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.dataentity.serialization.SerializationUtils;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
|
||||
public class XQSignHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usserName
|
||||
* @return跳转采购订单列表
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static String JumpPurchaseOrderList(String usserName) throws UnsupportedEncodingException {
|
||||
String dbId = "66681f2cfe8985";// 数据中心ID
|
||||
// String usserName = "系统实施";// 用户名称
|
||||
String appId = "284568_72bp7ZuGQqqWTU8J223C0aWHVv4WQtOu";// 第三方系统应用Id
|
||||
String appSecret = "019b5075692d4ca7af470b3bcd6ee2ea";// 第三方系统应用秘钥
|
||||
long currentTime = System.currentTimeMillis() / 1000;
|
||||
String timestamp = Long.toString(currentTime);
|
||||
String origintype = "SimPas";
|
||||
String entryrole = "";
|
||||
String formid = "PUR_PurchaseOrder";
|
||||
String formtype = "list";
|
||||
String pkid = "";
|
||||
String openmode = "Single";
|
||||
String[] strArray = { dbId, usserName, appId, appSecret, timestamp };
|
||||
Arrays.sort(strArray);
|
||||
String combStr = null;
|
||||
for (int i = 0; i < strArray.length; i++) {
|
||||
if (combStr == null || combStr == "") {
|
||||
combStr = strArray[i];
|
||||
} else {
|
||||
combStr = combStr + strArray[i];
|
||||
}
|
||||
}
|
||||
byte[] strByte = combStr.getBytes("UTF-8");
|
||||
|
||||
byte[] strSign = DigestUtils.sha(strByte);
|
||||
|
||||
String sign = bytesToHexString(strSign);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("dbId",dbId);
|
||||
jsonObject.put("username",usserName);
|
||||
jsonObject.put("appId",appId);
|
||||
jsonObject.put("signeddata",sign);
|
||||
jsonObject.put("timestamp",timestamp);
|
||||
jsonObject.put("lcid","2052");
|
||||
jsonObject.put("origintype",origintype);
|
||||
jsonObject.put("entryrole",entryrole);
|
||||
jsonObject.put("formid",formid);
|
||||
jsonObject.put("formtype",formtype);
|
||||
jsonObject.put("pkid",pkid);
|
||||
String urlPara = SerializationUtils.toJsonString(jsonObject);
|
||||
// String urlPara = String.format("|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", dbId, usserName, appId, sign, timestamp, "2052",origintype,entryrole,formid,formtype,pkid);
|
||||
System.out.println("urlPara:"+urlPara);
|
||||
urlPara = java.net.URLEncoder.encode(urlPara, "UTF-8");
|
||||
String encodedJson = Base64.getEncoder().encodeToString(urlPara.getBytes(StandardCharsets.UTF_8));
|
||||
String url = "http://222.71.193.253:8098/K3Cloud/html5/Index.aspx?ud=" + urlPara;// Silverlight入口链接
|
||||
|
||||
System.out.println(url);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static String bytesToHexString(byte[] src) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class XhlAdjpstbillPlugin extends AbstractFormPlugin {
|
||||
|
||||
private final static Log logger = LogFactory.getLog(XhlAdjpstbillPlugin.class);
|
||||
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate operate = (FormOperate)args.getSource();
|
||||
String entityId = this.getView().getEntityId();
|
||||
if( StringUtils.equals(operate.getOperateKey(), "submit")){
|
||||
//对公报销单或借款单
|
||||
if(entityId.equals("bgm_adjpstbill") || entityId.equals("er_dailyloanbill")){
|
||||
Object departmenttes = this.getModel().getValue("department");
|
||||
logger.info("departmenttes:"+departmenttes.toString());
|
||||
Object id = this.getModel().getValue("id");
|
||||
DynamicObject department1 = BusinessDataServiceHelper.loadSingle(id, entityId, "id,department");
|
||||
if(department1 != null){
|
||||
DynamicObject department = department1.getDynamicObject("department");
|
||||
if(department != null){
|
||||
Object id1 = department.get("id");
|
||||
logger.info("departmentid:"+id1);
|
||||
Object o = department.get("name.zh_CN");
|
||||
Object o1 = department.get("name");
|
||||
logger.info("departmentnamezh_CN:"+o+"departmentname"+o1);
|
||||
DynamicObject org = BusinessDataServiceHelper.loadSingle(id1, "bos_org", "name");
|
||||
if(org != null){
|
||||
Object name = org.get("name");
|
||||
logger.info("name:"+name);
|
||||
DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
|
||||
List<String> orgnums = new ArrayList();
|
||||
if (entryentity.size()>0){
|
||||
int i = 0;
|
||||
for (DynamicObject dynamicObject : entryentity) {
|
||||
DynamicObject adjentity = dynamicObject.getDynamicObject("adjentity");
|
||||
String number = adjentity.getString("number");
|
||||
String substring = number.substring(0, 3);
|
||||
logger.info("预算组织编码:"+number+"截取前三位字符:"+substring);
|
||||
if(i == 0){
|
||||
orgnums.add(substring);
|
||||
++i;
|
||||
}else{
|
||||
if(!orgnums.contains(substring)){
|
||||
this.getView().showMessage("预算组织所属公司不是同一家,请重新选择");
|
||||
args.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.operate.OperateOptionConst;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.validate.ValidateResult;
|
||||
import kd.bos.entity.validate.ValidateResultCollection;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class XhlDailyReimbursePlugin001 extends AbstractBillPlugIn implements Plugin {
|
||||
|
||||
private final static Log logger = LogFactory.getLog(XhlDailyReimbursePlugin001.class);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param afterDoOperationEventArgs
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
|
||||
super.afterDoOperation(afterDoOperationEventArgs);
|
||||
String operateKey = afterDoOperationEventArgs.getOperateKey();
|
||||
logger.info("新浩隆-afterDoOperation"+operateKey);
|
||||
if(operateKey.equals("audit")){
|
||||
logger.info("新浩隆-调用二开审核方法");
|
||||
String entityId = this.getView().getEntityId();
|
||||
Object id = this.getModel().getValue("id");
|
||||
Long[] ids = new Long[1];
|
||||
ids[0] = Long.parseLong(id.toString());
|
||||
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills(entityId, ids);
|
||||
logger.info("新浩隆-调用二开审核方法:sourceBills"+sourceBills);
|
||||
if(sourceBills != null) {
|
||||
HashSet<Long> longs = sourceBills.get("er_dailyapplybill");
|
||||
if(longs != null){
|
||||
Object[] idss = longs.toArray();
|
||||
DynamicObject dailyapplybillType = BusinessDataServiceHelper.newDynamicObject("er_dailyapplybill");
|
||||
DynamicObject[] srcdatas = BusinessDataServiceHelper.load(idss,dailyapplybillType.getDynamicObjectType());
|
||||
logger.info("新浩隆-调用二开审核方法:srcdatas数量:"+srcdatas.length);
|
||||
OperateOption option= OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true)); // 不执行警告级别校验器
|
||||
OperationResult operationResult = OperationServiceHelper.executeOperate("closebill", "er_dailyapplybill", srcdatas, option);
|
||||
List<String> errors = new ArrayList<String>();
|
||||
if(operationResult.isSuccess()){
|
||||
logger.info("新浩隆-执行成功,");
|
||||
logger.info("新浩隆-执行成功,"+operationResult.getMessage());
|
||||
}else{
|
||||
ValidateResultCollection validateResult = operationResult.getValidateResult();
|
||||
for (int j = 0; j < validateResult.errorSize(); j++) {
|
||||
List<ValidateResult> validateErrors = validateResult.getValidateErrors();
|
||||
for (int k = 0; k < validateErrors.size(); k++) {
|
||||
ValidateResult errinfo = validateErrors.get(k);
|
||||
List<OperateErrorInfo> allErrorInfo = errinfo.getAllErrorInfo();
|
||||
for (int l = 0; l < allErrorInfo.size(); l++) {
|
||||
errors.add(allErrorInfo.get(l).getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("新浩隆-执行失败,");
|
||||
logger.info("新浩隆-执行失败,"+errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(operateKey.equals("unaudit") || operateKey.equals("noapprive")){
|
||||
logger.info("新浩隆-调用二开驳回、审核不通过方法");
|
||||
String entityId = this.getView().getEntityId();
|
||||
Object id = this.getModel().getValue("id");
|
||||
Long[] ids = new Long[1];
|
||||
ids[0] = Long.parseLong(id.toString());
|
||||
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills(entityId, ids);
|
||||
logger.info("新浩隆-调用二开驳回、审核不通过方法:sourceBills"+sourceBills);
|
||||
if(sourceBills != null) {
|
||||
HashSet<Long> longs = sourceBills.get("er_dailyapplybill");
|
||||
if(longs != null){
|
||||
Object[] idss = longs.toArray();
|
||||
DynamicObject dailyapplybillType = BusinessDataServiceHelper.newDynamicObject("er_dailyapplybill");
|
||||
DynamicObject[] srcdatas = BusinessDataServiceHelper.load(idss,dailyapplybillType.getDynamicObjectType());
|
||||
logger.info("新浩隆-调用二开驳回、审核不通过方法:srcdatas数量:"+srcdatas.length);
|
||||
OperateOption option= OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true)); // 不执行警告级别校验器
|
||||
OperationResult operationResult = OperationServiceHelper.executeOperate("submit1", "er_dailyapplybill", srcdatas, option);
|
||||
List<String> errors = new ArrayList<String>();
|
||||
if(operationResult.isSuccess()){
|
||||
logger.info("新浩隆-执行成功,");
|
||||
logger.info("新浩隆-执行成功,"+operationResult.getMessage());
|
||||
}else{
|
||||
ValidateResultCollection validateResult = operationResult.getValidateResult();
|
||||
for (int j = 0; j < validateResult.errorSize(); j++) {
|
||||
List<ValidateResult> validateErrors = validateResult.getValidateErrors();
|
||||
for (int k = 0; k < validateErrors.size(); k++) {
|
||||
ValidateResult errinfo = validateErrors.get(k);
|
||||
List<OperateErrorInfo> allErrorInfo = errinfo.getAllErrorInfo();
|
||||
for (int l = 0; l < allErrorInfo.size(); l++) {
|
||||
errors.add(allErrorInfo.get(l).getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("新浩隆-执行失败,");
|
||||
logger.info("新浩隆-执行失败,"+errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package q79l.pur.cosmic.plugin.form;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class XhlDailyReimbursePlugin02 extends AbstractFormPlugin {
|
||||
|
||||
private final static Log logger = LogFactory.getLog(XhlDailyReimbursePlugin02.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param args
|
||||
* 处理报销单关联申请选择申请单时不允许选择已被关联的申请单
|
||||
*/
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
logger.info("新浩隆-beforeDoOperation");
|
||||
FormOperate operate = (FormOperate)args.getSource();
|
||||
logger.info("新浩隆-beforeDoOperation"+operate.getOperateKey());
|
||||
String entityId = this.getView().getEntityId();
|
||||
Object id = this.getModel().getValue("id");
|
||||
logger.info("新浩隆-id"+id);
|
||||
Long[] ids = new Long[1];
|
||||
ids[0] = Long.parseLong(id.toString());
|
||||
if( StringUtils.equals(operate.getOperateKey(), "save") || StringUtils.equals(operate.getOperateKey(), "submit")){
|
||||
logger.info("新浩隆-调用二开保存提交");
|
||||
DynamicObjectCollection writeoffapplys = this.getModel().getEntryEntity("writeoffapply");
|
||||
logger.info("新浩隆-调用二开保存提交,writeoffapplys:"+writeoffapplys.size());
|
||||
List<String> applybillnos = new ArrayList();
|
||||
for (DynamicObject writeoffapply : writeoffapplys) {
|
||||
String applybillno = writeoffapply.getString("applybillno");
|
||||
applybillnos.add(applybillno);
|
||||
}
|
||||
QFilter qFilter = new QFilter("writeoffapply.applybillno", QCP.in,applybillnos);
|
||||
DynamicObject[] load = BusinessDataServiceHelper.load("er_dailyreimbursebill", "id,writeoffapply,writeoffapply.applybillno", qFilter.toArray());
|
||||
logger.info("新浩隆-调用二开保存提交,load:"+load.length);
|
||||
if(load.length>0){
|
||||
for (DynamicObject dynamicObject : load) {
|
||||
if(!id.equals(dynamicObject.get("id"))){
|
||||
DynamicObjectCollection writeoffapply = dynamicObject.getDynamicObjectCollection("writeoffapply");
|
||||
for (DynamicObject object : writeoffapply) {
|
||||
Object applybillno = object.get("applybillno");
|
||||
logger.info("新浩隆-调用二开保存提交,applybillno:"+applybillno);
|
||||
if (applybillnos.contains(applybillno.toString())){
|
||||
this.getView().showMessage("此申请单已被关联,请重选"+applybillno);
|
||||
args.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package q79l.pur.cosmic.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.MainEntityType;
|
||||
import kd.bos.entity.operate.OperateOptionConst;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
||||
import kd.bos.entity.validate.ValidateResult;
|
||||
import kd.bos.entity.validate.ValidateResultCollection;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class XhlAuditOpPlugin extends AbstractOperationServicePlugIn {
|
||||
private final static Log logger = LogFactory.getLog(XhlAuditOpPlugin.class);
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
List<String> fieldKeys = e.getFieldKeys();
|
||||
fieldKeys.addAll(this.billEntityType.getAllFields().keySet());
|
||||
}
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||
super.endOperationTransaction(e);
|
||||
MainEntityType entityType = this.billEntityType;
|
||||
String entityName = entityType.getName();
|
||||
DynamicObject[] entities = e.getDataEntities();
|
||||
String operationKey = e.getOperationKey();
|
||||
if(operationKey.equals("audit")){
|
||||
logger.info("新浩隆-调用二开审核方法");
|
||||
Long[] ids = new Long[entities.length];
|
||||
for (DynamicObject entity : entities) {
|
||||
int k = 0;
|
||||
Object id = entity.getPkValue();
|
||||
ids[k] = Long.parseLong(id.toString());
|
||||
++k;
|
||||
}
|
||||
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills(entityName, ids);
|
||||
logger.info("新浩隆-调用二开审核方法:sourceBills"+sourceBills);
|
||||
if(sourceBills != null) {
|
||||
HashSet<Long> longs = sourceBills.get("er_dailyapplybill");
|
||||
if(longs != null){
|
||||
Object[] idss = longs.toArray();
|
||||
DynamicObject dailyapplybillType = BusinessDataServiceHelper.newDynamicObject("er_dailyapplybill");
|
||||
DynamicObject[] srcdatas = BusinessDataServiceHelper.load(idss,dailyapplybillType.getDynamicObjectType());
|
||||
logger.info("新浩隆-调用二开审核方法:srcdatas数量:"+srcdatas.length);
|
||||
OperateOption option= OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true)); // 不执行警告级别校验器
|
||||
OperationResult operationResult = OperationServiceHelper.executeOperate("closebill", "er_dailyapplybill", srcdatas, option);
|
||||
List<String> errors = new ArrayList<String>();
|
||||
if(operationResult.isSuccess()){
|
||||
logger.info("新浩隆-执行成功,");
|
||||
logger.info("新浩隆-执行成功,"+operationResult.getMessage());
|
||||
}else{
|
||||
ValidateResultCollection validateResult = operationResult.getValidateResult();
|
||||
for (int j = 0; j < validateResult.errorSize(); j++) {
|
||||
List<ValidateResult> validateErrors = validateResult.getValidateErrors();
|
||||
for (int k = 0; k < validateErrors.size(); k++) {
|
||||
ValidateResult errinfo = validateErrors.get(k);
|
||||
List<OperateErrorInfo> allErrorInfo = errinfo.getAllErrorInfo();
|
||||
for (int l = 0; l < allErrorInfo.size(); l++) {
|
||||
errors.add(allErrorInfo.get(l).getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("新浩隆-执行失败,");
|
||||
logger.info("新浩隆-执行失败,"+errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(operationKey.equals("unaudit") || operationKey.equals("noapprive")){
|
||||
logger.info("新浩隆-调用二开驳回、审核不通过方法");
|
||||
Long[] ids = new Long[entities.length];
|
||||
for (DynamicObject entity : entities) {
|
||||
int k = 0;
|
||||
Object id = entity.getPkValue();
|
||||
ids[k] = Long.parseLong(id.toString());
|
||||
++k;
|
||||
}
|
||||
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills(entityName, ids);
|
||||
logger.info("新浩隆-调用二开驳回、审核不通过方法:sourceBills"+sourceBills);
|
||||
if(sourceBills != null) {
|
||||
HashSet<Long> longs = sourceBills.get("er_dailyapplybill");
|
||||
if(longs != null){
|
||||
Object[] idss = longs.toArray();
|
||||
DynamicObject dailyapplybillType = BusinessDataServiceHelper.newDynamicObject("er_dailyapplybill");
|
||||
DynamicObject[] srcdatas = BusinessDataServiceHelper.load(idss,dailyapplybillType.getDynamicObjectType());
|
||||
logger.info("新浩隆-调用二开驳回、审核不通过方法:srcdatas数量:"+srcdatas.length);
|
||||
OperateOption option= OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true)); // 不执行警告级别校验器
|
||||
OperationResult operationResult = OperationServiceHelper.executeOperate("submit1", "er_dailyapplybill", srcdatas, option);
|
||||
List<String> errors = new ArrayList<String>();
|
||||
if(operationResult.isSuccess()){
|
||||
logger.info("新浩隆-执行成功,");
|
||||
logger.info("新浩隆-执行成功,"+operationResult.getMessage());
|
||||
}else{
|
||||
ValidateResultCollection validateResult = operationResult.getValidateResult();
|
||||
for (int j = 0; j < validateResult.errorSize(); j++) {
|
||||
List<ValidateResult> validateErrors = validateResult.getValidateErrors();
|
||||
for (int k = 0; k < validateErrors.size(); k++) {
|
||||
ValidateResult errinfo = validateErrors.get(k);
|
||||
List<OperateErrorInfo> allErrorInfo = errinfo.getAllErrorInfo();
|
||||
for (int l = 0; l < allErrorInfo.size(); l++) {
|
||||
errors.add(allErrorInfo.get(l).getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("新浩隆-执行失败,");
|
||||
logger.info("新浩隆-执行失败,"+errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package q79l.pur.cosmic.plugin.operate;
|
||||
|
||||
import kd.sdk.scm.pur.extpoint.IBatchStockSupport;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class xqconvert implements IBatchStockSupport{
|
||||
@Override
|
||||
public Map<String, String> assembleExtHeadPro() {
|
||||
//表头塞值
|
||||
Map<String, String> extPro = new LinkedHashMap<>(16);
|
||||
//终止原因
|
||||
extPro.put("shkd_remark", "F_XQZD_Remarks");
|
||||
//研发项目
|
||||
extPro.put("shkd_yfxm", "F_XQZD_YFXM");
|
||||
//需求人
|
||||
extPro.put("shkd_xqr", "F_XQZD_XQR");
|
||||
return extPro;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Map<String, String> assembleExtPro() {
|
||||
// //分录塞值
|
||||
// Map<String, String> extPro = new LinkedHashMap<>(16);
|
||||
// extPro.put("kdtest_cardNum", "F_PAEZ_DRIVERPHONE");
|
||||
// return extPro;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package q79l.pur.cosmic.plugin.util;
|
||||
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.Properties;
|
||||
|
||||
public class SendEmailUtil {
|
||||
|
||||
// 发件人电子邮箱
|
||||
static String from = "xxx@qq.com";
|
||||
|
||||
// 发件人邮箱密码(这里以授权码为例,非邮箱登录密码)
|
||||
static String password = "xxx";
|
||||
|
||||
// 邮件发送服务器的SMTP地址
|
||||
static String host = "smtp.qq.com";
|
||||
|
||||
// 邮件的接收者电子邮箱
|
||||
static String to = "xxx@qq.com";
|
||||
|
||||
public static void sendEmail(){
|
||||
|
||||
Session session = CreateSession();
|
||||
try {
|
||||
// 创建默认的 MimeMessage 对象
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
|
||||
// 设置 From: 头部头字段
|
||||
message.setFrom(new InternetAddress(from));
|
||||
|
||||
// 设置 To: 头部头字段
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
|
||||
|
||||
// 设置 Subject: 头部头字段
|
||||
message.setSubject("这是邮件的主题");
|
||||
|
||||
// 现在设置实际消息
|
||||
message.setText("这是邮件的正文");
|
||||
|
||||
|
||||
|
||||
// 发送消息
|
||||
Transport.send(message);
|
||||
System.out.println("邮件发送成功...");
|
||||
|
||||
} catch (MessagingException mex) {
|
||||
mex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Session CreateSession(){
|
||||
|
||||
|
||||
// 获取系统属性
|
||||
Properties properties = System.getProperties();
|
||||
|
||||
// 设置邮件服务器
|
||||
properties.put("mail.smtp.host", host);
|
||||
properties.put("mail.smtp.port", "465"); // SSL端口号,如果是TLS则是587
|
||||
properties.put("mail.smtp.auth", "true");
|
||||
properties.put("mail.smtp.ssl.enable", "true"); // 要求使用SSL
|
||||
|
||||
// 获取默认session对象
|
||||
Session session = Session.getInstance(properties, new javax.mail.Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(from, password);
|
||||
}
|
||||
});
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package q79l.pur.cosmic.plugin.workflow;
|
||||
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.DispatchServiceHelper;
|
||||
import kd.bos.workflow.api.AgentExecution;
|
||||
import kd.bos.workflow.engine.extitf.IWorkflowPlugin;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class XhlWorkFlowPlugin implements Plugin, IWorkflowPlugin {
|
||||
|
||||
private static final Log log = LogFactory.getLog(XhlWorkFlowPlugin.class);
|
||||
|
||||
@Override
|
||||
public void notify(AgentExecution execution) {
|
||||
IWorkflowPlugin.super.notify(execution);
|
||||
log.info("进notify方法");
|
||||
String entityNumber = execution.getEntityNumber();//单据标识
|
||||
String billId = execution.getBusinessKey();//单据id
|
||||
String handleState = execution.getCurrentTask().getHandleState();//审核状态:批准approve 拒绝reject
|
||||
String currentName = execution.getCurrentFlowElement().getName();
|
||||
log.info("notify方法handleState参数:"+handleState);
|
||||
log.info("notify方法billId参数:"+billId);
|
||||
log.info("notify方法entityNumber参数:"+entityNumber);
|
||||
if("approve".equals(handleState)) {
|
||||
DynamicObject bill = BusinessDataServiceHelper.loadSingle(billId, entityNumber);
|
||||
|
||||
DynamicObject eborgid = bill.getDynamicObject("eborgid");
|
||||
Object id = eborgid.get("id");
|
||||
QFilter qFilter = new QFilter("id", QCP.equals,id);
|
||||
DynamicObject org = BusinessDataServiceHelper.loadSingle("epm_entitymembertree","number",qFilter.toArray());
|
||||
String number = org.getString("number");
|
||||
log.info("预算组织id:"+id);
|
||||
log.info("预算组织number:"+number);
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
List priodNumbers = new ArrayList();
|
||||
priodNumbers.add("FY2024.M01");
|
||||
priodNumbers.add("FY2024.M02");
|
||||
priodNumbers.add("FY2024.M03");
|
||||
priodNumbers.add("FY2024.M04");
|
||||
priodNumbers.add("FY2024.M05");
|
||||
priodNumbers.add("FY2024.M06");
|
||||
priodNumbers.add("FY2024.M07");
|
||||
priodNumbers.add("FY2024.M08");
|
||||
priodNumbers.add("FY2024.M09");
|
||||
priodNumbers.add("FY2024.M10");
|
||||
priodNumbers.add("FY2024.M11");
|
||||
priodNumbers.add("FY2024.M12");
|
||||
priodNumbers.add("FY2025.M01");
|
||||
priodNumbers.add("FY2025.M02");
|
||||
priodNumbers.add("FY2025.M03");
|
||||
priodNumbers.add("FY2025.M04");
|
||||
priodNumbers.add("FY2025.M05");
|
||||
priodNumbers.add("FY2025.M06");
|
||||
priodNumbers.add("FY2025.M07");
|
||||
priodNumbers.add("FY2025.M08");
|
||||
priodNumbers.add("FY2025.M09");
|
||||
priodNumbers.add("FY2025.M10");
|
||||
priodNumbers.add("FY2025.M11");
|
||||
priodNumbers.add("FY2025.M12");
|
||||
priodNumbers.add("FY2026.M01");
|
||||
List datatypeNumbers = new ArrayList();
|
||||
datatypeNumbers.add("Budget");
|
||||
List entityNumbers = new ArrayList();
|
||||
entityNumbers.add(number);
|
||||
params.put("modelNumber","001");//String-体系编码
|
||||
params.put("businessModelNumber","AunnalBudget");//String-业务模型编码
|
||||
params.put("priodNumbers",priodNumbers);//List-预算期间编码集合(明细成员)
|
||||
params.put("datatypeNumbers",datatypeNumbers);//List-数据类型编码集合(明细成员)
|
||||
params.put("srcVersion","VNone");//String-源版本(明细成员)
|
||||
params.put("targetVersion","KZBB");//String-目标版本(明细成员)
|
||||
params.put("entityNumbers",entityNumbers);//List-执行组织编码集合(明细成员)
|
||||
log.info("版本复制接口入参:"+params);
|
||||
Object o = DispatchServiceHelper.invokeBizService("epm", "eb", "VersionCopyApiService", "copyExecuteV1", new Object[]{params});
|
||||
log.info("版本复制接口返回值:"+o.toString());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue