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