md
This commit is contained in:
parent
5d75e793df
commit
ace0ed0a12
@ -0,0 +1,101 @@
|
||||
package com.xdadan.erp.emis.service.sms;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dysmsapi20170525.Client;
|
||||
import com.aliyun.tea.TeaModel;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.system.service.ISysConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("Sms253Service")
|
||||
public class Sms253Service {
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* @param signName 签名
|
||||
* @param templateCode 模板
|
||||
* @param phone 手机号
|
||||
* @param tplParam 参数
|
||||
*/
|
||||
public int sendMessage(String signName,String phone, String templateCode,String tplParam) throws EmisBizError {
|
||||
|
||||
String jsonParamStr=configService.selectConfigByKey("sys.sms253.sms");
|
||||
JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
||||
String accessKeyId=jObjAliyunParam.getString("accessKeyId");
|
||||
String accessKeySecret=jObjAliyunParam.getString("accessKeySecret");
|
||||
|
||||
return innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phone,tplParam);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用AK&SK初始化账号Client
|
||||
* @param accessKeyId
|
||||
* @param accessKeySecret
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
.setAccessKeyId(accessKeyId)
|
||||
.setAccessKeySecret(accessKeySecret);
|
||||
// 访问的域名
|
||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||
return new Client(config);
|
||||
}
|
||||
|
||||
public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
||||
try {
|
||||
Client client = createClient(accessKeyId, accessKeySecret);
|
||||
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
||||
sendSmsRequest.setPhoneNumbers(phone);
|
||||
sendSmsRequest.setSignName(signName);
|
||||
sendSmsRequest.setTemplateCode(templateCode);
|
||||
// sendSmsRequest.setTemplateParam("{\"code\":\""+param+"\"}");
|
||||
sendSmsRequest.setTemplateParam(tplParam);
|
||||
RuntimeOptions runtime = new RuntimeOptions();
|
||||
com.aliyun.dysmsapi20170525.models.SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
String jsonStr= Common.toJSONString(TeaModel.buildMap(response));
|
||||
|
||||
if(response.getStatusCode()==200) {
|
||||
if ("OK".equals(response.getBody().getCode())) {
|
||||
return 1;
|
||||
} else {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
||||
}
|
||||
}else{
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String accessKeyId="LTAI5tA1yz1QK6BVhzg3ne5D";
|
||||
String accessKeySecret="bFbFle1hFsy1zeyTeN79FXopPx9yRS";
|
||||
String signName="跨境助手";
|
||||
String templateCode="SMS_179215861";
|
||||
String phoneNumbers="13764645922";
|
||||
String param="1234";
|
||||
try {
|
||||
int ret = innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phoneNumbers,param);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -37,14 +37,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="confirmSiteCode" column="confirm_site_code" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="EmisSettleSubBillResult" type="EmisSettleSubBill" extends="BaseEmisSettleSubBillResult" >
|
||||
<association property="waybillDetail"
|
||||
column="bill_code"
|
||||
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
|
||||
fetchType="lazy"
|
||||
/>
|
||||
<!-- <association property="waybillDetail"-->
|
||||
<!-- column="bill_code"-->
|
||||
<!-- select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"-->
|
||||
<!-- fetchType="lazy"-->
|
||||
<!-- />-->
|
||||
|
||||
|
||||
|
||||
<result property="waybillDetail.sendSiteName" column="send_site_name"/>
|
||||
<result property="waybillDetail.dispatchUnderlingSiteName" column="dispatch_underling_site_name"/>
|
||||
<result property="waybillDetail.transLineTypeName" column="trans_line_type_name"/>
|
||||
<result property="waybillDetail.productTypeName" column="product_type_name"/>
|
||||
<result property="waybillDetail.problemTypeName" column="problem_type_name"/>
|
||||
|
||||
<result property="waybillDetail.blSpecialQuote" column="bl_special_quote"/>
|
||||
<result property="waybillDetail.calcFeeType" column="calc_fee_type"/>
|
||||
<result property="waybillDetail.sendDate" column="send_date"/>
|
||||
<result property="waybillDetail.sendCompany" column="send_company"/>
|
||||
<result property="waybillDetail.custName" column="cust_no"/>
|
||||
<result property="waybillDetail.custName" column="cust_name"/>
|
||||
<result property="waybillDetail.paymentType" column="payment_type"/>
|
||||
|
||||
<result property="waybillDetail.timeType" column="time_type"/>
|
||||
<result property="waybillDetail.sendName" column="send_name"/>
|
||||
<result property="waybillDetail.parcelQty" column="parcel_qty"/>
|
||||
<result property="waybillDetail.billWeight" column="bill_weight"/>
|
||||
<result property="waybillDetail.totalVolume" column="total_volume"/>
|
||||
<result property="waybillDetail.volumeWeight" column="volume_weight"/>
|
||||
<result property="waybillDetail.freight" column="freight"/>
|
||||
<result property="waybillDetail.realFee" column="real_fee"/>
|
||||
<result property="waybillDetail.feeRemark" column="fee_remark"/>
|
||||
<result property="waybillDetail.paymentType" column="payment_type"/>
|
||||
<result property="waybillDetail.remark" column="remark"/>
|
||||
<result property="waybillDetail.payee" column="payee"/>
|
||||
<result property="waybillDetail.salesmen" column="salesmen"/>
|
||||
<result property="waybillDetail.blIsQuestion" column="bl_is_question"/>
|
||||
<result property="waybillDetail.problemCause" column="problem_cause"/>
|
||||
|
||||
|
||||
<association property="feeitemList"
|
||||
column="bill_no"
|
||||
@ -69,11 +106,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
b.bill_fee, b.currency, b.settle_type, b.bl_split, b.bl_merge, b.bill_month, b.cust_no,b.cust_name,
|
||||
b.customer_code, b.customer_name, b.payee, b.salesmen, b.bl_special_quote, b.bl_sensitive,
|
||||
b.bl_confirm_center, b.confirm_center_date, b.confirm_center_note, b.confirm_center_man_code,
|
||||
b.confirm_center_code, b.bl_confirm_site, b.confirm_site_date, b.confirm_site_man_code,
|
||||
b.confirm_site_note, b.confirm_site_code, b.del_flag, b.create_by, b.create_time, b.update_by,
|
||||
b.update_time, b.create_site, b.update_site
|
||||
b.confirm_center_code, b.bl_confirm_site, b.confirm_site_date, b.confirm_site_man_code,
|
||||
b.confirm_site_note, b.confirm_site_code, b.del_flag, b.create_by, b.create_time, b.update_by,
|
||||
b.update_time, b.create_site, b.update_site,
|
||||
|
||||
a.bl_special_quote,a.calc_fee_type,a.send_date,a.send_company,
|
||||
a.cust_no,a.cust_name,a.payment_type,a.time_type,
|
||||
a.send_name,a.parcel_qty,a.bill_weight,a.total_volume,a.volume_weight,
|
||||
a.freight,real_fee,a.fee_remark,a.payment_type,a.remark,
|
||||
a.payee,a.salesmen,a.bl_is_question,a.problem_cause,
|
||||
|
||||
j.prod_name as product_type_name,
|
||||
k.line_name as trans_line_type_name,
|
||||
l.site_name as send_site_name,
|
||||
m.site_name as dispatch_underling_site_name,
|
||||
z.type_name as problem_type_name
|
||||
|
||||
|
||||
from emis_settle_sub_bill b ,emis_waybill a
|
||||
left join emis_trans_product j on a.product_type=j.prod_code and j.del_flag='0'
|
||||
left join emis_trans_line k on a.trans_line_type=k.line_code and k.del_flag='0'
|
||||
left join emis_site l on a.send_site_code=l.site_code and l.del_flag=0 and l.del_flag='0'
|
||||
left join emis_site m on a.dispatch_underling_site_code=m.site_code and m.del_flag=0
|
||||
left join emis_problem_type z on a.problem_type=z.id and z.del_flag='0'
|
||||
|
||||
<where>
|
||||
a.bill_code=b.bill_code and a.del_flag='0' and b.del_flag='0'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user