|
@@ -0,0 +1,70 @@
|
|
|
|
+package com.iamberry.rst.controllers.pts;
|
|
|
|
+
|
|
|
|
+import com.iamberry.rst.controllers.sys.SysController;
|
|
|
|
+import com.iamberry.rst.faces.sms.SmsService;
|
|
|
|
+import com.iamberry.rst.utils.ExcelUtil;
|
|
|
|
+import com.iamberry.wechat.tools.ResponseJson;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.text.MessageFormat;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import static com.iamberry.rst.util.SmsConfig.SEND_NOTICE;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Created by Administrator on 2017/10/24.
|
|
|
|
+ */
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("/admin/code")
|
|
|
|
+public class PtsCodeController {
|
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(SysController.class);
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SmsService smsService;
|
|
|
|
+ /**
|
|
|
|
+ * 手动向特定手机发送滤芯故障短信
|
|
|
|
+ * @param response
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ /*@RequestMapping("/failureInform")*/
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public String informShipping(HttpServletResponse response, @RequestParam("file") String file)throws IOException {
|
|
|
|
+ String msg = "";
|
|
|
|
+ Integer successNumber = 0;
|
|
|
|
+ Integer errorNumber = 0;
|
|
|
|
+ List<String> listString = ExcelUtil.readExcelHead(file);
|
|
|
|
+ List<String> phones = ExcelUtil.readCell2(file,listString.get(1));//手机号
|
|
|
|
+ List<String> kuyaidi = ExcelUtil.readCell2(file,listString.get(6));//快递公司
|
|
|
|
+ List<String> danhao = ExcelUtil.readCell2(file,listString.get(7));//快递单号
|
|
|
|
+ if(phones.size() != kuyaidi.size() || phones.size() != danhao.size()){
|
|
|
|
+ return "数据不合格,请检查文档内的数据是否正常!";
|
|
|
|
+ }
|
|
|
|
+ for(int i = 0;i< phones.size();i++){
|
|
|
|
+ String kd = "";
|
|
|
|
+ if(kuyaidi.get(i).indexOf("申通") != -1){
|
|
|
|
+ kd = "申通";
|
|
|
|
+ }else if(kuyaidi.get(i).indexOf("EMS") != -1){
|
|
|
|
+ kd = "EMS";
|
|
|
|
+ }else{
|
|
|
|
+ return "快递公司出错,请检查文档内的数据是否正常!";
|
|
|
|
+ }
|
|
|
|
+ String text = MessageFormat.format(SEND_NOTICE, kd + " "+danhao.get(i));
|
|
|
|
+ msg = smsService.sendOtherCMS(phones.get(i),text);
|
|
|
|
+ if(msg.equals("SUCCESS")){
|
|
|
|
+ successNumber++;
|
|
|
|
+ }else{
|
|
|
|
+ errorNumber++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ msg = "共发送"+(successNumber+errorNumber)+"条,成功:"+successNumber+"条,失败:"+errorNumber+"条。";
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+}
|