|
@@ -14,6 +14,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import com.uas.erp.service.oa.SendMailService;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
@@ -101,6 +102,8 @@ public class SingleFormItemsServiceImpl implements SingleFormItemsService {
|
|
|
private EmployeeService employeeService;
|
|
|
@Autowired
|
|
|
private EnterpriseService enterpriseService;
|
|
|
+ @Autowired
|
|
|
+ private SendMailService sendMailService;
|
|
|
|
|
|
@Override
|
|
|
public FormPanel getFormItemsByCaller(String caller, String condition, String language, Employee employee, boolean isCloud) {
|
|
@@ -1165,6 +1168,10 @@ public class SingleFormItemsServiceImpl implements SingleFormItemsService {
|
|
|
@Override
|
|
|
public void vastResCloseDetail(String language, Employee employee, String caller, String data) {
|
|
|
dealdetail(language, employee, caller, data, Operation.RESCLOSE);
|
|
|
+ if ("Purchase!FinishReStart!Deal".equals(caller)&&baseDao.isDBSetting("Purchase", "AuditedAutoEmail")) {
|
|
|
+ List<Map<Object, Object>> maps = BaseUtil.parseGridStoreToMaps(data);
|
|
|
+ purchase_endORRes_sendMail(CollectionUtil.pluckSqlString(maps, "pd_id"),Operation.RESCLOSE);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1493,8 +1500,86 @@ public class SingleFormItemsServiceImpl implements SingleFormItemsService {
|
|
|
baseDao.updateByCondition("purchasedetail", "pd_endstatus='待上传'", "pd_id=" + id);
|
|
|
}
|
|
|
dealdetail(language, employee, caller, data, Operation.FINISH);
|
|
|
+ if (baseDao.isDBSetting("Purchase", "AuditedAutoEmail")) {
|
|
|
+ purchase_endORRes_sendMail(CollectionUtil.pluckSqlString(maps, "pd_id"),Operation.FINISH);
|
|
|
+ }
|
|
|
}
|
|
|
+ public void purchase_endORRes_sendMail(String ids,Operation operation) {
|
|
|
+ new Thread() {
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ //按照供应商发
|
|
|
+ SqlRowList vendList = baseDao.queryForRowSet("select ve_name,ve_email,to_char(wm_concat(pd_id)) pd_ids " +
|
|
|
+ " from purchase left join vendor on ve_code = pu_vendcode left join purchasedetail on pd_puid = pu_id " +
|
|
|
+ " where pd_ID IN (" + ids + ") and nvl(ve_uu,' ')<>' ' and nvl(ve_b2benable,0)=1 and nvl(ve_endmailremind,0)=-1 and trim(upper(NVL(ve_email,'NULL'))) <> 'NULL' " +
|
|
|
+ " group by ve_name,ve_email ");
|
|
|
+ while (vendList.next()) {
|
|
|
+ String veName = vendList.getGeneralString("ve_name");
|
|
|
+ String veEmail = vendList.getGeneralString("ve_email");
|
|
|
+ String pd_ids = vendList.getGeneralString("pd_ids");
|
|
|
+ StringBuffer endMsg = new StringBuffer();
|
|
|
+ SqlRowList sendList = baseDao.queryForRowSet("select pu_code,wm_concat(pd_detno) pd_detnos "
|
|
|
+ +(operation.name().equals("FINISH")?",pd_textbox":"")+
|
|
|
+ " from purchasedetail left join purchase on pd_puid = pu_id where pd_ID IN (" + pd_ids + ") " +
|
|
|
+ " group by pu_code"+(operation.name().equals("FINISH")?",pd_textbox ":"")
|
|
|
+ );
|
|
|
+ while (sendList.next()) {
|
|
|
+ endMsg.append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'>")
|
|
|
+ .append("<SPAN style='mso-spacerun: yes'> ").append(" </SPAN>")
|
|
|
+ .append("<SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>")
|
|
|
+ .append("订单编号:").append(sendList.getGeneralString("pu_code"))
|
|
|
+ .append(",序号:").append(sendList.getGeneralString("pd_detnos"));
|
|
|
+ if(operation.name().equals("FINISH")){
|
|
|
+ endMsg.append(",取消原因:").append(StringUtil.nvl(sendList.getGeneralString("pd_textbox"),"无"));
|
|
|
+ }
|
|
|
+ endMsg.append("</SPAN>");
|
|
|
+ endMsg.append("</P>");
|
|
|
+ }
|
|
|
+ purchase_sendMail(veName,veEmail,endMsg.toString(),operation);
|
|
|
+ baseDao.execute("insert into messagelog(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
|
|
|
+ " SELECT messagelog_Seq.nextval,sysdate,'" + SystemSession.getUser().getEm_name() + "','邮件发送("+operation.getTitle()+")','发送邮件成功'" +
|
|
|
+ ",'Purchase|pu_id='||pu_id,pu_code " +
|
|
|
+ " FROM (select pu_id,pu_code from purchasedetail left join purchase on pu_id = pd_puid WHERE PD_ID IN ("+pd_ids+") group by pu_id,pu_code )");
|
|
|
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.start();
|
|
|
+ }
|
|
|
+ public void purchase_sendMail(String veName,String email,String endMsg,Operation operation) {
|
|
|
+ if (email == null || "".equals(email.trim()) || "null".equals(email.trim())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 标题和内容一致
|
|
|
+ String op = (operation.name().equals("FINISH")?"取消":"重启");
|
|
|
+ String encop = baseDao.getFieldDataByCondition("enterprise", "en_name", "1=1").toString();
|
|
|
+ String title = "订单已"+op+",请查看订单";
|
|
|
+ StringBuffer context = new StringBuffer();
|
|
|
+ context.append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'><SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>")
|
|
|
+ .append(veName).append(",您好!:<SPAN lang=EN-US><?xml:namespace prefix = 'o' ns = 'urn:schemas-microsoft-com:office:office' /><o:p></o:p></SPAN></SPAN></P>")
|
|
|
+ .append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'>")
|
|
|
+ .append("<SPAN lang=EN-US style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>" )
|
|
|
+ .append("<SPAN style='mso-spacerun: yes'> ").append(" </SPAN>")
|
|
|
+ .append("</SPAN>")
|
|
|
+ .append("<SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>")
|
|
|
+ .append("您有一张来自于")
|
|
|
+ .append("<SPAN style='COLOR: blue'>")
|
|
|
+ .append("公司名称(").append("<SPAN lang=EN-US>").append(encop).append("</SPAN>").append(")")
|
|
|
+ .append("</SPAN>")
|
|
|
+ .append("的采购单"+op+"提醒。")
|
|
|
+ .append("</SPAN>")
|
|
|
+ .append("</P>")
|
|
|
+ .append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'><SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>").append( "取消订单情况如下:</SPAN></P>" )
|
|
|
+ .append(endMsg)
|
|
|
+ .append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'><SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>").append( "请及时登入优软商务平台查取您的订单<SPAN lang=EN-US>!<o:p></o:p></SPAN></SPAN></P>" )
|
|
|
+ .append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'><SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>登入平台的地址:<SPAN lang=EN-US><A href='http://www.usoftchina.com/'><FONT color=#0000ff>www.usoftchina.com</FONT></A><o:p></o:p></SPAN></SPAN></P>")
|
|
|
+ .append("<P class=MsoNormal style='MARGIN: 0cm 0cm 0pt'><SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑'>如在使用平台过程中,遇到任何操作问题,请及时与深圳市优软科技有限公司客服人员(谭小姐)联系,联系电话:<SPAN lang=EN-US>0755-26996828<o:p></o:p></SPAN></SPAN></P>")
|
|
|
+ .append("<SPAN style='FONT-SIZE: 14pt; FONT-FAMILY: '微软雅黑','sans-serif'; mso-bidi-font-family: 微软雅黑; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA'>致敬!</SPAN>");
|
|
|
+// System.out.println(context.toString());
|
|
|
+ sendMailService.sendSysMail(title, context.toString(), email);
|
|
|
+ }
|
|
|
@Override
|
|
|
public String refreshSync(Employee employee, String caller, String to, String data) {
|
|
|
return baseDao.callProcedure("SYS_POST",
|