Administrator
2023-04-15 4c64dca2491f0ae298ee160c1e8df22448a588ae
提交 | 用户 | 时间
58d006 1 package com.mandi.webservice.service.impl;
A 2
3 import com.google.gson.JsonArray;
4 import com.google.gson.JsonElement;
5 import com.google.gson.JsonObject;
6 import com.google.gson.JsonParser;
7 import com.mandi.basicconfig.mapper.FdRepertoryNexusMapper;
8 import com.mandi.basicconfig.mapper.NczsjMapper;
4c64dc 9 import com.mandi.basicconfig.persist.*;
58d006 10 import com.mandi.common.JSONobj;
A 11 import com.mandi.common.ParamFileter.BigDecimalfiter;
4c64dc 12 import com.mandi.common.Wxhtmethod;
58d006 13 import com.mandi.dao.common.ObjectResult;
A 14 import com.mandi.dao.common.PageResult;
4c64dc 15 import com.mandi.fendan.mapper.*;
A 16 import com.mandi.fendan.persist.*;
58d006 17 import com.mandi.fendan.util.Contants;
4c64dc 18 import com.mandi.fendan.util.ConvertTool;
A 19 import com.mandi.fendan.util.ThreadPoolUtil;
58d006 20 import com.mandi.fendan.util.persist.Serviceenum;
A 21 import com.mandi.fendan.util.persist.WaitXSTDMX;
22 import com.mandi.fendan.util.persist.Yktbsitem;
4c64dc 23 import com.mandi.servlet.file.impl.FileLoadImpl;
58d006 24 import com.mandi.webservice.service.IFdXSTDService;
4c64dc 25 import org.apache.commons.lang3.StringUtils;
A 26 import org.apache.log4j.Logger;
27 import org.springframework.stereotype.Service;
28 import org.springframework.transaction.annotation.Transactional;
29
30 import javax.annotation.Resource;
31 import java.util.*;
58d006 32
A 33 @Service
34 public class FdXSTDService implements IFdXSTDService{
35
36     @Resource
37     private Fd_XSTDMapper tdper;
38     @Resource
39     private Fd_XSTDMXMapper tdmxper;
40     @Resource
41     private Fd_YKTMapper yktper;
42     @Resource
43     private VehicleXSTDMapper vhxper;
44     @Resource
45     private Fd_VehicleMapper  vhper;
46     @Resource
47     private NczsjMapper zsjper;
48     @Resource
49     private Fd_BsheetMapper fbper;
50     @Resource
51     private Fd_CompanyMapper cmper;
52     @Resource
53     private Fd_GbxstdMapper gbper;
54     @Resource
55     private Fd_GbxstdmxMapper gbmxper;
56     @Resource
57     private BusinessMapper bsper;
58     @Resource
59     private BsheetEcgbMapper beper;
60     @Resource
61     private FdRepertoryNexusMapper reNxPer;
62
63     private Logger log= Logger.getLogger(FileLoadImpl.class);
64
65     @Override
66     @Transactional(rollbackFor=Exception.class)
67     public ObjectResult<Boolean> saveFd_xstd(String dataArr) throws Exception {
68         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
69         JsonArray ja=null;
70         try {
71             JsonParser jp=new JsonParser();
72              ja=jp.parse(dataArr).getAsJsonArray();
73         } catch (Exception e) {
74             throw new Exception("数据解析错误,参数不是json数组!");
75         }
76         if(ja!=null){
77             for (JsonElement je : ja) {
78                 JsonObject jo=je.getAsJsonObject();
79                 JsonObject objJo=null;
80                 JsonArray tdmxArr=null;
81                 try {
82                      objJo=jo.getAsJsonObject("head");
83                      tdmxArr=jo.getAsJsonArray("body");
84                 } catch (Exception e) {
85                     throw new Exception("数据解析错误,数据格式不正确!");
86                 }
87                 String ztbz=JSONobj.getstring(objJo, "td_ztbz");
88                 Fd_XSTD xstd=new Fd_XSTD();
89                 xstd=JSONobj.getobj(objJo, xstd);
90                 if("01".equals(ztbz)){
91                     xstd.setTd_ztbz(2);
92                 }else if("02".equals(ztbz)){
93                     xstd.setTd_ztbz(1);
94                 }else if("03".equals(ztbz)){
95                     xstd.setTd_ztbz(3);
96                 }else{
97                     xstd.setTd_ztbz(1);
98                 }
99                 //明细业务单元
100                 String mxywyd="";
101                 //根据仓库查找对应的厂区编号
102                 String ckNo="";//明细仓库编号
103
104                 Ncywdy cn=this.zsjper.getNcywdybyCode(xstd.getTd_ywdybh());
105                 //系统部门找不到不做处理
106                 if(cn==null||cn.getYktCode()==null||StringUtils.isEmpty(cn.getYktCode())){
107                     continue;
108                 }
109                 Ncworker ncw=this.zsjper.getNcworkerbyCode(xstd.getTd_zdr());
110                 Ncdepart ncd=this.zsjper.getNcdepartbyCode(xstd.getTd_bmbh());
111                 if(ncw!=null)
112                     xstd.setTd_zdrmc(ncw.getName());
113                 if(ncd!=null)
114                     xstd.setTd_bmmc(ncd.getName());
115                 int td_wfdsl=0;//未分单数量
116                 double td_wfdzl=0;//未分单重量
117                 String td_tdls=xstd.getTd_tdls();//提单流水号
118                 for (int i = 0; i < tdmxArr.size(); i++) {
119                     objJo=tdmxArr.get(i).getAsJsonObject();
120                     String h=JSONobj.getstring(objJo, "h");
121                     String k=JSONobj.getstring(objJo, "k");
122                     String c=JSONobj.getstring(objJo, "c");
123                     Fd_XSTDMX xstdmx=new Fd_XSTDMX();
124                     xstdmx=JSONobj.getobj(objJo,xstdmx);
125                     double mz=xstdmx.getTdmx_mz();
126
127                     xstdmx.setTdmx_ggxh((h==null?"C":h)+"*"+(k==null?"C":k)+"*"+(c==null?"C":c));
128                     if(StringUtils.isEmpty(td_tdls)){
129                         td_tdls=xstdmx.getTdmx_tdls();
130                     }
131                     if(StringUtils.isBlank(mxywyd)){
132                         cn=this.zsjper.getNcywdybyCode(xstdmx.getTdmx_fhzz());
133                         //系统部门找不到不做处理
134                         if(cn!=null && StringUtils.isNotBlank(cn.getYktCode())){
135                             mxywyd=xstdmx.getTdmx_fhzz();
136                         }else{
137                             continue;
138                         }
139                         if(StringUtils.isBlank(ckNo)) {
140                             Ncck ck=this.zsjper.getNcckbyPkid(xstdmx.getTdmx_ck());
141                             if(ck!=null)
142                                 ckNo=ck.getCode();
143
144                         }
145                     }
146                     //有上次已装车记录
147                     Fd_XSTDMX ccr=this.tdmxper.get(xstdmx.getTdmx_tdfl());
148                     if(ccr!=null&&ccr.getTdmx_zcbz()>0){
149                         continue;
150                     }else{
151                         if(ccr!=null){
152                             this.tdmxper.del(xstdmx.getTdmx_tdfl());
153                         }
154                     }
155
156
157                     if(Contants.NcNosend.equals(mxywyd)){
158                         this.tdmxper.delbyTDLS(xstd.getTd_tdls());
159                         this.tdper.del(xstd.getTd_tdls());
160                         break;
161                     }
162                     this.tdmxper.insert(xstdmx);
163                     //如果这次推过来的是关闭的 明细保存  表头不增加未分单数量
164                     if(xstdmx.getTdmx_gbbz()==0){
165                         td_wfdsl++;
166                         td_wfdzl+=mz;
167                     }
168
169                 }
170
171                 if(!Contants.NcNosend.equals(mxywyd)){
172                     //获取生成厂区编号
173                     FdRepertoryNexus renx=this.reNxPer.getbyckNoAndYwdyNo(ckNo,mxywyd);
174                     if(renx!=null)
175                         xstd.setTd_cqNo(renx.getSdepartNo());
176                     xstd.setTd_wfdsl(td_wfdsl);
177                     xstd.setTd_wfdzl(td_wfdzl);
178                     xstd.setTd_ywdybh(mxywyd);
179                     this.tdper.insert(xstd);
180                 }
181             }
182         }
183         orr.setCode(0);
184         orr.setErrmsg("新增成功!");
185         return orr;
186     }
187
188     @Override
189     @Transactional(rollbackFor=Exception.class)
190     public ObjectResult<Boolean> delFd_xstd(String dataArr) throws Exception {
191         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
192         JsonArray ja=null;
193         try {
194             JsonParser jp=new JsonParser();
195             ja=jp.parse(dataArr).getAsJsonArray();
196         } catch (Exception e) {
197             throw new Exception("数据解析错误,参数不是json数组!");
198         }
199         if(ja!=null){
200             for (JsonElement je : ja) {
201                 JsonObject jo=je.getAsJsonObject();
202                 JsonObject objJo=null;
203                 try {
204                      objJo=jo.getAsJsonObject("head");
205                 } catch (Exception e) {
206                     throw new Exception("数据解析错误,数据格式不正确!");
207                 }
208                 String td_tdls=JSONobj.getstring(objJo, "td_tdls");
209                 if(StringUtils.isBlank(td_tdls)){
210                     throw new Exception("数据解析错误,提单流水号不能为空!");
211                 }
212
213                 Fd_XSTD td_xstd=this.tdper.get(td_tdls);
214                 if(td_xstd!=null){
215                     int c=this.tdmxper.getbytdlswithZCorFD(td_tdls);
216                     if(c>0){
217                         throw new Exception("发货单:"+td_xstd.getTd_tdbh()+" 已经分单或装车,不能删除!");
218                     }
219 //                    //只删除标志是未装车的
220                     this.tdmxper.delbyTDLS(td_tdls);
221                     this.tdper.del(td_tdls);
222                     this.gbper.del(td_xstd.getTd_tdbh());
223                     this.gbmxper.del(td_xstd.getTd_tdbh());
224                 }
225             }
226         }
227         orr.setCode(0);
228         orr.setErrmsg("删除成功!");
229         return orr;
230     }
231
232     @Override
233     @Transactional(rollbackFor=Exception.class)
234     public ObjectResult<Boolean> closeFd_xstd(String dataArr) throws Exception {
235         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
236         JsonArray ja=null;
237         try {
238             JsonParser jp=new JsonParser();
239             ja=jp.parse(dataArr).getAsJsonArray();
240         } catch (Exception e) {
241             throw new Exception("数据解析错误,参数不是json数组!");
242         }
243         if(ja!=null){
244             for (JsonElement je : ja) {
245                 JsonObject jo=je.getAsJsonObject();
246                 JsonObject objJo=null;
247                 JsonArray tdmxArr=null;
248                 try {
249                      objJo=jo.getAsJsonObject("head");
250                      tdmxArr=jo.getAsJsonArray("body");
251                 } catch (Exception e) {
252                     throw new Exception("数据解析错误,数据格式不正确!");
253                 }
254
255                 //提单流水号
256                 String td_tdls=objJo.get("td_tdls")==null?"":objJo.get("td_tdls").getAsString();
257                 Fd_XSTD xstd=this.tdper.get(td_tdls);
258                 if(xstd!=null){
259                     for (int i = 0; i < tdmxArr.size(); i++) {
260                         objJo=tdmxArr.get(i).getAsJsonObject();
261                         String tdmx_tdfl=objJo.get("tdmx_tdfl")==null?"":objJo.get("tdmx_tdfl").getAsString();
262                         String sfckgb=objJo.get("sfckgb")==null?"":objJo.get("sfckgb").getAsString();
263                         Fd_XSTDMX tdmx=this.tdmxper.get(tdmx_tdfl);
264                         if(tdmx!=null&&tdmx.getTdmx_gbbz()==0){
265                             tdmx.setTdmx_gbbz(1);
266                             this.tdmxper.updateGB(tdmx);
267 //                            if(tdmx.getTdmx_zcbz()!=0){
268 //                                continue;
269 //                            }
270                             if(tdmx.getTdmx_fdbz()!=0){
271                                 //已分单未装车
272                                 if("N".equals(sfckgb)){
273                                     if(tdmx.getTdmx_zcbz()==0){
274                                         throw new Exception("提单明细:批次号:"+tdmx.getTdmx_pch()+" 已分单未装车,请联系物流公司取消分单!");
275                                     }
276                                 }
277                             }
278 //                            if(tdmx.getTdmx_zcbz()!=0){
279 //                                throw new Exception("提单流水号:"+xstd.getTd_tdls()+" 已扫码装车,不能关闭!");
280 //                            }
281
282                             if(tdmx.getTdmx_fdbz()==0){
283                                 xstd.setTd_wfdsl(xstd.getTd_wfdsl()-1);
284                                 xstd.setTd_wfdzl(xstd.getTd_wfdzl()-tdmx.getTdmx_mz());
285                                 this.tdper.updateFD(xstd);
286                             }else{
287                                 if(tdmx.getTdmx_zcbz()==0){
288                                     tdmx.setTdmx_fdywbh(null);
289                                     tdmx.setTdmx_fdwlgsbh(null);
290                                     tdmx.setTdmx_fdbz(0);
291                                     tdmx.setTdmx_fdcph(null);
292                                     this.tdmxper.updateFD(tdmx);
293                                 }
294                             }
295
296                             //这个关闭记录表示的是一卡通里的关闭操作
297                             Fd_Gbxstdmx gbmx=this.gbmxper.get(tdmx_tdfl);
298                             if(gbmx!=null){
299                                 Fd_Gbxstd gb=this.gbper.get(xstd.getTd_tdbh());
300                                 if(gb!=null){
301                                     gb.setTd_gbsl(gb.getTd_gbsl()-1);
302                                     gb.setTd_gbzl(BigDecimalfiter.sub(gb.getTd_gbzl(),tdmx.getTdmx_mz()));
303                                     this.gbper.update(gb);
304                                 }
305                                 this.gbmxper.delbyId(tdmx_tdfl);
306                             }
307                         }
308                     }
309                 }
310             }
311         }
312         orr.setCode(0);
313         orr.setErrmsg("关闭成功!");
314         return orr;
315     }
316
317     @Override
318     @Transactional(rollbackFor=Exception.class)
319     public ObjectResult<Boolean> openFd_xstd(String dataArr) throws Exception {
320         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
321         JsonArray ja=null;
322         try {
323             JsonParser jp=new JsonParser();
324              ja=jp.parse(dataArr).getAsJsonArray();
325         } catch (Exception e) {
326             throw new Exception("数据解析错误,参数不是json数组!");
327         }
328         if(ja!=null){
329             for (JsonElement je : ja) {
330                 JsonObject jo=je.getAsJsonObject();
331                 JsonObject objJo=null;
332                 JsonArray tdmxArr=null;
333                 try {
334                      objJo=jo.getAsJsonObject("head");
335                      tdmxArr=jo.getAsJsonArray("body");
336                 } catch (Exception e) {
337                     throw new Exception("数据解析错误,数据格式不正确!");
338                 }
339
340                 //提单流水号
341                 String td_tdls=objJo.get("td_tdls")==null?"":objJo.get("td_tdls").getAsString();
342                 Fd_XSTD xstd=this.tdper.get(td_tdls);
343                 if(xstd!=null){
344                     for (int i = 0; i < tdmxArr.size(); i++) {
345                         objJo=tdmxArr.get(i).getAsJsonObject();
346                         String tdmx_tdfl=objJo.get("tdmx_tdfl")==null?"":objJo.get("tdmx_tdfl").getAsString();
347                         Fd_XSTDMX tdmx=this.tdmxper.get(tdmx_tdfl);
348                         if(tdmx!=null&&tdmx.getTdmx_gbbz()==1){
349                             tdmx.setTdmx_gbbz(0);
350                             this.tdmxper.updateGB(tdmx);
351                             if(tdmx.getTdmx_fdbz()==0){
352                                 xstd.setTd_wfdsl(xstd.getTd_wfdsl()+1);
353                                 xstd.setTd_wfdzl(xstd.getTd_wfdzl()+tdmx.getTdmx_mz());
354                                 this.tdper.updateFD(xstd);
355                             }
356                         }
357                     }
358                 }
359             }
360         }
361         orr.setCode(0);
362         orr.setErrmsg("打开成功!");
363         return orr;
364     }
365
366     @Override
367     @Transactional(rollbackFor=Exception.class)
368     public PageResult<Map<String, Object>> addZCMX(String cardID,String yktywdh, JsonArray dataArr) throws Exception {
369         PageResult<Map<String, Object>> prr=new PageResult<Map<String,Object>>();
370         List<Map<String, Object>> relist=new ArrayList<Map<String,Object>>();
371         if(StringUtils.isEmpty(yktywdh)){
372             prr.setCode(1);
373             prr.setErrmsg("参数:一卡通业务单号为空!");
374             return prr;
375         }
376         //根据卡号判断分单信息
377         //循环批次号 如果没有分单 修改为分单和装车
378         Fd_Bsheet fdb=this.fbper.getbybsNo(StringUtils.isNotBlank(yktywdh)?yktywdh:"");
379         String vehicleId="";
380         if(fdb==null){
381             prr.setCode(1);
382             prr.setErrmsg("一卡通业务单未找到,请确认单号是否正确!");
383             return prr;
384         }
cc0cbf 385
A 386         if (fdb.getStatus() != Serviceenum.在办) {
387             prr.setCode(2);
388             prr.setErrmsg("一卡通业务单不是在办状态,系统不做处理!");
389             return prr;
390         }
391         if (StringUtils.isBlank(cardID)) {
392             prr.setCode(1);
393             prr.setErrmsg("参数:一卡通卡号为空!");
394             return prr;
395         }
396         if (dataArr == null) {
397             prr.setCode(1);
398             prr.setErrmsg("参数:批次号为空!");
399             return prr;
400         }
401
402         Map<String, Object> mp = this.yktper.getcardinuse(cardID);
403         if (mp == null) {
404             throw new Exception("卡号不正确未找到在用卡!");
405         }
406         vehicleId = mp.get("numberplates") == null ? "" : mp.get("numberplates").toString();
407         if (!vehicleId.equals(fdb.getVehicleId())) {
408             prr.setCode(1);
409             prr.setErrmsg("参数:卡号关联的车牌号和业务单关联的车牌号不一致");
410             return prr;
411         }
412         // yktywdh = fdb.getBsNo();
58d006 413
A 414         int wcnum=this.bsper.getweightDoc(vehicleId, fdb.getBsNo());
415         if(wcnum<=0){
416             prr.setCode(1);
417             prr.setErrmsg("车辆:"+vehicleId+" 未找到过磅单,请先过磅!");
418             return prr;
419         }
420         yktywdh=fdb.getBsNo();
421         //是否郑州厂区
422         boolean iszz=false;
423
424         //检查是否装车完成
425         Map<String, Object> mmr=this.bsper.selectTaskTime(fdb.getBsNo());
426         try {
427             if(mmr!=null&&mmr.get("zcWc")!=null&&Boolean.valueOf(mmr.get("zcWc").toString())) {
428                 prr.setCode(1);
429                 prr.setErrmsg("联系成品库办公室取消装车完成!");
430                 return prr;
431             }
432         } catch (Exception e) {
433             // TODO: handle exception
434         }
435
4c64dc 436         String currPch="";// 当前批次号
58d006 437         //第一次添加装卸记录发送装车信息
A 438         int sfzc=this.fbper.getbsitembyNo(fdb.getBsNo());
439         if(sfzc<=0) {
440             //发送微信公众号提醒信息
441             String url=Contants.yktLocalAdd+"/routine/sendZcMsg.htm";
cc0cbf 442             Map<String, String> paramMp=new HashMap<String, String>();
58d006 443             mp.put("sdepartNo", fdb.getSdepartNo());
A 444             mp.put("vehicleId", vehicleId);
445             mp.put("businessNo", fdb.getBsNo());
cc0cbf 446             Wxhtmethod.postJson(url, paramMp);
58d006 447         }
cc0cbf 448         // 现场过完毛重后出现扫码装车的,必须重新过磅
58d006 449         int grossNum=this.bsper.getgrosstDoc(vehicleId, fdb.getBsNo());
A 450
451         for (JsonElement je : dataArr) {
452             JsonObject jo=je.getAsJsonObject();
453             String tdmx_pch = jo.get("tdmx_pch").getAsString();
454 //            Fd_XSTDMX tdmx=this.tdmxper.getbyPCH(tdmx_pch);
455             Fd_XSTDMX tdmx=this.tdmxper.getbyPCHONE(tdmx_pch,vehicleId);
456             if(tdmx==null){
457                 prr.setCode(1);
458                 prr.setErrmsg("车辆:"+vehicleId+"没有该明细的分单记录或已关闭,不能添加装车!");
459                 return prr;
460             }
461             // 下面部分注释掉,改为sql语句中判断是否为未关闭
462             /*if(tdmx.getTdmx_gbbz()!=0){
463                 prr.setCode(1);
464                 prr.setErrmsg("明细:"+tdmx.getTdmx_pch()+" 在NC是已关闭状态,不能添加装车!");
465                 return prr;
466             }*/
467
468
469 //            boolean booff=false;
470 //            if(tdmx.getTdmx_zcbz()!=0){
471 //                booff=true;
472 //                throw new Exception("批次号:"+tdmx_pch+" 已经提交装车,不能重复提交装车!");
473 //            }
474             Fd_XSTD xstd=this.tdper.get(tdmx.getTdmx_tdls());
475             if(Contants.nc_ywdy_ZZ.equals(xstd.getTd_cqNo())&&!iszz){
476                 iszz=true;
477             }
478             Vehicle_XSTD vxs=this.vhxper.getVhicleByIDs(vehicleId, xstd.getTd_tdbh());
479             if(vxs==null) {
480                 prr.setCode(1);
481                 prr.setErrmsg("未找到配车关联记录,不能添加装车!");
482                 return prr;
483             }
484             //修改提单的未分单数量和重量
485             //修改提单vehicle_XSTD表
486             Fd_Company fdc=null;
487             //是否分单
488             if(tdmx.getTdmx_fdbz()==0){
489                 fdc=this.cmper.getByCompanyNo(vxs.getCompanyNo());
490                 tdmx.setTdmx_fdbz(1);
491                 tdmx.setTdmx_fdcph(vehicleId);
492                 tdmx.setTdmx_fdywbh(yktywdh);
493                 tdmx.setTdmx_fdwlgsbh(vxs.getCompanyNo());
494                 xstd.setTd_wfdsl(xstd.getTd_wfdsl()-1);
495                 xstd.setTd_wfdzl(xstd.getTd_wfdzl()-tdmx.getTdmx_mz());
496                 this.tdper.updateFD(xstd);
497                 vxs.setFd_num(vxs.getFd_num()+1);
498                 vxs.setFd_weight(vxs.getFd_weight()+tdmx.getTdmx_mz());
499                 this.vhxper.updatewithIDs(vxs);
500             }else {
501                 fdc=this.cmper.getByCompanyNo(tdmx.getTdmx_fdwlgsbh());
502             }
503             tdmx.setTdmx_zcbz(1);
504             tdmx.setTdmx_zccph(vehicleId);
505             tdmx.setTdmx_zcwlgsName(fdc.getName());
506             tdmx.setTdmx_zcdriver(fdb.getDriver());
507             tdmx.setTdmx_zcphone(fdb.getPhone());
508             this.tdmxper.updateZCnoFD(tdmx);
509
510             WaitXSTDMX wx=this.fbper.getWaittdmx(tdmx.getTdmx_tdls(), tdmx.getTdmx_tdfl());
511             this.fbper.delbsitem(tdmx.getTdmx_pch(), fdb.getBsNo());
512             Yktbsitem bsi=new Yktbsitem();
513             bsi.setId(UUID.randomUUID()+"");
514             bsi.setBussinessNo(fdb.getBsNo());
515             bsi.setName(wx.getTdmx_wlmc());
516             bsi.setMaterielNo(tdmx.getTdmx_wlbh());
517             bsi.setNorms(wx.getTdmx_ggxh());
518             bsi.setUnitname("Kg");
519             bsi.setNum(1);
520             bsi.setWeight(BigDecimalfiter.mulcon(tdmx.getTdmx_jz(), 1000, Contants.scale));
521             bsi.setPrice(0);
522             bsi.setPreweight(BigDecimalfiter.mulcon(tdmx.getTdmx_jz(), 1000, Contants.scale));
523             bsi.setPici(tdmx.getTdmx_pch());
524             bsi.setHejin(wx.getTdmx_hjzt());
525             bsi.setGross(BigDecimalfiter.mulcon(tdmx.getTdmx_mz(), 1000, Contants.scale));
526             bsi.setTaotongWeight(0);
527             bsi.setMoney(0);
528             bsi.setCdepart("");
529             bsi.setCdepartid(0);
530             bsi.setCname("");
531             bsi.setCreateid("");
532             bsi.setCtime(new Date());
533             bsi.setLoadbuild(false);
534             bsi.setFachang(false);
535             bsi.setFachang(true);
536             bsi.setFcnum(0);
537             if(StringUtils.isBlank(xstd.getTd_fpbh())){
538                 bsi.setRecompany(wx.getTdmx_shdw());
539             }else{
540                 bsi.setRecompany(
541                           ConvertTool.covertToCustoms(xstd.getTd_ywdybh())
542                             );
543             }
544             bsi.setReID("");
545             bsi.setDecompany(ConvertTool.ncCovertToFactoryName(xstd.getTd_ywdybh()));
546             bsi.setDeID("");
547             bsi.setFrombatch("ERP系统");
548             bsi.setForshowindx(1);
549             bsi.setReserved11(0);
550             bsi.setReserved12(0);
551             bsi.setReserved13(0);
552             bsi.setJsnum(0);
553             this.fbper.insertbsitem(bsi);
554             Map<String, Object> remp=new HashMap<String, Object>();
555             remp.put("tdmx_pch",tdmx.getTdmx_pch());
556             remp.put("td_tdls",tdmx.getTdmx_tdls());
557             remp.put("tdmx_tdfl",tdmx.getTdmx_tdfl());
558             relist.add(remp);
4c64dc 559             currPch  = tdmx.getTdmx_pch();
58d006 560         }
A 561
562         if(grossNum>0) {
563             Map<String, Object> xstm=new HashMap<String, Object>();
564             xstm.put("canCm",false);
565             xstm.put("businessNo",fdb.getBsNo());
566             this.bsper.updateCanCm(xstm);
567             this.bsper.updatecanFb(vehicleId, fdb.getBsNo());
568         }
569
570         //如果是郑州的销售业务单删除排队信息
571         if(iszz){
572             int ca=this.bsper.getvehicleQ(vehicleId);
573             if(ca>0){
574 //                this.bsper.delvehicleQ(vehicleId);
575                 //删除车辆排队信息
576                 String url=Contants.yktLocalAdd+"/search/vehicleQueue/delItem.htm";
cc0cbf 577                 Map<String, String> paramMp=new HashMap<String, String>();
58d006 578                 mp.put("vehicleID", vehicleId);
cc0cbf 579                 Wxhtmethod.postJson(url, paramMp);
58d006 580             }
A 581         }
582
cc0cbf 583          // 此处异步触发一下明晟发车
A 584         if("06".equals(fdb.getSdepartNo())) {
4c64dc 585             final String cph = currPch;
A 586             ThreadPoolUtil.getInstance().execute(()->sendToMsLed(cph));
cc0cbf 587         }
58d006 588         prr.setCode(0);
A 589         prr.setErrmsg("装车操作成功!");
590         prr.setList(relist);
591         return prr;
592     }
593
4c64dc 594     /**
A 595      *
596      * @param currPch 当前批次号
597      */
598     public void sendToMsLed(String currPch){
cc0cbf 599         //A区  76-86 +  99-1
A 600         //B区  14-33 +  99-2
601         //C区  53-67 +  99-3
602         List<Map> totalList =  tdmxper.getHwList("06"); // 获取明晟所有在办业务单的信息
603         Map<String,List<Map>> ywbhListMap = new HashMap<>();
604         for (Map map : totalList) {
605             String ywdw = (String) map.get("tdmx_fdywbh");
606             if(ywbhListMap.get(ywdw) == null) {
607                 ywbhListMap.put(ywdw, new ArrayList<>());
608             }
609             ywbhListMap.get(ywdw).add(map);
610         }
4c64dc 611         String str1 = " 车号  A区  B区  C区" + "\r\n", str2="";
cc0cbf 612         //"(车牌号)\\-(A区已装车)/(A区总计)\\-(B区已装车)/(B区总计)\\-(C区已装车)/(C区总计)\\r\\n";
4c64dc 613         String formatStr = "%s %s/%s %s/%s %s/%s\r\n";
A 614         // 只有1个区
615         String speakTxtFormatStr1 = "车号%s ,装货%d件已完成,请司机清点货物后尽快驶离装货区。";
616         // 只有2个区
617         String speakTxtFormatStr2 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区装货。";
618         // 只有3个区
619         String speakTxtFormatStr3 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区%s区装货。";
620         Map speakParam = new HashMap(1);
cc0cbf 621         for (Map.Entry<String, List<Map>> entry : ywbhListMap.entrySet()) { // 遍历每个业务单的
4c64dc 622             // 当前装车A、B、C区
A 623             boolean currA = false,currB = false, currC = false;
cc0cbf 624             boolean hasZcwc = false; // 保证已经完成了
4c64dc 625             // String ywhb = entry.getKey();
cc0cbf 626             List<Map> vehicleIdTotalList = entry.getValue();
A 627             Map<String, Integer> totalAbcMap = new HashMap(3); // 总计信息
628             totalAbcMap.put("A", 0);
629             totalAbcMap.put("B", 0);
630             totalAbcMap.put("C", 0);
631             Map<String, Integer> abcMap = new HashMap(3); // 已装信息
632             abcMap.put("A", 0);
633             abcMap.put("B", 0);
634             abcMap.put("C", 0);
635             String cph = ""; // 车牌号
636             for (Map map : vehicleIdTotalList) {
637                 String hw = (String) map.get("tdmx_hwmc");
4c64dc 638                 String pch = (String) map.get("tdmx_pch");
A 639                 if("".equals(cph))  cph = (String) map.get("tdmx_fdcph");
cc0cbf 640                 Integer zcbz = (Integer) map.get("tdmx_zcbz");
A 641                 String hh = hw.replaceAll("\\-.*","");
642                 hh = hh.substring(hh.length()-2); // 取最后两位
643                 int num = Integer.parseInt(hh);
644                 if (num >= 76 && num <= 86 || hw.lastIndexOf("99-1") >= 0) { // A区
4c64dc 645                     totalAbcMap.put("A",totalAbcMap.get("A") + 1);
cc0cbf 646                     if (zcbz != null && zcbz == 1) { // 装车完成
A 647                         abcMap.put("A", abcMap.get("A") + 1);
648                         hasZcwc = true;
649                     }
4c64dc 650                     if(pch.equals(currPch)) {
A 651                         currA = true; currB = false;currC =false;
652                     }
cc0cbf 653                 } else if (num >= 14 && num <= 33 || hw.lastIndexOf("99-2") >= 0) { // B区
4c64dc 654                     totalAbcMap.put("B", totalAbcMap.get("B") + 1);
cc0cbf 655                     if (zcbz != null && zcbz == 1) {
A 656                         abcMap.put("B", abcMap.get("B") + 1);
657                         hasZcwc = true;
658                     }
4c64dc 659                     if(pch.equals(currPch)) {
A 660                         currA = false; currB = true;currC =false;
661                     }
cc0cbf 662                 } else if (num >= 53 && num <= 67 || hw.lastIndexOf("99-3") >= 0) { // C区
4c64dc 663                     totalAbcMap.put("C", totalAbcMap.get("C") + 1);
cc0cbf 664                     if (zcbz != null && zcbz == 1) {
A 665                         abcMap.put("C", abcMap.get("C") + 1);
666                         hasZcwc = true;
667                     }
4c64dc 668                     if(pch.equals(currPch)) {
A 669                         currA = false; currB = false; currC =true;
670                     }
cc0cbf 671                 }
A 672             }
4c64dc 673             if (!hasZcwc) continue; //没有装车完成的也跳过
A 674             if (!(currA || currB || currC) && abcMap.get("A") + abcMap.get("B") + abcMap.get("C") ==
675                     totalAbcMap.get("A") + totalAbcMap.get("B") + totalAbcMap.get("C")) { // 非当前车牌号,已经装车完成但是未出厂
676                 continue;
677             }
678             str2 += String.format(formatStr, cph, fillSpace(abcMap.get("A")), fillSpace(totalAbcMap.get("A")),
679                     fillSpace(abcMap.get("B")), fillSpace(totalAbcMap.get("B")),
680                     fillSpace(abcMap.get("C")), fillSpace(totalAbcMap.get("C")));
681             // 开始准备语音
682             int total = 0;
683             if(currA && abcMap.get("A") == totalAbcMap.get("A")) { // 当前车在A区装车完成
684                 total = totalAbcMap.get("A");
685             }
686             if(currB && abcMap.get("B") == totalAbcMap.get("B")) {// 当前车在B区装车完成
687                 total = totalAbcMap.get("B");
688             }
689             if(currC && abcMap.get("C") == totalAbcMap.get("C")) {// 当前车在C区装车完成
690                 total = totalAbcMap.get("C");
691             }
692             if(total > 0) { // 播放语音,请离开区域
693                 speakParam.clear();
694                 String speakTxt=null ;
695                 if( (abcMap.get("A")>0  && totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0) ||
696                         (abcMap.get("B")>0  && totalAbcMap.get("A")==0 && totalAbcMap.get("C")==0)  ||
697                         (abcMap.get("C")>0  && totalAbcMap.get("B")==0 && totalAbcMap.get("D")==0)
698                 ) { // 只有一个区域有货物
699                     speakTxt= String.format(speakTxtFormatStr1, cph, total);
700                 }else  if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 &&
701                         (totalAbcMap.get("C")==0 || totalAbcMap.get("C") == abcMap.get("C"))){ // AB都有货 C区已完或无货
702                     if(totalAbcMap.get("C")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { // C装完AB未装完
703                         speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B");
704                     } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { //A完B未完
705                         speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "B");
706                     }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("A")< totalAbcMap.get("A")) {//B完A未完
707                         speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "A");
708                     }else { // 全部装完
709                         speakTxt= String.format(speakTxtFormatStr1, cph, total);
710                     }
711                 }else if(totalAbcMap.get("C")>0 && totalAbcMap.get("B")>0 &&
712                         (totalAbcMap.get("A")==0 || totalAbcMap.get("A") == abcMap.get("A")) ){ //BC有货 A区已完或无货
713                     if(totalAbcMap.get("A")>0 && abcMap.get("C")< totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) {  // A装完BC未装完
714                         speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C");
715                     } else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // C完B未装完
716                         speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "B");
717                     }else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("C")< totalAbcMap.get("C")) {// B完C未装完
718                         speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "C");
719                     }else { // 全部装完
720                         speakTxt= String.format(speakTxtFormatStr1, cph, total);
721                     }
722                 }else  if (totalAbcMap.get("A")>0 && totalAbcMap.get("C")>0 &&
723                         (totalAbcMap.get("B")==0 || totalAbcMap.get("B") == abcMap.get("B")) ) { //AC有货
724                     if(totalAbcMap.get("B")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) {
725                         speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C");
726                     } else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { // A装完C未装完
727                         speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "C");
728                     }else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("A")< totalAbcMap.get("A")) {// C装完A未装完
729                         speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "A");
730                     }else { // 全部装完
731                         speakTxt= String.format(speakTxtFormatStr1, cph, total);
732                     }
733                 }else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && totalAbcMap.get("C")>0) { // 3区都有货物,且只有一个取装完了
734                     if(abcMap.get("A")>0 && abcMap.get("B")<totalAbcMap.get("B") && abcMap.get("C")<totalAbcMap.get("C")) {
735                         speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C");
736                     } else if(abcMap.get("B")>0 && abcMap.get("C")==0 && abcMap.get("A")==0) {
737                         speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C");
738                     } else if(abcMap.get("C")>0 && abcMap.get("A")==0 && abcMap.get("B")==0) {
739                         speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B");
740                     } else { // 全部装完
741                         speakTxt= String.format(speakTxtFormatStr1, cph, total);
742                     }
743                 } else {
744                     speakTxt= String.format(speakTxtFormatStr1, cph, total);
745                 }
746                 speakParam.put("SpeakTxt", speakTxt);
747                 log.info("SpeakTxt:"+ speakTxt);
748             }
cc0cbf 749             // 单辆车的单个业务单的信息结束
A 750         }
751         Map paramMap = new HashMap();
4c64dc 752         paramMap.put("strTitle",str1);
A 753         paramMap.put("strContent",str2);
754         try {
755           String re = Wxhtmethod.post(Contants.msLedServiceAddr + "/SendLED",paramMap);
756           // 语音只播一条
757           String re1 = Wxhtmethod.post(Contants.msLedServiceAddr + "/Speak",speakParam);
758         }catch (Exception e){}
759
760
761     }
762     String fillSpace(int str){
763         String s;
764         if(str<10 && str>=0) s= "0" + str;
765         else s=String.valueOf(str);
766         return s;
cc0cbf 767     }
A 768
58d006 769     @Override
A 770     @Transactional(rollbackFor=Exception.class)
771     public ObjectResult<Boolean> delZCMX(String cardID, String yktywdh,JsonArray dataArr) throws Exception {
772         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
773         //根据卡号判断分单信息
774         //循环批次号 如果没有分单 修改为分单和装车
775         Fd_Bsheet fdb=this.fbper.getbybsNo(StringUtils.isNotBlank(yktywdh)?yktywdh:"");
776         String vehicleId="";
777         if(fdb==null){
778             orr.setCode(1);
779             orr.setErrmsg("一卡通业务单未找到,请确认单号是否正确!");
780             return orr;
781         }else{
782             if(fdb.getStatus()!=Serviceenum.在办){
783                 orr.setCode(1);
784                 orr.setErrmsg("一卡通业务单不是在办状态,系统不做处理!");
785                 return orr;
786             }
787             if(StringUtils.isBlank(cardID)){
788                 orr.setCode(1);
789                 orr.setErrmsg("参数:一卡通卡号为空!");
790                 return orr;
791             }
792             if(dataArr==null){
793                 orr.setCode(1);
794                 orr.setErrmsg("参数:批次号为空!");
795                 return orr;
796             }
797
798             Map<String, Object> mp=this.yktper.getcardinuse(cardID);
799             if(mp==null){
800                 throw new Exception("卡号不正确未找到在用卡!");
801             }
802             vehicleId=mp.get("numberplates")==null?"":mp.get("numberplates").toString();
803             if(!vehicleId.equals(fdb.getVehicleId())){
804                 orr.setCode(1);
805                 orr.setErrmsg("参数:卡号关联的车牌号和业务单关联的车牌号不一致");
806                 return orr;
807             }
808             yktywdh=fdb.getBsNo();
809         }
810         //检查是否装车完成
811         Map<String, Object> mmr=this.bsper.selectTaskTime(fdb.getBsNo());
812         try {
813             if(mmr!=null&&mmr.get("zcWc")!=null&&Boolean.valueOf(mmr.get("zcWc").toString())) {
814                 orr.setCode(1);
815                 orr.setErrmsg("联系成品库办公室取消装车完成!");
816                 return orr;
817             }
818         } catch (Exception e) {
819             // TODO: handle exception
820         }
821 //        Fd_Bsheet nr=this.fbper.getbyVehicleId(vehicleId, Serviceenum.在办);
822 //        if(nr==null){
823 //            orr.setCode(1);
824 //            orr.setErrmsg("卡号:"+cardID+" 未找到在办销售发货单!");
825 //            return orr;
826 //        }
827
828 //        Fd_Vehicle fdv=this.vhper.getByVehicleId(vehicleId);
829 //        if(fdv==null){
830 //            orr.setCode(1);
831 //            orr.setErrmsg("车牌号:"+cardID+" 未录入车辆信息!");
832 //            return orr;
833 //        }
834         //现场过完毛重后出现扫码装车的,必须重新过磅
835         int grossNum=this.bsper.getgrosstDoc(vehicleId, fdb.getBsNo());
836         if(grossNum>0) {
837             Map<String, Object> xstm=new HashMap<String, Object>();
838             xstm.put("canCm",false);
839             xstm.put("businessNo",fdb.getBsNo());
840             this.bsper.updateCanCm(xstm);
841             this.bsper.updatecanFb(vehicleId, fdb.getBsNo());
842         }
843         for (JsonElement je : dataArr) {
844             JsonObject jo=je.getAsJsonObject();
845             String tdmx_pch=jo.get("tdmx_pch").getAsString();
846 //            Fd_XSTDMX tdmx=this.tdmxper.getbyPCH(tdmx_pch);
847             Fd_XSTDMX tdmx=this.tdmxper.getbyPCHONE(tdmx_pch,vehicleId);
23f938 848             if(tdmx == null) {
A 849                 String errMsg = "一卡通卸车失败,请查看【" + tdmx_pch +"】出库关闭标志!";
850                 throw  new Exception(errMsg);
851             }
58d006 852 //            if(tdmx.getTdmx_zcbz()!=1){
A 853 ////                throw new Exception("批次号:"+tdmx_pch+" 已经提交装车,不能重复提交装车!");
854 //                continue;
855 //            }
856 //            Fd_XSTD xstd=this.tdper.get(tdmx.getTdmx_tdls());
857 //            if(xstd==null){
858 //                continue;
859 //            }
860             //修改Fd_Bsheetitem表  这张表去掉了
861             this.fbper.delbsitem(tdmx.getTdmx_pch(), yktywdh);
862 //            //修改一卡通明细表bsitem
863 //            if(tdmx.getTdmx_zcbz()==0){
864 //                continue;
865 //            }
866             tdmx.setTdmx_zcbz(0);
867             tdmx.setTdmx_zccph(null);
868             tdmx.setTdmx_zcdriver(null);
869             tdmx.setTdmx_zcphone(null);
870             tdmx.setTdmx_zcwlgsName(null);
871             this.tdmxper.updateZCnoFD(tdmx);
872         }
873
874         orr.setCode(0);
875         orr.setErrmsg("取消装车操作成功!");
876         return orr;
877     }
878
879     @Override
880     public ObjectResult<Map<String, Object>> getcInfo(String cardID) {
881         ObjectResult<Map<String, Object>> orr=new ObjectResult<Map<String,Object>>();
882         Map<String, Object> rem=new HashMap<String, Object>();
883         Map<String, Object> mp=this.yktper.getcardinuse(cardID);
884         if(mp==null){
885             orr.setCode(1);
886             orr.setErrmsg("卡号不正确未找到在用卡!");
887             return orr;
888         }
889         String vehicleId=mp.get("numberplates")==null?"":mp.get("numberplates").toString();
5aa407 890
A 891         String type = (String)mp.get("type");
892         String sdepartNo = null;
893         if(type.equals("外来车辆卡")) {
894             sdepartNo = (String) mp.get("sdepartNo");
895         }
896
58d006 897         List<Fd_Bsheet> fd_bList = this.fbper.getListbyVehicleId(vehicleId, Serviceenum.在办);
A 898         if (fd_bList == null||fd_bList.isEmpty()) {
899             orr.setCode(1);
900             orr.setErrmsg("车辆未找到在办分单!");
901             return orr;
902         }
903         Fd_Bsheet fd_b=null;
904         if(fd_bList.size()>1) {
905             for (Fd_Bsheet fd_Bsheet : fd_bList) {
906                 int wd=this.bsper.getweightDoc(vehicleId, fd_Bsheet.getBsNo());
907                 if(wd>0) {
908                     fd_b=fd_Bsheet;
909                     break;
910                 }
911             }
912             if(fd_b==null) {
913                 orr.setCode(1);
914                 orr.setErrmsg("车辆:"+vehicleId+" 当前业务未找到绑定的过磅单,请先过磅或者重绑磅单!");
915                 return orr;
916             }
917         }else {
918             fd_b=fd_bList.get(0);
919             int wcnum=this.bsper.getweightDoc(vehicleId, fd_b.getBsNo());
920             if(wcnum<=0){
921                 orr.setCode(1);
922                 orr.setErrmsg("车辆:"+vehicleId+" 当前业务未找到绑定的过磅单,请先过磅或者重绑磅单!");
923                 return orr;
924             }
925         }
5aa407 926         // 改成使用在用卡的卡号、车牌号码、厂区来确认是否有销售的业务单 btid=3 businesstype00002
A 927         String businessNo = bsper.getBusinessNoByCardNo(cardID,vehicleId,sdepartNo);
58d006 928         if(StringUtils.isBlank(businessNo)) {
A 929             orr.setCode(1);
930             orr.setErrmsg("未找到该卡的在办业务单!");
931             return orr;
932         }
933 //        List<Vehicle_XSTD> vxl=this.vhxper.getlistbyVehicleId(vehicleId);
934         List<Vehicle_XSTD> vxl= this.vhxper.getlistbyVehicleIdandbsNoGp(vehicleId, businessNo);
935         List<Map<String, Object>> datamp=new ArrayList<Map<String, Object>>();
5aa407 936         Map<String,Fd_XSTD> xstdMap = new HashMap(); // 缓存Fd_XSTD,避免多查
58d006 937         for (Vehicle_XSTD vx : vxl) {
A 938             String tdbh=vx.getXstdNo();
939             Fd_XSTD td=this.tdper.getbyTDBH(tdbh);
940             String wlgsbh=vx.getCompanyNo();
941             Fd_Company fd_c=this.cmper.getByCompanyNo(wlgsbh);
942             Map<String, Object> tdm=new HashMap<String, Object>();
943             if(fd_c!=null){
944                 tdm.put("td_wlgs", fd_c.getName());//物流公司
945             }else{
946                 tdm.put("td_wlgs", "");//物流公司
947             }
948             if(td==null){
949                 continue;
950             }
951             // List<Fd_XSTDMX> tdmxl=this.tdmxper.getbytdls(td.getTd_tdls());
952             List<Fd_XSTDMX> tdmxl= tdmxper.getListByTdlsAndCph(td.getTd_tdls(),vehicleId);
953             if(tdmxl==null||tdmxl.size()<=0){
954                 continue;
955             }
956             Map<String, Object> mm=new HashMap<String, Object>();
957             tdm.put("td_tdbh", td.getTd_tdbh());
958             tdm.put("td_tdls", td.getTd_tdls());
959             tdm.put("td_jylx", td.getTd_jylx());
5aa407 960             Fd_XSTD fd_xstd = xstdMap.get(td.getTd_tdbh());
A 961             if(xstdMap.get(td.getTd_tdbh())==null) { // 保证同一个提单只查一遍
962                 fd_xstd = tdper.getbyttdbh(td.getTd_tdbh());
963             }
964             //增加客户名称 备注
965             if(StringUtils.isBlank(fd_xstd.getTd_fpbh())){
966                 Nckh nckh = zsjper.getNckhbyCode(fd_xstd.getTd_khbh());// 客户不存在的特殊情况是不应该存在的,以防万一,加判空。
967                 tdm.put("td_khmc",nckh!=null?nckh.getName():"");
968             }else {
969                 String name = ConvertTool.covertToCustoms(fd_xstd.getTd_ywdybh());
970                 tdm.put("td_khmc", name);
971             }
972             tdm.put("td_bz",fd_xstd.getTd_bz());
58d006 973             mm.put("td", tdm);
A 974             mm.put("tdmx", tdmxl);
975             datamp.add(mm);
976         }
5aa407 977
A 978
58d006 979         rem.put("cph", vehicleId);
A 980         rem.put("sjmc", fd_b.getDriver());
981         rem.put("dh", fd_b.getPhone());
982 //        rem.put("sjmc", fdv.getDriver());
983 //        rem.put("dh", fdv.getPhone());
984         rem.put("ywdh", fd_b.getBsNo());
985         rem.put("respcode", 111);
986         rem.put("data", datamp);
987
988         //修改装车记录
989         Map<String, Object> mr=this.bsper.selectTaskTime(fd_b.getBsNo());
990         if(mr!=null) {
991             if(mr.get("firstzxhtime")!=null) {
992                 mr.put("lastzxhtime", new Date());
993             }else {
994                 mr.put("firstzxhtime", new Date());
995             }
996             this.bsper.updateTaskTime(mr);
997         }else {
998             orr.setCode(1);
999             orr.setErrmsg("未找到装车记录");
1000             return orr;
1001         }
1002
1003         orr.setCode(0);
1004         orr.setItem(rem);
1005         return orr;
1006     }
1007
1008     @Override
1009     public ObjectResult<Map<String, Object>> getxstdInfo(String xstdNo) {
1010         ObjectResult<Map<String, Object>> orr=new ObjectResult<Map<String,Object>>();
1011         Fd_XSTD xstd=this.tdper.getbyTDBH(xstdNo);
1012         if(xstd==null){
1013             orr.setCode(1);
1014             orr.setErrmsg("提单未找到!");
1015             return orr;
1016         }
1017         Map<String, Object> rm=new HashMap<String, Object>();
1018         List<Fd_XSTDMX> tdmxlist=this.tdmxper.getListbytdls(xstd.getTd_tdls());
1019         rm.put("code", 0);
1020         rm.put("item", xstd);
1021         rm.put("itemList", tdmxlist);
1022         orr.setCode(0);
1023         orr.setItem(rm);
1024         return orr;
1025     }
1026
1027     @Override
1028     @Transactional(rollbackFor=Exception.class)
1029     public ObjectResult<Boolean> savewdControl(JsonArray dataArr)throws Exception {
1030         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
1031         if(dataArr==null){
1032             orr.setCode(0);
1033             orr.setErrmsg("添加过磅控制成功!");
1034             return orr;
1035         }
1036         for (JsonElement je : dataArr) {
1037             JsonObject jo=je.getAsJsonObject();
1038             String bsNo=jo.get("yktywdh").getAsString();
1039             BsheetEcgb be=this.beper.getbyNo(bsNo);
1040             if(be==null){
1041                 be=new BsheetEcgb();
1042                 be.setBsNo(bsNo);
1043                 be.setCtime(new Date());
1044                 be.setCname("生产系统添加");
1045                 be.setSate(1);
1046                 this.beper.insert(be);
1047             }
1048         }
1049         orr.setCode(0);
1050         orr.setErrmsg("添加过磅控制成功!");
1051         return orr;
1052     }
1053
1054
1055
1056
1057 }