Administrator
2022-12-15 9ce4bb2b6bd1378ba7b0bd6681d22cb37a5e1452
提交 | 用户 | 时间
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         }
A 136         // 判断是否存在客户
137         if(StringUtils.isBlank(xstd.getTd_fpbh())){
138             Nckh nckh = zsjper.getNckhbyCode(xstd.getTd_khbh());// 客户不存在的特殊情况是不应该存在的,以防万一,加判空。
139             if(nckh == null) {
140                 orr.setCode(1);
141                 orr.setErrmsg("该提单客户不存在,请检查数据!");
142                 return orr;
143             }
58d006 144         }
A 145         //送货
146         if(xstd.getTd_ztbz()==2){
147             if(fdc!=null){
148                 if(!fdc.isHasSPR()){
149                     orr.setCode(1);
150                     orr.setErrmsg("该账号没有自提权限!");
151                     return orr;
152                 }
153             }
154         }else{
155
156 //            Fd_wlgs_fhdq wldq=this.dqper.getbyNos(lg.getDepartno(),xstd.getTd_shddbh(),
157             // todo 下面的意义何在????默认查科技???
158 //                    xstd.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ)?Contants.nc_ywdy_ZZ
159 //                        :xstd.getTd_ywdybh().equals(Contants.nc_ywdy_MS)?Contants.nc_ywdy_MS
160 //                        :Contants.nc_ywdy_KJ);
161             Fd_wlgs_fhdq wldq = this.dqper.getbyNos(lg.getDepartno(),xstd.getTd_shddbh(), ConvertTool.ncGetDefault(xstd.getTd_ywdybh()));
162             int total = fdMxWlgsMapper.selectCountByTdTdls(xstd.getTd_tdls());
163             if(wldq==null && total == 0){
164                 orr.setCode(1);
165                 orr.setErrmsg("该账号没有配置该地区的分单权限!");
166                 return orr;
167             }
168         }
169         String Rcompany="";
170         Map<String, Object> mm=this.dqper.getKH(xstd.getTd_khbh());
171         if(StringUtils.isBlank(xstd.getTd_fpbh())){
172             if(mm!=null)
173                 Rcompany=mm.get("name")==null?"":mm.get("name").toString();
174         }else{
175             /*Rcompany=(xstd.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ)?"郑州报关":
176                         xstd.getTd_ywdybh().equals(Contants.nc_ywdy_MT)?"河南报关":
177                             xstd.getTd_ywdybh().equals(Contants.nc_ywdy_MS)?"明晟报关":
178                         "科技报关");*/
179             Rcompany = ConvertTool.covertToCustoms(xstd.getTd_ywdybh());
180         }
181
182         List<Fd_XSTD> tdl= new ArrayList<Fd_XSTD>();
183         Map<String, List<Fd_XSTDMX>> mxMp=new HashMap<String, List<Fd_XSTDMX>>();
184         List<Fd_XSTDMX> mxl=new ArrayList<Fd_XSTDMX>();
185         //是否保存一卡通业务单表头信息
186         boolean saveBT=false;
187         /*String bsDE=xstd.getTd_cqNo().equals(Contants.nc_ywdy_ZZ) ?
188                 Contants.zzSdepartNo :xstd.getTd_cqNo().equals(Contants.nc_ywdy_MS)?Contants.msSdepartNo:Contants.kjSdepartNo;*/
189         String bsDE = ConvertTool.ncCovertToYkt(xstd.getTd_cqNo());
190         String bbsNo="";
191         String ziti="";//是否自提
192         // 系统部门未找到
193         if (StringUtils.isBlank(bsDE)) {
194             orr.setCode(1);
195             orr.setErrmsg("提单未找到系统部门字段,请重新操作!");
196             return orr;
197         }
198         try {
199             JsonParser jp=new JsonParser();
200             JsonObject vjo=jp.parse(vehicleInfo).getAsJsonObject();
201             Fd_Vehicle fdv=new Fd_Vehicle();
202             fdv=JSONobj.getobj(vjo, fdv);
203             String driver=JSONobj.getstring(vjo, "driver");
204             String phone=JSONobj.getstring(vjo, "phone");
205             String vehicleId=JSONobj.getstring(vjo, "vehicleId").toUpperCase();
206 //            String IDNum=JSONobj.getstring(vjo, "IDNum");
207             fdv.setVehicleId(vehicleId);
208             if(StringUtils.isEmpty(fdv.getVehicleId())||StringUtils.isEmpty(fdv.getDriver())||StringUtils.isEmpty(fdv.getIDNum())||StringUtils.isEmpty(fdv.getPhone())){
209                 orr.setCode(1);
210                 orr.setErrmsg("车辆必填项不能为空!");
211                 return orr;
212             }
213             Fd_Vehicle fdv1=this.fdvper.getByVehicleId(fdv.getVehicleId());
214             if(fdv1==null){
215                 fdv.setCompanyNo(lg.getDepartno());
216                 fdv.setId(UUID.randomUUID()+"");
217                 fdv.setNote("");
218                 fdv.setState(true);
219                 fdv.setStatus(VehicleStatus.已配车);
220                 fdv.setType(VehicleType.临时车);
221                 fdvper.insert(fdv);
222             }else{
223                 if(fdv1.getType()==VehicleType.临时车){
224                     fdv.setDriver(fdv.getDriver());
225                     fdv.setPhone(fdv.getPhone());
226                     fdv.setIDNum(fdv.getIDNum());
227                     fdvper.update(fdv1);
228                 }
229             }
230
231 //            xstd.getTd_ywdybh().equals(Contants.zzywdyNo)?Contants.zzSdepartNo:Contants.kjSdepartNo
232             Fd_Bsheet fb=this.bsper.getbyVehicleId(fdv.getVehicleId(), Serviceenum.在办,bsDE);
233             if(fb==null){
234                 JsonObject pfob=Wxhtmethod.postJsonStr(Contants.YKTgetPrefix_url,PrefixEnum.productsale.toString());
235                 ObjectResult<String> pfor=new ObjectResult<String>();
236                 String bsNo=JSONobj.getstring(pfob, "item");
237                 int code=JSONobj.getint(pfob, "code");
238                 String errmsg=JSONobj.getstring(pfob, "errmsg");
239                 pfor.setCode(code);
240                 pfor.setErrmsg(errmsg);
241                 pfor.setItem(bsNo);
242                 if(pfor==null||pfor.getCode()!=0){
243                     throw new Exception(pfor.getErrmsg());
244                 }
245                 fb=new Fd_Bsheet();
246                 fb.setBsNo(pfor.getItem());
247                 fb.setCompanyName(lg.getDepartname());
248                 fb.setCompanyNo(lg.getDepartno());
249                 fb.setCreateid(lg.getUserid());
250                 fb.setCreateName(lg.getWorkername());
251                 fb.setCtime(new Date());
252                 fb.setDriver(driver);
253                 fb.setFdsheetNo(pfor.getItem());
254                 fb.setId(UUID.randomUUID()+"");
255                 fb.setPhone(phone);
256                 fb.setSendmsg(false);
257                 fb.setStatus(Serviceenum.在办);
258                 fb.setVehicleId(fdv.getVehicleId());
259                 fb.setSdepartNo(bsDE);
260                 fb.setUpdateTime(new Date());
261                 this.bsper.insert(fb);
262                 saveBT=true;
263             }else{
264                 fb.setDriver(driver);
265                 fb.setPhone(phone);
266                 fb.setUpdateTime(new Date());
267                 this.bsper.update(fb);
268             }
269             Fd_Company_Vehicle fdcv=cvper.getbyIDs(fdv.getVehicleId(), lg.getDepartno(),bsDE);
270             if(fdcv==null){
271                 fdcv=new Fd_Company_Vehicle();
272                 fdcv.setCompanyNo(lg.getDepartno());
273                 fdcv.setVehicleId(fdv.getVehicleId());
274                 fdcv.setSdepartNo(bsDE);
275                 cvper.insertIDs(fdcv);
276             }
277 //            if(StringUtils.isBlank(fb.getSdepartNo())){
278 //                if(xstd.getTd_ywdybh().equals(Contants.zzywdyNo)){
279 //                    this.bsper.updatesdepartNo(fb.getId(), Contants.zzSdepartNo);
280 //                    fb.setSdepartNo(Contants.zzSdepartNo);
281 //                    Fd_Company_Vehicle fdcv=cvper.getbyIDs(fdv.getVehicleId(), lg.getDepartno(),Contants.zzSdepartNo);
282 //                    if(fdcv==null){
283 //                        fdcv=new Fd_Company_Vehicle();
284 //                        fdcv.setCompanyNo(lg.getDepartno());
285 //                        fdcv.setVehicleId(fdv.getVehicleId());
286 //                        fdcv.setSdepartNo(Contants.zzSdepartNo);
287 //                        cvper.insertIDs(fdcv);
288 //                    }
289 //                }else{
290 //                    this.bsper.updatesdepartNo(fb.getId(), Contants.kjSdepartNo);
291 //                    fb.setSdepartNo(Contants.kjSdepartNo);
292 //                    Fd_Company_Vehicle fdcv=cvper.getbyIDs(fdv.getVehicleId(), lg.getDepartno(),Contants.kjSdepartNo);
293 //                    if(fdcv==null){
294 //                        fdcv=new Fd_Company_Vehicle();
295 //                        fdcv.setCompanyNo(lg.getDepartno());
296 //                        fdcv.setVehicleId(fdv.getVehicleId());
297 //                        fdcv.setSdepartNo(Contants.kjSdepartNo);
298 //                        cvper.insertIDs(fdcv);
299 //                    }
300 //                }
301 //            }
302             if(StringUtils.isBlank(ziti)){
303                 ziti=xstd.getTd_ztbz()==2?"自提":"非自提";
304             }
305 //            if(StringUtils.isBlank(fb.getSdepartNo())){
306 //                throw new Exception("生成的分单业务单:"+fb.getFdsheetNo()+"厂区未找到!");
307 //            }
308             //郑州
309 //            if(fb.getSdepartNo().equals(Contants.zzSdepartNo)){
310 //                if(!xstd.getTd_ywdybh().equals(Contants.zzywdyNo)){
311 ////                    throw new Exception("车辆生成的是郑州厂区一卡通业务单,科技提单:"+xstd.getTd_tdbh()+"不能配车!");
312 //                    if(saveBT){
313 //                        throw new Exception("科技厂区提单和郑州厂区提单不能同时使用同一辆车!");
314 //                    }else{
315 //                        throw new Exception(fb.getVehicleId()+" 有郑州厂区一卡通销售业务单,科技提单:"+xstd.getTd_tdbh()+"不能使用该车!");
316 //                    }
317 //                }
318 //            }else{
319 //                if(xstd.getTd_ywdybh().equals(Contants.zzywdyNo)){
320 ////                    throw new Exception("车辆生成的是科技厂区一卡通业务单,郑州提单:"+xstd.getTd_tdbh()+"不能配车!");
321 //                    if(saveBT){
322 //                        throw new Exception("科技厂区提单和郑州厂区提单不能同时使用同一辆车!");
323 //                    }else{
324 //                        throw new Exception(fb.getVehicleId()+" 有科技厂区一卡通销售业务单,郑州提单:"+xstd.getTd_tdbh()+"不能使用该车!");
325 //                    }
326 //                }
327 //            }
328
329             JsonArray ja=jp.parse(bsitemlistStr).getAsJsonArray();
330             //分单数量和毛重
331             int fdsl=0;
332             double fdmz=0;
333             for (JsonElement je: ja) {
334                 JsonObject itemJo=je.getAsJsonObject();
335                 //主键
336                 String tdmx_tdfl=JSONobj.getstring(itemJo, "tdfl");
337                 Fd_XSTDMX tdmx=this.mxper.get(tdmx_tdfl);
338                 //未找到的过滤掉  已分单的过滤掉  已装车的不处理
339                 if(tdmx==null||tdmx.getTdmx_fdbz()!=0||tdmx.getTdmx_zcbz()!=0){
340                     continue;
341                 }
342                 //关闭标志不为0不做处理
343                 if(tdmx.getTdmx_gbbz()!=0){
344                     continue;
345                 }
346                 fdsl++;
347                 fdmz=BigDecimalfiter.addscal(fdmz, tdmx.getTdmx_mz(), Contants.scale);
348
349                 tdmx.setTdmx_fdbz(1);
350                 tdmx.setTdmx_fdcph(fdv.getVehicleId());
351                 tdmx.setTdmx_fdywbh(fb.getBsNo());
352                 tdmx.setTdmx_fdwlgsbh(lg.getDepartno());
353                 this.mxper.updateFD(tdmx);
354                 mxl.add(tdmx);
355
356             }
357             Vehicle_XSTD vhxstd=this.vhxper.getbyIDs(fdv.getVehicleId(), xstdNo,lg.getDepartno());
358             if(vhxstd==null){
359                 vhxstd=new Vehicle_XSTD();
360                 vhxstd.setBsNo(fb.getBsNo());
361                 vhxstd.setCompanyNo(lg.getDepartno());
362                 vhxstd.setFd_num(fdsl);
363                 vhxstd.setFd_weight(fdmz);
364                 vhxstd.setVehicleId(fdv.getVehicleId());
365                 vhxstd.setXstdNo(xstdNo);
366                 this.vhxper.insert(vhxstd);
367             }else{
368                 vhxstd.setBsNo(fb.getBsNo());
369                 vhxstd.setCompanyNo(lg.getDepartno());
370                 vhxstd.setFd_num(vhxstd.getFd_num()+fdsl);
371                 vhxstd.setFd_weight(BigDecimalfiter.add(vhxstd.getFd_weight(),fdmz));
372                 vhxstd.setVehicleId(fdv.getVehicleId());
373                 vhxstd.setXstdNo(xstdNo);
374                 this.vhxper.updatewithIDs(vhxstd);
375             }
376             xstd.setTd_wfdsl(xstd.getTd_wfdsl()-fdsl);
377             xstd.setTd_wfdzl(BigDecimalfiter.subscal(xstd.getTd_wfdzl(), fdmz, Contants.scale));
378             this.tdper.updateFD(xstd);
379             if(saveBT){
380                 YktBsheet bs=new YktBsheet();
381 //                if(iskj==1){
382 //                    bs.setSdepartNo(Contants.kjSdepartNo);
383 //                    bs.setDcompany("明泰科技");
384 //                }else{
385 //                    bs.setSdepartNo(Contants.zzSdepartNo);
386 //                    bs.setDcompany("郑州眀泰");
387 //                }
388                 bs.setSdepartNo(fb.getSdepartNo());
389                 /*bs.setDcompany(fb.getSdepartNo().equals(Contants.kjSdepartNo)?"明泰科技":
390                     fb.getSdepartNo().equals(Contants.msSdepartNo)?"河南明晟新材料":
391                     "郑州眀泰"
392                     );*/
393                 bs.setDcompany(ConvertTool.covertToFactoryName(fb.getSdepartNo()));
394                 bs.setDriver(fdv.getDriver());
395                 bs.setNumberplates(StringUtils.upperCase(fdv.getVehicleId()));
396                 bs.setPhone(fdv.getPhone());
397                 bs.setRcompany(Rcompany);
398                 bs.setBussinessNo(fb.getBsNo());
399                 bs.setNote(ziti+";"+lg.getDepartname()+":"+lg.getWorkername()+"; 分单系统自动生成");
400                 String bsStr=Jacksonmethod.tojson(bs, false);
401                 bsDE=bs.getSdepartNo();
402                 bbsNo=bs.getBussinessNo();
403                 JsonObject joADDYWD=Wxhtmethod.postJsonStr(Contants.YKTaddYwd_url,bsStr);
404                 ObjectResult<String> ors=new ObjectResult<String>();
405                 String bsNo=JSONobj.getstring(joADDYWD, "item");
406                 int code=JSONobj.getint(joADDYWD, "code");
407                 String errmsg=JSONobj.getstring(joADDYWD, "errmsg");
408                 ors.setItem(bsNo);
409                 ors.setCode(code);
410                 ors.setErrmsg(errmsg);
411                 if(ors.getCode()!=0){
412                     throw new Exception(ors.getErrmsg());
413                 }
414                 this.bsper.updateShdw(fb.getId(), StringUtils.isBlank(Rcompany)?"未知发货单位":Rcompany);
415             }else {
416                 List<WaitXSTD> l=this.bsper.getAllKH(fb.getBsNo(), fb.getId());
417                 if(l!=null) {
418                     boolean iscz=false;//收货单位在明细中是否存在
419                     WaitXSTD wt=null;
420                     for (WaitXSTD waitXSTD : l) {
421                         if(fb.getShdw().equals(waitXSTD.getTd_khmc())) {
422                             iscz=true;
423                             break;
424                         }else {
425                             if(wt==null&&StringUtils.isNotBlank(waitXSTD.getTd_khmc())) {
426                                 wt=waitXSTD;
427                             }
428                         }
429                     }
430                     if(!iscz&&wt!=null) {
431                         fb.setShdw(wt.getTd_khmc());
432                         this.yktmper.updateshcompany(fb.getBsNo(), wt.getTd_khmc(),wt.getTd_shdd());
433                     }
434                 }
435
436             }
437             tdl.add(xstd);
438             mxMp.put(xstdNo, mxl);
439             //分单推送NC系统
440             if(tdl!=null&&tdl.size()>0){
441                 String fdhx=this.fdtonc.getNcdata(tdl, mxMp);
442                 Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "明细配车 请求参数 ::"+fdhx);
443                 //todo 先注释掉NC部分,接口不通
444                 JsonObject joADDYWD=Wxhtmethod.postJsonStr(Contants.NCfdhx_url,fdhx);
445                 Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "明细配车 url返回值 ::"+joADDYWD);
446                 if(joADDYWD==null||JSONobj.getint(joADDYWD, "code")!=0){
447                     throw new Exception(StringUtils.isEmpty(joADDYWD.get("msg").getAsString())?"分单回写NC系统出错!":joADDYWD.get("msg").getAsString());
448                 }else{
449                     String restult=joADDYWD.get("result").getAsString();
450                     JsonObject jr=jp.parse(restult).getAsJsonObject();
451                     if(jr==null||JSONobj.getint(jr, "respcode")!=111){
452                         throw new Exception(jr.get("respmsg").getAsString());
453                     }
454                 }
455             }
456         }catch(Exception e){
9ce4bb 457             e.printStackTrace();
58d006 458             if(saveBT){
A 459                 JsonObject jo=new JsonObject();
460                 jo.addProperty("bussinessNo", bbsNo);
461                 jo.addProperty("sdepartNo",bsDE);
462                 Wxhtmethod.postJsonStr(Contants.YKTdelYwd_url,jo.toString());
463             }
464             throw new Exception(StringUtils.isEmpty(e.getMessage())?"提单明细分单出错!":e.getMessage());
465         }
466
467         orr.setCode(0);
468         orr.setItem(null);
469         return orr;
470     }
471
472     @Override
473     @Transactional(rollbackFor=Exception.class)
474     public ObjectResult<String> sendMsg(Login lg, String bussinessNo)throws Exception {
475         ObjectResult<String> orr=new ObjectResult<String>();
476         if(lg==null){
477             orr.setCode(1);
478             orr.setErrmsg("请登录账号!");
479             return orr;
480         }
481         if(UserType.admin.toString().equals(lg.getWorkerno())){
482             orr.setCode(1);
483             orr.setErrmsg("管理员账号没有分单权限!");
484             return orr;
485         }
486         if(StringUtils.isEmpty(bussinessNo)){
487             orr.setCode(1);
488             orr.setErrmsg("业务单参数为空!");
489             return orr;
490         }
491         Fd_Bsheet fdb=bsper.getbybsNo(bussinessNo);
492         if(fdb==null){
493             orr.setCode(1);
494             orr.setErrmsg("业务单未找到!");
495             return orr;
496         }
497         if(fdb.getStatus()!=Serviceenum.在办){
498             orr.setCode(1);
499             orr.setErrmsg("业务单不是在办状态!");
500             return orr;
501         }
502         JsonObject jos=new JsonObject();
503         jos.addProperty("bussinessNo", bussinessNo);
504         JsonObject jo=Wxhtmethod.postJsonStr(Contants.YKTsendMsg_url,jos.toString());
505         if(jo==null||jo.get("code").getAsInt()!=0){
506             throw new Exception(jo.get("errmsg").getAsString());
507         }
508         fdb.setSendmsg(true);
509         fdb.setInvitecode(jo.get("item").getAsString());
510         bsper.updateInvitaCode(fdb);
511
512         orr.setCode(0);
513         return orr;
514     }
515
516 }