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