package com.mandi.webservice.service.impl; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; import javax.annotation.Resource; import com.mandi.basicconfig.persist.*; import com.mandi.fendan.util.ConvertTool; import com.mandi.fendan.util.ThreadPoolUtil; import com.mandi.servlet.file.impl.FileLoadImpl; import javafx.concurrent.Task; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.mandi.basicconfig.mapper.FdRepertoryNexusMapper; import com.mandi.basicconfig.mapper.NczsjMapper; import com.mandi.common.JSONobj; import com.mandi.common.Wxhtmethod; import com.mandi.common.ParamFileter.BigDecimalfiter; import com.mandi.dao.common.ObjectResult; import com.mandi.dao.common.PageResult; import com.mandi.fendan.mapper.BsheetEcgbMapper; import com.mandi.fendan.mapper.BusinessMapper; import com.mandi.fendan.mapper.Fd_BsheetMapper; import com.mandi.fendan.mapper.Fd_CompanyMapper; import com.mandi.fendan.mapper.Fd_GbxstdMapper; import com.mandi.fendan.mapper.Fd_GbxstdmxMapper; import com.mandi.fendan.mapper.Fd_VehicleMapper; import com.mandi.fendan.mapper.Fd_XSTDMXMapper; import com.mandi.fendan.mapper.Fd_XSTDMapper; import com.mandi.fendan.mapper.Fd_YKTMapper; import com.mandi.fendan.mapper.VehicleXSTDMapper; import com.mandi.fendan.persist.BsheetEcgb; import com.mandi.fendan.persist.Fd_Bsheet; import com.mandi.fendan.persist.Fd_Company; import com.mandi.fendan.persist.Fd_Gbxstd; import com.mandi.fendan.persist.Fd_Gbxstdmx; import com.mandi.fendan.persist.Fd_XSTD; import com.mandi.fendan.persist.Fd_XSTDMX; import com.mandi.fendan.persist.Vehicle_XSTD; import com.mandi.fendan.util.Contants; import com.mandi.fendan.util.persist.Serviceenum; import com.mandi.fendan.util.persist.WaitXSTDMX; import com.mandi.fendan.util.persist.Yktbsitem; import com.mandi.webservice.service.IFdXSTDService; @Service public class FdXSTDService implements IFdXSTDService{ @Resource private Fd_XSTDMapper tdper; @Resource private Fd_XSTDMXMapper tdmxper; @Resource private Fd_YKTMapper yktper; @Resource private VehicleXSTDMapper vhxper; @Resource private Fd_VehicleMapper vhper; @Resource private NczsjMapper zsjper; @Resource private Fd_BsheetMapper fbper; @Resource private Fd_CompanyMapper cmper; @Resource private Fd_GbxstdMapper gbper; @Resource private Fd_GbxstdmxMapper gbmxper; @Resource private BusinessMapper bsper; @Resource private BsheetEcgbMapper beper; @Resource private FdRepertoryNexusMapper reNxPer; private Logger log= Logger.getLogger(FileLoadImpl.class); @Override @Transactional(rollbackFor=Exception.class) public ObjectResult saveFd_xstd(String dataArr) throws Exception { ObjectResult orr=new ObjectResult(); JsonArray ja=null; try { JsonParser jp=new JsonParser(); ja=jp.parse(dataArr).getAsJsonArray(); } catch (Exception e) { throw new Exception("数据解析错误,参数不是json数组!"); } if(ja!=null){ for (JsonElement je : ja) { JsonObject jo=je.getAsJsonObject(); JsonObject objJo=null; JsonArray tdmxArr=null; try { objJo=jo.getAsJsonObject("head"); tdmxArr=jo.getAsJsonArray("body"); } catch (Exception e) { throw new Exception("数据解析错误,数据格式不正确!"); } String ztbz=JSONobj.getstring(objJo, "td_ztbz"); Fd_XSTD xstd=new Fd_XSTD(); xstd=JSONobj.getobj(objJo, xstd); if("01".equals(ztbz)){ xstd.setTd_ztbz(2); }else if("02".equals(ztbz)){ xstd.setTd_ztbz(1); }else if("03".equals(ztbz)){ xstd.setTd_ztbz(3); }else{ xstd.setTd_ztbz(1); } //明细业务单元 String mxywyd=""; //根据仓库查找对应的厂区编号 String ckNo="";//明细仓库编号 Ncywdy cn=this.zsjper.getNcywdybyCode(xstd.getTd_ywdybh()); //系统部门找不到不做处理 if(cn==null||cn.getYktCode()==null||StringUtils.isEmpty(cn.getYktCode())){ continue; } Ncworker ncw=this.zsjper.getNcworkerbyCode(xstd.getTd_zdr()); Ncdepart ncd=this.zsjper.getNcdepartbyCode(xstd.getTd_bmbh()); if(ncw!=null) xstd.setTd_zdrmc(ncw.getName()); if(ncd!=null) xstd.setTd_bmmc(ncd.getName()); int td_wfdsl=0;//未分单数量 double td_wfdzl=0;//未分单重量 String td_tdls=xstd.getTd_tdls();//提单流水号 for (int i = 0; i < tdmxArr.size(); i++) { objJo=tdmxArr.get(i).getAsJsonObject(); String h=JSONobj.getstring(objJo, "h"); String k=JSONobj.getstring(objJo, "k"); String c=JSONobj.getstring(objJo, "c"); Fd_XSTDMX xstdmx=new Fd_XSTDMX(); xstdmx=JSONobj.getobj(objJo,xstdmx); double mz=xstdmx.getTdmx_mz(); xstdmx.setTdmx_ggxh((h==null?"C":h)+"*"+(k==null?"C":k)+"*"+(c==null?"C":c)); if(StringUtils.isEmpty(td_tdls)){ td_tdls=xstdmx.getTdmx_tdls(); } if(StringUtils.isBlank(mxywyd)){ cn=this.zsjper.getNcywdybyCode(xstdmx.getTdmx_fhzz()); //系统部门找不到不做处理 if(cn!=null && StringUtils.isNotBlank(cn.getYktCode())){ mxywyd=xstdmx.getTdmx_fhzz(); }else{ continue; } if(StringUtils.isBlank(ckNo)) { Ncck ck=this.zsjper.getNcckbyPkid(xstdmx.getTdmx_ck()); if(ck!=null) ckNo=ck.getCode(); } } //有上次已装车记录 Fd_XSTDMX ccr=this.tdmxper.get(xstdmx.getTdmx_tdfl()); if(ccr!=null&&ccr.getTdmx_zcbz()>0){ continue; }else{ if(ccr!=null){ this.tdmxper.del(xstdmx.getTdmx_tdfl()); } } if(Contants.NcNosend.equals(mxywyd)){ this.tdmxper.delbyTDLS(xstd.getTd_tdls()); this.tdper.del(xstd.getTd_tdls()); break; } this.tdmxper.insert(xstdmx); //如果这次推过来的是关闭的 明细保存 表头不增加未分单数量 if(xstdmx.getTdmx_gbbz()==0){ td_wfdsl++; td_wfdzl+=mz; } } if(!Contants.NcNosend.equals(mxywyd)){ //获取生成厂区编号 FdRepertoryNexus renx=this.reNxPer.getbyckNoAndYwdyNo(ckNo,mxywyd); if(renx!=null) xstd.setTd_cqNo(renx.getSdepartNo()); xstd.setTd_wfdsl(td_wfdsl); xstd.setTd_wfdzl(td_wfdzl); xstd.setTd_ywdybh(mxywyd); this.tdper.insert(xstd); } } } orr.setCode(0); orr.setErrmsg("新增成功!"); return orr; } @Override @Transactional(rollbackFor=Exception.class) public ObjectResult delFd_xstd(String dataArr) throws Exception { ObjectResult orr=new ObjectResult(); JsonArray ja=null; try { JsonParser jp=new JsonParser(); ja=jp.parse(dataArr).getAsJsonArray(); } catch (Exception e) { throw new Exception("数据解析错误,参数不是json数组!"); } if(ja!=null){ for (JsonElement je : ja) { JsonObject jo=je.getAsJsonObject(); JsonObject objJo=null; try { objJo=jo.getAsJsonObject("head"); } catch (Exception e) { throw new Exception("数据解析错误,数据格式不正确!"); } String td_tdls=JSONobj.getstring(objJo, "td_tdls"); if(StringUtils.isBlank(td_tdls)){ throw new Exception("数据解析错误,提单流水号不能为空!"); } Fd_XSTD td_xstd=this.tdper.get(td_tdls); if(td_xstd!=null){ int c=this.tdmxper.getbytdlswithZCorFD(td_tdls); if(c>0){ throw new Exception("发货单:"+td_xstd.getTd_tdbh()+" 已经分单或装车,不能删除!"); } // //只删除标志是未装车的 this.tdmxper.delbyTDLS(td_tdls); this.tdper.del(td_tdls); this.gbper.del(td_xstd.getTd_tdbh()); this.gbmxper.del(td_xstd.getTd_tdbh()); } } } orr.setCode(0); orr.setErrmsg("删除成功!"); return orr; } @Override @Transactional(rollbackFor=Exception.class) public ObjectResult closeFd_xstd(String dataArr) throws Exception { ObjectResult orr=new ObjectResult(); JsonArray ja=null; try { JsonParser jp=new JsonParser(); ja=jp.parse(dataArr).getAsJsonArray(); } catch (Exception e) { throw new Exception("数据解析错误,参数不是json数组!"); } if(ja!=null){ for (JsonElement je : ja) { JsonObject jo=je.getAsJsonObject(); JsonObject objJo=null; JsonArray tdmxArr=null; try { objJo=jo.getAsJsonObject("head"); tdmxArr=jo.getAsJsonArray("body"); } catch (Exception e) { throw new Exception("数据解析错误,数据格式不正确!"); } //提单流水号 String td_tdls=objJo.get("td_tdls")==null?"":objJo.get("td_tdls").getAsString(); Fd_XSTD xstd=this.tdper.get(td_tdls); if(xstd!=null){ for (int i = 0; i < tdmxArr.size(); i++) { objJo=tdmxArr.get(i).getAsJsonObject(); String tdmx_tdfl=objJo.get("tdmx_tdfl")==null?"":objJo.get("tdmx_tdfl").getAsString(); String sfckgb=objJo.get("sfckgb")==null?"":objJo.get("sfckgb").getAsString(); Fd_XSTDMX tdmx=this.tdmxper.get(tdmx_tdfl); if(tdmx!=null&&tdmx.getTdmx_gbbz()==0){ tdmx.setTdmx_gbbz(1); this.tdmxper.updateGB(tdmx); // if(tdmx.getTdmx_zcbz()!=0){ // continue; // } if(tdmx.getTdmx_fdbz()!=0){ //已分单未装车 if("N".equals(sfckgb)){ if(tdmx.getTdmx_zcbz()==0){ throw new Exception("提单明细:批次号:"+tdmx.getTdmx_pch()+" 已分单未装车,请联系物流公司取消分单!"); } } } // if(tdmx.getTdmx_zcbz()!=0){ // throw new Exception("提单流水号:"+xstd.getTd_tdls()+" 已扫码装车,不能关闭!"); // } if(tdmx.getTdmx_fdbz()==0){ xstd.setTd_wfdsl(xstd.getTd_wfdsl()-1); xstd.setTd_wfdzl(xstd.getTd_wfdzl()-tdmx.getTdmx_mz()); this.tdper.updateFD(xstd); }else{ if(tdmx.getTdmx_zcbz()==0){ tdmx.setTdmx_fdywbh(null); tdmx.setTdmx_fdwlgsbh(null); tdmx.setTdmx_fdbz(0); tdmx.setTdmx_fdcph(null); this.tdmxper.updateFD(tdmx); } } //这个关闭记录表示的是一卡通里的关闭操作 Fd_Gbxstdmx gbmx=this.gbmxper.get(tdmx_tdfl); if(gbmx!=null){ Fd_Gbxstd gb=this.gbper.get(xstd.getTd_tdbh()); if(gb!=null){ gb.setTd_gbsl(gb.getTd_gbsl()-1); gb.setTd_gbzl(BigDecimalfiter.sub(gb.getTd_gbzl(),tdmx.getTdmx_mz())); this.gbper.update(gb); } this.gbmxper.delbyId(tdmx_tdfl); } } } } } } orr.setCode(0); orr.setErrmsg("关闭成功!"); return orr; } @Override @Transactional(rollbackFor=Exception.class) public ObjectResult openFd_xstd(String dataArr) throws Exception { ObjectResult orr=new ObjectResult(); JsonArray ja=null; try { JsonParser jp=new JsonParser(); ja=jp.parse(dataArr).getAsJsonArray(); } catch (Exception e) { throw new Exception("数据解析错误,参数不是json数组!"); } if(ja!=null){ for (JsonElement je : ja) { JsonObject jo=je.getAsJsonObject(); JsonObject objJo=null; JsonArray tdmxArr=null; try { objJo=jo.getAsJsonObject("head"); tdmxArr=jo.getAsJsonArray("body"); } catch (Exception e) { throw new Exception("数据解析错误,数据格式不正确!"); } //提单流水号 String td_tdls=objJo.get("td_tdls")==null?"":objJo.get("td_tdls").getAsString(); Fd_XSTD xstd=this.tdper.get(td_tdls); if(xstd!=null){ for (int i = 0; i < tdmxArr.size(); i++) { objJo=tdmxArr.get(i).getAsJsonObject(); String tdmx_tdfl=objJo.get("tdmx_tdfl")==null?"":objJo.get("tdmx_tdfl").getAsString(); Fd_XSTDMX tdmx=this.tdmxper.get(tdmx_tdfl); if(tdmx!=null&&tdmx.getTdmx_gbbz()==1){ tdmx.setTdmx_gbbz(0); this.tdmxper.updateGB(tdmx); if(tdmx.getTdmx_fdbz()==0){ xstd.setTd_wfdsl(xstd.getTd_wfdsl()+1); xstd.setTd_wfdzl(xstd.getTd_wfdzl()+tdmx.getTdmx_mz()); this.tdper.updateFD(xstd); } } } } } } orr.setCode(0); orr.setErrmsg("打开成功!"); return orr; } @Override @Transactional(rollbackFor=Exception.class) public PageResult> addZCMX(String cardID,String yktywdh, JsonArray dataArr) throws Exception { PageResult> prr=new PageResult>(); List> relist=new ArrayList>(); if(StringUtils.isEmpty(yktywdh)){ prr.setCode(1); prr.setErrmsg("参数:一卡通业务单号为空!"); return prr; } //根据卡号判断分单信息 //循环批次号 如果没有分单 修改为分单和装车 Fd_Bsheet fdb=this.fbper.getbybsNo(StringUtils.isNotBlank(yktywdh)?yktywdh:""); String vehicleId=""; if(fdb==null){ prr.setCode(1); prr.setErrmsg("一卡通业务单未找到,请确认单号是否正确!"); return prr; } if (fdb.getStatus() != Serviceenum.在办) { prr.setCode(2); prr.setErrmsg("一卡通业务单不是在办状态,系统不做处理!"); return prr; } if (StringUtils.isBlank(cardID)) { prr.setCode(1); prr.setErrmsg("参数:一卡通卡号为空!"); return prr; } if (dataArr == null) { prr.setCode(1); prr.setErrmsg("参数:批次号为空!"); return prr; } Map mp = this.yktper.getcardinuse(cardID); if (mp == null) { throw new Exception("卡号不正确未找到在用卡!"); } vehicleId = mp.get("numberplates") == null ? "" : mp.get("numberplates").toString(); if (!vehicleId.equals(fdb.getVehicleId())) { prr.setCode(1); prr.setErrmsg("参数:卡号关联的车牌号和业务单关联的车牌号不一致"); return prr; } // yktywdh = fdb.getBsNo(); int wcnum=this.bsper.getweightDoc(vehicleId, fdb.getBsNo()); if(wcnum<=0){ prr.setCode(1); prr.setErrmsg("车辆:"+vehicleId+" 未找到过磅单,请先过磅!"); return prr; } yktywdh=fdb.getBsNo(); //是否郑州厂区 boolean iszz=false; //检查是否装车完成 Map mmr=this.bsper.selectTaskTime(fdb.getBsNo()); try { if(mmr!=null&&mmr.get("zcWc")!=null&&Boolean.valueOf(mmr.get("zcWc").toString())) { prr.setCode(1); prr.setErrmsg("联系成品库办公室取消装车完成!"); return prr; } } catch (Exception e) { // TODO: handle exception } //第一次添加装卸记录发送装车信息 int sfzc=this.fbper.getbsitembyNo(fdb.getBsNo()); if(sfzc<=0) { //发送微信公众号提醒信息 String url=Contants.yktLocalAdd+"/routine/sendZcMsg.htm"; Map paramMp=new HashMap(); mp.put("sdepartNo", fdb.getSdepartNo()); mp.put("vehicleId", vehicleId); mp.put("businessNo", fdb.getBsNo()); Wxhtmethod.postJson(url, paramMp); } // 现场过完毛重后出现扫码装车的,必须重新过磅 int grossNum=this.bsper.getgrosstDoc(vehicleId, fdb.getBsNo()); for (JsonElement je : dataArr) { JsonObject jo=je.getAsJsonObject(); String tdmx_pch = jo.get("tdmx_pch").getAsString(); // Fd_XSTDMX tdmx=this.tdmxper.getbyPCH(tdmx_pch); Fd_XSTDMX tdmx=this.tdmxper.getbyPCHONE(tdmx_pch,vehicleId); if(tdmx==null){ prr.setCode(1); prr.setErrmsg("车辆:"+vehicleId+"没有该明细的分单记录或已关闭,不能添加装车!"); return prr; } // 下面部分注释掉,改为sql语句中判断是否为未关闭 /*if(tdmx.getTdmx_gbbz()!=0){ prr.setCode(1); prr.setErrmsg("明细:"+tdmx.getTdmx_pch()+" 在NC是已关闭状态,不能添加装车!"); return prr; }*/ // boolean booff=false; // if(tdmx.getTdmx_zcbz()!=0){ // booff=true; // throw new Exception("批次号:"+tdmx_pch+" 已经提交装车,不能重复提交装车!"); // } Fd_XSTD xstd=this.tdper.get(tdmx.getTdmx_tdls()); if(Contants.nc_ywdy_ZZ.equals(xstd.getTd_cqNo())&&!iszz){ iszz=true; } Vehicle_XSTD vxs=this.vhxper.getVhicleByIDs(vehicleId, xstd.getTd_tdbh()); if(vxs==null) { prr.setCode(1); prr.setErrmsg("未找到配车关联记录,不能添加装车!"); return prr; } //修改提单的未分单数量和重量 //修改提单vehicle_XSTD表 Fd_Company fdc=null; //是否分单 if(tdmx.getTdmx_fdbz()==0){ fdc=this.cmper.getByCompanyNo(vxs.getCompanyNo()); tdmx.setTdmx_fdbz(1); tdmx.setTdmx_fdcph(vehicleId); tdmx.setTdmx_fdywbh(yktywdh); tdmx.setTdmx_fdwlgsbh(vxs.getCompanyNo()); xstd.setTd_wfdsl(xstd.getTd_wfdsl()-1); xstd.setTd_wfdzl(xstd.getTd_wfdzl()-tdmx.getTdmx_mz()); this.tdper.updateFD(xstd); vxs.setFd_num(vxs.getFd_num()+1); vxs.setFd_weight(vxs.getFd_weight()+tdmx.getTdmx_mz()); this.vhxper.updatewithIDs(vxs); }else { fdc=this.cmper.getByCompanyNo(tdmx.getTdmx_fdwlgsbh()); } tdmx.setTdmx_zcbz(1); tdmx.setTdmx_zccph(vehicleId); tdmx.setTdmx_zcwlgsName(fdc.getName()); tdmx.setTdmx_zcdriver(fdb.getDriver()); tdmx.setTdmx_zcphone(fdb.getPhone()); this.tdmxper.updateZCnoFD(tdmx); WaitXSTDMX wx=this.fbper.getWaittdmx(tdmx.getTdmx_tdls(), tdmx.getTdmx_tdfl()); this.fbper.delbsitem(tdmx.getTdmx_pch(), fdb.getBsNo()); Yktbsitem bsi=new Yktbsitem(); bsi.setId(UUID.randomUUID()+""); bsi.setBussinessNo(fdb.getBsNo()); bsi.setName(wx.getTdmx_wlmc()); bsi.setMaterielNo(tdmx.getTdmx_wlbh()); bsi.setNorms(wx.getTdmx_ggxh()); bsi.setUnitname("Kg"); bsi.setNum(1); bsi.setWeight(BigDecimalfiter.mulcon(tdmx.getTdmx_jz(), 1000, Contants.scale)); bsi.setPrice(0); bsi.setPreweight(BigDecimalfiter.mulcon(tdmx.getTdmx_jz(), 1000, Contants.scale)); bsi.setPici(tdmx.getTdmx_pch()); bsi.setHejin(wx.getTdmx_hjzt()); bsi.setGross(BigDecimalfiter.mulcon(tdmx.getTdmx_mz(), 1000, Contants.scale)); bsi.setTaotongWeight(0); bsi.setMoney(0); bsi.setCdepart(""); bsi.setCdepartid(0); bsi.setCname(""); bsi.setCreateid(""); bsi.setCtime(new Date()); bsi.setLoadbuild(false); bsi.setFachang(false); bsi.setFachang(true); bsi.setFcnum(0); if(StringUtils.isBlank(xstd.getTd_fpbh())){ bsi.setRecompany(wx.getTdmx_shdw()); }else{ bsi.setRecompany( ConvertTool.covertToCustoms(xstd.getTd_ywdybh()) ); } bsi.setReID(""); bsi.setDecompany(ConvertTool.ncCovertToFactoryName(xstd.getTd_ywdybh())); bsi.setDeID(""); bsi.setFrombatch("ERP系统"); bsi.setForshowindx(1); bsi.setReserved11(0); bsi.setReserved12(0); bsi.setReserved13(0); bsi.setJsnum(0); this.fbper.insertbsitem(bsi); Map remp=new HashMap(); remp.put("tdmx_pch",tdmx.getTdmx_pch()); remp.put("td_tdls",tdmx.getTdmx_tdls()); remp.put("tdmx_tdfl",tdmx.getTdmx_tdfl()); relist.add(remp); } if(grossNum>0) { Map xstm=new HashMap(); xstm.put("canCm",false); xstm.put("businessNo",fdb.getBsNo()); this.bsper.updateCanCm(xstm); this.bsper.updatecanFb(vehicleId, fdb.getBsNo()); } //如果是郑州的销售业务单删除排队信息 if(iszz){ int ca=this.bsper.getvehicleQ(vehicleId); if(ca>0){ // this.bsper.delvehicleQ(vehicleId); //删除车辆排队信息 String url=Contants.yktLocalAdd+"/search/vehicleQueue/delItem.htm"; Map paramMp=new HashMap(); mp.put("vehicleID", vehicleId); Wxhtmethod.postJson(url, paramMp); } } // 此处异步触发一下明晟发车 if("06".equals(fdb.getSdepartNo())) { ThreadPoolUtil.getInstance().execute(()->sendToMsLed()); } prr.setCode(0); prr.setErrmsg("装车操作成功!"); prr.setList(relist); return prr; } public void sendToMsLed(){ // todo 明天需要测试一下 //A区 76-86 + 99-1 //B区 14-33 + 99-2 //C区 53-67 + 99-3 List totalList = tdmxper.getHwList("06"); // 获取明晟所有在办业务单的信息 Map> ywbhListMap = new HashMap<>(); for (Map map : totalList) { String ywdw = (String) map.get("tdmx_fdywbh"); if(ywbhListMap.get(ywdw) == null) { ywbhListMap.put(ywdw, new ArrayList<>()); } ywbhListMap.get(ywdw).add(map); } String str1 = "车号-A区-B区-C区" + "\r\n", str2=""; //"(车牌号)\\-(A区已装车)/(A区总计)\\-(B区已装车)/(B区总计)\\-(C区已装车)/(C区总计)\\r\\n"; String formatStr = "%s-%d/%d- %d/%d-%d/%d\r\n"; for (Map.Entry> entry : ywbhListMap.entrySet()) { // 遍历每个业务单的 boolean hasZcwc = false; // 保证已经完成了 String ywhb = entry.getKey(); List vehicleIdTotalList = entry.getValue(); Map totalAbcMap = new HashMap(3); // 总计信息 totalAbcMap.put("A", 0); totalAbcMap.put("B", 0); totalAbcMap.put("C", 0); Map abcMap = new HashMap(3); // 已装信息 abcMap.put("A", 0); abcMap.put("B", 0); abcMap.put("C", 0); String cph = ""; // 车牌号 for (Map map : vehicleIdTotalList) { String hw = (String) map.get("tdmx_hwmc"); if(!"".equals(cph)) cph = (String) map.get("tdmx_zccph"); Integer zcbz = (Integer) map.get("tdmx_zcbz"); String hh = hw.replaceAll("\\-.*",""); hh = hh.substring(hh.length()-2); // 取最后两位 int num = Integer.parseInt(hh); if (num >= 76 && num <= 86 || hw.lastIndexOf("99-1") >= 0) { // A区 totalAbcMap.put("A", 1); if (zcbz != null && zcbz == 1) { // 装车完成 abcMap.put("A", abcMap.get("A") + 1); hasZcwc = true; } } else if (num >= 14 && num <= 33 || hw.lastIndexOf("99-2") >= 0) { // B区 totalAbcMap.put("B", 1); if (zcbz != null && zcbz == 1) { abcMap.put("B", abcMap.get("B") + 1); hasZcwc = true; } } else if (num >= 53 && num <= 67 || hw.lastIndexOf("99-3") >= 0) { // C区 totalAbcMap.put("C", 1); if (zcbz != null && zcbz == 1) { abcMap.put("C", abcMap.get("C") + 1); hasZcwc = true; } } } if (!hasZcwc) continue; str2 += String.format(formatStr, cph, abcMap.get("A"), totalAbcMap.get("A"), abcMap.get("B"), totalAbcMap.get("B"), abcMap.get("C"), totalAbcMap.get("C")); // 单辆车的单个业务单的信息结束 } Map paramMap = new HashMap(); paramMap.put("str1",str1); paramMap.put("str2",str2); Wxhtmethod.post("192.168.112.21/api/xxx",paramMap); } @Override @Transactional(rollbackFor=Exception.class) public ObjectResult delZCMX(String cardID, String yktywdh,JsonArray dataArr) throws Exception { ObjectResult orr=new ObjectResult(); //根据卡号判断分单信息 //循环批次号 如果没有分单 修改为分单和装车 Fd_Bsheet fdb=this.fbper.getbybsNo(StringUtils.isNotBlank(yktywdh)?yktywdh:""); String vehicleId=""; if(fdb==null){ orr.setCode(1); orr.setErrmsg("一卡通业务单未找到,请确认单号是否正确!"); return orr; }else{ if(fdb.getStatus()!=Serviceenum.在办){ orr.setCode(1); orr.setErrmsg("一卡通业务单不是在办状态,系统不做处理!"); return orr; } if(StringUtils.isBlank(cardID)){ orr.setCode(1); orr.setErrmsg("参数:一卡通卡号为空!"); return orr; } if(dataArr==null){ orr.setCode(1); orr.setErrmsg("参数:批次号为空!"); return orr; } Map mp=this.yktper.getcardinuse(cardID); if(mp==null){ throw new Exception("卡号不正确未找到在用卡!"); } vehicleId=mp.get("numberplates")==null?"":mp.get("numberplates").toString(); if(!vehicleId.equals(fdb.getVehicleId())){ orr.setCode(1); orr.setErrmsg("参数:卡号关联的车牌号和业务单关联的车牌号不一致"); return orr; } yktywdh=fdb.getBsNo(); } //检查是否装车完成 Map mmr=this.bsper.selectTaskTime(fdb.getBsNo()); try { if(mmr!=null&&mmr.get("zcWc")!=null&&Boolean.valueOf(mmr.get("zcWc").toString())) { orr.setCode(1); orr.setErrmsg("联系成品库办公室取消装车完成!"); return orr; } } catch (Exception e) { // TODO: handle exception } // Fd_Bsheet nr=this.fbper.getbyVehicleId(vehicleId, Serviceenum.在办); // if(nr==null){ // orr.setCode(1); // orr.setErrmsg("卡号:"+cardID+" 未找到在办销售发货单!"); // return orr; // } // Fd_Vehicle fdv=this.vhper.getByVehicleId(vehicleId); // if(fdv==null){ // orr.setCode(1); // orr.setErrmsg("车牌号:"+cardID+" 未录入车辆信息!"); // return orr; // } //现场过完毛重后出现扫码装车的,必须重新过磅 int grossNum=this.bsper.getgrosstDoc(vehicleId, fdb.getBsNo()); if(grossNum>0) { Map xstm=new HashMap(); xstm.put("canCm",false); xstm.put("businessNo",fdb.getBsNo()); this.bsper.updateCanCm(xstm); this.bsper.updatecanFb(vehicleId, fdb.getBsNo()); } for (JsonElement je : dataArr) { JsonObject jo=je.getAsJsonObject(); String tdmx_pch=jo.get("tdmx_pch").getAsString(); // Fd_XSTDMX tdmx=this.tdmxper.getbyPCH(tdmx_pch); Fd_XSTDMX tdmx=this.tdmxper.getbyPCHONE(tdmx_pch,vehicleId); if(tdmx == null) { String errMsg = "一卡通卸车失败,请查看【" + tdmx_pch +"】出库关闭标志!"; throw new Exception(errMsg); } // if(tdmx.getTdmx_zcbz()!=1){ //// throw new Exception("批次号:"+tdmx_pch+" 已经提交装车,不能重复提交装车!"); // continue; // } // Fd_XSTD xstd=this.tdper.get(tdmx.getTdmx_tdls()); // if(xstd==null){ // continue; // } //修改Fd_Bsheetitem表 这张表去掉了 this.fbper.delbsitem(tdmx.getTdmx_pch(), yktywdh); // //修改一卡通明细表bsitem // if(tdmx.getTdmx_zcbz()==0){ // continue; // } tdmx.setTdmx_zcbz(0); tdmx.setTdmx_zccph(null); tdmx.setTdmx_zcdriver(null); tdmx.setTdmx_zcphone(null); tdmx.setTdmx_zcwlgsName(null); this.tdmxper.updateZCnoFD(tdmx); } orr.setCode(0); orr.setErrmsg("取消装车操作成功!"); return orr; } @Override public ObjectResult> getcInfo(String cardID) { ObjectResult> orr=new ObjectResult>(); Map rem=new HashMap(); Map mp=this.yktper.getcardinuse(cardID); if(mp==null){ orr.setCode(1); orr.setErrmsg("卡号不正确未找到在用卡!"); return orr; } String vehicleId=mp.get("numberplates")==null?"":mp.get("numberplates").toString(); String type = (String)mp.get("type"); String sdepartNo = null; if(type.equals("外来车辆卡")) { sdepartNo = (String) mp.get("sdepartNo"); } List fd_bList = this.fbper.getListbyVehicleId(vehicleId, Serviceenum.在办); if (fd_bList == null||fd_bList.isEmpty()) { orr.setCode(1); orr.setErrmsg("车辆未找到在办分单!"); return orr; } Fd_Bsheet fd_b=null; if(fd_bList.size()>1) { for (Fd_Bsheet fd_Bsheet : fd_bList) { int wd=this.bsper.getweightDoc(vehicleId, fd_Bsheet.getBsNo()); if(wd>0) { fd_b=fd_Bsheet; break; } } if(fd_b==null) { orr.setCode(1); orr.setErrmsg("车辆:"+vehicleId+" 当前业务未找到绑定的过磅单,请先过磅或者重绑磅单!"); return orr; } }else { fd_b=fd_bList.get(0); int wcnum=this.bsper.getweightDoc(vehicleId, fd_b.getBsNo()); if(wcnum<=0){ orr.setCode(1); orr.setErrmsg("车辆:"+vehicleId+" 当前业务未找到绑定的过磅单,请先过磅或者重绑磅单!"); return orr; } } // 改成使用在用卡的卡号、车牌号码、厂区来确认是否有销售的业务单 btid=3 businesstype00002 String businessNo = bsper.getBusinessNoByCardNo(cardID,vehicleId,sdepartNo); if(StringUtils.isBlank(businessNo)) { orr.setCode(1); orr.setErrmsg("未找到该卡的在办业务单!"); return orr; } // List vxl=this.vhxper.getlistbyVehicleId(vehicleId); List vxl= this.vhxper.getlistbyVehicleIdandbsNoGp(vehicleId, businessNo); List> datamp=new ArrayList>(); Map xstdMap = new HashMap(); // 缓存Fd_XSTD,避免多查 for (Vehicle_XSTD vx : vxl) { String tdbh=vx.getXstdNo(); Fd_XSTD td=this.tdper.getbyTDBH(tdbh); String wlgsbh=vx.getCompanyNo(); Fd_Company fd_c=this.cmper.getByCompanyNo(wlgsbh); Map tdm=new HashMap(); if(fd_c!=null){ tdm.put("td_wlgs", fd_c.getName());//物流公司 }else{ tdm.put("td_wlgs", "");//物流公司 } if(td==null){ continue; } // List tdmxl=this.tdmxper.getbytdls(td.getTd_tdls()); List tdmxl= tdmxper.getListByTdlsAndCph(td.getTd_tdls(),vehicleId); if(tdmxl==null||tdmxl.size()<=0){ continue; } Map mm=new HashMap(); tdm.put("td_tdbh", td.getTd_tdbh()); tdm.put("td_tdls", td.getTd_tdls()); tdm.put("td_jylx", td.getTd_jylx()); Fd_XSTD fd_xstd = xstdMap.get(td.getTd_tdbh()); if(xstdMap.get(td.getTd_tdbh())==null) { // 保证同一个提单只查一遍 fd_xstd = tdper.getbyttdbh(td.getTd_tdbh()); } //增加客户名称 备注 if(StringUtils.isBlank(fd_xstd.getTd_fpbh())){ Nckh nckh = zsjper.getNckhbyCode(fd_xstd.getTd_khbh());// 客户不存在的特殊情况是不应该存在的,以防万一,加判空。 tdm.put("td_khmc",nckh!=null?nckh.getName():""); }else { String name = ConvertTool.covertToCustoms(fd_xstd.getTd_ywdybh()); tdm.put("td_khmc", name); } tdm.put("td_bz",fd_xstd.getTd_bz()); mm.put("td", tdm); mm.put("tdmx", tdmxl); datamp.add(mm); } rem.put("cph", vehicleId); rem.put("sjmc", fd_b.getDriver()); rem.put("dh", fd_b.getPhone()); // rem.put("sjmc", fdv.getDriver()); // rem.put("dh", fdv.getPhone()); rem.put("ywdh", fd_b.getBsNo()); rem.put("respcode", 111); rem.put("data", datamp); //修改装车记录 Map mr=this.bsper.selectTaskTime(fd_b.getBsNo()); if(mr!=null) { if(mr.get("firstzxhtime")!=null) { mr.put("lastzxhtime", new Date()); }else { mr.put("firstzxhtime", new Date()); } this.bsper.updateTaskTime(mr); }else { orr.setCode(1); orr.setErrmsg("未找到装车记录"); return orr; } orr.setCode(0); orr.setItem(rem); return orr; } @Override public ObjectResult> getxstdInfo(String xstdNo) { ObjectResult> orr=new ObjectResult>(); Fd_XSTD xstd=this.tdper.getbyTDBH(xstdNo); if(xstd==null){ orr.setCode(1); orr.setErrmsg("提单未找到!"); return orr; } Map rm=new HashMap(); List tdmxlist=this.tdmxper.getListbytdls(xstd.getTd_tdls()); rm.put("code", 0); rm.put("item", xstd); rm.put("itemList", tdmxlist); orr.setCode(0); orr.setItem(rm); return orr; } @Override @Transactional(rollbackFor=Exception.class) public ObjectResult savewdControl(JsonArray dataArr)throws Exception { ObjectResult orr=new ObjectResult(); if(dataArr==null){ orr.setCode(0); orr.setErrmsg("添加过磅控制成功!"); return orr; } for (JsonElement je : dataArr) { JsonObject jo=je.getAsJsonObject(); String bsNo=jo.get("yktywdh").getAsString(); BsheetEcgb be=this.beper.getbyNo(bsNo); if(be==null){ be=new BsheetEcgb(); be.setBsNo(bsNo); be.setCtime(new Date()); be.setCname("生产系统添加"); be.setSate(1); this.beper.insert(be); } } orr.setCode(0); orr.setErrmsg("添加过磅控制成功!"); return orr; } }