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