提交 | 用户 | 时间
|
58d006
|
1 |
package com.mandi.fendan.service.impl; |
A |
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Date; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
import java.util.UUID; |
|
9 |
|
|
10 |
import javax.annotation.Resource; |
|
11 |
|
9ce4bb
|
12 |
import com.mandi.basicconfig.mapper.NczsjMapper; |
A |
13 |
import com.mandi.basicconfig.persist.Nckh; |
58d006
|
14 |
import com.mandi.fendan.mapper.*; |
A |
15 |
import com.mandi.fendan.util.ConvertTool; |
9ce4bb
|
16 |
import com.mandi.servlet.file.impl.FileLoadImpl; |
A |
17 |
import com.mandi.springmvc.logs.OpLogs; |
|
18 |
import com.mandi.system.persist.ModuleEnum; |
58d006
|
19 |
import org.apache.commons.lang3.StringUtils; |
9ce4bb
|
20 |
import org.apache.log4j.Logger; |
58d006
|
21 |
import org.apache.poi.ss.usermodel.charts.ScatterChartSeries; |
A |
22 |
import org.springframework.stereotype.Service; |
|
23 |
import org.springframework.transaction.annotation.Transactional; |
|
24 |
|
|
25 |
import com.google.gson.JsonArray; |
|
26 |
import com.google.gson.JsonElement; |
|
27 |
import com.google.gson.JsonObject; |
|
28 |
import com.google.gson.JsonParser; |
|
29 |
import com.mandi.basicconfig.penum.PrefixEnum; |
|
30 |
import com.mandi.common.BigDecimalfiter; |
|
31 |
import com.mandi.common.JSONobj; |
|
32 |
import com.mandi.common.Jacksonmethod; |
|
33 |
import com.mandi.common.Wxhtmethod; |
|
34 |
import com.mandi.common.ParamFileter.Fileoperation; |
|
35 |
import com.mandi.dao.common.ObjectResult; |
|
36 |
import com.mandi.fendan.persist.Fd_Bsheet; |
|
37 |
import com.mandi.fendan.persist.Fd_Company; |
|
38 |
import com.mandi.fendan.persist.Fd_Company_Vehicle; |
|
39 |
import com.mandi.fendan.persist.Fd_Vehicle; |
|
40 |
import com.mandi.fendan.persist.Fd_XSTD; |
|
41 |
import com.mandi.fendan.persist.Fd_XSTDMX; |
|
42 |
import com.mandi.fendan.persist.Fd_wlgs_fhdq; |
|
43 |
import com.mandi.fendan.persist.VehicleStatus; |
|
44 |
import com.mandi.fendan.persist.VehicleType; |
|
45 |
import com.mandi.fendan.persist.Vehicle_XSTD; |
|
46 |
import com.mandi.fendan.service.Ifd_bsheetService; |
|
47 |
import com.mandi.fendan.util.Contants; |
|
48 |
import com.mandi.fendan.util.FdtoNc; |
|
49 |
import com.mandi.fendan.util.persist.Serviceenum; |
|
50 |
import com.mandi.fendan.util.persist.WaitXSTD; |
|
51 |
import com.mandi.fendan.util.persist.YktBsheet; |
|
52 |
import com.mandi.system.persist.Login; |
|
53 |
import com.mandi.system.persist.UserType; |
|
54 |
|
|
55 |
import static com.mandi.fendan.util.Contants.*; |
|
56 |
|
|
57 |
@Service |
|
58 |
public class Fd_BsheetService implements Ifd_bsheetService { |
9ce4bb
|
59 |
private Logger log= Logger.getLogger(Fd_BsheetService.class); |
58d006
|
60 |
|
A |
61 |
@Resource |
|
62 |
private Fd_BsheetMapper bsper; |
|
63 |
@Resource |
|
64 |
private Fd_VehicleMapper fdvper; |
|
65 |
@Resource |
|
66 |
private Fd_BsheetitemMapper bsiper; |
|
67 |
@Resource |
|
68 |
private VehicleXSTDMapper vhxper; |
|
69 |
@Resource |
|
70 |
private Fd_CompanyMapper fdcper; |
|
71 |
@Resource |
|
72 |
private Fd_ComVehicleMapper cvper; |
|
73 |
@Resource |
|
74 |
private Fd_XSTDMXMapper mxper; |
|
75 |
@Resource |
|
76 |
private Fd_XSTDMapper tdper; |
|
77 |
@Resource |
|
78 |
private Fd_fhdqMapper dqper; |
|
79 |
@Resource |
|
80 |
private FdtoNc fdtonc; |
|
81 |
@Resource |
|
82 |
private Fd_YKTMapper yktmper; |
|
83 |
@Resource |
|
84 |
private FdMxWlgsMapper fdMxWlgsMapper; |
9ce4bb
|
85 |
|
A |
86 |
@Resource |
|
87 |
private NczsjMapper zsjper; |
58d006
|
88 |
|
A |
89 |
@Override |
|
90 |
@Transactional(rollbackFor=Exception.class) |
|
91 |
public ObjectResult<Map<String, Object>> saveFd_Bsheet(String vehicleInfo,String xstdNo, String bsitemlistStr, Login lg) throws Exception { |
|
92 |
ObjectResult<Map<String, Object>> orr=new ObjectResult<Map<String,Object>>(); |
|
93 |
if(StringUtils.isEmpty(bsitemlistStr)){ |
|
94 |
orr.setCode(1); |
|
95 |
orr.setErrmsg("业务参数为空,不能保存!"); |
|
96 |
return orr; |
|
97 |
} |
|
98 |
if(lg==null){ |
|
99 |
orr.setCode(1); |
|
100 |
orr.setErrmsg("请登录账号!"); |
|
101 |
return orr; |
|
102 |
} |
|
103 |
if(StringUtils.isBlank(xstdNo)){ |
|
104 |
orr.setCode(1); |
|
105 |
orr.setErrmsg("提单编号为空!"); |
|
106 |
return orr; |
|
107 |
} |
|
108 |
if(UserType.admin.toString().equals(lg.getWorkerno())){ |
|
109 |
orr.setCode(1); |
|
110 |
orr.setErrmsg("管理员账号没有分单权限!"); |
|
111 |
return orr; |
|
112 |
} |
|
113 |
Fd_Company fdc=fdcper.getByCompanyNo(lg.getDepartno()); |
|
114 |
if(fdc==null){ |
|
115 |
orr.setCode(1); |
|
116 |
orr.setErrmsg("账号没有配置物流公司,请联系管理员进行配置!"); |
|
117 |
return orr; |
|
118 |
} |
|
119 |
|
|
120 |
Fd_XSTD xstd=this.tdper.getbyttdbh(xstdNo); |
|
121 |
if(xstd==null){ |
|
122 |
orr.setCode(1); |
|
123 |
orr.setErrmsg("提单编号:"+xstdNo+" 不正确,未查询到该提单!"); |
|
124 |
return orr; |
|
125 |
} |
|
126 |
if(xstd.isTd_zcwcbz()){ |
|
127 |
orr.setCode(1); |
|
128 |
orr.setErrmsg("该提单已经完成装车,不能分单!"); |
|
129 |
return orr; |
|
130 |
} |
|
131 |
if(xstd.getTd_wfdsl()<=0){ |
|
132 |
orr.setCode(1); |
|
133 |
orr.setErrmsg("该提单已经分单完成,不能分单!"); |
|
134 |
return orr; |
9ce4bb
|
135 |
} |
58d006
|
136 |
//送货 |
A |
137 |
if(xstd.getTd_ztbz()==2){ |
|
138 |
if(fdc!=null){ |
|
139 |
if(!fdc.isHasSPR()){ |
|
140 |
orr.setCode(1); |
|
141 |
orr.setErrmsg("该账号没有自提权限!"); |
|
142 |
return orr; |
|
143 |
} |
|
144 |
} |
|
145 |
}else{ |
|
146 |
Fd_wlgs_fhdq wldq = this.dqper.getbyNos(lg.getDepartno(),xstd.getTd_shddbh(), ConvertTool.ncGetDefault(xstd.getTd_ywdybh())); |
|
147 |
int total = fdMxWlgsMapper.selectCountByTdTdls(xstd.getTd_tdls()); |
|
148 |
if(wldq==null && total == 0){ |
|
149 |
orr.setCode(1); |
|
150 |
orr.setErrmsg("该账号没有配置该地区的分单权限!"); |
|
151 |
return orr; |
|
152 |
} |
|
153 |
} |
|
154 |
String Rcompany=""; |
|
155 |
Map<String, Object> mm=this.dqper.getKH(xstd.getTd_khbh()); |
|
156 |
if(StringUtils.isBlank(xstd.getTd_fpbh())){ |
|
157 |
if(mm!=null) |
|
158 |
Rcompany=mm.get("name")==null?"":mm.get("name").toString(); |
5694bb
|
159 |
// 判断是否存在客户 |
A |
160 |
if(mm == null || mm.size() == 0) { // 客户必须存在,否则无法分单 |
|
161 |
orr.setCode(1); |
|
162 |
orr.setErrmsg("该提单客户不存在,请检查数据!"); |
|
163 |
return orr; |
|
164 |
} |
58d006
|
165 |
}else{ |
A |
166 |
Rcompany = ConvertTool.covertToCustoms(xstd.getTd_ywdybh()); |
|
167 |
} |
|
168 |
|
|
169 |
List<Fd_XSTD> tdl= new ArrayList<Fd_XSTD>(); |
|
170 |
Map<String, List<Fd_XSTDMX>> mxMp=new HashMap<String, List<Fd_XSTDMX>>(); |
|
171 |
List<Fd_XSTDMX> mxl=new ArrayList<Fd_XSTDMX>(); |
|
172 |
//是否保存一卡通业务单表头信息 |
|
173 |
boolean saveBT=false; |
|
174 |
String bsDE = ConvertTool.ncCovertToYkt(xstd.getTd_cqNo()); |
|
175 |
String bbsNo=""; |
|
176 |
String ziti="";//是否自提 |
|
177 |
// 系统部门未找到 |
|
178 |
if (StringUtils.isBlank(bsDE)) { |
|
179 |
orr.setCode(1); |
|
180 |
orr.setErrmsg("提单未找到系统部门字段,请重新操作!"); |
|
181 |
return orr; |
|
182 |
} |
|
183 |
try { |
|
184 |
JsonParser jp=new JsonParser(); |
|
185 |
JsonObject vjo=jp.parse(vehicleInfo).getAsJsonObject(); |
|
186 |
Fd_Vehicle fdv=new Fd_Vehicle(); |
|
187 |
fdv=JSONobj.getobj(vjo, fdv); |
|
188 |
String driver=JSONobj.getstring(vjo, "driver"); |
|
189 |
String phone=JSONobj.getstring(vjo, "phone"); |
|
190 |
String vehicleId=JSONobj.getstring(vjo, "vehicleId").toUpperCase(); |
|
191 |
// String IDNum=JSONobj.getstring(vjo, "IDNum"); |
|
192 |
fdv.setVehicleId(vehicleId); |
|
193 |
if(StringUtils.isEmpty(fdv.getVehicleId())||StringUtils.isEmpty(fdv.getDriver())||StringUtils.isEmpty(fdv.getIDNum())||StringUtils.isEmpty(fdv.getPhone())){ |
|
194 |
orr.setCode(1); |
|
195 |
orr.setErrmsg("车辆必填项不能为空!"); |
|
196 |
return orr; |
|
197 |
} |
|
198 |
Fd_Vehicle fdv1=this.fdvper.getByVehicleId(fdv.getVehicleId()); |
|
199 |
if(fdv1==null){ |
|
200 |
fdv.setCompanyNo(lg.getDepartno()); |
|
201 |
fdv.setId(UUID.randomUUID()+""); |
|
202 |
fdv.setNote(""); |
|
203 |
fdv.setState(true); |
|
204 |
fdv.setStatus(VehicleStatus.已配车); |
|
205 |
fdv.setType(VehicleType.临时车); |
|
206 |
fdvper.insert(fdv); |
|
207 |
}else{ |
|
208 |
if(fdv1.getType()==VehicleType.临时车){ |
|
209 |
fdv.setDriver(fdv.getDriver()); |
|
210 |
fdv.setPhone(fdv.getPhone()); |
|
211 |
fdv.setIDNum(fdv.getIDNum()); |
|
212 |
fdvper.update(fdv1); |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
// xstd.getTd_ywdybh().equals(Contants.zzywdyNo)?Contants.zzSdepartNo:Contants.kjSdepartNo |
|
217 |
Fd_Bsheet fb=this.bsper.getbyVehicleId(fdv.getVehicleId(), Serviceenum.在办,bsDE); |
|
218 |
if(fb==null){ |
|
219 |
JsonObject pfob=Wxhtmethod.postJsonStr(Contants.YKTgetPrefix_url,PrefixEnum.productsale.toString()); |
|
220 |
ObjectResult<String> pfor=new ObjectResult<String>(); |
|
221 |
String bsNo=JSONobj.getstring(pfob, "item"); |
|
222 |
int code=JSONobj.getint(pfob, "code"); |
|
223 |
String errmsg=JSONobj.getstring(pfob, "errmsg"); |
|
224 |
pfor.setCode(code); |
|
225 |
pfor.setErrmsg(errmsg); |
|
226 |
pfor.setItem(bsNo); |
|
227 |
if(pfor==null||pfor.getCode()!=0){ |
|
228 |
throw new Exception(pfor.getErrmsg()); |
|
229 |
} |
|
230 |
fb=new Fd_Bsheet(); |
|
231 |
fb.setBsNo(pfor.getItem()); |
|
232 |
fb.setCompanyName(lg.getDepartname()); |
|
233 |
fb.setCompanyNo(lg.getDepartno()); |
|
234 |
fb.setCreateid(lg.getUserid()); |
|
235 |
fb.setCreateName(lg.getWorkername()); |
|
236 |
fb.setCtime(new Date()); |
|
237 |
fb.setDriver(driver); |
|
238 |
fb.setFdsheetNo(pfor.getItem()); |
|
239 |
fb.setId(UUID.randomUUID()+""); |
|
240 |
fb.setPhone(phone); |
|
241 |
fb.setSendmsg(false); |
|
242 |
fb.setStatus(Serviceenum.在办); |
|
243 |
fb.setVehicleId(fdv.getVehicleId()); |
|
244 |
fb.setSdepartNo(bsDE); |
|
245 |
fb.setUpdateTime(new Date()); |
|
246 |
this.bsper.insert(fb); |
|
247 |
saveBT=true; |
|
248 |
}else{ |
|
249 |
fb.setDriver(driver); |
|
250 |
fb.setPhone(phone); |
|
251 |
fb.setUpdateTime(new Date()); |
|
252 |
this.bsper.update(fb); |
|
253 |
} |
|
254 |
Fd_Company_Vehicle fdcv=cvper.getbyIDs(fdv.getVehicleId(), lg.getDepartno(),bsDE); |
|
255 |
if(fdcv==null){ |
|
256 |
fdcv=new Fd_Company_Vehicle(); |
|
257 |
fdcv.setCompanyNo(lg.getDepartno()); |
|
258 |
fdcv.setVehicleId(fdv.getVehicleId()); |
|
259 |
fdcv.setSdepartNo(bsDE); |
|
260 |
cvper.insertIDs(fdcv); |
|
261 |
} |
|
262 |
// if(StringUtils.isBlank(fb.getSdepartNo())){ |
|
263 |
// if(xstd.getTd_ywdybh().equals(Contants.zzywdyNo)){ |
|
264 |
// this.bsper.updatesdepartNo(fb.getId(), Contants.zzSdepartNo); |
|
265 |
// fb.setSdepartNo(Contants.zzSdepartNo); |
|
266 |
// Fd_Company_Vehicle fdcv=cvper.getbyIDs(fdv.getVehicleId(), lg.getDepartno(),Contants.zzSdepartNo); |
|
267 |
// if(fdcv==null){ |
|
268 |
// fdcv=new Fd_Company_Vehicle(); |
|
269 |
// fdcv.setCompanyNo(lg.getDepartno()); |
|
270 |
// fdcv.setVehicleId(fdv.getVehicleId()); |
|
271 |
// fdcv.setSdepartNo(Contants.zzSdepartNo); |
|
272 |
// cvper.insertIDs(fdcv); |
|
273 |
// } |
|
274 |
// }else{ |
|
275 |
// this.bsper.updatesdepartNo(fb.getId(), Contants.kjSdepartNo); |
|
276 |
// fb.setSdepartNo(Contants.kjSdepartNo); |
|
277 |
// Fd_Company_Vehicle fdcv=cvper.getbyIDs(fdv.getVehicleId(), lg.getDepartno(),Contants.kjSdepartNo); |
|
278 |
// if(fdcv==null){ |
|
279 |
// fdcv=new Fd_Company_Vehicle(); |
|
280 |
// fdcv.setCompanyNo(lg.getDepartno()); |
|
281 |
// fdcv.setVehicleId(fdv.getVehicleId()); |
|
282 |
// fdcv.setSdepartNo(Contants.kjSdepartNo); |
|
283 |
// cvper.insertIDs(fdcv); |
|
284 |
// } |
|
285 |
// } |
|
286 |
// } |
|
287 |
if(StringUtils.isBlank(ziti)){ |
|
288 |
ziti=xstd.getTd_ztbz()==2?"自提":"非自提"; |
|
289 |
} |
|
290 |
// if(StringUtils.isBlank(fb.getSdepartNo())){ |
|
291 |
// throw new Exception("生成的分单业务单:"+fb.getFdsheetNo()+"厂区未找到!"); |
|
292 |
// } |
|
293 |
//郑州 |
|
294 |
// if(fb.getSdepartNo().equals(Contants.zzSdepartNo)){ |
|
295 |
// if(!xstd.getTd_ywdybh().equals(Contants.zzywdyNo)){ |
|
296 |
//// throw new Exception("车辆生成的是郑州厂区一卡通业务单,科技提单:"+xstd.getTd_tdbh()+"不能配车!"); |
|
297 |
// if(saveBT){ |
|
298 |
// throw new Exception("科技厂区提单和郑州厂区提单不能同时使用同一辆车!"); |
|
299 |
// }else{ |
|
300 |
// throw new Exception(fb.getVehicleId()+" 有郑州厂区一卡通销售业务单,科技提单:"+xstd.getTd_tdbh()+"不能使用该车!"); |
|
301 |
// } |
|
302 |
// } |
|
303 |
// }else{ |
|
304 |
// if(xstd.getTd_ywdybh().equals(Contants.zzywdyNo)){ |
|
305 |
//// throw new Exception("车辆生成的是科技厂区一卡通业务单,郑州提单:"+xstd.getTd_tdbh()+"不能配车!"); |
|
306 |
// if(saveBT){ |
|
307 |
// throw new Exception("科技厂区提单和郑州厂区提单不能同时使用同一辆车!"); |
|
308 |
// }else{ |
|
309 |
// throw new Exception(fb.getVehicleId()+" 有科技厂区一卡通销售业务单,郑州提单:"+xstd.getTd_tdbh()+"不能使用该车!"); |
|
310 |
// } |
|
311 |
// } |
|
312 |
// } |
|
313 |
|
|
314 |
JsonArray ja=jp.parse(bsitemlistStr).getAsJsonArray(); |
|
315 |
//分单数量和毛重 |
|
316 |
int fdsl=0; |
|
317 |
double fdmz=0; |
|
318 |
for (JsonElement je: ja) { |
|
319 |
JsonObject itemJo=je.getAsJsonObject(); |
|
320 |
//主键 |
|
321 |
String tdmx_tdfl=JSONobj.getstring(itemJo, "tdfl"); |
|
322 |
Fd_XSTDMX tdmx=this.mxper.get(tdmx_tdfl); |
|
323 |
//未找到的过滤掉 已分单的过滤掉 已装车的不处理 |
|
324 |
if(tdmx==null||tdmx.getTdmx_fdbz()!=0||tdmx.getTdmx_zcbz()!=0){ |
|
325 |
continue; |
|
326 |
} |
|
327 |
//关闭标志不为0不做处理 |
|
328 |
if(tdmx.getTdmx_gbbz()!=0){ |
|
329 |
continue; |
|
330 |
} |
|
331 |
fdsl++; |
|
332 |
fdmz=BigDecimalfiter.addscal(fdmz, tdmx.getTdmx_mz(), Contants.scale); |
|
333 |
|
|
334 |
tdmx.setTdmx_fdbz(1); |
|
335 |
tdmx.setTdmx_fdcph(fdv.getVehicleId()); |
|
336 |
tdmx.setTdmx_fdywbh(fb.getBsNo()); |
|
337 |
tdmx.setTdmx_fdwlgsbh(lg.getDepartno()); |
|
338 |
this.mxper.updateFD(tdmx); |
|
339 |
mxl.add(tdmx); |
|
340 |
|
|
341 |
} |
|
342 |
Vehicle_XSTD vhxstd=this.vhxper.getbyIDs(fdv.getVehicleId(), xstdNo,lg.getDepartno()); |
|
343 |
if(vhxstd==null){ |
|
344 |
vhxstd=new Vehicle_XSTD(); |
|
345 |
vhxstd.setBsNo(fb.getBsNo()); |
|
346 |
vhxstd.setCompanyNo(lg.getDepartno()); |
|
347 |
vhxstd.setFd_num(fdsl); |
|
348 |
vhxstd.setFd_weight(fdmz); |
|
349 |
vhxstd.setVehicleId(fdv.getVehicleId()); |
|
350 |
vhxstd.setXstdNo(xstdNo); |
|
351 |
this.vhxper.insert(vhxstd); |
|
352 |
}else{ |
|
353 |
vhxstd.setBsNo(fb.getBsNo()); |
|
354 |
vhxstd.setCompanyNo(lg.getDepartno()); |
|
355 |
vhxstd.setFd_num(vhxstd.getFd_num()+fdsl); |
|
356 |
vhxstd.setFd_weight(BigDecimalfiter.add(vhxstd.getFd_weight(),fdmz)); |
|
357 |
vhxstd.setVehicleId(fdv.getVehicleId()); |
|
358 |
vhxstd.setXstdNo(xstdNo); |
|
359 |
this.vhxper.updatewithIDs(vhxstd); |
|
360 |
} |
|
361 |
xstd.setTd_wfdsl(xstd.getTd_wfdsl()-fdsl); |
|
362 |
xstd.setTd_wfdzl(BigDecimalfiter.subscal(xstd.getTd_wfdzl(), fdmz, Contants.scale)); |
|
363 |
this.tdper.updateFD(xstd); |
|
364 |
if(saveBT){ |
|
365 |
YktBsheet bs=new YktBsheet(); |
|
366 |
// if(iskj==1){ |
|
367 |
// bs.setSdepartNo(Contants.kjSdepartNo); |
|
368 |
// bs.setDcompany("明泰科技"); |
|
369 |
// }else{ |
|
370 |
// bs.setSdepartNo(Contants.zzSdepartNo); |
|
371 |
// bs.setDcompany("郑州眀泰"); |
|
372 |
// } |
|
373 |
bs.setSdepartNo(fb.getSdepartNo()); |
|
374 |
/*bs.setDcompany(fb.getSdepartNo().equals(Contants.kjSdepartNo)?"明泰科技": |
|
375 |
fb.getSdepartNo().equals(Contants.msSdepartNo)?"河南明晟新材料": |
|
376 |
"郑州眀泰" |
|
377 |
);*/ |
|
378 |
bs.setDcompany(ConvertTool.covertToFactoryName(fb.getSdepartNo())); |
|
379 |
bs.setDriver(fdv.getDriver()); |
|
380 |
bs.setNumberplates(StringUtils.upperCase(fdv.getVehicleId())); |
|
381 |
bs.setPhone(fdv.getPhone()); |
|
382 |
bs.setRcompany(Rcompany); |
|
383 |
bs.setBussinessNo(fb.getBsNo()); |
|
384 |
bs.setNote(ziti+";"+lg.getDepartname()+":"+lg.getWorkername()+"; 分单系统自动生成"); |
|
385 |
String bsStr=Jacksonmethod.tojson(bs, false); |
|
386 |
bsDE=bs.getSdepartNo(); |
|
387 |
bbsNo=bs.getBussinessNo(); |
|
388 |
JsonObject joADDYWD=Wxhtmethod.postJsonStr(Contants.YKTaddYwd_url,bsStr); |
|
389 |
ObjectResult<String> ors=new ObjectResult<String>(); |
|
390 |
String bsNo=JSONobj.getstring(joADDYWD, "item"); |
|
391 |
int code=JSONobj.getint(joADDYWD, "code"); |
|
392 |
String errmsg=JSONobj.getstring(joADDYWD, "errmsg"); |
|
393 |
ors.setItem(bsNo); |
|
394 |
ors.setCode(code); |
|
395 |
ors.setErrmsg(errmsg); |
|
396 |
if(ors.getCode()!=0){ |
|
397 |
throw new Exception(ors.getErrmsg()); |
|
398 |
} |
|
399 |
this.bsper.updateShdw(fb.getId(), StringUtils.isBlank(Rcompany)?"未知发货单位":Rcompany); |
|
400 |
}else { |
|
401 |
List<WaitXSTD> l=this.bsper.getAllKH(fb.getBsNo(), fb.getId()); |
|
402 |
if(l!=null) { |
|
403 |
boolean iscz=false;//收货单位在明细中是否存在 |
|
404 |
WaitXSTD wt=null; |
|
405 |
for (WaitXSTD waitXSTD : l) { |
|
406 |
if(fb.getShdw().equals(waitXSTD.getTd_khmc())) { |
|
407 |
iscz=true; |
|
408 |
break; |
|
409 |
}else { |
|
410 |
if(wt==null&&StringUtils.isNotBlank(waitXSTD.getTd_khmc())) { |
|
411 |
wt=waitXSTD; |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
if(!iscz&&wt!=null) { |
|
416 |
fb.setShdw(wt.getTd_khmc()); |
|
417 |
this.yktmper.updateshcompany(fb.getBsNo(), wt.getTd_khmc(),wt.getTd_shdd()); |
|
418 |
} |
|
419 |
} |
|
420 |
|
|
421 |
} |
|
422 |
tdl.add(xstd); |
|
423 |
mxMp.put(xstdNo, mxl); |
|
424 |
//分单推送NC系统 |
|
425 |
if(tdl!=null&&tdl.size()>0){ |
|
426 |
String fdhx=this.fdtonc.getNcdata(tdl, mxMp); |
|
427 |
Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "明细配车 请求参数 ::"+fdhx); |
|
428 |
//todo 先注释掉NC部分,接口不通 |
|
429 |
JsonObject joADDYWD=Wxhtmethod.postJsonStr(Contants.NCfdhx_url,fdhx); |
|
430 |
Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "明细配车 url返回值 ::"+joADDYWD); |
|
431 |
if(joADDYWD==null||JSONobj.getint(joADDYWD, "code")!=0){ |
|
432 |
throw new Exception(StringUtils.isEmpty(joADDYWD.get("msg").getAsString())?"分单回写NC系统出错!":joADDYWD.get("msg").getAsString()); |
|
433 |
}else{ |
|
434 |
String restult=joADDYWD.get("result").getAsString(); |
|
435 |
JsonObject jr=jp.parse(restult).getAsJsonObject(); |
|
436 |
if(jr==null||JSONobj.getint(jr, "respcode")!=111){ |
|
437 |
throw new Exception(jr.get("respmsg").getAsString()); |
|
438 |
} |
|
439 |
} |
|
440 |
} |
|
441 |
}catch(Exception e){ |
9ce4bb
|
442 |
e.printStackTrace(); |
58d006
|
443 |
if(saveBT){ |
A |
444 |
JsonObject jo=new JsonObject(); |
|
445 |
jo.addProperty("bussinessNo", bbsNo); |
|
446 |
jo.addProperty("sdepartNo",bsDE); |
|
447 |
Wxhtmethod.postJsonStr(Contants.YKTdelYwd_url,jo.toString()); |
|
448 |
} |
|
449 |
throw new Exception(StringUtils.isEmpty(e.getMessage())?"提单明细分单出错!":e.getMessage()); |
|
450 |
} |
|
451 |
|
|
452 |
orr.setCode(0); |
|
453 |
orr.setItem(null); |
|
454 |
return orr; |
|
455 |
} |
|
456 |
|
|
457 |
@Override |
|
458 |
@Transactional(rollbackFor=Exception.class) |
|
459 |
public ObjectResult<String> sendMsg(Login lg, String bussinessNo)throws Exception { |
|
460 |
ObjectResult<String> orr=new ObjectResult<String>(); |
|
461 |
if(lg==null){ |
|
462 |
orr.setCode(1); |
|
463 |
orr.setErrmsg("请登录账号!"); |
|
464 |
return orr; |
|
465 |
} |
|
466 |
if(UserType.admin.toString().equals(lg.getWorkerno())){ |
|
467 |
orr.setCode(1); |
|
468 |
orr.setErrmsg("管理员账号没有分单权限!"); |
|
469 |
return orr; |
|
470 |
} |
|
471 |
if(StringUtils.isEmpty(bussinessNo)){ |
|
472 |
orr.setCode(1); |
|
473 |
orr.setErrmsg("业务单参数为空!"); |
|
474 |
return orr; |
|
475 |
} |
|
476 |
Fd_Bsheet fdb=bsper.getbybsNo(bussinessNo); |
|
477 |
if(fdb==null){ |
|
478 |
orr.setCode(1); |
|
479 |
orr.setErrmsg("业务单未找到!"); |
|
480 |
return orr; |
|
481 |
} |
|
482 |
if(fdb.getStatus()!=Serviceenum.在办){ |
|
483 |
orr.setCode(1); |
|
484 |
orr.setErrmsg("业务单不是在办状态!"); |
|
485 |
return orr; |
|
486 |
} |
|
487 |
JsonObject jos=new JsonObject(); |
|
488 |
jos.addProperty("bussinessNo", bussinessNo); |
|
489 |
JsonObject jo=Wxhtmethod.postJsonStr(Contants.YKTsendMsg_url,jos.toString()); |
|
490 |
if(jo==null||jo.get("code").getAsInt()!=0){ |
|
491 |
throw new Exception(jo.get("errmsg").getAsString()); |
|
492 |
} |
|
493 |
fdb.setSendmsg(true); |
|
494 |
fdb.setInvitecode(jo.get("item").getAsString()); |
|
495 |
bsper.updateInvitaCode(fdb); |
|
496 |
|
|
497 |
orr.setCode(0); |
|
498 |
return orr; |
|
499 |
} |
|
500 |
|
|
501 |
} |