Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 package com.mandi.fendan.controller;
A 2
3 import java.io.IOException;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 import javax.annotation.Resource;
8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse;
10
11 import org.apache.commons.lang3.StringUtils;
12 import org.springframework.stereotype.Controller;
13 import org.springframework.web.bind.annotation.RequestMapping;
14 import org.springframework.web.bind.annotation.RequestMethod;
15 import org.springframework.web.bind.annotation.ResponseBody;
16
17 import com.google.gson.Gson;
18 import com.google.gson.JsonObject;
19 import com.mandi.common.JSONobj;
20 import com.mandi.common.Jacksonmethod;
21 import com.mandi.common.RequestParam;
22 import com.mandi.common.SessionMethod;
23 import com.mandi.common.Wxhtmethod;
24 import com.mandi.dao.common.ObjectResult;
25 import com.mandi.dao.common.PageRequest;
26 import com.mandi.dao.common.PageResult;
27 import com.mandi.fendan.mapper.BusinessMapper;
28 import com.mandi.fendan.mapper.Fd_BsheetMapper;
29 import com.mandi.fendan.service.IErpService;
30 import com.mandi.fendan.service.Ifd_bsheetService;
31 import com.mandi.fendan.util.Contants;
32 import com.mandi.fendan.util.persist.WaitXSTDMX;
33 import com.mandi.system.persist.Login;
34
35 @Controller("fd_bsheettaskcon")
36 @RequestMapping(value="/task",method={RequestMethod.POST})
37 public class Fd_bsheetTaskCon {
38     
39     @Resource
40     private IErpService erpser;
41     @Resource
42     private Fd_BsheetMapper bsper;
43     @Resource
44     private Ifd_bsheetService fdbser;
45     @Resource
46     private BusinessMapper bsiper;
47     
48     /**
49      * 获取已分单列表
50      * @param r
51      * @param re
52      * @return
53      */
54     @RequestMapping(value="/getList.htm",method={RequestMethod.POST})
55     @ResponseBody
56     public String getXSTDList(HttpServletRequest r,HttpServletResponse re){
57         String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号
58         String companyNo=RequestParam.getSqlString(r, "companyNo");//物流公司编号
59         int page=RequestParam.getInt(r, "page"); 
60         int pagesize=RequestParam.getInt(r, "pagesize");
61         int pages=RequestParam.getInt(r, "pages");
62         String cqV=RequestParam.getSqlString(r, "cqV");//厂区
63         PageRequest pr=new PageRequest(page, pagesize, null);
64         if(pages>0)
65             pr.setNeedPages(true);
66         else
67             pr.setNeedPages(false);
68         Login lg=SessionMethod.getlogin(r.getSession());
69         PageResult<Map<String, Object>> prr=erpser.getFdlist(lg,companyNo,vehicleId, pr,cqV);
70         String str=Jacksonmethod.tojson(prr, false);
71         SessionMethod.writeresp(re, str);
72         return null;
73     }
74     
75     /**
76      * 换车
77      * @param r
78      * @param re
79      * @return
80      */
81     @RequestMapping(value="/changeVehicle.htm",method={RequestMethod.POST})
82     @ResponseBody
83     public String changeVehicle(HttpServletRequest r,HttpServletResponse re){
84         String bsNo=RequestParam.getSqlString(r, "bussinessNo");
85         String vehicleInfo=RequestParam.getString(r, "vehicle");
86         //vehicle: {vehicleId, driver, phone, vehicleweight, loadweight, feature, note}
87         Login lg=SessionMethod.getlogin(r.getSession());
88         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
89         try {
90             orr=erpser.changeVehicle(lg, bsNo, vehicleInfo);
91         } catch (Exception e) {
92             e.printStackTrace();
93             orr.setCode(1);
94             orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"换车程序错误!":e.getMessage());
95         }
96         String str=Jacksonmethod.tojson(orr, false);
97         SessionMethod.writeresp(re, str);;
98         return null;
99     }
100     /**
101      * 取消派车
102      * @param r
103      * @param re
104      * @return
105      */
106     @RequestMapping(value="/delItem.htm",method={RequestMethod.POST})
107     @ResponseBody
108     public String delXSFD(HttpServletRequest r,HttpServletResponse re){
109         String bsNo=RequestParam.getSqlString(r, "bussinessNo");
110         Login lg=SessionMethod.getlogin(r.getSession());
111         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
112         try {
113             orr=erpser.delFdsheet(lg, bsNo);
114         } catch (Exception e) {
115             e.printStackTrace();
116             orr.setCode(1);
117             orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"取消派车程序错误!":e.getMessage());
118         }
119         String str=Jacksonmethod.tojson(orr, false);
120         SessionMethod.writeresp(re, str);;
121         return null;
122     }
123     
124     
125     
126     /**
127      * 获取分单物资
128      * @param r
129      * @param re
130      * @return
131      */
132     @RequestMapping(value="/getVehicleDetails.htm",method={RequestMethod.POST})
133     @ResponseBody
134     public String getVehicleDetails(HttpServletRequest r,HttpServletResponse re){
135         String bsNo=RequestParam.getSqlString(r, "keyword");
136         Login lg=SessionMethod.getlogin(r.getSession());
137         PageResult<WaitXSTDMX> pr=erpser.getVehicleDetails(lg, bsNo);
138         String str=Jacksonmethod.tojson(pr, false);
139         SessionMethod.writeresp(re, str);;
140         return null;
141     }
142     
143     /**
144      * 发验证码
145      * @param r
146      * @param re
147      * @return
148      */
149     @RequestMapping(value="/send.htm",method={RequestMethod.POST})
150     @ResponseBody
151     @Deprecated
152     public String send(HttpServletRequest r,HttpServletResponse re){
153         ObjectResult<String> orr=new ObjectResult<String>();
154         String bussinessNo=RequestParam.getSqlString(r, "item");
155         Map<String, Object> mp=new HashMap<String, Object>();
156         mp.put("bussinessNo", bussinessNo);
157         String str=Jacksonmethod.tojson(mp, false);
158         JsonObject result=Wxhtmethod.postJsonStr(Contants.NCfdhx_url,str);
159         if(result==null||JSONobj.getint(result, "code")!=0){
160             orr.setCode(1);
161             orr.setErrmsg(StringUtils.isEmpty(JSONobj.getstring(result, "errmsg"))?"邀请码生成出错,请重新操作!":JSONobj.getstring(result, "errmsg"));
162         }else{
163             orr.setCode(0);
164             orr.setItem(JSONobj.getstring(result, "item"));
165         }
166         str=Jacksonmethod.tojson(orr, false);
167         SessionMethod.writeresp(re, str);
168         return null;
169     }
170     /**
171      * 重发验证码
172      * @param r
173      * @param re
174      * @return
175      */
176     @RequestMapping(value="/resend.htm",method={RequestMethod.POST,RequestMethod.GET})
177     @ResponseBody
178     public String resend(HttpServletRequest r,HttpServletResponse re){
179         String bussinessNo=RequestParam.getSqlString(r, "item");
180         Login lg=SessionMethod.getlogin(r.getSession());
181         ObjectResult<String> orr=new ObjectResult<String>();
182         try {
183             orr = fdbser.sendMsg(lg,bussinessNo);
184         } catch (Exception e) {
185             e.printStackTrace();
186             orr.setCode(1);
187             orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"短信邀请码发送失败!":e.getMessage());
188         }
189         String str=Jacksonmethod.tojson(orr, false);
190         SessionMethod.writeresp(re, str);
191         return null;
192     }
193     
194     /**
195      * 通过车牌号打印装车通知单
196      * @param r
197      * @param re
198      * @return
199      */
200     @RequestMapping(value="/Printfdxq.htm",method={RequestMethod.POST,RequestMethod.GET})
201     @ResponseBody
202     public String Printfdxq(HttpServletRequest r,HttpServletResponse re){
203         String bsNo =RequestParam.getSqlString(r, "bsNo");
204         Login lg=SessionMethod.getlogin(r.getSession());
205         JsonObject jo=new JsonObject();
206         Gson g=new Gson(); 
207         String ipadd=r.getLocalAddr();
208         if(lg==null){
209             jo.addProperty("code", 1);
210             jo.addProperty("errmsg", "请登录账号!");
211             String str=g.toJson(jo);
212             SessionMethod.writeresp(re, str);
213             return null;
214         }
215         ObjectResult<String> orr=erpser.tzPrint(lg, bsNo,ipadd);
216         if(orr.getCode()!=0){
217             String str=Jacksonmethod.tojson(orr, false);
218             SessionMethod.writeresp(re, str);
219             return null;
220         }else{
221             try {
222                 re.sendRedirect(orr.getItem());
223             } catch (IOException e) {
224                 e.printStackTrace();
225             }
226         }
227         return null;
228     }
229     
230     /**
231      * 通过卡号打印装车通知单
232      * @param r
233      * @param re
234      * @return
235      */
236     @RequestMapping(value="/printbycard.htm",method={RequestMethod.POST,RequestMethod.GET})
237     @ResponseBody
238     public String printbyCard(HttpServletRequest r,HttpServletResponse re){
239         String cardno =RequestParam.getSqlString(r, "cardno");
240         String cqNo =RequestParam.getSqlString(r, "cqNo");
241         String ipadd=r.getLocalAddr();
242         ObjectResult<String> orr=erpser.tzPrint(cardno,ipadd,cqNo);
243         if(orr.getCode()!=0){
244             String str=Jacksonmethod.tojson(orr, false);
245             SessionMethod.writeresp(re, str);
246             return null;
247         }else{
248             try {
249                 re.sendRedirect(orr.getItem());
250             } catch (IOException e) {
251                 e.printStackTrace();
252             }
253         }
254         return null;
255     }
256     /**
257      * 打印提单全部
258      * @param r
259      * @param re
260      * @return
261      */
262     @RequestMapping(value="/printtdall.htm",method={RequestMethod.POST,RequestMethod.GET})
263     @ResponseBody
264     public String printtdall(HttpServletRequest r,HttpServletResponse re){
265         String tdNo =RequestParam.getSqlString(r, "tdNo");
266         Login lg=SessionMethod.getlogin(r.getSession());
267         String ipadd=r.getLocalAddr();
268         ObjectResult<String> orr=new ObjectResult<String>();
269         if(lg==null){
270             orr.setCode(1);
271             orr.setErrmsg("请登录账号!");
272             String str=Jacksonmethod.tojson(orr, false);
273             SessionMethod.writeresp(re, str);
274             return null;
275         }
276         if(StringUtils.isEmpty(tdNo)){
277             orr.setCode(1);
278             orr.setErrmsg("提单编号为空!");
279             String str=Jacksonmethod.tojson(orr, false);
280             SessionMethod.writeresp(re, str);
281             return null;
282         }
283         String dyAdd=this.bsiper.getUsedbyAdd();
284         if(StringUtils.isBlank(dyAdd)){
285             orr.setCode(1);
286             orr.setErrmsg("系统未设置打印地址!");
287             String str=Jacksonmethod.tojson(orr, false);
288             SessionMethod.writeresp(re, str);
289             return null;
290         }
291         orr.setCode(0);
292         orr.setItem("http://"+dyAdd+Contants.GJTDALLPrintAdd+"&tdNo="+tdNo);
293 //        System.err.println(":::::::::::http://"+dyAdd+Contants.GJTDALLPrintAdd+"&tdNo="+tdNo);
294         if(!StringUtils.isEmpty(orr.getItem())){
295             try {
296                 re.sendRedirect(orr.getItem());
297             } catch (IOException e) {
298                 e.printStackTrace();
299             }
300         }else{
301             orr.setCode(1);
302             orr.setErrmsg("未找到跳转地址!");
303             String str=Jacksonmethod.tojson(orr, false);
304             SessionMethod.writeresp(re, str);
305         }
306         return null;
307     }
308     
309     /**
310      * 通过批次号单条删除
311      * @param r
312      * @param re
313      * @return
314      */
315     @RequestMapping(value="/delbypch.htm",method={RequestMethod.POST})
316     @ResponseBody
317     public String delbypc(HttpServletRequest r,HttpServletResponse re){
318         String tdno =RequestParam.getSqlString(r, "tdno");//提单编号
319         String pch =RequestParam.getSqlString(r, "pch");//批次号
320         String cph =RequestParam.getSqlString(r, "cph");//车牌号
321         String bsno =RequestParam.getSqlString(r, "bsno");//车牌号
322         Login lg=SessionMethod.getlogin(r.getSession());
323         JsonObject jo=new JsonObject();
324         Gson g=new Gson(); 
325         if(lg==null){
326             jo.addProperty("code", 1);
327             jo.addProperty("errmsg", "请登录账号!");
328             String str=g.toJson(jo);
329             SessionMethod.writeresp(re, str);
330             return null;
331         }
332         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
333         try {
334             orr = erpser.delbyPCH(lg, tdno, pch,cph,bsno);
335         } catch (Exception e) {
336             e.printStackTrace();
337             orr.setCode(1);
338             orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"单条删除出错!":e.getMessage());
339         }
340         String str=Jacksonmethod.tojson(orr, false);
341         SessionMethod.writeresp(re, str);
342         return null;
343     }
344     
345
346 }