Explorar el Código

【功能完善】+【反馈:2024080199】+【每日出货数据邮件推送-加try catch】

DINGYL hace 1 semana
padre
commit
62351c3378
Se han modificado 1 ficheros con 57 adiciones y 50 borrados
  1. 57 50
      src/com/uas/erp/service/scm/impl/ProdInOutServiceImpl.java

+ 57 - 50
src/com/uas/erp/service/scm/impl/ProdInOutServiceImpl.java

@@ -7341,60 +7341,67 @@ public class ProdInOutServiceImpl implements ProdInOutService {
 			em_con="( "+con.toString()+" )";
 		}
 		while(ra_ma.next()){
-			SpObserver.putSp(ra_ma.getString("ma_user"));
-			System.out.println("邮件发送开始,账套:" +ra_ma.getString("ma_user"));
-			int n=baseDao.getCount("select count(1) from Prodio_sale_mail_view order by pi_inoutno,pd_pdno");
-			System.out.println("账套:" +ra_ma.getString("ma_user")+" count:"+n);
-			if(n>0){
-				String email="";
-				String title=DateUtil.getCurrentDate()+"出货数汇总";
-				StringBuffer content=new StringBuffer();
-				Object em_email_em = baseDao.getFieldDataByCondition("Employee", "replace(wm_concat(em_email),',',';')", "nvl(em_class,' ')<>'离职' and em_email is not null and "+em_con);
-				if(em_email_em != null && !"".equals(em_email_em.toString().trim()) && !"null".equals(em_email_em.toString().trim())){
-					email=em_email_em.toString();
-				}
-				if (email != null && !"".equals(email.trim()) && !"null".equals(email.trim())) {
-					content.append("<html><body>").append("<div style=\"text-align: center;\"><B>深圳市英瀚天成科技有限公司</b></div>");
-					content.append("<img alt=\"Logo\" src=\"cid:LogoId\" width=\"100\" geight=\"100\"><br/>");
-					content.append("<br/><br/>"+DateUtil.getYear(new Date())+"年"+DateUtil.getMonth(new Date())+"月"+DateUtil.getDay(new Date())+"日出货数据</p>");
-					content.append("<table border=\"1\" cellspacing=\"0\" style=\"font-size:12px;width:1000px \">")
-							.append("<tr>")
-							.append("<th width=\"100px\">出货单号</th>")
-							.append("<th width=\"180px\">客户名称</th>")
-							.append("<th width=\"110px\">物料型号</th>")
-							.append("<th width=\"100px\">品牌</th>")
-							.append("<th width=\"90px\">出货数量</th>")
-							.append("<th width=\"120px\">批次</th>")
-							.append("<th width=\"100px\">客户PO号</th>")
-							.append("<th width=\"100px\">客户的收件人</th>")
-							.append("<th width=\"90px\">联系电话</th>")
-							.append("<th width=\"180px\">收货地址</th>")
-							.append("<th width=\"100px\">物流单号</th>")
-							.append("</tr>");
-					SqlRowList rs = baseDao.queryForRowSet("select * from Prodio_sale_mail_view order by pi_inoutno,pd_pdno");
-					while (rs.next()){
-						content.append("<tr>")
-								.append("<th>").append(rs.getGeneralString("PI_INOUTNO")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PI_TITLE")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PR_SPEC")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PR_BRAND")).append("</th>")
-								.append("<th align=\"right\">").append(rs.getGeneralDouble("PD_OUTQTY")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PD_DESCRIPTION")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PD_POCODE")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PI_PURPOSENAME")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PI_EXPRESSCODE")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PI_ADDRESS")).append("</th>")
-								.append("<th>").append(rs.getGeneralString("PI_LOGISTICSCODE")).append("</th>")
+			try{
+				SpObserver.putSp(ra_ma.getString("ma_user"));
+				System.out.println("邮件发送开始,账套:" +ra_ma.getString("ma_user"));
+				int n=baseDao.getCount("select count(1) from Prodio_sale_mail_view order by pi_inoutno,pd_pdno");
+				System.out.println("账套:" +ra_ma.getString("ma_user")+" count:"+n);
+				if(n>0){
+					String email="";
+					String title=DateUtil.getCurrentDate()+"出货数汇总";
+					StringBuffer content=new StringBuffer();
+					Object em_email_em = baseDao.getFieldDataByCondition("Employee", "replace(wm_concat(em_email),',',';')", "nvl(em_class,' ')<>'离职' and em_email is not null and "+em_con);
+					if(em_email_em != null && !"".equals(em_email_em.toString().trim()) && !"null".equals(em_email_em.toString().trim())){
+						email=em_email_em.toString();
+					}
+					if (email != null && !"".equals(email.trim()) && !"null".equals(email.trim())) {
+						content.append("<html><body>").append("<div style=\"text-align: center;\"><B>深圳市英瀚天成科技有限公司</b></div>");
+						content.append("<img alt=\"Logo\" src=\"cid:LogoId\" width=\"100\" geight=\"100\"><br/>");
+						content.append("<br/><br/>"+DateUtil.getYear(new Date())+"年"+DateUtil.getMonth(new Date())+"月"+DateUtil.getDay(new Date())+"日出货数据</p>");
+						content.append("<table border=\"1\" cellspacing=\"0\" style=\"font-size:12px;width:1000px \">")
+								.append("<tr>")
+								.append("<th width=\"100px\">出货单号</th>")
+								.append("<th width=\"180px\">客户名称</th>")
+								.append("<th width=\"110px\">物料型号</th>")
+								.append("<th width=\"100px\">品牌</th>")
+								.append("<th width=\"90px\">出货数量</th>")
+								.append("<th width=\"120px\">批次</th>")
+								.append("<th width=\"100px\">客户PO号</th>")
+								.append("<th width=\"100px\">客户的收件人</th>")
+								.append("<th width=\"90px\">联系电话</th>")
+								.append("<th width=\"180px\">收货地址</th>")
+								.append("<th width=\"100px\">物流单号</th>")
 								.append("</tr>");
+						SqlRowList rs = baseDao.queryForRowSet("select * from Prodio_sale_mail_view order by pi_inoutno,pd_pdno");
+						while (rs.next()){
+							content.append("<tr>")
+									.append("<th>").append(rs.getGeneralString("PI_INOUTNO")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PI_TITLE")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PR_SPEC")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PR_BRAND")).append("</th>")
+									.append("<th align=\"right\">").append(rs.getGeneralDouble("PD_OUTQTY")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PD_DESCRIPTION")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PD_POCODE")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PI_PURPOSENAME")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PI_EXPRESSCODE")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PI_ADDRESS")).append("</th>")
+									.append("<th>").append(rs.getGeneralString("PI_LOGISTICSCODE")).append("</th>")
+									.append("</tr>");
+						}
+						content.append("</table>");
+						content.append("<br/><br/><p>深圳市英瀚天成科技有限公司</p><p>深圳市南山区招商街道水湾社区太子路111号水湾壹玖柒玖广场(二期)18F-1</p>" +
+								"<p>江西省九江市瑞昌市科技园示范园研发楼5楼 西门</p>" +
+								"<p>www.hkyinghan.com   | 国产化元器件与方案一站式服务商 |</p></body></html>");
+						sendMailService.sendSysMailBySaleOut(title, content.toString(), email);
 					}
-					content.append("</table>");
-					content.append("<br/><br/><p>深圳市英瀚天成科技有限公司</p><p>深圳市南山区招商街道水湾社区太子路111号水湾壹玖柒玖广场(二期)18F-1</p>" +
-							"<p>江西省九江市瑞昌市科技园示范园研发楼5楼 西门</p>" +
-							"<p>www.hkyinghan.com   | 国产化元器件与方案一站式服务商 |</p></body></html>");
-					sendMailService.sendSysMailBySaleOut(title, content.toString(), email);
 				}
+				System.out.println("邮件发送结束,账套:" +ra_ma.getString("ma_user"));
+			}catch (Exception e){
+				e.printStackTrace();
+			}finally {
+				SpObserver.putSp(defaultSob);// 切回原账套
 			}
-			System.out.println("邮件发送结束,账套:" +ra_ma.getString("ma_user"));
+
 		}
 		SpObserver.putSp(defaultSob);// 切回原账套