hjg
2024-07-09 30304784e82d4bba24121328da8eb8490aec4f4f
提交 | 用户 | 时间
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="";
a0879b 279         boolean needRecord=true;
58d006 280         Map<String, Object> mm=new HashMap<String, Object>();
A 281         try {
282             JsonParser jp=new JsonParser();
283             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
284             cardID=JSONobj.getstring(jo, "yktkh");
a0879b 285             if(jo.has("needRecord")) {
H 286                 needRecord = JSONobj.getbool(jo, "needRecord");
287             }
58d006 288         } catch (Exception e) {
A 289             mm.put("respcode", 999);
290             mm.put("respmsg", "数据解析出错!");
291             String str=Jacksonmethod.tojson(mm, false);
292             return str;
293         }
a0879b 294         ObjectResult<Map<String, Object>> prs=fdser.getcInfo(cardID,needRecord);
58d006 295         if(prs.getCode() == 1) {
A 296             log.info("卡号:" + cardID + "---- 错误:"+ prs.getErrmsg());
297         }
298         if(prs!=null){
299             if(prs.getCode()==0){
300                 mm=prs.getItem();
301             }else{
302                 mm.put("respcode", 999);
303                 mm.put("respmsg", prs.getErrmsg());
304             }
305         }
306         String str=Jacksonmethod.tojson(mm, false);
307         return str;
308     }
309
310     @Override
311     public String getxstdInfo(HttpServletRequest r, String jsonParam) {
312         String xstdNo="";
313         Map<String, Object> mm=new HashMap<String, Object>();
314         try {
315             JsonParser jp=new JsonParser();
316             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
317             xstdNo=JSONobj.getstring(jo, "xstdNo");
318         } catch (Exception e) {
319             mm.put("respcode", 999);
320             mm.put("respmsg", "数据解析出错!");
321             String str=Jacksonmethod.tojson(mm, false);
322             return str;
323         }
324         ObjectResult<Map<String, Object>> or=fdser.getxstdInfo(xstdNo);
325         String str="";
326         if(or.getCode()!=0){
327             str=Jacksonmethod.tojson(or, false);
328         }else{
329             str=Jacksonmethod.tojson(or.getItem(), false);
330         }
331         return str;
332     }
333
334     @Override
335     public String savewdControl(HttpServletRequest r, String jsonParam) {
336         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "请求ip::::"+r.getRemoteAddr());
337         Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "参数savewdControl::b::"+jsonParam);
338         JsonArray dataArr=null;
339         Map<String, Object> mm=new HashMap<String, Object>();
340         try {
341             JsonParser jp=new JsonParser();
342             JsonObject jo=jp.parse(jsonParam).getAsJsonObject();
343             dataArr=JSONobj.getJsonArray(jo, "data");
344             System.err.println("savewdControl ddata::::"+dataArr);
345         } catch (Exception e) {
346             mm.put("respcode", 999);
347             mm.put("respmsg", "数据解析出错!");
348             String str=Jacksonmethod.tojson(mm, false);
349             return str;
350         }
351         ObjectResult<Boolean> prs=new ObjectResult<Boolean>();
352         try {
353             prs=fdser.savewdControl(dataArr);
354             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "savewdControl返回值::::"+Jacksonmethod.tojson(prs, false));
355         } catch (Exception e) {
356             mm.put("respcode", 999);
357             mm.put("respmsg", e.getMessage());
358             Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "savewdControl返回值::::"+Jacksonmethod.tojson(mm, false));
359             String str=Jacksonmethod.tojson(mm, false);
360             return str;
361         }
362         if(prs!=null){
363             if(prs.getCode()==0){
364                 mm.put("respcode", 111);
365                 mm.put("respmsg", "操作成功!");
366             }else{
367                 mm.put("respcode", 999);
368                 mm.put("respmsg", prs.getErrmsg());
369             }
370         }
371         String str=Jacksonmethod.tojson(mm, false);
372         return str;
373     }
374
63fbfd 375     @Override
A 376     public String receiveCurrWeight(HttpServletRequest r, String jsonParam) { // 获取业务单号 一次称重 二次称重
303047 377         JsonParser jp = new JsonParser();
H 378         JsonObject jo = jp.parse(jsonParam).getAsJsonObject();
63fbfd 379         String businessNo = JSONobj.getstring(jo, "businessNo");
A 380         boolean firstWeighing = JSONobj.getbool(jo, "firstWeighing");
381         boolean secondWeighing = JSONobj.getbool(jo, "secondWeighing");
303047 382         boolean isJc = JSONobj.getbool(jo, "isJc");
63fbfd 383         String sdepartNo = JSONobj.getstring(jo, "sdepartNo");
303047 384         if (StringUtils.isBlank(businessNo) || businessNo.indexOf("XS") != 0 || StringUtils.isBlank(sdepartNo)
63fbfd 385         ) {
A 386             return null;
387         }
388         // 刷新
303047 389         if (firstWeighing || secondWeighing) { // 称重需要刷新一下
63fbfd 390             if ("06".equals(sdepartNo)) { // 明晟
A 391                 synchronized (FdXSTDService.refreshMsLedLock) {
392                     if (FdXSTDService.refreshMsLedLock) { // 系统繁忙
393                         return null;
394                     }
395                 }
396                 try {
397                     synchronized (FdXSTDService.refreshMsLedLock) {
398                         FdXSTDService.refreshMsLedLock = true;
399                     }
400                     fdser.sendToMsLed(null);
401                 } finally {
402                     synchronized (FdXSTDService.refreshMsLedLock) {
403                         FdXSTDService.refreshMsLedLock = false;
404                     }
405                 }
303047 406             }
H 407         }
408         if (firstWeighing || secondWeighing || isJc) { // 称重需要刷新一下
409             if ("08".equals(sdepartNo)) { // 义瑞
63fbfd 410                 synchronized (FdXSTDService.refreshYrLedLock) {
A 411                     if (FdXSTDService.refreshYrLedLock) { // 系统繁忙
412                         return null;
413                     }
414                 }
415                 try {
416                     synchronized (FdXSTDService.refreshYrLedLock) {
417                         FdXSTDService.refreshYrLedLock = true;
418                     }
419                     fdser.sendToYrLed(null);
303047 420                 } finally {
63fbfd 421                     synchronized (FdXSTDService.refreshYrLedLock) {
A 422                         FdXSTDService.refreshYrLedLock = false;
423                     }
424                 }
425             }
303047 426             if ("04".equals(sdepartNo)) { // 科技
H 427                 synchronized (FdXSTDService.refreshYrLedLock) {
428                     if (FdXSTDService.refreshKjLedLock) { // 系统繁忙
429                         return null;
430                     }
bb48ed 431                 }
303047 432                 try {
H 433                     synchronized (FdXSTDService.refreshKjLedLock) {
434                         FdXSTDService.refreshKjLedLock = true;
435                     }
436                     fdser.sendToKjLed(null);
437                 } finally {
438                     synchronized (FdXSTDService.refreshKjLedLock) {
439                         FdXSTDService.refreshKjLedLock = false;
440                     }
bb48ed 441                 }
H 442             }
63fbfd 443         }
A 444         return null;
445     }
446
58d006 447
A 448 }