Administrator
2023-02-17 d3d8ceb38e114db791a7c9eed710065465c3d1da
提交 | 用户 | 时间
58d006 1 package com.mandi.webservice.service.impl;
A 2
3 import com.google.gson.JsonArray;
4 import com.google.gson.JsonObject;
5 import com.google.gson.JsonParser;
6 import com.mandi.common.JSONobj;
7 import com.mandi.common.Jacksonmethod;
8 import com.mandi.common.ParamFileter.Fileoperation;
9 import com.mandi.dao.common.ObjectResult;
10 import com.mandi.dao.common.PageResult;
11 import com.mandi.fendan.mapper.BusinessMapper;
12 import com.mandi.fendan.mapper.Fd_BsheetMapper;
13 import com.mandi.fendan.mapper.Fd_YKTMapper;
14 import com.mandi.fendan.persist.Fd_Bsheet;
15 import com.mandi.fendan.util.Contants;
16 import com.mandi.fendan.util.persist.Serviceenum;
17 import com.mandi.fendan.util.persist.WaitXSTD;
18 import com.mandi.servlet.file.impl.FileLoadImpl;
19 import com.mandi.webservice.service.IFdXSTDService;
20 import com.mandi.webservice.service.IInvoiceService;
21 import org.apache.commons.lang3.StringUtils;
22 import org.apache.log4j.Logger;
23 import org.springframework.stereotype.Service;
24
25 import javax.annotation.Resource;
26 import javax.servlet.http.HttpServletRequest;
27 import java.util.Date;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32 @Service
33 public class InvoiceService implements IInvoiceService{
34     @Resource
35     private IFdXSTDService fdser;
36     @Resource
37     private BusinessMapper bsPer;
38     @Resource
39     private Fd_BsheetMapper fdbPer;
40     @Resource
41     private Fd_YKTMapper yktmper;
42
43     private Logger log= Logger.getLogger(FileLoadImpl.class);
44
45     @Override
46     public String action(HttpServletRequest r,String jsonParam) {
47         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "请求ip::::"+r.getRemoteAddr());
48         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "数据值::b::"+jsonParam);
49         String action="";
50         String dataArr="";
51         try {
52             JsonParser jp=new JsonParser();
53             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
54             action=JSONobj.getstring(jo, "action");
55             dataArr=jo.get("data").toString();
56         } catch (Exception e) {
57
58         }
59 //        Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数action::::"+action);
60 //        Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数dataArr::::"+dataArr);
61         Map<String, Object> mm=new HashMap<String, Object>();
62         ObjectResult<Boolean> orr=null;
63         if(!StringUtils.isEmpty(action)){
64             try {
65                 if(Contants.NcactionCode_add.equals(action)){
66                     orr=fdser.saveFd_xstd(dataArr);
67                 }else if(Contants.NcactionCode_del.equals(action)){
68                     orr=fdser.delFd_xstd(dataArr);
69                 }else if(Contants.NcactionCode_open.equals(action)){
70                     orr=fdser.openFd_xstd(dataArr);
71                 }else if(Contants.NcactionCode_close.equals(action)){
72                     orr=fdser.closeFd_xstd(dataArr);
73                 }else{
74                     mm.put("respcode", 999);
75                     mm.put("respmsg", "动作参数不正确!");
76                 }
77                 if(orr!=null){
78                     if(orr.getCode()==0){
79                         mm.put("respcode", 111);
80                         mm.put("respmsg", orr.getErrmsg());
81                     }else{
82                         mm.put("respcode", 999);
83                         mm.put("respmsg", orr.getErrmsg());
84                     }
85                 }
86             } catch (Exception e) {
87                 mm.put("respcode", 999);
88                 mm.put("respmsg", "错误:"+e.getMessage());
89             }
90         }else{
91             mm.put("respcode", 999);
92             mm.put("respmsg", "动作参数未找到!");
93         }
94         String str=Jacksonmethod.tojson(mm, false);
95         return str;
96     }
97
98     @Override
99     public String delLoading(HttpServletRequest r,String jsonParam) {
100         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "请求ip::::"+r.getRemoteAddr());
101         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数metaid::b::"+jsonParam);
102         String cardID="";
103         String yktywdh="";
104         JsonArray dataArr=null;
105         Map<String, Object> mm=new HashMap<String, Object>();
106         try {
107             JsonParser jp=new JsonParser();
108             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
109             cardID=JSONobj.getstring(jo, "cardID");
110             yktywdh=JSONobj.getstring(jo, "yktywdh");
111             dataArr=JSONobj.getJsonArray(jo, "data");
112         } catch (Exception e) {
113             mm.put("respcode", 999);
114             mm.put("respmsg", "数据解析出错!");
115             String str=Jacksonmethod.tojson(mm, false);
116             return str;
117         }
118         ObjectResult<Boolean> prs=new ObjectResult<Boolean>();
119         try {
120             prs=fdser.delZCMX(cardID, yktywdh, dataArr);
121             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "delLoading返回值::::"+Jacksonmethod.tojson(prs, false));
122         } catch (Exception e) {
123             mm.put("respcode", 999);
124             mm.put("respmsg", e.getMessage());
125             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "delLoading返回值::::"+Jacksonmethod.tojson(mm, false));
126             String str=Jacksonmethod.tojson(mm, false);
127             return str;
128         }
129         if(prs!=null){
130             if(prs.getCode()==0){
131                 mm.put("respcode", 111);
132                 mm.put("respmsg", "操作成功!");
133             }else{
134                 if(prs.getCode()==2){
135                     mm.put("respcode", 222);
136                     mm.put("respmsg", prs.getErrmsg());
137                 }else{
138                     mm.put("respcode", 999);
139                     mm.put("respmsg", prs.getErrmsg());
140                 }
141             }
142         }
143         String str=Jacksonmethod.tojson(mm, false);
144         return str;
145     }
146
147     @Override
148     public String addLoading(HttpServletRequest r,String jsonParam) {
149         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "请求ip::::"+r.getRemoteAddr());
150         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数metaid::b::"+jsonParam);
151         String cardID="";
152         String yktywdh="";
153         JsonArray dataArr=null;
154         Map<String, Object> mm=new HashMap<String, Object>();
155         try {
156             JsonParser jp=new JsonParser();
157             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
158             cardID=JSONobj.getstring(jo, "cardID");
159             yktywdh=JSONobj.getstring(jo, "yktywdh");
160             dataArr=JSONobj.getJsonArray(jo, "data");
161 //            System.err.println("ddata::::"+dataArr);
162         } catch (Exception e) {
163             mm.put("respcode", 999);
164             mm.put("respmsg", "数据解析出错!");
165             String str=Jacksonmethod.tojson(mm, false);
166             return str;
167         }
168         PageResult<Map<String, Object>> prs=new PageResult<Map<String, Object>>();
169         try {
170             prs=fdser.addZCMX(cardID, yktywdh, dataArr);
171             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "addLoading返回值::::"+Jacksonmethod.tojson(prs, false));
172         } catch (Exception e) {
173             mm.put("respcode", 999);
174             mm.put("respmsg", e.getMessage());
175             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "addLoading返回值::::"+Jacksonmethod.tojson(mm, false));
176             String str=Jacksonmethod.tojson(mm, false);
177             return str;
178         }
179         if(prs!=null){
180             if(prs.getCode()==0){
181                 mm.put("respcode", 111);
182                 mm.put("respmsg", "操作成功!");
183                 mm.put("data", prs.getList());
184             }else{
185 //                mm.put("respcode", 999);
186 //                mm.put("respmsg", prs.getErrmsg());
187                 if(prs.getCode()==2){
188                     mm.put("respcode", 222);
189                     mm.put("respmsg", prs.getErrmsg());
190                 }else{
191                     mm.put("respcode", 999);
192                     mm.put("respmsg", prs.getErrmsg());
193                 }
194             }
195         }
196         String str=Jacksonmethod.tojson(mm, false);
197         return str;
198     }
199
200     @Override
201     public String zcFinish(HttpServletRequest r, String jsonParam) {
202         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "zcFinish参数map::::" + jsonParam);
203         Map<String, Object> mm = new HashMap<String, Object>();
204         String businessNo = "";
205         boolean zcWc = false;
206         try {
207             JsonParser jp = new JsonParser();
208             JsonObject jo = jp.parse(jsonParam).getAsJsonObject();
209             businessNo = JSONobj.getstring(jo, "businessNo");
210             zcWc = JSONobj.getbool(jo, "isWc");
211         } catch (Exception e) {
212             mm.put("respcode", 999);
213             mm.put("respmsg", "数据解析出错!");
214             String str = Jacksonmethod.tojson(mm, false);
215             return str;
216         }
217         if (StringUtils.isBlank(businessNo)) {
218             mm.put("respcode", 999);
219             mm.put("respmsg", "业务单号参数为空!");
220             String str = Jacksonmethod.tojson(mm, false);
221             return str;
222         }
223         Fd_Bsheet fb = this.fdbPer.getbybsNo(businessNo);
224         if (fb == null && fb.getStatus() != Serviceenum.在办) {
225             mm.put("respcode", 999);
226             mm.put("respmsg", "未找到在办业务单!");
227             String str = Jacksonmethod.tojson(mm, false);
228             return str;
229         }
230         Map<String, Object> xsTask = bsPer.selectTaskTime(businessNo);
231         if (xsTask != null) {
232             Map<String, Object> xstm = new HashMap<String, Object>();
233             xstm.put("businessNo", businessNo);
234             xstm.put("zcWc", zcWc);
235             if (zcWc)
236                 xstm.put("zcwcTime", new Date());
237             else
238                 xstm.put("zcwcTime", null);
239             bsPer.updateZcWcTime(xstm);
240
241             if (zcWc) {
242                 List<WaitXSTD> l = this.fdbPer.getAllKH(fb.getBsNo(), fb.getId());
243                 if (l != null) {
244                     boolean iscz = false;//收货单位在明细中是否存在
245                     WaitXSTD wt = null;
246                     for (WaitXSTD waitXSTD : l) {
247                         if (fb.getShdw().equals(waitXSTD.getTd_khmc())) {
248                             iscz = true;
249                             break;
250                         } else {
251                             if (wt == null && StringUtils.isNotBlank(waitXSTD.getTd_khmc())) {
252                                 wt = waitXSTD;
253                             }
254                         }
255                     }
256                     if (!iscz && wt != null) {
257                         fb.setShdw(wt.getTd_khmc());
258                         this.yktmper.updateshcompany(fb.getBsNo(), wt.getTd_khmc(), wt.getTd_shdd());
259                     }
260                 }
261             }
262             mm.put("respcode", 111);
263             mm.put("respmsg", "完成装车操作成功!");
264         } else {
265             mm.put("respcode", 999);
266             mm.put("respmsg", "业务单号参数错误!");
267         }
268         String str = Jacksonmethod.tojson(mm, false);
269         return str;
270     }
271
272     @Override
273     public String getVInfo(HttpServletRequest r,String jsonParam) {
274
275         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "getVInfo参数map::::"+jsonParam);
276 //        Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数yktkh::::"+RequestParam.getString(r, "yktkh"));
277
278         String cardID="";
279         Map<String, Object> mm=new HashMap<String, Object>();
280         try {
281             JsonParser jp=new JsonParser();
282             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
283             cardID=JSONobj.getstring(jo, "yktkh");
284         } catch (Exception e) {
285             mm.put("respcode", 999);
286             mm.put("respmsg", "数据解析出错!");
287             String str=Jacksonmethod.tojson(mm, false);
288             return str;
289         }
290         ObjectResult<Map<String, Object>> prs=fdser.getcInfo(cardID);
291         if(prs.getCode() == 1) {
292             log.info("卡号:" + cardID + "---- 错误:"+ prs.getErrmsg());
293         }
294         if(prs!=null){
295             if(prs.getCode()==0){
296                 mm=prs.getItem();
297             }else{
298                 mm.put("respcode", 999);
299                 mm.put("respmsg", prs.getErrmsg());
300             }
301         }
302         String str=Jacksonmethod.tojson(mm, false);
303         return str;
304     }
305
306     @Override
307     public String getxstdInfo(HttpServletRequest r, String jsonParam) {
308         String xstdNo="";
309         Map<String, Object> mm=new HashMap<String, Object>();
310         try {
311             JsonParser jp=new JsonParser();
312             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
313             xstdNo=JSONobj.getstring(jo, "xstdNo");
314         } catch (Exception e) {
315             mm.put("respcode", 999);
316             mm.put("respmsg", "数据解析出错!");
317             String str=Jacksonmethod.tojson(mm, false);
318             return str;
319         }
320         ObjectResult<Map<String, Object>> or=fdser.getxstdInfo(xstdNo);
321         String str="";
322         if(or.getCode()!=0){
323             str=Jacksonmethod.tojson(or, false);
324         }else{
325             str=Jacksonmethod.tojson(or.getItem(), false);
326         }
327         return str;
328     }
329
330     @Override
331     public String savewdControl(HttpServletRequest r, String jsonParam) {
332         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "请求ip::::"+r.getRemoteAddr());
333         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数savewdControl::b::"+jsonParam);
334         JsonArray dataArr=null;
335         Map<String, Object> mm=new HashMap<String, Object>();
336         try {
337             JsonParser jp=new JsonParser();
338             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
339             dataArr=JSONobj.getJsonArray(jo, "data");
340             System.err.println("savewdControl ddata::::"+dataArr);
341         } catch (Exception e) {
342             mm.put("respcode", 999);
343             mm.put("respmsg", "数据解析出错!");
344             String str=Jacksonmethod.tojson(mm, false);
345             return str;
346         }
347         ObjectResult<Boolean> prs=new ObjectResult<Boolean>();
348         try {
349             prs=fdser.savewdControl(dataArr);
350             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "savewdControl返回值::::"+Jacksonmethod.tojson(prs, false));
351         } catch (Exception e) {
352             mm.put("respcode", 999);
353             mm.put("respmsg", e.getMessage());
354             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "savewdControl返回值::::"+Jacksonmethod.tojson(mm, false));
355             String str=Jacksonmethod.tojson(mm, false);
356             return str;
357         }
358         if(prs!=null){
359             if(prs.getCode()==0){
360                 mm.put("respcode", 111);
361                 mm.put("respmsg", "操作成功!");
362             }else{
363                 mm.put("respcode", 999);
364                 mm.put("respmsg", prs.getErrmsg());
365             }
366         }
367         String str=Jacksonmethod.tojson(mm, false);
368         return str;
369     }
370
371
372 }