package com.mandi.fendan.service.impl; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.mandi.basicconfig.penum.PrefixEnum; import com.mandi.basicconfig.persist.Nckh; import com.mandi.common.*; import com.mandi.common.ParamFileter.Fileoperation; import com.mandi.common.ParamFileter.RegexCheck; import com.mandi.dao.common.Daomethod; import com.mandi.dao.common.ObjectResult; import com.mandi.dao.common.PageRequest; import com.mandi.dao.common.PageResult; import com.mandi.fendan.mapper.*; import com.mandi.fendan.persist.*; import com.mandi.fendan.service.IErpService; import com.mandi.fendan.util.Contants; import com.mandi.fendan.util.ConvertTool; import com.mandi.fendan.util.FdtoNc; import com.mandi.fendan.util.persist.*; import com.mandi.springmvc.logs.OpLogs; import com.mandi.system.persist.Login; import com.mandi.system.persist.ModuleEnum; import com.mandi.system.persist.UserType; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.log4j.Logger; import org.apache.poi.util.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; @Service public class ErpService implements IErpService { private Logger log = Logger.getLogger(ErpService.class); @Resource(name = "dtf") private SimpleDateFormat sdf; @Resource(name = "ydf") private SimpleDateFormat ydf; @Resource(name = "df") private SimpleDateFormat df; @Resource private Fd_BsheetMapper fdbsper; @Resource private Fd_VehicleMapper vhper; @Resource private VehicleXSTDMapper vhxper; @Resource private Fd_CompanyMapper fdcper; @Resource private Fd_ComVehicleMapper fdvcper; @Resource private Fd_XSTDMapper tdper; @Resource private Fd_XSTDMXMapper tdmxper; @Resource private Fd_GbxstdMapper gbtdper; @Resource private Fd_GbxstdmxMapper gbtdmxper; @Resource private Fd_fhdqMapper dqper; @Resource private BusinessMapper bsper; @Resource private Fd_YKTMapper yktmper; @Resource private FdtoNc fdtonc; @Resource private fd_errsheetMapper errPer; @Resource private FdMxWlgsMapper fdMxWlgsMapper; @Resource private SqlSessionFactory sqlSessionFactory; @Override public ObjectResult tzPrint(Login lg, String bssNo, String ipadd) { ObjectResult orr = new ObjectResult(); if (lg == null) { orr.setCode(1); orr.setErrmsg("请登录账号!"); return orr; } if (StringUtils.isEmpty(bssNo)) { orr.setCode(1); orr.setErrmsg("业务参数为空!"); return orr; } Fd_Bsheet fd_b = this.fdbsper.getbybsNo(bssNo);// this.fdbsper.getbyVehicleId(vehicleId, Serviceenum.在办); if (fd_b == null) { orr.setCode(1); orr.setErrmsg("车辆业务单未找到,不能打印!"); return orr; } if (fd_b.getStatus() != Serviceenum.在办) { orr.setCode(1); orr.setErrmsg("车辆业务单不是在办状态,不能打印!"); return orr; } String comNo = ""; if (!UserType.admin.toString().equals(lg.getWorkerno())) { // List // ll=this.vhxper.getlistbyVehandcompanyNo(vehicleId,lg.getDepartno()); // if(ll!=null){ // for (Vehicle_XSTD vhx : ll) { // if(StringUtils.isEmpty(comNo)){ // comNo+=vhx.getXstdNo(); // }else{ // comNo+=(","+vhx.getXstdNo()); // } // } // } if (StringUtils.isNotBlank(lg.getDepartno())) { comNo = lg.getDepartno(); } } // Map mp=this.bsper.getBsheet(fd_b.getBsNo()); // if(mp==null){ // orr.setCode(1); // orr.setErrmsg("业务单未找到!"); // return orr; // } String dyAdd = this.bsper.getUsedbyAdd(); if (StringUtils.isBlank(dyAdd)) { orr.setCode(1); orr.setErrmsg("系统未设置打印地址!"); return orr; } try { orr.setItem("http://" + dyAdd + Contants.GYPrintAdd + "&vehicleId=" + URLEncoder.encode(fd_b.getVehicleId(), "utf-8") + "&bsNo=" + fd_b.getBsNo() + "&phone=" + fd_b.getPhone() + "&comNo=" + comNo); // log.info("::::::::::;"+orr.getItem()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } orr.setCode(0); return orr; } // 暂时没有使用 public PageResult> getBillofLadingList(Login lg, String type, String searchStr, String companyNo, Date sdate, Date edate, int wcSign, PageRequest pr, String sortStr, String cqNo) { PageResult> prr = new PageResult>(); // 销售提单查询值不为空 if (lg == null) { prr.setCode(1); prr.setErrmsg("请登录账号!"); return prr; } if (StringUtils.isEmpty(companyNo)) { if (!UserType.admin.toString().equals(lg.getWorkerno())) { companyNo = lg.getDepartno(); } } if (pr == null) { pr = new PageRequest(0, 30, null); pr.setNeedPages(true); } // 查询参数 Map pmp = new HashMap(); // 查询值 type if (StringUtils.isNotBlank(searchStr)) { pmp.put(type, searchStr); } if (sdate != null) { Date now = new Date(); Calendar theCa = Calendar.getInstance(); theCa.setTime(now); theCa.add(Calendar.DATE, -Contants.XSTDlastSearchday); Date csdate = theCa.getTime(); if (csdate.after(sdate)) { sdate = csdate; } pmp.put("sdate", df.format(sdate)); } else { Date now = new Date(); Calendar theCa = Calendar.getInstance(); theCa.setTime(now); theCa.add(Calendar.DATE, -Contants.XSTDlastSearchday); sdate = theCa.getTime(); pmp.put("sdate", df.format(sdate)); } if (edate != null) { pmp.put("edate", df.format(edate)); } if (!StringUtils.isEmpty(companyNo)) { pmp.put("companyNo", companyNo); Fd_Company fdc = this.fdcper.getByCompanyNo(companyNo); if (fdc != null) { pmp.put("ztbz", fdc.isHasSPR() ? 1 : 0); } } pmp.put("page", pr.getStart()); pmp.put("pagesize", pr.getPageSize()); pmp.put("wcSign", wcSign); if(StringUtils.isNotBlank(cqNo)) pmp.put("cqV", cqNo); // 排序字段 pmp.put("sort", sortStr); if (pr.isNeedPages()) { int count = this.tdper.countPage(pmp); int pages = Daomethod.countpages(count, pr.getPageSize()); prr.setPages(pages); } List l = this.tdper.getList(pmp); List> rl = new ArrayList>(); if (l != null) { for (WaitXSTD wt : l) { String fhdqbh = wt.getTd_shddbh(); String ztbz = wt.getTd_ztbz(); Map mm = new HashMap(); try { mm = BeanUtils.describe(wt); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { prr.setCode(1); prr.setErrmsg("对象转Map出错,出错提单编号::" + wt.getTd_tdbh()); return prr; } if (!"自提".equals(ztbz)) { /*List fcl = this.dqper.getCbyNoandsNo(fhdqbh, wt.getTd_ywdybh(), *//*wt.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ : wt.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*//* ConvertTool.ncGetDefault(wt.getTd_ywdybh()) ); if (fcl != null) { for (Fd_Company fdc : fcl) { if (StringUtils .isNotBlank(mm.get("companyNo") == null ? "" : mm.get("companyNo").toString())) { mm.put("companyName", mm.get("companyName") + "," + fdc.getName()); mm.put("companyNo", mm.get("companyNo") + "," + fdc.getCompanyNo()); } else { mm.put("companyName", fdc.getName()); mm.put("companyNo", fdc.getCompanyNo()); } } }*/ } try { mm.put("td_wfdsl", wt.getTd_wfdsl()); mm.put("td_wfdzl", BigDecimalfiter.addscal(0, wt.getTd_wfdzl(), Contants.scale)); } catch (Exception e) { // TODO: handle exception } rl.add(mm); } } prr.setCode(0); prr.setList(rl); return prr; } @Override public PageResult> getXSTDList(Login lg, String type, String searchStr, String companyNo, Date sdate, Date edate, int wcSign, String fdAdmin,PageRequest pr, String sortStr, String cqNo) { PageResult> prr = new PageResult>(); // 销售提单查询值不为空 if (lg == null) { prr.setCode(1); prr.setErrmsg("请登录账号!"); return prr; } // 如果是管理员或者非提单更物流公司的操作 boolean isAdminOrFdAdmin = UserType.admin.toString().equals(lg.getWorkerno()) || StringUtils.isNotBlank(fdAdmin); if (StringUtils.isEmpty(companyNo)) { if (!isAdminOrFdAdmin) { // 如果不是更改车辆分单管理员和也不是系统管理员,需要加上公司no companyNo = lg.getDepartno(); } } if (pr == null) { pr = new PageRequest(0, 30, null); pr.setNeedPages(true); } // 查询参数 Map pmp = new HashMap(); // 查询值 type if (StringUtils.isNotBlank(searchStr)) { pmp.put(type, searchStr); } if (sdate != null) { Date now = new Date(); Calendar theCa = Calendar.getInstance(); theCa.setTime(now); theCa.add(Calendar.DATE, -Contants.XSTDlastSearchday); Date csdate = theCa.getTime(); if (csdate.after(sdate)) { sdate = csdate; } pmp.put("sdate", df.format(sdate)); } else { Date now = new Date(); Calendar theCa = Calendar.getInstance(); theCa.setTime(now); theCa.add(Calendar.DATE, -Contants.XSTDlastSearchday); sdate = theCa.getTime(); pmp.put("sdate", df.format(sdate)); } if (edate != null) { pmp.put("edate", df.format(edate)); } if (!StringUtils.isEmpty(companyNo)) { pmp.put("companyNo", companyNo); Fd_Company fdc = this.fdcper.getByCompanyNo(companyNo); if (fdc != null) { pmp.put("ztbz", fdc.isHasSPR() ? 1 : 0); } } pmp.put("page", pr.getStart()); pmp.put("pagesize", pr.getPageSize()); pmp.put("wcSign", wcSign); pmp.put("fdAdmin", fdAdmin); if(StringUtils.isNotBlank(cqNo)) pmp.put("cqV", cqNo); // 排序字段 pmp.put("sort", sortStr); if (pr.isNeedPages()) { int count = this.tdper.countPage(pmp); int pages = Daomethod.countpages(count, pr.getPageSize()); prr.setPages(pages); } List l = this.tdper.getList(pmp); List> rl = new ArrayList>(); if (l != null) { for (WaitXSTD wt : l) { String fhdqbh = wt.getTd_shddbh(); String ztbz = wt.getTd_ztbz(); Map mm = new HashMap(); try { mm = BeanUtils.describe(wt); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { prr.setCode(1); prr.setErrmsg("对象转Map出错,出错提单编号::" + wt.getTd_tdbh()); return prr; } if (!"自提".equals(ztbz)) { /*List fcl = this.dqper.getCbyNoandsNo(fhdqbh, wt.getTd_ywdybh(), wt.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ : *//*wt.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*//* ConvertTool.ncGetDefault(wt.getTd_ywdybh()) ); if (fcl != null) { for (Fd_Company fdc : fcl) { if (StringUtils .isNotBlank(mm.get("companyNo") == null ? "" : mm.get("companyNo").toString())) { mm.put("companyName", mm.get("companyName") + "," + fdc.getName()); mm.put("companyNo", mm.get("companyNo") + "," + fdc.getCompanyNo()); } else { mm.put("companyName", fdc.getName()); mm.put("companyNo", fdc.getCompanyNo()); } } }*/ } try { mm.put("td_wfdsl", wt.getTd_wfdsl()); mm.put("td_wfdzl", BigDecimalfiter.addscal(0, wt.getTd_wfdzl(), Contants.scale)); } catch (Exception e) { // TODO: handle exception } rl.add(mm); } } prr.setCode(0); prr.setList(rl); return prr; } @Override public PageResult> getCloseXSTDlist(Login lg, String type, String searchStr, String companyNo, Date sdate, Date edate, int wcSign, PageRequest pr, List sortc) { // type 只有两种类型 提单编号/关闭人 sdate 关闭开始时间 edate 关闭结束时间 companyNo 运输公司 查询值 PageResult> prr = new PageResult>(); if (lg == null) { prr.setCode(1); prr.setErrmsg("请登录账号!"); return prr; } if (pr == null) { pr = new PageRequest(0, 30, null); pr.setNeedPages(true); } Map pmp = new HashMap(); pmp.put("page", pr.getStart()); pmp.put("pagesize", pr.getPageSize()); if (sdate != null) { pmp.put("stime", sdate); } if (edate != null) { pmp.put("etime", edate); } if (UserType.admin.toString().equals(lg.getWorkerno())) { if (!StringUtils.isEmpty(companyNo)) { pmp.put("companyNo", companyNo); } } else { Fd_Company fdc = this.fdcper.getByCompanyNo(lg.getDepartno()); if (fdc != null) { if (fdc.isHasSPR()) { pmp.put("isHSR", true); } else { pmp.put("companyNo", lg.getDepartno()); } } else { pmp.put("companyNo", "aaaaa"); } } // 提单号 模糊查询 if (StringUtils.isNotBlank(searchStr)) { pmp.put(type, searchStr); } // if(!StringUtils.isEmpty(searchStr)&&"tdbh".equals(type)){ // if(!StringUtils.isEmpty(searchStr)){ // pmp.put("tdbh", searchStr); // } // }else if(){ // if(!StringUtils.isEmpty(searchStr)){ // pmp.put("td_gbr", searchStr); // } // }else if (pr.isNeedPages()) { int count = gbtdper.counts(pmp); int pages = Daomethod.countpages(count, pr.getPageSize()); prr.setPages(pages); } List llc = this.fdcper.getall(); Map fdcmp = new HashMap(); if (llc != null) { for (Fd_Company fd_Company : llc) { fdcmp.put(fd_Company.getCompanyNo() + "", fd_Company.getName()); } } List> tdl = gbtdper.getList(pmp); // List> rel=new ArrayList>(); // if(tdl!=null){ // for (Fd_Gbxstd gbtd : tdl) { // Map rmp=this.tdper.getGBXSTD(gbtd.getXstdNo()); // rel.add(rmp); // } // } List> rl = new ArrayList>(); if (tdl != null) { for (Map wt : tdl) { String fhdqbh = wt.get("td_shddbh") == null ? "" : wt.get("td_shddbh").toString(); String td_ywdybh = wt.get("td_ywdybh") == null ? "" : wt.get("td_ywdybh").toString(); // String td_tdbh=wt.get("td_tdbh")==null?"":wt.get("td_tdbh").toString(); String ztbz = wt.get("td_ztbz") == null ? "" : wt.get("td_ztbz").toString(); Map mm = wt; mm.put("companyName", ""); mm.put("companyNo", ""); // try { // mm=BeanUtils.describe(wt); // } catch (IllegalAccessException | InvocationTargetException| // NoSuchMethodException e) { // prr.setCode(1); // prr.setErrmsg("对象转Map出错,出错提单编号::"+td_tdbh); // return prr; // } if (!"自提".equals(ztbz)) { /*List fcl = this.dqper.getCbyNoandsNo(fhdqbh, td_ywdybh, *//*td_ywdybh.equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ : td_ywdybh.equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*//* ConvertTool.ncGetDefault(td_ywdybh) );// getCbyNo(fhdqbh); if (fcl != null) { for (Fd_Company fdc : fcl) { if (StringUtils .isNotBlank(mm.get("companyNo") == null ? "" : mm.get("companyNo").toString())) { mm.put("companyName", mm.get("companyName") + "," + fdc.getName()); mm.put("companyNo", mm.get("companyNo") + "," + fdc.getCompanyNo()); } else { mm.put("companyName", fdc.getName()); mm.put("companyNo", fdc.getCompanyNo()); } } }*/ } // try { // mm.put("td_wfdsl",wt.getTd_wfdsl()); // mm.put("td_wfdzl",BigDecimalfiter.addscal(0, wt.getTd_wfdzl(), // Contants.scale)); // } catch (Exception e) { // // TODO: handle exception // } rl.add(mm); } } prr.setCode(0); prr.setList(rl); return prr; } /** * @param lg * @param XSTD * @return */ @Override public Map getXSTD(Login lg, String XSTD) { Map mp = new HashMap(); if (lg == null) { mp.put("code", 1); mp.put("errmsg", "请登录账号!"); return mp; } if (StringUtils.isBlank(XSTD)) { mp.put("code", 1); mp.put("errmsg", "查询值:提单号 为空!"); return mp; } Fd_XSTD xstd = this.tdper.getbyttdbh(XSTD); if (xstd == null) { mp.put("code", 1); mp.put("errmsg", "提单查询为空!"); return mp; } String companyNo = null; if (!UserType.admin.toString().equals(lg.getWorkerno())) { Fd_Company fdc = this.fdcper.getByCompanyNo(lg.getDepartno()); companyNo = fdc.getCompanyNo(); } String shdqbh = xstd.getTd_shddbh(); // 自提 if (xstd.getTd_ztbz() == 2) { if (!UserType.admin.toString().equals(lg.getWorkerno())) { Fd_Company fdc = this.fdcper.getByCompanyNo(lg.getDepartno()); if (fdc != null) { if (!fdc.isHasSPR()) { mp.put("code", 1); mp.put("errmsg", "没有查看该提单的权限!"); return mp; } } else { mp.put("code", 1); mp.put("errmsg", "物流公司未找到!"); return mp; } } } else { if (!UserType.admin.toString().equals(lg.getWorkerno())) { Fd_wlgs_fhdq ccr = this.dqper.getbyNos(lg.getDepartno(), shdqbh, /*xstd.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ: xstd.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*/ ConvertTool.ncGetDefault(xstd.getTd_ywdybh()) ); // 这个地方改一下,允许fd_mx_wlgs中存在的单查看 int total = fdMxWlgsMapper.selectCountByTdTdls(xstd.getTd_tdls()); if (ccr == null && total == 0) { mp.put("code", 1); mp.put("errmsg", "没有查看该提单的权限!"); return mp; } } } // 编号转名字 // 转watiXSTD对象 // 查找明细:未装车 // 过滤掉已经配车并且配车车辆不是该公司的: 虽然两个物流公司可以使用同一个销售发货单,但是两个物流公司的分单时间是错开的 WaitXSTD wxt = this.tdper.getWaitXSTD(XSTD); Map mxpmp = new HashMap(); // 过滤条件 mxpmp.put("tdls", wxt.getTd_tdls()); mxpmp.put("zcbz", 0); mxpmp.put("pagesize", 0); mxpmp.put("page", 0); if(StringUtils.isNotBlank(companyNo)) { mxpmp.put("companyNo", companyNo); } List> XSTDMX_list = this.tdmxper.getList(mxpmp); mp.put("code", 0); mp.put("item", wxt); mp.put("list", XSTDMX_list); return mp; } @Override public Map getBillofLadingXSTD(Login lg,String XSTD){ String companyNo = null; boolean isFdAdmin = lg.isFdAdmin(); // 是否为管理员或分单管理员 boolean isAdminOrFdAdmin = UserType.admin.toString().equals(lg.getWorkerno()) || isFdAdmin; if (!isAdminOrFdAdmin) { Fd_Company fdc = this.fdcper.getByCompanyNo(lg.getDepartno()); companyNo = fdc.getCompanyNo(); } Map mp = new HashMap(); if (lg == null) { mp.put("code", 1); mp.put("errmsg", "请登录账号!"); return mp; } if (StringUtils.isBlank(XSTD)) { mp.put("code", 1); mp.put("errmsg", "查询值:提单号 为空!"); return mp; } Fd_XSTD xstd = this.tdper.getbyttdbh(XSTD); if (xstd == null) { mp.put("code", 1); mp.put("errmsg", "提单查询为空!"); return mp; } String shdqbh = xstd.getTd_shddbh(); // 自提 if (xstd.getTd_ztbz() == 2) { if (!isAdminOrFdAdmin) { Fd_Company fdc = this.fdcper.getByCompanyNo(lg.getDepartno()); if (fdc != null) { if (!fdc.isHasSPR()) { mp.put("code", 1); mp.put("errmsg", "没有查看该提单的权限!"); return mp; } } else { mp.put("code", 1); mp.put("errmsg", "物流公司未找到!"); return mp; } } } else { if (!isAdminOrFdAdmin) { Fd_wlgs_fhdq ccr = this.dqper.getbyNos(lg.getDepartno(), shdqbh, /*xstd.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ: xstd.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*/ ConvertTool.ncGetDefault(xstd.getTd_ywdybh()) ); int total = fdMxWlgsMapper.selectCountByTdTdls(xstd.getTd_tdls()); if (ccr == null && total == 0) { mp.put("code", 1); mp.put("errmsg", "没有查看该提单的权限!"); return mp; } } } // 编号转名字 // 转watiXSTD对象 // 查找明细:未装车 // 过滤掉已经配车并且配车车辆不是该公司的: 虽然两个物流公司可以使用同一个销售发货单,但是两个物流公司的分单时间是错开的 WaitXSTD wxt = this.tdper.getWaitXSTD(XSTD); Map mxpmp = new HashMap(); // 过滤条件 mxpmp.put("tdls", wxt.getTd_tdls()); // 已经装车的也要显示,方便调整 // mxpmp.put("zcbz", 0); mxpmp.put("pagesize", 0); mxpmp.put("page", 0); if(StringUtils.isNotBlank(companyNo)) { mxpmp.put("companyNo", companyNo); } List> XSTDMX_list = this.tdmxper.getList(mxpmp); mp.put("code", 0); mp.put("item", wxt); mp.put("list", XSTDMX_list); return mp; } @Override public PageResult> getFdlist(Login lg, String companyNo, String vehicleId, PageRequest pr, String cqV) { PageResult> prr = new PageResult>(); if (pr == null) { pr = new PageRequest(0, 30, null); pr.setNeedPages(true); } if (lg == null) { prr.setCode(1); prr.setErrmsg("请登录账号!"); return prr; } Map mp = new HashMap(); // 按公司划分 String crc = ""; if (StringUtils.isNotBlank(companyNo)) { mp.put("companyNo", companyNo); crc = companyNo; } else { if (lg.getWorkerno().equals(UserType.admin.toString())) { mp.put("companyNo", ""); crc = ""; } else { mp.put("companyNo", lg.getDepartno()); crc = lg.getDepartno(); } } if (!StringUtils.isEmpty(vehicleId)) { mp.put("vehicleId", vehicleId); } mp.put("pagesize", pr.getPageSize()); mp.put("page", pr.getStart()); if(StringUtils.isNotBlank(cqV)) { mp.put("cqV",/*Contants.nc_ywdy_ZZ.equals(cqV)?Contants.zzSdepartNo: Contants.nc_ywdy_MS.equals(cqV)?Contants.msSdepartNo:Contants.kjSdepartNo*/ ConvertTool.ncCovertToYkt(cqV) ); } if (pr.isNeedPages()) { int count = bsper.getbspages(mp); int pages = Daomethod.countpages(count, pr.getPageSize()); prr.setPages(pages); } List> list = bsper.getbslist(mp); List> relist = new ArrayList>(); if (list != null && list.size() > 0) { List vxlist = StringUtils.isBlank(crc) ? this.vhxper.getlistAll() : this.vhxper.getlistbycomNo(crc); // List cl=this.vhxper.getAllCom(); for (Map map : list) { Map remp = map; String bsNo = remp.get("bussinessNo") + ""; String vc = remp.get("vehicleId") + ""; // 销售分单值: 本单位分单数量和重量 其他单位分车数量和重量 if (vxlist != null) { for (Vehicle_XSTD vehicle_XSTD : vxlist) { try { if (vehicle_XSTD.getVehicleId().equals(vc)) { remp.put("fdCnum", Integer.parseInt( remp.get("fdCnum") == null ? "0" : remp.get("fdCnum").toString()) + vehicle_XSTD.getFd_num()); remp.put("fdCweight", BigDecimalfiter.addscal( Double.parseDouble( remp.get("fdCweight") == null ? "0" : remp.get("fdCweight").toString()), vehicle_XSTD.getFd_weight(), 4)); if (lg.getDepartno() != null && lg.getDepartno().equals(vehicle_XSTD.getCompanyNo())) { remp.put("fdnum", Double.parseDouble( remp.get("fdnum") == null ? "0" : remp.get("fdnum").toString()) + vehicle_XSTD.getFd_num()); remp.put("fdweight", BigDecimalfiter.addscal( Double.parseDouble(remp.get("fdweight") == null ? "0" : remp.get("fdweight").toString()), vehicle_XSTD.getFd_weight(), 4)); } } } catch (Exception e) { prr.setCode(1); prr.setErrmsg("数据转换错误,请刷新页面重新获取数据!"); return prr; } } } // 销售分单单位值: List cl = vhxper.getCompany(vc, bsNo); if (cl != null && cl.size() > 1) { remp.remove("companyName"); remp.remove("companyNo"); for (Fd_Company fd_Company : cl) { remp.put("companyName", fd_Company.getName() + (remp.get("companyName") == null ? "" : "," + remp.get("companyName").toString())); remp.put("companyNo", fd_Company.getCompanyNo() + (remp.get("companyNo") == null ? "" : "," + remp.get("companyNo").toString())); } } relist.add(remp); } } prr.setCode(0); prr.setList(relist); return prr; } @Override @Transactional public ObjectResult delFdsheet(Login lg, String bsNo) throws Exception{ ObjectResult or = new ObjectResult(); if (lg == null) { or.setCode(1); or.setErrmsg("请登录账号!"); return or; } if (UserType.admin.toString().equals(lg.getWorkerno())) { or.setCode(1); or.setErrmsg("管理员不能执行分单操作!"); return or; } Fd_Company fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { or.setCode(1); or.setErrmsg("登录账号所属的物流公司不存在!"); return or; } Fd_Bsheet fb = fdbsper.getbybsNo(bsNo); if (fb == null) { or.setCode(1); or.setErrmsg("分单业务单未找到!"); return or; } if (fb.getStatus() != Serviceenum.在办) { or.setCode(1); or.setErrmsg("分单业务单状态不是在办状态!"); return or; } String vehicleId = fb.getVehicleId(); Fd_Vehicle fdv = vhper.getByVehicleId(vehicleId); if (fdv == null) { or.setCode(1); or.setErrmsg("分单系统未找到车牌号:" + vehicleId + " 车辆信息!"); return or; } int zcsl = this.tdmxper.getbyBsNowith(bsNo,vehicleId); if (zcsl > 0) { or.setCode(1); or.setErrmsg("该车已经扫码装车,请先联系成品库删除装车记录并解绑磅单!"); return or; } int wdNum = this.bsper.getweightDoc(vehicleId, bsNo); if (wdNum > 0) { or.setCode(1); or.setErrmsg("车辆:" + vehicleId + " 已经过磅,请先联系成品库解绑磅单!"); return or; } List fdvcl = this.vhxper.getlistbyVehicleIdandbsNoGp(vehicleId, bsNo); // 判断是否删除业务单:如果两个物流公司使用同一辆车,不删除业务单,只修改该物流公司分单的信息 String sdNo = fb.getSdepartNo(); boolean delYWD = true; List vxl = new ArrayList(); if (fdvcl != null) { for (Vehicle_XSTD vhxstd : fdvcl) { // 同一个业务单 if (bsNo.equals(vhxstd.getBsNo())) { if (lg.getDepartno().equals(vhxstd.getCompanyNo())) { vxl.add(vhxstd); } else { delYWD = false; } } } } else { or.setCode(1); or.setErrmsg("该业务单未找到分单记录!"); return or; } // 发送NC List tdl = new ArrayList(); Map> mxMp = new HashMap>(); if (vxl != null && vxl.size() > 0) { Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(),"取消配车业务单 vheicle_xstd ::" + Jacksonmethod.tojson(vxl, false)); for (Vehicle_XSTD VX : vxl) { String xstdNo = VX.getXstdNo(); List mxl = new ArrayList(); Fd_XSTD xstd = this.tdper.getbyTDBH(xstdNo); List MXL = this.tdmxper.getbyBsNoandcmNo(xstd.getTd_tdls(), bsNo, lg.getDepartno()); double ZZL = 0; int ZZS = 0; for (Fd_XSTDMX MX : MXL) { // // 已经关闭的不做处理 // if (MX.getTdmx_gbbz() != 0) { // continue; // } // 没有分单的跳过 // if (MX.getTdmx_fdbz() == 0) { // MX.setTdmx_fdcph(null); // MX.setTdmx_fdwlgsbh(null); // MX.setTdmx_fdywbh(null); // this.tdmxper.updateFD(MX); // continue; // } // 已经装车的不做处理 // if (MX.getTdmx_zcbz() != 0) { // or.setCode(1); // or.setErrmsg("提单:" + xstd.getTd_tdbh() + " 明细:" + MX.getTdmx_pch() + " 已经装车不能取消配车!"); // return or; // } // 提单流水号 ZZL = BigDecimalfiter.addscal(ZZL, MX.getTdmx_mz(), Contants.scale); ZZS++; MX.setTdmx_fdbz(0); MX.setTdmx_fdcph(null); MX.setTdmx_fdwlgsbh(null); MX.setTdmx_fdywbh(null); // this.tdmxper.updateFD(MX); mxl.add(MX); } this.tdmxper.updatebyBsNoandcmNo(xstd.getTd_tdls(), bsNo, lg.getDepartno()); this.vhxper.delbyIDs(vehicleId, xstdNo, lg.getDepartno()); xstd.setTd_wfdsl(xstd.getTd_wfdsl() + ZZS); xstd.setTd_wfdzl(BigDecimalfiter.addscal(xstd.getTd_wfdzl(), ZZL, Contants.scale)); this.tdper.updateFD(xstd); if (ZZS > 0) { tdl.add(xstd); mxMp.put(xstdNo, mxl); } } } else { Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "取消配车业务单 vehicleId ::" + vehicleId + "::::dNo::::" + lg.getDepartno()); sdNo = fb.getSdepartNo(); } if (StringUtils.isBlank(sdNo)) { or.setCode(1); or.setErrmsg("业务单元未找到不能删除一卡通业务单"); return or; } this.fdvcper.del(vehicleId, lg.getDepartno(), fb.getSdepartNo()); // 发送NC系统删除分单信息 if (tdl != null && tdl.size() > 0) { Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "取消配车业务单 请求提单 ::" + Jacksonmethod.tojson(tdl, false)); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "取消配车业务单 请求提单明细 ::" + Jacksonmethod.tojson(mxMp, false)); String fdhx = this.fdtonc.getNcdata(tdl, mxMp); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "取消配车业务单 请求参数 ::" + fdhx); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.NCfdhx_url, fdhx); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "取消配车业务单 返回值 ::" + joADDYWD); if (joADDYWD == null || JSONobj.getint(joADDYWD, "code") != 0) { throw new Exception( (joADDYWD.get("msg")==null||StringUtils.isBlank(joADDYWD.get("msg").getAsString())) ? "分单回写NC系统出错!" : joADDYWD.get("msg").getAsString()); } else { String restult = joADDYWD.get("result").getAsString(); JsonParser jp = new JsonParser(); JsonObject jr = jp.parse(restult).getAsJsonObject(); if (jr == null || JSONobj.getint(jr, "respcode") != 111) { throw new Exception(jr.get("respmsg").getAsString()); } } } if (delYWD) { if (fdv.getType() == VehicleType.临时车) { Fd_Bsheet fdbb=this.fdbsper.getbyVehicleWithNoSdepartNo(vehicleId, fb.getSdepartNo()); if(fdbb==null) this.vhper.delByVehicleId(vehicleId); } else { fdv.setStatus(VehicleStatus.未配车); this.vhper.update(fdv); } this.fdbsper.delbybsNo(bsNo); // 发送一卡通服务删除表头信息 JsonObject jo = new JsonObject(); jo.addProperty("bussinessNo", bsNo); jo.addProperty("sdepartNo", sdNo); JsonObject pfob = Wxhtmethod.postJsonStr(Contants.YKTdelYwd_url, jo.toString()); int code = JSONobj.getint(pfob, "code"); if (code != 0) { throw new Exception(JSONobj.getstring(pfob, "errmsg")); } } or.setCode(0); or.setItem(true); return or; } @Override public PageResult getVehicleDetails(Login lg, String bsNo) { PageResult pr = new PageResult(); if (lg == null) { pr.setCode(1); pr.setErrmsg("请登录账号!"); return pr; } if (StringUtils.isBlank(bsNo)) { pr.setCode(1); pr.setErrmsg("查询参数不能为空!"); return pr; } Fd_Bsheet fb = this.fdbsper.getbybsNo(bsNo);// fdbsper.getbyVehicleId(vehicleId,Serviceenum.在办); if (fb == null) { pr.setCode(1); pr.setErrmsg("该车辆没有在办的业务单!"); return pr; } if (fb.getStatus() != Serviceenum.在办) { pr.setCode(1); pr.setErrmsg("车辆业务单不是在办状态,不能打印!"); return pr; } Fd_Company fdc = null; List mxl = new ArrayList(); if (!UserType.admin.toString().equals(lg.getWorkerno())) { fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { pr.setCode(1); pr.setErrmsg("物流公司不存在!"); return pr; } // 直接根据业务单号 车牌号 分单标志查找 fd_xstdmx表 mxl = this.tdmxper.getwaitMXbyBsNoandcmNo(fb.getBsNo(), lg.getDepartno()); } else { mxl = this.tdmxper.getwaitMXbyBsNo(fb.getBsNo()); } pr.setCode(0); pr.setList(mxl); return pr; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult doBindByList(Login lg, String tdlist, String vehicleInfo) throws Exception { ObjectResult orr = new ObjectResult(); if (StringUtils.isBlank(tdlist)) { orr.setCode(1); orr.setErrmsg("提单编号参数为空!"); return orr; } if (StringUtils.isBlank(vehicleInfo)) { orr.setCode(1); orr.setErrmsg("车辆信息参数为空!"); return orr; } if (lg == null) { orr.setCode(1); orr.setErrmsg("账号未登录,请登录账号!"); return orr; } if (UserType.admin.toString().equals(lg.getWorkerno())) { orr.setCode(1); orr.setErrmsg("管理员账号没有分单权限!"); return orr; } Fd_Company fdc = null; if (StringUtils.isNotBlank(lg.getDepartno())) { fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { orr.setCode(1); orr.setErrmsg("登录账号没有配置物流公司,请联系管理员配置!"); return orr; } } JsonParser jp = new JsonParser(); Fd_Vehicle fdv1 = new Fd_Vehicle(); // 检查车辆信息 try { JsonElement je = jp.parse(vehicleInfo); JsonObject jo = je.getAsJsonObject(); String vehicleId =JSONobj.getstring(jo, "vehicleId")==null?"": JSONobj.getstring(jo, "vehicleId").trim().toUpperCase(); String driver = JSONobj.getstring(jo, "driver"); String phone = JSONobj.getstring(jo, "phone"); double vehicleweight = JSONobj.getdouble(jo, "vehicleweight"); double loadweight = JSONobj.getdouble(jo, "loadweight"); String feature = JSONobj.getstring(jo, "feature"); String note = JSONobj.getstring(jo, "note"); String IDNum = JSONobj.getstring(jo, "IDNum"); if (StringUtils.isBlank(vehicleId) || StringUtils.isBlank(driver) || StringUtils.isBlank(IDNum) || StringUtils.isBlank(phone)) { orr.setCode(1); orr.setErrmsg("车辆信息必填项:车牌号,司机姓名,身份证号,手机号不能为空!"); return orr; } fdv1.setCompanyNo(lg.getDepartno()); fdv1.setDriver(driver); fdv1.setFeature(feature); fdv1.setId(UUID.randomUUID() + ""); fdv1.setIDNum(IDNum); fdv1.setLoadweight(loadweight); fdv1.setNote(note); fdv1.setPhone(phone); fdv1.setState(true); fdv1.setStatus(VehicleStatus.未配车); fdv1.setType(VehicleType.临时车); fdv1.setVehicleId(vehicleId); fdv1.setVehicleweight(vehicleweight); } catch (Exception e) { orr.setCode(1); orr.setErrmsg("车辆信息解析出错,请重新操作!"); return orr; } String Rcompany = "";// 收货单位 String bsDE = "";// 系统部门 String ziti = "";// 是否自提 List tdl = new ArrayList(); //校验提单信息数据是否合法:1.提单是否存在 2.当前账号是否可以操作该提单 JsonArray tdja = jp.parse(tdlist).getAsJsonArray(); for (JsonElement tdje : tdja) { String tdNo = tdje.getAsString(); if (StringUtils.isNotBlank(tdNo)) { Fd_XSTD td = this.tdper.getbyTDBH(tdNo); if (td == null || td.getTd_wfdsl()<=0 ) { continue; } // 这一块是判断用户有没有这个提单的操作权限 : //1.在页面获取提单列表的时候已经加过校验,同一厂区的提单可以同时显示不同厂区的提单不能同时显示,用户只能同时操作同一厂区的提单 //当前用户只能看到可以操作的提单 不可以操作的提单看不到 //所有以下else操作去掉 if (StringUtils.isBlank(bsDE)) { bsDE = ConvertTool.ncCovertToYkt(td.getTd_cqNo()); } if (StringUtils.isBlank(ziti)) { ziti = td.getTd_ztbz() == 2 ? "自提" : "非自提"; } if (StringUtils.isBlank(Rcompany)) { Map mm = this.dqper.getKH(td.getTd_khbh()); /* * 1、外贸有发票编号,内贸没有发票编号 * 2、内贸取实际公司名称,外贸取相应组织的公司简称+‘报关’ * */ if (StringUtils.isBlank(td.getTd_fpbh())) { if (mm != null) { Rcompany = mm.get("name") == null ? "" : mm.get("name").toString(); } if(mm == null || mm.size() == 0) { // 客户必须存在,否则无法分单 orr.setCode(1); orr.setErrmsg("该提单客户不存在,请检查数据!"); return orr; } } else { Rcompany = ConvertTool.covertToCustoms(td.getTd_ywdybh()); } } tdl.add(td); } } // 系统部门未找到 if (StringUtils.isBlank(bsDE)) { orr.setCode(1); orr.setErrmsg("提单未找到系统部门字段,请重新操作!"); return orr; } boolean saveBT = false;// 保存一卡通业务单表头信息 String bsNo=""; // 保存表相关信息 try { // 保存业务单 Fd_Bsheet fb = this.fdbsper.getbyVehicleId(fdv1.getVehicleId(), Serviceenum.在办, bsDE); if (fb == null) { // // 获取业务单号 建议加上 记录一下开始时间和结束时间 判断地方的请求时间 JsonObject pfob = Wxhtmethod.postJsonStr(Contants.YKTgetPrefix_url, PrefixEnum.productsale.toString()); ObjectResult pfor = new ObjectResult(); String bssNo = JSONobj.getstring(pfob, "item"); int code = JSONobj.getint(pfob, "code"); String errmsg = JSONobj.getstring(pfob, "errmsg"); pfor.setCode(code); pfor.setErrmsg(errmsg); pfor.setItem(bssNo); if (pfor == null || pfor.getCode() != 0) { orr.setCode(1); orr.setErrmsg(pfor.getErrmsg()); return orr; } fb = new Fd_Bsheet(); fb.setBsNo(pfor.getItem()); fb.setCompanyName(lg.getDepartname()); fb.setCompanyNo(lg.getDepartno()); fb.setCreateid(lg.getUserid()); fb.setCreateName(lg.getWorkername()); fb.setCtime(new Date()); fb.setDriver(fdv1.getDriver()); fb.setFdsheetNo(pfor.getItem()); fb.setId(UUID.randomUUID() + ""); fb.setPhone(fdv1.getPhone()); fb.setSendmsg(false); fb.setStatus(Serviceenum.在办); fb.setVehicleId(fdv1.getVehicleId()); fb.setSdepartNo(bsDE); fb.setShdw(StringUtils.isBlank(Rcompany) ? "未知发货单位" : Rcompany); fb.setUpdateTime(new Date()); this.fdbsper.insertAll(fb); saveBT=true; bsNo=bssNo; } else { fb.setDriver(fdv1.getDriver()); fb.setPhone(fdv1.getPhone()); fb.setUpdateTime(new Date()); fdbsper.update(fb); bsNo=fb.getBsNo(); } // 保存车辆信息 Fd_Vehicle fdv = this.vhper.getByVehicleId(fdv1.getVehicleId()); if (fdv == null) { vhper.insert(fdv1); } else { if (fdv.getType() == VehicleType.临时车) { fdv.setDriver(fdv1.getDriver()); fdv.setPhone(fdv1.getPhone()); fdv.setIDNum(fdv1.getIDNum()); vhper.update(fdv); } } Fd_Company_Vehicle fdcv = fdvcper.getbyIDs(fdv1.getVehicleId(), lg.getDepartno(), bsDE); if (fdcv == null) { fdcv = new Fd_Company_Vehicle(); fdcv.setCompanyNo(lg.getDepartno()); fdcv.setVehicleId(fdv1.getVehicleId()); fdcv.setSdepartNo(bsDE); fdvcper.insertIDs(fdcv); } // 保存分单表相关信息 Map> mxMp = new HashMap>(); if(tdl!=null&&!tdl.isEmpty()) { for (Fd_XSTD td : tdl) { int fdsl = 0; double fdmz = 0; List mxl = this.tdmxper.getNOZCandFD(td.getTd_tdls()); if (mxl == null || mxl.isEmpty()) { continue; } for (Fd_XSTDMX tdmx : mxl) { fdsl++; fdmz = BigDecimalfiter.addscal(fdmz, tdmx.getTdmx_mz(), Contants.scale); tdmx.setTdmx_fdbz(1); tdmx.setTdmx_fdcph(fdv1.getVehicleId()); tdmx.setTdmx_fdywbh(bsNo); tdmx.setTdmx_fdwlgsbh(lg.getDepartno()); } Fd_XSTDMX tdmx=mxl.get(0); tdmx.setTdmx_fdbz(1); tdmx.setTdmx_fdcph(fdv1.getVehicleId()); tdmx.setTdmx_fdywbh(bsNo); tdmx.setTdmx_fdwlgsbh(lg.getDepartno()); tdmx.setTdmx_tdls(td.getTd_tdls()); this.tdmxper.updateFDBatch(tdmx); Vehicle_XSTD vhx=this.vhxper.getbyIDs(fdv1.getVehicleId(), td.getTd_tdbh(),lg.getDepartno()); if(vhx==null){ vhx=new Vehicle_XSTD(); vhx.setBsNo(bsNo); vhx.setCompanyNo(lg.getDepartno()); vhx.setFd_num(fdsl); vhx.setFd_weight(fdmz); vhx.setVehicleId(fdv1.getVehicleId()); vhx.setXstdNo(td.getTd_tdbh()); this.vhxper.insert(vhx); }else{ vhx.setBsNo(bsNo); vhx.setCompanyNo(lg.getDepartno()); vhx.setFd_num(vhx.getFd_num()+fdsl); vhx.setFd_weight(BigDecimalfiter.add(vhx.getFd_weight(),fdmz)); vhx.setVehicleId(fdv1.getVehicleId()); vhx.setXstdNo(td.getTd_tdbh()); this.vhxper.updatewithIDs(vhx); } td.setTd_wfdsl(td.getTd_wfdsl() - fdsl); td.setTd_wfdzl(BigDecimalfiter.subscal(td.getTd_wfdzl(), fdmz, Contants.scale)); this.tdper.updateFD(td); mxMp.put(td.getTd_tdbh(), mxl); } } if (saveBT) { YktBsheet bs = new YktBsheet(); bs.setSdepartNo(bsDE); /*bs.setDcompany( bsDE.equals(Contants.kjSdepartNo) ? "明泰科技" :bsDE.equals(Contants.msSdepartNo) ? "河南明晟新材料" : "郑州眀泰");*/ bs.setDcompany(ConvertTool.covertToFactoryName(bsDE)); bs.setDriver(fdv1.getDriver()); bs.setNumberplates(StringUtils.upperCase(fdv1.getVehicleId())); bs.setPhone(fdv1.getPhone()); bs.setRcompany(StringUtils.isBlank(Rcompany) ? "未知发货单位" : Rcompany); bs.setBussinessNo(fb.getBsNo()); bs.setNote(ziti + ";" + lg.getDepartname() + ":" + lg.getWorkername() + "; 分单系统自动生成"); String bsStr = Jacksonmethod.tojson(bs, false); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.YKTaddYwd_url, bsStr); ObjectResult ors = new ObjectResult(); ors = JSONobj.getobj(joADDYWD, ors); if (ors.getCode() != 0) { throw new Exception(ors.getErrmsg()); } }else { List l=this.fdbsper.getAllKH(bsNo, fb.getId()); if(l!=null) { boolean iscz=false;//收货单位在明细中是否存在 WaitXSTD wt=null; for (WaitXSTD waitXSTD : l) { if(fb.getShdw().equals(waitXSTD.getTd_khmc())) { iscz=true; break; }else { if(wt==null&&StringUtils.isNotBlank(waitXSTD.getTd_khmc())) { wt=waitXSTD; } } } if(!iscz&&wt!=null) { fb.setShdw(wt.getTd_khmc()); this.yktmper.updateshcompany(bsNo, wt.getTd_khmc(),wt.getTd_shdd()); } } } if (tdl != null && tdl.size() > 0 ) { String fdhx = this.fdtonc.getNcdata(tdl, mxMp); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "整单配车 请求参数 ::" + fdhx); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.NCfdhx_url, fdhx); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "整单配车 返回值 ::" + joADDYWD); if (joADDYWD == null || JSONobj.getint(joADDYWD, "code") != 0) { throw new Exception( (joADDYWD.get("msg")==null||StringUtils.isBlank(joADDYWD.get("msg").getAsString())) ? "分单回写NC系统出错!" : joADDYWD.get("msg").getAsString()); } else { String restult = joADDYWD.get("result").getAsString(); JsonObject jr = jp.parse(restult).getAsJsonObject(); if (jr == null || JSONobj.getint(jr, "respcode") != 111) { throw new Exception(jr.get("respmsg").getAsString()); } } } } catch (Exception e) { if (saveBT) { JsonObject jo = new JsonObject(); jo.addProperty("bussinessNo", bsNo); jo.addProperty("sdepartNo", bsDE); Wxhtmethod.postJsonStr(Contants.YKTdelYwd_url, jo.toString()); } e.printStackTrace(); throw new Exception(e.getMessage()); } orr.setCode(0); orr.setItem(true); return orr; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult dounBindByList(Login lg, String tdbhlist) throws Exception { ObjectResult orr = new ObjectResult(); if (lg == null) { orr.setCode(1); orr.setErrmsg("请登录账号!"); return orr; } if (StringUtils.isBlank(tdbhlist)) { orr.setCode(1); orr.setErrmsg("业务参数为空,请选择提单!"); return orr; } if (UserType.admin.toString().equals(lg.getWorkerno())) { orr.setCode(1); orr.setErrmsg("管理员不能操作分单!"); return orr; } Fd_Company fdc = null; if (StringUtils.isNotBlank(lg.getDepartno())) { fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { orr.setCode(1); orr.setErrmsg("账号没有配置物流公司,请联系管理员进行配置!"); return orr; } } // for循环 tdbhlist // 查找td_xstd 对象 筛选是否有操作权限 // 修改 td_xstdmx 表 修改 td_xstd 表 修改 vehicle_xstd表 JsonParser jp = new JsonParser(); JsonArray tdja = jp.parse(tdbhlist).getAsJsonArray(); List tdl = new ArrayList(); Map> mxMp = new HashMap>(); for (JsonElement tdje : tdja) { String tdNo = tdje.getAsString(); Fd_XSTD td = this.tdper.getbyTDBH(tdNo); if (td == null) { continue; } // 这一块是判断用户有没有这个提单的操作权限 : //页面获取提单里诶包信息的时候已经加过校验 当前用户只能看到可以操作的提单 不可以操作的提单看不到 // 这一块可以省略 // 自提 // if (td.getTd_ztbz() == 2) { // if (fdc != null) { // if (!fdc.isHasSPR()) { // continue; // } // } // } else { // Fd_wlgs_fhdq dq = this.dqper.getbyNos(lg.getDepartno(), td.getTd_shddbh(), // td.getTd_ywdybh().equals(Contants.zzywdyNo) ? Contants.zzywdyNo : "103"); // if (dq == null) { // continue; // } // } // 如果该业务单已经装车 过滤掉不处理 //这一块应该在页面中提示出来:提示:销售提单:XXXX 部分明细已经装车,请进入提单明细取消配车! List vxl = this.vhxper.getbyxstdNoandcmNo(tdNo, lg.getDepartno()); if (vxl != null) { boolean sffd=false; for (Vehicle_XSTD vx : vxl) { int zcsl = this.tdmxper.getbyBsNowithZC(vx.getBsNo(),td.getTd_tdls(),vx.getVehicleId()); if (zcsl > 0) { sffd=true; break; } Fd_Bsheet fb=this.fdbsper.getbyVehicleId(vx.getVehicleId(), Serviceenum.在办, lg.getSdepartNo()); if(fb !=null) { fb.setUpdateTime(new Date()); this.fdbsper.update(fb); } } if(sffd) { continue; } } else { continue; } List mxl = this.tdmxper.getbytdlsandcmNo(td.getTd_tdls(), lg.getDepartno()); List rels = new ArrayList(); if (mxl != null) { int wfdsl = 0; double wfdzl = 0; for (Fd_XSTDMX mx : mxl) { // 提单明细未关闭的做处理 wfdsl++; wfdzl = BigDecimalfiter.addscal(wfdzl, mx.getTdmx_mz(), Contants.scale); mx.setTdmx_fdbz(0); mx.setTdmx_fdcph(null); mx.setTdmx_fdwlgsbh(null); mx.setTdmx_fdywbh(null); rels.add(mx); } this.tdmxper.updatebytdlsandcmNo(td.getTd_tdls(), lg.getDepartno()); this.vhxper.delbyIDandcomNo(td.getTd_tdbh(),lg.getDepartno()); td.setTd_wfdsl(td.getTd_wfdsl() + wfdsl); td.setTd_wfdzl(BigDecimalfiter.addscal(td.getTd_wfdzl(), wfdzl, Contants.scale)); this.tdper.updateFD(td); if (wfdsl > 0) { tdl.add(td); mxMp.put(tdNo, rels); } } } // 发送NC系统 if (tdl != null && tdl.size() > 0) { String fdhx = this.fdtonc.getNcdata(tdl, mxMp); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "整单取消配车 请求参数 ::" + fdhx); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.NCfdhx_url, fdhx); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "整单取消配车 返回值 ::" + joADDYWD); if (joADDYWD == null || JSONobj.getint(joADDYWD, "code") != 0) { throw new Exception( (joADDYWD.get("msg")==null||StringUtils.isBlank(joADDYWD.get("msg").getAsString())) ? "分单回写NC系统出错!" : joADDYWD.get("msg").getAsString()); } else { String restult = joADDYWD.get("result").getAsString(); JsonObject jr = jp.parse(restult).getAsJsonObject(); if (jr == null || JSONobj.getint(jr, "respcode") != 111) { throw new Exception(jr.get("respmsg").getAsString()); } } } orr.setCode(0); return orr; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult sxccCheck(String bsNo, String vehicleId, String ZZ) throws Exception { ObjectResult orr = new ObjectResult(); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(),"出门检查 业务参数:::: ::ZZ::" + ZZ + "::bsNo::" + bsNo + "::vehicleId::" + vehicleId); if (StringUtils.isBlank(vehicleId)) { orr.setCode(1); orr.setErrmsg("车牌号为空!"); return orr; } if (StringUtils.isBlank(bsNo)) { orr.setCode(1); orr.setErrmsg("一卡通业务单号为空!"); return orr; } //先删除错误信息 errPer.delBybsNo(bsNo); try { Fd_Bsheet fdb = fdbsper.getbybsNo(bsNo); if (fdb != null) { fdb.setStatus(Serviceenum.结束); fdbsper.update(fdb); } Fd_Vehicle fdv = vhper.getByVehicleId(vehicleId); if (fdv != null) { if (fdv.getType() == VehicleType.临时车) { Fd_Bsheet fdbb=this.fdbsper.getbyVehicleWithNoSdepartNo(vehicleId,fdb.getSdepartNo()); if(fdbb==null) { vhper.delByVehicleId(vehicleId); } this.fdvcper.delbyID(vehicleId, fdb.getSdepartNo()); } else { fdv.setStatus(VehicleStatus.未配车); vhper.update(fdv); this.fdvcper.delIDandNoC(vehicleId, fdv.getCompanyNo(), fdb.getSdepartNo()); } } // 查找fd_vehicle 判断车辆信息是否正确 修改 fd_vehicle 修改fd_vehicle_company // 查找fd_bsheet 判断业务状态 修改 fd_bsheet // 查找fd_xstdmx 表 按照业务单号,车牌号,查找已分单未装车的 // 修改 fd_xstdmx fd_xstd fd_vehicle_xstd List mxl = this.tdmxper.getbybsNoandNOZCandFD(fdb == null ? "" : fdb.getBsNo()); List tdl = new ArrayList(); Map tdM = new HashMap(); Map> mxMp = new HashMap>(); // Map rmtd = new HashMap(); if (mxl != null) { for (Fd_XSTDMX mx : mxl) { // 已经关闭的明细不做处理 if (mx.getTdmx_gbbz() != 0) { continue; } // Fd_XSTD td = this.tdper.get(mx.getTdmx_tdls()); // if (td != null) { // td.setTd_wfdsl(td.getTd_wfdsl() + 1); // td.setTd_wfdzl(BigDecimalfiter.addscal(td.getTd_wfdzl(), mx.getTdmx_mz(), Contants.scale)); // tdper.updateFD(td); // tdM.put(td.getTd_tdbh(), td); // } Fd_XSTD tdtt=tdM.get(mx.getTdmx_tdls()); if(tdtt==null) { tdtt = this.tdper.get(mx.getTdmx_tdls()); if(tdtt==null) { continue; } } tdtt.setTd_wfdsl(tdtt.getTd_wfdsl()+1); tdtt.setTd_wfdzl(BigDecimalfiter.addscal(tdtt.getTd_wfdzl(), mx.getTdmx_mz(), Contants.scale)); tdM.put(mx.getTdmx_tdls(), tdtt); mx.setTdmx_fdbz(0); mx.setTdmx_fdcph(null); mx.setTdmx_fdwlgsbh(null); mx.setTdmx_fdywbh(null); // this.tdmxper.updateFD(mx); if (mxMp.get(tdtt.getTd_tdbh()) != null) { List lr = mxMp.get(tdtt.getTd_tdbh()); lr.add(mx); mxMp.put(tdtt.getTd_tdbh(), lr); } else { List lr = new ArrayList(); lr.add(mx); mxMp.put(tdtt.getTd_tdbh(), lr); } } this.tdmxper.updatebybsNoandNOZCandFD(fdb.getBsNo()); this.vhxper.delbyVehicleId(vehicleId,fdb.getBsNo() ); if (tdM != null && tdM.size() > 0) { for (Entry ff : tdM.entrySet()) { tdl.add(ff.getValue()); this.tdper.updateFD(ff.getValue()); } } } // List vxls = this.vhxper.getlistbyVehicleId(vehicleId); // if (vxls != null) { // for (Vehicle_XSTD vxx : vxls) { // this.vhxper.delbyIDs(vehicleId, vxx.getXstdNo()); // } // } // 发送NC系统 if (tdl != null && tdl.size() > 0) { String fdhx = this.fdtonc.getNcdata(tdl, mxMp); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "出门检查 请求参数 ::" + fdhx); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.NCfdhx_url, fdhx); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "出门检查 返回值 ::" + joADDYWD); if (joADDYWD == null || JSONobj.getint(joADDYWD, "code") != 0) { throw new Exception( (joADDYWD.get("msg")==null||StringUtils.isBlank(joADDYWD.get("msg").getAsString())) ? "分单回写NC系统出错!" : joADDYWD.get("msg").getAsString()); } else { String restult = joADDYWD.get("result").getAsString(); JsonParser jp = new JsonParser(); JsonObject jr = jp.parse(restult).getAsJsonObject(); if (jr == null || JSONobj.getint(jr, "respcode") != 111) { throw new Exception(jr.get("respmsg").getAsString()); } } } } catch (Exception e) { log.error("销售业务车辆出厂程序" + e.getMessage(),e); throw new Exception(StringUtils.isEmpty(e.getMessage()) ? "销售业务车辆出厂程序出错!" : e.getMessage()); } orr.setCode(0); return orr; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult doUnbind(Login lg, String mlist, String tdNo) throws Exception { ObjectResult orr = new ObjectResult(); if (lg == null) { orr.setCode(1); orr.setErrmsg("请登录账号!"); return orr; } if (StringUtils.isEmpty(mlist)) { orr.setCode(1); orr.setErrmsg("业务参数为空!"); return orr; } if (StringUtils.isEmpty(tdNo)) { orr.setCode(1); orr.setErrmsg("提单编号为空!"); return orr; } if (UserType.admin.toString().equals(lg.getWorkerno())) { orr.setCode(1); orr.setErrmsg("管理员没有分单权限!"); return orr; } Fd_Company fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { orr.setCode(1); orr.setErrmsg("该账号没有配置物流公司!"); return orr; } // 查找fd_xstd表 判断物流公司是否有操作权限 如果有装车明细不让删除完 // for循环mlist 判断 fd_xstdmx是否符合条件 // 修改fd_xstdmx 表 修改 vehicle_xstd表 修改fd_company_xstd表:只在取消分单和出门的时候删除 // 修改 fd_xstd 表 Fd_XSTD td = this.tdper.getbyTDBH(tdNo); if (td == null) { orr.setCode(1); orr.setErrmsg("提单未找到!"); return orr; } if (td.isTd_zcwcbz()) { orr.setCode(1); orr.setErrmsg("该提单已经完成装车,不能分单!"); return orr; } // 自提 if (td.getTd_ztbz() == 2) { if (fdc != null) { if (!fdc.isHasSPR()) { orr.setCode(1); orr.setErrmsg("该账号没有自提权限!"); return orr; } } } else { Fd_wlgs_fhdq wldq = this.dqper.getbyNos(lg.getDepartno(), td.getTd_shddbh(), /*td.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ :td.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*/ ConvertTool.ncGetDefault(td.getTd_ywdybh()) ); int total = fdMxWlgsMapper.selectCountByTdTdls(td.getTd_tdls()); if (wldq == null && total == 0) { orr.setCode(1); orr.setErrmsg("当前账号所属物流公司没有配置该地区的分单权限!"); return orr; } } JsonParser jp = new JsonParser(); JsonArray mArr = jp.parse(mlist).getAsJsonArray(); // 分单数量和毛重 int fdsl = 0; double fdmz = 0; List tdl = new ArrayList(); Map> mxMp = new HashMap>(); List tdmxl = new ArrayList(); Map rm=new HashMap(); for (JsonElement mJe : mArr) { JsonObject jo = mJe.getAsJsonObject(); // 提单分录号 String tdfl = JSONobj.getstring(jo, "tdfl"); String vehicleId = JSONobj.getstring(jo, "vehicleId"); Fd_XSTDMX mx = this.tdmxper.get(tdfl); if (mx != null) { // 没有分单的跳过 if (mx.getTdmx_fdbz() == 0) { continue; } // 已经装车的报错 if (mx.getTdmx_zcbz() != 0) { continue; } // 没有关闭明细做处理 if (mx.getTdmx_gbbz() == 0) { fdsl++; fdmz = BigDecimalfiter.addscal(fdmz, mx.getTdmx_mz(), Contants.scale); Fd_XSTD ttr=rm.get(vehicleId+"_"+mx.getTdmx_fdwlgsbh()); if(ttr!=null) { ttr.setTd_wfdsl(ttr.getTd_wfdsl()+1); ttr.setTd_wfdzl(BigDecimalfiter.addscal(ttr.getTd_wfdzl(), mx.getTdmx_mz(), Contants.scale)); rm.put(vehicleId+"_"+mx.getTdmx_fdwlgsbh(), ttr); }else { ttr=new Fd_XSTD(); ttr.setTd_wfdsl(1); ttr.setTd_wfdzl(BigDecimalfiter.addscal(0, mx.getTdmx_mz(), Contants.scale)); rm.put(vehicleId+"_"+mx.getTdmx_fdwlgsbh(), ttr); } } mx.setTdmx_fdbz(0); mx.setTdmx_fdcph(null); mx.setTdmx_fdwlgsbh(null); mx.setTdmx_fdywbh(null); this.tdmxper.updateFD(mx); tdmxl.add(mx); } } Iterator> entries = rm.entrySet().iterator(); while (entries.hasNext()) { Entry entry = entries.next(); Vehicle_XSTD vxs = this.vhxper.getbyIDs(entry.getKey().split("_")[0], td.getTd_tdbh(),entry.getKey().split("_")[1]); if (vxs != null) { if (vxs.getFd_num() == 1) { this.vhxper.delbyIDs(entry.getKey().split("_")[0], td.getTd_tdbh(),entry.getKey().split("_")[1]); } else { vxs.setFd_num(vxs.getFd_num() - entry.getValue().getTd_wfdsl()); vxs.setFd_weight(BigDecimalfiter.subscal(vxs.getFd_weight(), entry.getValue().getTd_wfdzl(), Contants.scale)); this.vhxper.updatewithIDs(vxs); } Fd_Bsheet fb=this.fdbsper.getbyVehicleId(vxs.getVehicleId(), Serviceenum.在办, lg.getSdepartNo()); if(fb !=null) { fb.setUpdateTime(new Date()); this.fdbsper.update(fb); } } } td.setTd_wfdsl(td.getTd_wfdsl() + fdsl); td.setTd_wfdzl(BigDecimalfiter.addscal(td.getTd_wfdzl(), fdmz, Contants.scale)); this.tdper.updateFD(td); if (fdsl > 0) { tdl.add(td); mxMp.put(td.getTd_tdbh(), tdmxl); } // 发送NC if (tdl != null && tdl.size() > 0) { String fdhx = this.fdtonc.getNcdata(tdl, mxMp); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "明细取消配车 请求参数 ::" + fdhx); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.NCfdhx_url, fdhx); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "明细取消配车 返回值 ::" + joADDYWD); if (joADDYWD == null || JSONobj.getint(joADDYWD, "code") != 0) { throw new Exception( (joADDYWD.get("msg")==null||StringUtils.isBlank(joADDYWD.get("msg").getAsString())) ? "分单回写NC系统出错!" : joADDYWD.get("msg").getAsString()); } else { String restult = joADDYWD.get("result").getAsString(); JsonObject jr = jp.parse(restult).getAsJsonObject(); if (jr == null || JSONobj.getint(jr, "respcode") != 111) { throw new Exception(jr.get("respmsg").getAsString()); } } } orr.setCode(0); orr.setItem(true); return orr; } @Override public ObjectResult tzPrint(String cardno, String ipadda,String cqNo) { ObjectResult orr = new ObjectResult(); if (StringUtils.isBlank(cardno)) { orr.setCode(1); orr.setErrmsg("提单编号为空!"); return orr; } if (StringUtils.isBlank(ipadda)) { orr.setCode(1); orr.setErrmsg("批次号为空!"); return orr; } Map cardinuse = this.yktmper.getcardinuse(cardno); if (cardinuse == null) { orr.setCode(1); orr.setErrmsg("在用卡未找到!"); return orr; } Fd_Vehicle fd_v = this.vhper.getByVehicleId(cardinuse.get("numberplates") + ""); if (fd_v == null) { orr.setCode(1); orr.setErrmsg("车辆" + cardinuse.get("numberplates").toString() + "分单系统未找到!"); return orr; } Fd_Bsheet fd_b = this.fdbsper.getbyVehicleId(fd_v.getVehicleId(), Serviceenum.在办, cqNo); if (fd_b == null) { orr.setCode(1); orr.setErrmsg("车辆未找到在办分单!"); return orr; } String dyAdd = this.bsper.getUsedbyAdd(); if (StringUtils.isBlank(dyAdd)) { orr.setCode(1); orr.setErrmsg("系统未设置打印地址!"); return orr; } try { orr.setItem("http://" + dyAdd + Contants.GYPrintAdd + "&vehicleId=" + URLEncoder.encode(fd_v.getVehicleId(), "utf-8") + "&bsNo=" + fd_b.getBsNo() + "&phone=" + fd_b.getPhone() + "&comNo="); // log.info("::::::::::;"+orr.getItem()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // 存打印日志:方便以后查找 orr.setCode(0); return orr; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult delbyPCH(Login lg, String tdNo, String pch, String cph,String bsNo) throws Exception { ObjectResult orr = new ObjectResult(); if (lg == null) { orr.setCode(1); orr.setErrmsg("请登录账号!"); return orr; } if (StringUtils.isEmpty(tdNo)) { orr.setCode(1); orr.setErrmsg("提单编号为空!"); return orr; } if (StringUtils.isEmpty(pch)) { orr.setCode(1); orr.setErrmsg("批次号为空!"); return orr; } Fd_Bsheet fdb = this.fdbsper.getbybsNo(bsNo);//getbyVehicleId(cph, Serviceenum.在办); if (fdb == null) { orr.setCode(1); orr.setErrmsg("车牌号:" + cph + " 业务单未找到!"); return orr; } if (fdb.getStatus()!=Serviceenum.在办) { orr.setCode(1); orr.setErrmsg("车牌号:" + cph + " 业务单不是在办状态!"); return orr; } Fd_Company fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { orr.setCode(1); orr.setErrmsg("账号没有配置物流公司!"); return orr; } // 根据提单号找到 fd_xstd 判断xstd数据 // 根据批次号和提单流水号找到 fd_xstdmx 判断xstdmx数据 // 如果是已经装车了 至少保留一件 // 修改fd_xstdmx vehicle_xstd表 Fd_XSTD td = this.tdper.getbyTDBH(tdNo); if (td == null) { orr.setCode(1); orr.setErrmsg("提单号:" + tdNo + " 未找到!"); return orr; } // Fd_XSTDMX mx=this.tdmxper.getbyPCH(pch); Fd_XSTDMX mx = this.tdmxper.getbyPCHandTDNOONE(pch, td.getTd_tdbh()); if (mx == null) { orr.setCode(1); orr.setErrmsg("提单明细未找到!"); return orr; } if (mx.getTdmx_zcbz() != 0) { orr.setCode(1); orr.setErrmsg("明细已经装车不能删除!"); return orr; } if (!mx.getTdmx_tdls().equals(td.getTd_tdls())) { orr.setCode(1); orr.setErrmsg("参数错误,明细不属于该提单!"); return orr; } // 已经分单了未关闭 if (mx.getTdmx_fdbz() != 0 && mx.getTdmx_gbbz() == 0) { fdb.setUpdateTime(new Date()); this.fdbsper.update(fdb); List tdl = new ArrayList(); Map> mxMp = new HashMap>(); List mxl = new ArrayList(); mx.setTdmx_fdbz(0); mx.setTdmx_fdcph(null); mx.setTdmx_fdwlgsbh(null); mx.setTdmx_fdywbh(null); this.tdmxper.updateFD(mx); Vehicle_XSTD vx = this.vhxper.getbyIDs(cph, tdNo,lg.getDepartno()); if (vx != null) { if (vx.getFd_num() > 1) { vx.setFd_num(vx.getFd_num() - 1); vx.setFd_weight(BigDecimalfiter.subscal(vx.getFd_weight(), mx.getTdmx_mz(), Contants.scale)); this.vhxper.updatewithIDs(vx); } else { this.vhxper.delbyIDs(cph, tdNo,lg.getDepartno()); } } td.setTd_wfdsl(td.getTd_wfdsl() + 1); td.setTd_wfdzl(BigDecimalfiter.addscal(td.getTd_wfdzl(), mx.getTdmx_mz(), Contants.scale)); this.tdper.updateFD(td); tdl.add(td); mxl.add(mx); mxMp.put(tdNo, mxl); // 发送NC if (tdl != null && tdl.size() > 0) { String fdhx = this.fdtonc.getNcdata(tdl, mxMp); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "批次号取消配车 请求参数 ::" + fdhx); JsonObject joADDYWD = Wxhtmethod.postJsonStr(Contants.NCfdhx_url, fdhx); Fileoperation.AppendContentToFile(Fileoperation.gettestFileName(), "批次号取消配车 返回值 ::" + joADDYWD); if (joADDYWD == null || JSONobj.getint(joADDYWD, "code") != 0) { throw new Exception( (joADDYWD.get("msg")==null||StringUtils.isBlank(joADDYWD.get("msg").getAsString())) ? "分单回写NC系统出错!" : joADDYWD.get("msg").getAsString()); } else { String restult = joADDYWD.get("result").getAsString(); JsonParser jp = new JsonParser(); JsonObject jr = jp.parse(restult).getAsJsonObject(); if (jr == null || JSONobj.getint(jr, "respcode") != 111) { throw new Exception(jr.get("respmsg").getAsString()); } } } } orr.setCode(0); orr.setItem(true); return orr; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult closeXstd(String vehicleId, String driver, String phone, String xstdNo, Login lg) throws Exception { ObjectResult or = new ObjectResult(); if (lg == null) { or.setCode(1); or.setErrmsg("请重新登录账号!"); return or; } // 根据xstdNo查找fd_xstd信息 vehicle_xstd // 判断vehicle_xstd的销售提单的状态 // 查找fd_xstdmx // for循环 list 获取未分单未装车 // 修改fd_xstdmx 修改Fd_Gbxstd, Fd_Gbxstdmx,修改fd_xstd if (StringUtils.isEmpty(xstdNo)) { or.setCode(1); or.setErrmsg("销售提单号为空,不能执行该操作!"); return or; } if (!StringUtils.isEmpty(vehicleId)) { if (!RegexCheck.isVehicleID(vehicleId)) { or.setCode(1); or.setErrmsg("请输入正确的车牌号!"); return or; } } if (!StringUtils.isEmpty(phone)) { if (!RegexCheck.checkphone(phone)) { or.setCode(1); or.setErrmsg("请输入正确的手机号!"); return or; } } Fd_Gbxstd gbtd = gbtdper.get(xstdNo); if (gbtd != null) { or.setCode(1); or.setErrmsg("销售提单:" + xstdNo + " 已经有关闭记录,不能保存重复的关闭记录!"); return or; } List vxl = vhxper.getlistbytdNo(xstdNo); if (vxl != null && vxl.size() > 0) { or.setCode(1); or.setErrmsg("销售提单:" + xstdNo + " 已经分单给:" + vxl.get(0).getVehicleId() + ",不能执行该操作!"); return or; } Fd_XSTD tdx = this.tdper.getbyttdbh(xstdNo); if (tdx == null) { or.setCode(1); or.setErrmsg("销售提单:" + xstdNo + "未找到,不能执行该操作!"); return or; } Fd_Company fdc = new Fd_Company(); if (!UserType.admin.toString().equals(lg.getWorkerno())) { fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { or.setCode(1); or.setErrmsg("登录账号未指定物流公司!"); return or; } // 自提 if (tdx.getTd_ztbz() == 2) { if (!fdc.isHasSPR()) { or.setCode(1); or.setErrmsg("该账号没有操作该提单的权限!"); return or; } } else { String shdqbh = tdx.getTd_shddbh(); Fd_wlgs_fhdq acb = this.dqper.getbyNos(lg.getDepartno(), shdqbh, /*tdx.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ :tdx.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*/ ConvertTool.ncGetDefault(tdx.getTd_ywdybh()) ); int total = fdMxWlgsMapper.selectCountByTdTdls(tdx.getTd_tdls()); if (acb == null && total == 0) { or.setCode(1); or.setErrmsg("账号没有操作该提单的权限!"); return or; } } } List mxL = this.tdmxper.getforClose(tdx.getTd_tdls()); int dd = 0; double cc = 0; if (mxL != null) { for (Fd_XSTDMX mx : mxL) { dd++; cc = BigDecimalfiter.addscal(cc, mx.getTdmx_mz(), Contants.scale); mx.setTdmx_zcbz(1); mx.setTdmx_zccph(vehicleId); mx.setTdmx_zcdriver(driver); mx.setTdmx_zcphone(phone); mx.setTdmx_zcwlgsName(lg.getDepartname()); this.tdmxper.updateZCANDFD(mx); Fd_Gbxstdmx gb = this.gbtdmxper.get(mx.getTdmx_tdfl()); if (gb == null) { gb = new Fd_Gbxstdmx(); gb.setId(mx.getTdmx_tdfl()); gb.setTdfl(mx.getTdmx_tdfl()); gb.setPch(mx.getTdmx_pch()); gb.setTdNo(tdx.getTd_tdbh()); this.gbtdmxper.insert(gb); } } } tdx.setTd_wfdsl(0); tdx.setTd_wfdzl(0); this.tdper.updateFD(tdx); if (dd > 0) { gbtd = new Fd_Gbxstd(); gbtd.setCompanyNo(lg.getDepartname() == null ? "管理员关闭" : lg.getDepartname()); gbtd.setHSR(tdx.getTd_ztbz() == 2); gbtd.setTd_gbr(lg.getWorkername()); gbtd.setTd_gbsj(new Date()); gbtd.setTd_gbsl(dd); gbtd.setTd_gbzl(cc); gbtd.setVehicleId(vehicleId); gbtd.setXstdNo(xstdNo); this.gbtdper.insert(gbtd); } or.setCode(0); return or; } @Override @Transactional(rollbackFor = Exception.class) public ObjectResult openXstd(String xstdNo, Login lg) throws Exception { ObjectResult or = new ObjectResult(); if (lg == null) { or.setCode(1); or.setErrmsg("请重新登录账号!"); return or; } if (StringUtils.isEmpty(xstdNo)) { or.setCode(1); or.setErrmsg("销售提单号为空,不能执行该操作!"); return or; } // 关闭之后不让打开了 // 根据xstdNo查找fd_xstd信息 vehicle_xstd // 判断vehicle_xstd的销售提单的状态 // 查找fd_xstdmx // for循环 list 获取未分单未装车 // 修改fd_xstdmx 修改Fd_Gbxstd, Fd_Gbxstdmx,修改fd_xstd Fd_Gbxstd gbtd = gbtdper.get(xstdNo); if (gbtd == null) { or.setCode(1); or.setErrmsg("销售提单:" + xstdNo + " 未找到关闭记录,不能恢复销售提单!"); return or; } if (BasicMethod.after(gbtd.getTd_gbsj(), 7)) { or.setCode(1); or.setErrmsg("已关闭超过7天,不能恢复提单!"); return or; } List vxl = vhxper.getlistbytdNo(xstdNo); if (vxl != null && vxl.size() > 0) { or.setCode(1); or.setErrmsg("销售提单:" + xstdNo + " 有在办的分车单,不能执行该操作!"); return or; } Fd_XSTD tdx = this.tdper.getbyttdbh(xstdNo); if (tdx == null) { or.setCode(1); or.setErrmsg("销售提单:" + xstdNo + "未找到,不能执行该操作!"); return or; } Fd_Company fdc = new Fd_Company(); if (!UserType.admin.toString().equals(lg.getWorkerno())) { fdc = fdcper.getByCompanyNo(lg.getDepartno()); if (fdc == null) { or.setCode(1); or.setErrmsg("登录账号未指定物流公司!"); return or; } // 自提 if (tdx.getTd_ztbz() == 2) { if (!fdc.isHasSPR()) { or.setCode(1); or.setErrmsg("该账号没有操作该提单的权限!"); return or; } } else { String shdqbh = tdx.getTd_shddbh(); Fd_wlgs_fhdq acb = this.dqper.getbyNos(lg.getDepartno(), shdqbh, /*tdx.getTd_ywdybh().equals(Contants.nc_ywdy_ZZ) ? Contants.nc_ywdy_ZZ :tdx.getTd_ywdybh().equals(Contants.nc_ywdy_MS) ? Contants.nc_ywdy_MS : Contants.nc_ywdy_KJ*/ ConvertTool.ncGetDefault(tdx.getTd_ywdybh()) ); int total = fdMxWlgsMapper.selectCountByTdTdls(tdx.getTd_tdls()); if (acb == null && total == 0) { or.setCode(1); or.setErrmsg("该账号没有操作该提单的权限!"); return or; } } } List mxL = this.gbtdmxper.getList(xstdNo); int dd = 0; if (mxL != null) { for (Fd_Gbxstdmx mx : mxL) { Fd_XSTDMX tdmx = this.tdmxper.getbytdflAndtdls(mx.getId(), tdx.getTd_tdls()); tdmx.setTdmx_zcbz(0); tdmx.setTdmx_zccph(null); tdmx.setTdmx_zcdriver(null); tdmx.setTdmx_zcphone(null); tdmx.setTdmx_zcwlgsName(null); dd++; this.tdmxper.updateZCANDFD(tdmx); this.gbtdmxper.delbyId(mx.getId()); } } if (dd > 0) { tdx.setTd_wfdsl(gbtd.getTd_gbsl()); tdx.setTd_wfdzl(gbtd.getTd_gbzl()); this.tdper.updateFD(tdx); this.gbtdper.del(xstdNo); } or.setCode(0); return or; } @Override @Transactional(rollbackFor = Exception.class) @Deprecated public ObjectResult changeVehicle(Login lg, String bsNo, String vehicleInfo) throws Exception { ObjectResult orr = new ObjectResult(); if (lg == null) { orr.setCode(1); orr.setErrmsg("请登录账号!"); return orr; } if (true) { orr.setCode(1); orr.setErrmsg("该方法不可用!"); return orr; } if (UserType.admin.toString().equals(lg.getWorkerno())) { orr.setCode(1); orr.setErrmsg("管理员不能执行该操作!"); return orr; } if (StringUtils.isEmpty(bsNo) || StringUtils.isEmpty(vehicleInfo)) { orr.setCode(1); orr.setErrmsg("业务参数为空!"); return orr; } Fd_Bsheet fdb = fdbsper.getbybsNo(bsNo); if (fdb == null) { orr.setCode(1); orr.setErrmsg("业务单未找到!"); return orr; } String vehicleId = fdb.getVehicleId(); Fd_Vehicle fdv = vhper.getByVehicleId(vehicleId); if (fdv == null) { orr.setCode(1); orr.setErrmsg("原来的车牌未找到!"); return orr; } JsonParser jp = new JsonParser(); JsonElement je = jp.parse(vehicleInfo); JsonObject jo = je.getAsJsonObject(); String nvehicleId = JSONobj.getstring(jo, "vehicleId"); String driver = JSONobj.getstring(jo, "driver"); String phone = JSONobj.getstring(jo, "phone"); double vehicleweight = JSONobj.getdouble(jo, "vehicleweight"); double loadweight = JSONobj.getdouble(jo, "loadweight"); String feature = JSONobj.getstring(jo, "feature"); String note = JSONobj.getstring(jo, "note"); String IDNum = JSONobj.getstring(jo, "IDNum"); if (StringUtils.isEmpty(vehicleId) || StringUtils.isEmpty(driver) || StringUtils.isEmpty(IDNum) || StringUtils.isEmpty(phone)) { orr.setCode(1); orr.setErrmsg("车辆必填信息不能为空!"); return orr; } Fd_Vehicle nfdv = vhper.getByVehicleId(nvehicleId); if (nfdv != null && nfdv.getStatus() != VehicleStatus.未配车) { orr.setCode(1); orr.setErrmsg("车辆:" + nvehicleId + "状态不是未配车状态,不能使用!"); return orr; } // 临时车直接删除 if (fdv.getType() == VehicleType.临时车) { vhper.delByVehicleId(fdv.getVehicleId()); } else { fdv.setStatus(VehicleStatus.未配车); vhper.update(fdv); } // 修改vehicle_xstd表 List lc = vhxper.getlistbycomNo(lg.getDepartno()); // List lc=vhxper.getlistbyVehicleId(fdv.getVehicleId()); if (lc != null) { for (Vehicle_XSTD vx : lc) { if (vx.getVehicleId().equals(fdv.getVehicleId())) { vx.setVehicleId(nvehicleId); vhxper.updatewithIDs(vx); } } } if (nfdv == null) { nfdv = new Fd_Vehicle(); nfdv.setCompanyNo(lg.getDepartno()); nfdv.setDriver(driver); nfdv.setId(UUID.randomUUID() + ""); nfdv.setLoadweight(loadweight); nfdv.setNote(note); nfdv.setPhone(phone); nfdv.setState(true); nfdv.setFeature(feature); nfdv.setStatus(VehicleStatus.已配车); nfdv.setType(VehicleType.临时车); nfdv.setVehicleId(nvehicleId); nfdv.setVehicleweight(vehicleweight); nfdv.setIDNum(IDNum); vhper.insert(nfdv); } // 换车用不用发送短信 orr.setCode(0); orr.setItem(true); return orr; } @Override @Transactional(rollbackFor = Exception.class) @Deprecated public ObjectResult saveZcInfo(Scxt_zcInfo zc) throws Exception { ObjectResult orr = new ObjectResult(); if (zc == null) { orr.setCode(1); orr.setErrmsg("参数为空不能保存!"); return orr; } if (true) { orr.setCode(1); orr.setErrmsg("该方法已作废!"); return orr; } String zcvehicleID = zc.getCph();// 车牌号 String pch = zc.getPch();// 批次号 String tdbh = zc.getTdbh();// 提单编号 Fd_Vehicle fdv = vhper.getByVehicleId(zcvehicleID); if (fdv == null) { orr.setCode(1); orr.setErrmsg("分单系统未找到该车牌号!"); return orr; } Map bsmp =null;// bsper.getbsbyBt(zcvehicleID, Contants.cpxsBtNo, Serviceenum.在办,Contants.kjSdepartNo); if (bsmp == null) { orr.setCode(1); orr.setErrmsg("该车辆没有找到一卡通业务单!"); return orr; } String dbsign = tdbh.split("-")[0]; // Fd_Erpconfig erpdb=erpper.getbySign(dbsign); // if(erpdb==null){ // orr.setCode(1); // orr.setErrmsg("根据提单编号未找到配置的数据库数据源!"); // return orr; // } // Map bsim=bsper.getbsi(pch, bsmp.get("bussinessNo")+"" ); // if(bsim!=null){ // orr.setCode(1); // orr.setErrmsg("该成品已经装车!"); // return orr; // } // try { // String // url="jdbc:jtds:sqlserver://"+erpdb.getUri()+":"+erpdb.getPost()+";databaseName="+erpdb.getDb(); // Connection con=ddbdao.open(url, erpdb.getUsername(), // erpdb.getPwd(),erpdb.getDbsign()); // if(con==null){ // ddbdao.close(); // orr.setCode(1); // orr.setErrmsg("erp数据库链接失败,请查询erp配置是否正确!"); // return orr; // } // String sql=SqlTxt.GYErpXSTDsql+" where EXISTS (SELECT 1 FROM XSTDMX WHERE // XSTDMX_TDLS=XSTD_TDLS AND XSTDMX_CKBZ='0') and a.XSTD_TDBH='"+tdbh+"' and // a.XSTD_SHBZ=1 and a.XSTD_TDBZ='LD' "; // Map tdmp=ddbdao.getmapnoclose(sql,erpdb.getDbsign()); // if(tdmp==null){ // orr.setCode(1); // orr.setErrmsg("销售提单未找到!"); // ddbdao.close(); // return orr; // } // WaitXSTD wt=new WaitXSTD(); // BeanUtils.populate(wt, tdmp); // // //判断该车辆有没有操作该提单的权限 // if(true){ // // } // sql=SqlTxt.GYErpXSTDMXsql+" where b.XSTDMX_CKBZ='0' and // a.XSTD_TDBH='"+tdbh+"' and b.XSTDMX_PCH='"+pch+"' ";//销售提单明细 // Map mxmp=ddbdao.getmapnoclose(sql,erpdb.getDbsign()); // if(mxmp==null){ // orr.setCode(1); // orr.setErrmsg("根据提单号和批次号Erp未找到销售提单明细!"); // ddbdao.close(); // return orr; // } // WaitXSTDMX wtdmx=new WaitXSTDMX(); // BeanUtils.populate(wtdmx, mxmp); // String hj=mxmp.get("hj")==null?"":mxmp.get("hj")+""; // String zt=mxmp.get("zt")==null?"":mxmp.get("zt")+""; // wtdmx.setTdmx_hjzt(hj+"/"+zt); // //如果扫的是没有分单的 // if(wtdmx.getTdmx_fdbz()==0){ // sql=SqlTxt.XGGYErpXSTDMXsql+" where a.XSTDMX_CKBZ='0' and // b.XSTD_TDBH='"+tdbh+"' and a.XSTDMX_PCH='"+pch+"' ";//修改销售提单明细 // List ll=new ArrayList(); // ll.add(zcvehicleID);//车牌号 // ll.add(2);//分单标志 // ll.add(bsmp.get("bussinessNo")+"");//分单单据编号 // ddbdao.modifySql(sql, ll,erpdb.getDbsign()); // // sql=SqlTxt.XGGYErpXSTDsql;//修改销售提单 // ll.clear(); // ll.add(wt.getTd_wfdsl()-1);//未分单数量 // ll.add(BigDecimalfiter.subscal(wt.getTd_wfdzl(), wtdmx.getTdmx_mz(), // Contants.scale));//未分单毛重 // ll.add(tdbh); // ddbdao.modifySql(sql, ll,erpdb.getDbsign()); // } // // if(fdv.getStatus()!=VehicleStatus.已装车){ // fdv.setStatus(VehicleStatus.已装车); // vhper.update(fdv); // } // Fd_Bsheetitem fbi=bsiper.getbyLsandFl(wtdmx.getTdmx_tdls(), // wtdmx.getTdmx_tdfl(),tdbh); // //该车辆有没有添加 // Vehicle_XSTD vhx=vhxper.getbyIDs(zcvehicleID, tdbh); // //已经分单 // if(fbi!=null){ // //未分到当前车辆 // if(!fbi.getTdmx_cph().equals(zcvehicleID)){ // Vehicle_XSTD vhx1=vhxper.getbyIDs(zcvehicleID, tdbh); // //该车辆已添加销售提单 // if(vhx!=null){ // vhx.setFd_num(vhx.getFd_num()+1); // vhx.setFd_weight(BigDecimalfiter.addscal(vhx.getFd_weight(),wtdmx.getTdmx_mz() // ,Contants.scale )); // vhxper.update(vhx); // }else{ // vhx=new Vehicle_XSTD(); // vhx.setFd_num(1); // vhx.setFd_weight(BigDecimalfiter.addscal(wtdmx.getTdmx_mz(), 0, // Contants.scale)); // vhx.setVehicleId(zcvehicleID); // vhx.setXstdNo(tdbh); // vhx.setBsNo( bsmp.get("bussinessNo")+""); // vhxper.insert(vhx); // } // if(vhx1.getFd_num()==1){ // vhxper.delbyIDs(vhx1.getVehicleId(), vhx1.getXstdNo()); // }else{ // vhx1.setFd_num(vhx1.getFd_num()-1); // vhx1.setFd_weight(BigDecimalfiter.subscal(vhx1.getFd_weight(), // wtdmx.getTdmx_mz(), Contants.scale)); // vhxper.update(vhx1); // } // fbi.setTdmx_cph(zcvehicleID); // } //// fbi.setTdmx_cph(zcvehicleID); // fbi.setTdmx_tdbh(tdbh); // fbi.setTdmx_fdbz(2); // fbi.setTdmx_fdywbh(bsmp.get("bussinessNo")+"" ); // fbi.setTdmx_zccph(zcvehicleID); // fbi.setTdmx_sfzc(1); // fbi.setBarcode(zc.getTmh()); // bsiper.update(fbi); // }else{ // fbi=new Fd_Bsheetitem(); // fbi.setId(UUID.randomUUID()+""); // fbi.setCompanyName(""); // fbi.setCompanyNo(""); // fbi.setCreateid(""); // fbi.setBarcode(zc.getTmh()); // fbi.setCtime(new Date()); // fbi.setTdmx_cph(zcvehicleID); // fbi.setTdmx_tdbh(tdbh); // fbi.setTdmx_fdbz(2); // fbi.setTdmx_fdywbh(bsmp.get("bussinessNo")+"" ); // fbi.setTdmx_zccph(zcvehicleID); // fbi.setTdmx_sfzc(1); // bsiper.insert(fbi); // //该装车车辆添加了这个提单的分单 // if(vhx!=null){ // vhx.setFd_num(vhx.getFd_num()+1); // vhx.setFd_weight(BigDecimalfiter.addscal(vhx.getFd_weight(),wtdmx.getTdmx_mz() // ,Contants.scale )); // vhxper.update(vhx); // }else{ // vhx=new Vehicle_XSTD(); // vhx.setFd_num(1); // vhx.setFd_weight(BigDecimalfiter.addscal(wtdmx.getTdmx_mz(), 0, // Contants.scale)); // vhx.setVehicleId(zcvehicleID); // vhx.setXstdNo(tdbh); // vhxper.insert(vhx); // } // } // // // // //添加一卡通明细; // Map mm=new HashMap(); // mm.put("id", UUID.randomUUID()+""); // mm.put("bussinessNo",bsmp.get("bussinessNo")+"" ); // mm.put("name", wtdmx.getTdmx_wlmc()); // mm.put("materielNo",wtdmx.getTdmx_wlbh() ); // mm.put("norms",wtdmx.getTdmx_ggxh() ); // mm.put("unitname", "Kg"); // mm.put("num", 1); // mm.put("note", null); // mm.put("weight", BigDecimalfiter.mulcon(wtdmx.getTdmx_jz(), 1000, // Contants.scale)); // mm.put("price", 0); // mm.put("preweight",BigDecimalfiter.mulcon(wtdmx.getTdmx_jz(), 1000, // Contants.scale)); // mm.put("pici", pch); // mm.put("hejin", wtdmx.getTdmx_hjzt()); // mm.put("gross",BigDecimalfiter.mulcon(wtdmx.getTdmx_mz(), 1000, // Contants.scale) ); // mm.put("taotong","" ); // mm.put("taotongWeight", BigDecimalfiter.subscal(wtdmx.getTdmx_mz()*1000, // wtdmx.getTdmx_jz()*1000, Contants.scale)); // mm.put("money", 0); // //// mm.put("createid", ); //// mm.put("cname", ); //// mm.put("createid", 0); // mm.put("cdepartid", 0); //// mm.put("cdepart", ); // mm.put("ctime", new Date()); // // mm.put("loadbuild", false); // mm.put("factory", false); // mm.put("fachang", true); // mm.put("fcnum", 0); // mm.put("product_billNo", tdbh); // mm.put("product_serialNo",wtdmx.getTdmx_tdls()); // mm.put("product_otherNo", null); //// mm.put("product_ywrq",wtdmx.gettdmx_ ); // mm.put("product_flh", wtdmx.getTdmx_tdfl()); // mm.put("recompany",wtdmx.getTdmx_shdw() ); //// mm.put("reID", ""); // mm.put("decompany", wtdmx.getTdmx_fhdw()==null?"明泰科技":wtdmx.getTdmx_fhdw()); //// mm.put("deID", ""); // mm.put("rcompany",wtdmx.getTdmx_shdw() ); //// mm.put("rID", ); // mm.put("frombatch", "ERP系统"); // mm.put("forshowindx",1 ); // mm.put("barcode",zc.getTmh()); // mm.put("reserved11",0 ); // mm.put("reserved12",0 ); // mm.put("reserved13",0 ); // mm.put("jsnum",0 ); // // bsper.insertBsi(mm); // } catch (Exception e) { // ddbdao.robackclose(); // throw new // Exception(StringUtils.isEmpty(e.getMessage())?"添加装车信息出错!":e.getMessage()); // }finally{ // ddbdao.close(); // } orr.setCode(0); orr.setItem(true); return orr; } @Override @Transactional(rollbackFor = Exception.class) @Deprecated public ObjectResult sxinCheck(String bsNo, String vehicleId) throws Exception { ObjectResult orr = new ObjectResult(); if (StringUtils.isEmpty(vehicleId)) { orr.setCode(1); orr.setErrmsg("车牌号为空!"); return orr; } if (StringUtils.isEmpty(bsNo)) { orr.setCode(1); orr.setErrmsg("一卡通业务单号为空!"); return orr; } if (true) { orr.setCode(1); orr.setErrmsg("该方法已经弃用!"); return orr; } Fd_Bsheet fdb = fdbsper.getbybsNo(bsNo); if (fdb == null) { orr.setCode(1); orr.setErrmsg("业务单未找到!"); return orr; } Fd_Vehicle fdv = vhper.getByVehicleId(vehicleId); if (fdv == null) { orr.setCode(1); orr.setErrmsg("业务车辆未找到!"); return orr; } try { } catch (Exception e) { throw new Exception(StringUtils.isEmpty(e.getMessage()) ? "销售业务车辆进厂程序出错!" : e.getMessage()); } orr.setCode(0); orr.setItem(true); return orr; } @Override @Deprecated public ObjectResult delZcInfo(Scxt_zcInfo zc) throws Exception { ObjectResult orr = new ObjectResult(); if (zc == null) { orr.setCode(1); orr.setErrmsg("业务参数为空!"); return orr; } if (true) { orr.setCode(1); orr.setErrmsg("该方法已经弃用!"); return orr; } String tmh = zc.getTmh();// 条码号 String cph = zc.getCph();// 车牌号 String cardno = zc.getYktkh();// 一卡通卡号 Map cdi = yktmper.getcardinuse(cardno); if (cdi == null) { orr.setCode(1); orr.setErrmsg("该卡一卡通未找到,请确认该卡是否正确!"); return orr; } if (cdi.get("numberplates") == null) { orr.setCode(1); orr.setErrmsg("该卡没有配置车牌号,请确认该卡是否可用!"); return orr; } Fd_Vehicle fdv = vhper.getByVehicleId(cph); if (fdv == null) { orr.setCode(1); orr.setErrmsg("未找到该分单车牌号!"); return orr; } Map bsmp = null;//bsper.getbsbyBt(cph, Contants.cpxsBtNo, Serviceenum.在办, Contants.kjSdepartNo); if (bsmp == null) { orr.setCode(1); orr.setErrmsg("该车辆没有找到在办的一卡通业务单!"); return orr; } if (StringUtils.isEmpty(bsmp.get("bussinessNo") + "")) { orr.setCode(1); orr.setErrmsg("一卡通业务单未找到!"); return orr; } int wdi = yktmper.getweight_doc(bsmp.get("bussinessNo") + ""); if (wdi <= 0) { orr.setCode(1); orr.setErrmsg("该车辆还未称重,请先去磅房称重!"); return orr; } // Fd_Bsheetitem fd_b=bsiper.getbyNoandCode(tmh, bsmp.get("bussinessNo")+"" ); // if(fd_b!=null){ // String tdNo=fd_b.getTdmx_tdbh();//提单编号 // bsper.delbysibyBarcode(tmh, bsmp.get("bussinessNo")+"" ); // Vehicle_XSTD v_x=vhxper.getbyIDs(cph, tdNo); // if(v_x!=null){ // if(v_x.getFd_num()>1){ // v_x.setFd_num(v_x.getFd_num()-1); // v_x.setFd_weight(BigDecimalfiter.subscal(v_x.getFd_weight(), // fd_b.getTdmx_mz(), Contants.scale)); // vhxper.update(v_x); // fdv.setStatus(VehicleStatus.已装车); // vhper.update(fdv); // }else{ // Map cc=vhxper.getbyVehcleId(cph, v_x.getBsNo()); // if(cc!=null){ // if(cc.get("fd_nums")!=null){ // int fd_nums=Integer.parseInt(cc.get("fd_nums")+""); // if(fd_nums>1){ // fdv.setStatus(VehicleStatus.已装车); // vhper.update(fdv); // }else{ // vhxper.delbyIDs(cph, tdNo); // fdv.setStatus(VehicleStatus.已进厂); // vhper.update(fdv); // } // }else{ // vhxper.delbyIDs(cph, tdNo); // fdv.setStatus(VehicleStatus.已进厂); // vhper.update(fdv); // } // }else{ // vhxper.delbyIDs(cph, tdNo); // fdv.setStatus(VehicleStatus.已进厂); // vhper.update(fdv); // } // } // }else{ // fdv.setStatus(VehicleStatus.已进厂); // vhper.update(fdv); // } // } orr.setCode(0); orr.setItem(true); return orr; } @Override @Deprecated public Map getClInfo(String cardno) { Map mp = new HashMap(); Map cdi = yktmper.getcardinuse(cardno); if (cdi == null) { mp.put("code", 1); mp.put("errmsg", "该卡一卡通未找到,请确认该卡是否发放!"); return mp; } if (cdi.get("numberplates") == null) { mp.put("code", 1); mp.put("errmsg", "该卡没有配置车牌号,请确认该卡是否可用!"); return mp; } String vehicleId = cdi.get("numberplates") + ""; Map bsmap = yktmper.getBsheet(vehicleId, Contants.cpxsBtNo, Serviceenum.在办, "04"); if (bsmap == null) { mp.put("code", 1); mp.put("errmsg", "该卡没有在办的一卡通销售业务单!"); return mp; } Fd_Bsheet fb =null ;//fdbsper.getbyVehicleId(vehicleId, Serviceenum.在办); if (fb == null) { mp.put("code", 1); mp.put("errmsg", "在办分车业务单未找到!"); return mp; } int c = this.yktmper.getweight_doc(fb.getBsNo()); if (c <= 0) { mp.put("code", 1); mp.put("errmsg", "业务单未找到磅单,请先去过磅!"); return mp; } List vxl = new ArrayList(); // List vxl=this.vhxper.getlistbyVehicleId(vehicleId); mp.put("tdbhs", null); if (vxl == null || vxl.size() <= 0) { mp.put("code", 1); mp.put("errmsg", "未找到销售提单!"); return mp; } else { String cc = ""; for (Vehicle_XSTD vx : vxl) { if (StringUtils.isEmpty(cc)) { cc += vx.getXstdNo(); } else { cc += "," + vx.getXstdNo(); } } mp.put("tdbhs", cc); } mp.put("code", 0); mp.put("cph", fb.getVehicleId()); mp.put("sjmc", fb.getDriver()); mp.put("dh", fb.getPhone()); mp.put("ywdh", fb.getBsNo()); return mp; } @Override @Transactional(rollbackFor = Exception.class) @Deprecated public ObjectResult batchSaveZcInfo(String zclist) throws Exception { ObjectResult orr = new ObjectResult(); if (StringUtils.isEmpty(zclist)) { orr.setCode(1); orr.setErrmsg("参数为空不能保存!"); return orr; } if (true) { orr.setCode(1); orr.setErrmsg("方法已经弃用!"); return orr; } // String Lcuuid=UUID.randomUUID()+""; // try { // JsonParser jp=new JsonParser(); // JsonArray ja=jp.parse(zclist).getAsJsonArray(); // int eachline=0; // //是否检查车辆 // boolean checkVehicle=true; // String bussinessNo=""; // Fd_Vehicle fdv=null; // Fd_Bsheet fdb=null; // Map dberpmp=new HashMap(); // double mzweight=0; // String instanceID=""; // Map lm=new HashMap(); // for (JsonElement tdje : ja) { // if(lm.size()>1){ // break; // } // JsonObject jo=tdje.getAsJsonObject(); // Scxt_zcInfo zc=new Scxt_zcInfo(); // eachline++; // zc=JSONobj.getobj(jo, zc); // if(zc==null){ // continue; // } // String tdNo=zc.getTdbh(); // if(!StringUtils.isEmpty(tdNo)){ // String tdsign=tdNo.split("-")[0]; // if(lm.get(tdsign)==null){ // lm.put(tdsign, "abc"); // } // } // } // if(lm.size()>1){ //// boolean lcboo=ddbdao.getLcmps(Lcuuid); // String dbcheck=DBchecksingleton.setDbc(Lcuuid,false); // if(!Lcuuid.equals(dbcheck)){ // throw new Exception("ERP数据库正在被占用,请重新操作!"); // } // } // List fdcl=this.fdcper.getall(); // Map fdcm=new HashMap(); // if(fdcl!=null){ // for (Fd_Company fdc : fdcl) { // if(!fdc.isHasSPR()){ // fdcm.put(fdc.getCompanyNo(), fdc.getName()); // } // } // } // for (JsonElement je : ja) { // JsonObject jo=je.getAsJsonObject(); // Scxt_zcInfo zc=new Scxt_zcInfo(); // eachline++; // zc=JSONobj.getobj(jo, zc); // if(zc==null){ // continue; // } // // // if(StringUtils.isEmpty(zc.getCph())||StringUtils.isEmpty(zc.getTdbh())||StringUtils.isEmpty(zc.getPch())){ // continue; // } // String dbsign=zc.getTdbh().split("-")[0]; // Fd_Erpconfig erpdb=null; // if(dberpmp.get(dbsign)==null){ // erpdb=erpper.getbySign(dbsign); // if(erpdb==null){ // throw new Exception("提单编号是"+dbsign+"-******* 类型的未配置ERP数据库!"); // } // dberpmp.put(dbsign, erpdb); // }else{ // erpdb=dberpmp.get(dbsign); // } // if(checkVehicle){ // fdv=vhper.getByVehicleId(zc.getCph()); // if(fdv==null){ // throw new Exception("分单系统车牌号:"+zc.getCph()+" 未找到,请确认车辆信息是否正确!"); // } // Map bsmp=bsper.getbsbyBt(zc.getCph(), Contants.cpxsBtNo, // Serviceenum.在办, Contants.ssdepartNo); // if(bsmp==null){ // throw new Exception("车牌号:"+zc.getCph()+" 未找到一卡通业务单!"); // } // bussinessNo=bsmp.get("bussinessNo")+""; // instanceID=bsmp.get("instanceID")==null?"":bsmp.get("instanceID")+""; // fdb=fdbsper.getbybsNo(bussinessNo); // if(fdb==null){ // throw new Exception("车牌号:"+zc.getCph()+" 未找到分单业务单!"); // }else{ // if(!fdb.getVehicleId().equals(zc.getCph())){ // throw new Exception("车牌号:"+zc.getCph()+"与 分单车牌号不一致!"); // } // } // checkVehicle=false; // } // // Vehicle_XSTD vhx=vhxper.getbyIDs(zc.getCph(), zc.getTdbh()); // if(vhx==null){ // throw new Exception("提单编号:"+zc.getTdbh()+"没有分单给车牌号:"+zc.getCph()+" !"); // } // String // url="jdbc:jtds:sqlserver://"+erpdb.getUri()+":"+erpdb.getPost()+";databaseName="+erpdb.getDb(); // Connection con=ddbdao.open(url, erpdb.getUsername(), // erpdb.getPwd(),erpdb.getDbsign()); // if(con==null){ // throw new Exception("ERP数据库链接失败,请检查分单系统ERP配置是否正确!"); // } // String sql=SqlTxt.GYErpXSTDsql+" where EXISTS (SELECT 1 FROM XSTDMX WHERE // XSTDMX_TDLS=XSTD_TDLS AND XSTDMX_CKBZ='0') and a.XSTD_TDBH='"+zc.getTdbh()+"' // and a.XSTD_SHBZ=1 and a.XSTD_TDBZ='LD' "; // Map tdmp=ddbdao.getmapnoclose(sql,erpdb.getDbsign()); // if(tdmp==null){ // throw new Exception("第"+eachline+"行 ,销售提单未找到!"); // } // WaitXSTD wt=new WaitXSTD(); // BeanUtils.populate(wt, tdmp); // // sql=SqlTxt.GYErpXSTDMXsql+" where b.XSTDMX_CKBZ='0' and // a.XSTD_TDBH='"+zc.getTdbh()+"' and b.XSTDMX_PCH='"+zc.getPch()+"' ";//销售提单明细 // Map mxmp=ddbdao.getmapnoclose(sql,erpdb.getDbsign()); // if(mxmp==null){ // throw new Exception("第"+eachline+"行 根据提单号和批次号Erp未找到销售提单明细!"); // } // WaitXSTDMX wtdmx=new WaitXSTDMX(); // BeanUtils.populate(wtdmx, mxmp); // String hj=mxmp.get("hj")==null?"":mxmp.get("hj")+""; // String zt=mxmp.get("zt")==null?"":mxmp.get("zt")+""; // wtdmx.setTdmx_hjzt(hj+"/"+zt); // //如果扫的是没有分单的 // if(wtdmx.getTdmx_fdbz()==0){ // sql=SqlTxt.XGGYErpXSTDMXsql1+" where a.XSTDMX_CKBZ='0' and // b.XSTD_TDBH='"+zc.getTdbh()+"' and a.XSTDMX_PCH='"+zc.getPch()+"' // ";//修改销售提单明细 // List ll=new ArrayList(); // ll.add(zc.getCph());//车牌号 // ll.add(2);//分单标志 // ll.add(bussinessNo);//分单单据编号 // ll.add(fdv.getDriver());//司机姓名 // ll.add(fdv.getPhone());//司机联系方式 // ll.add(fdcm.get(vhx.getCompanyNo())==null?"":fdcm.get(vhx.getCompanyNo()));//物流公司名称 //// ll.add(fdcm.get(fdv.getCompanyNo())==null?"":fdcm.get(fdv.getCompanyNo()));//物流公司名称 // ddbdao.modifySql(sql, ll,erpdb.getDbsign()); // // sql=SqlTxt.XGGYErpXSTDsql;//修改销售提单 // ll.clear(); // ll.add(wt.getTd_wfdsl()-1);//未分单数量 // ll.add(BigDecimalfiter.subscal(wt.getTd_wfdzl(), wtdmx.getTdmx_mz(), // Contants.scale));//未分单毛重 // ll.add(zc.getTdbh()); // ddbdao.modifySql(sql, ll,erpdb.getDbsign()); // // //修改vhx // vhx.setFd_num(vhx.getFd_num()+1); // vhx.setFd_weight(BigDecimalfiter.addscal(vhx.getFd_weight(), // wtdmx.getTdmx_mz(), Contants.scale)); // vhxper.update(vhx); // }else{ // sql=SqlTxt.XGGYErpXSTDMXsql2+" where a.XSTDMX_CKBZ='0' and // b.XSTD_TDBH='"+zc.getTdbh()+"' and a.XSTDMX_PCH='"+zc.getPch()+"' // ";//修改销售提单明细 // List ll=new ArrayList(); // ll.add(fdv.getDriver());//司机姓名 // ll.add(fdv.getPhone());//司机联系方式 // ll.add(fdcm.get(vhx.getCompanyNo())==null?"":fdcm.get(vhx.getCompanyNo()));//物流公司名称 //// ll.add(fdcm.get(fdv.getCompanyNo())==null?"":fdcm.get(fdv.getCompanyNo()));//物流公司名称 // ddbdao.modifySql(sql, ll,erpdb.getDbsign()); // // if(!zc.getCph().equals(wtdmx.getTdmx_cph())){ // Vehicle_XSTD vhx1=this.vhxper.getbyIDs(wtdmx.getTdmx_cph(), zc.getTdbh()); // if(vhx1!=null){ // vhx1.setFd_num(vhx1.getFd_num()-1); // vhx1.setFd_weight(BigDecimalfiter.subscal(vhx1.getFd_weight(), // wtdmx.getTdmx_mz(), Contants.scale)); // vhxper.update(vhx1); // } // //修改vhx // vhx.setFd_num(vhx.getFd_num()+1); // vhx.setFd_weight(BigDecimalfiter.addscal(vhx.getFd_weight(), // wtdmx.getTdmx_mz(), Contants.scale)); // vhxper.update(vhx); // } // } // //修改fbi // Fd_Bsheetitem fbi=bsiper.getbyLsandFl(wtdmx.getTdmx_tdls(), // wtdmx.getTdmx_tdfl(),zc.getTdbh()); // if(fbi!=null){ // fbi.setTdmx_cph(zc.getCph()); // fbi.setTdmx_tdbh(zc.getTdbh()); // fbi.setTdmx_fdbz(2); // fbi.setTdmx_fdywbh(fdb.getFdsheetNo()); // fbi.setTdmx_zccph(zc.getCph()); // fbi.setTdmx_sfzc(1); // fbi.setBarcode(zc.getTmh()); // bsiper.update(fbi); // }else{ // fbi=new Fd_Bsheetitem(); // fbi.setId(UUID.randomUUID()+""); // fbi.setCompanyName(fdb.getCompanyName()); // fbi.setCompanyNo(fdb.getCompanyNo()); // fbi.setCreateid(fdb.getCreateid()); // fbi.setBarcode(zc.getTmh()); // fbi.setCtime(new Date()); // fbi.setTdmx_cph(zc.getCph()); // fbi.setTdmx_tdbh(zc.getTdbh()); // fbi.setTdmx_fdbz(2); // fbi.setTdmx_fdywbh(fdb.getFdsheetNo()); // fbi.setTdmx_zccph(zc.getCph()); // fbi.setTdmx_sfzc(1); // bsiper.insert(fbi); // } // if(fdv.getStatus()!=VehicleStatus.已进厂){ // fdv.setStatus(VehicleStatus.已进厂); // vhper.update(fdv); // } // // //添加一卡通明细; // Map mm=new HashMap(); // mm.put("id", UUID.randomUUID()+""); // mm.put("bussinessNo",bussinessNo); // mm.put("name", wtdmx.getTdmx_wlmc()); // mm.put("materielNo",wtdmx.getTdmx_wlbh() ); // mm.put("norms",wtdmx.getTdmx_ggxh() ); // mm.put("unitname", "Kg"); // mm.put("num", 1); // mm.put("note", null); // mm.put("weight", BigDecimalfiter.mulcon(wtdmx.getTdmx_jz(), 1000, // Contants.scale)); // mm.put("price", 0); // mm.put("preweight",BigDecimalfiter.mulcon(wtdmx.getTdmx_jz(), 1000, // Contants.scale)); // mm.put("pici", zc.getPch()); // mm.put("hejin", wtdmx.getTdmx_hjzt()); // mm.put("gross",BigDecimalfiter.mulcon(wtdmx.getTdmx_mz(), 1000, // Contants.scale) ); // mm.put("taotong","" ); // mm.put("taotongWeight", BigDecimalfiter.subscal(wtdmx.getTdmx_mz()*1000, // wtdmx.getTdmx_jz()*1000, Contants.scale)); // mm.put("money", 0); //// mm.put("createid", ); //// mm.put("cname", ); //// mm.put("createid", 0); // mm.put("cdepartid", 0); //// mm.put("cdepart", ); // mm.put("ctime", new Date()); // mm.put("loadbuild", false); // mm.put("factory", false); // mm.put("fachang", true); // mm.put("fcnum", 0); // mm.put("product_billNo", zc.getTdbh()); // mm.put("product_serialNo",wtdmx.getTdmx_tdls()); // mm.put("product_otherNo", null); //// mm.put("product_ywrq",wtdmx.gettdmx_ ); // mm.put("product_flh", wtdmx.getTdmx_tdfl()); // mm.put("recompany",wtdmx.getTdmx_shdw() ); //// mm.put("reID", ""); // mm.put("decompany", wtdmx.getTdmx_fhdw()==null?"明泰科技":wtdmx.getTdmx_fhdw()); //// mm.put("deID", ""); // mm.put("rcompany",wtdmx.getTdmx_shdw() ); //// mm.put("rID", ); // mm.put("frombatch", "ERP系统"); // mm.put("forshowindx",1 ); // mm.put("barcode",zc.getTmh()); // mm.put("reserved11",0 ); // mm.put("reserved12",0 ); // mm.put("reserved13",0 ); // mm.put("jsnum",0 ); // Map mrc=this.bsper.getbsi(zc.getPch(), bussinessNo); // if(mrc==null){ // bsper.insertBsi(mm); // }else{ // mm.put("id", mrc.get("id")+""); // bsper.updateBsi(mm); // } // mzweight=BigDecimalfiter.addscal(mzweight, // BigDecimalfiter.mulcon(wtdmx.getTdmx_mz(), 1000, Contants.scale), // Contants.scale); // } // // if(mzweight>0&&!StringUtils.isEmpty(instanceID)){ // Map mm=this.yktmper.getweight_docgt(bussinessNo); // if(mm!=null){ // double gross=Double.parseDouble(mm.get("gross")+""); // double tare=Double.parseDouble(mm.get("tare")+""); // if(gross>0&& tare>0){ // Task tk=this.acpser.findTaskByInstanceID(instanceID, // Contants.weightTaskName); // Map mcm=new HashMap(); // if(tk!=null){ // if(((gross-tare)-mzweight>Contants.upweight)||(mzweight-(gross-tare)) batchdelZcInfo(String zcist) throws Exception { ObjectResult orr = new ObjectResult(); if (zcist == null) { orr.setCode(1); orr.setErrmsg("业务参数为空!"); return orr; } if (true) { orr.setCode(1); orr.setErrmsg("该方法已经弃用!"); return orr; } // try { // JsonParser jp=new JsonParser(); // JsonArray ja=jp.parse(zcist).getAsJsonArray(); // boolean checkvehicle=true; // Fd_Vehicle fdv=null; // String bussinessNo=""; // Fd_Bsheet fdb=null; // for (JsonElement je : ja) { // JsonObject jo=je.getAsJsonObject(); // Scxt_zcInfo zc=new Scxt_zcInfo(); // zc=JSONobj.getobj(jo, zc); // if(zc==null){ // continue; // } // if(StringUtils.isEmpty(zc.getCph())||StringUtils.isEmpty(zc.getYktkh())||StringUtils.isEmpty(zc.getPch())){ // continue; // } // String vehicleId=zc.getCph();//车牌号 // String cardno=zc.getYktkh();//卡号 // String pch=zc.getPch();//批次号 // if(checkvehicle){ // Map cdi=yktmper.getcardinuse(cardno); // if(cdi==null){ // throw new Exception("卡号一卡通未找到,请确认该卡是否正确!"); // }else if(!vehicleId.equals(cdi.get("numberplates"+""))){ // throw new Exception("卡号与车牌号不对应,请确认卡号或者车牌号是否正确!"); // } // fdv=vhper.getByVehicleId(zc.getCph()); // if(fdv==null){ // throw new Exception("分单系统车牌号:"+zc.getCph()+" 未找到,请确认车辆信息是否正确!"); // } // Map bsmp=bsper.getbsbyBt(zc.getCph(), Contants.cpxsBtNo, // Serviceenum.在办, Contants.ssdepartNo); // if(bsmp==null){ // throw new Exception("车牌号:"+zc.getCph()+" 未找到一卡通业务单!"); // } // bussinessNo=bsmp.get("bussinessNo")+""; // fdb=fdbsper.getbybsNo(bussinessNo); // if(fdb==null){ // throw new Exception("车牌号:"+zc.getCph()+" 未找到分单业务单!"); // }else{ // if(!fdb.getVehicleId().equals(zc.getCph())){ // throw new Exception("车牌号:"+zc.getCph()+"与 分单车牌号不一致!"); // } // } // checkvehicle=false; // } // bsper.delbypchandNo(pch, bussinessNo); // Fd_Bsheetitem fdbi=bsiper.getbypchandNo(bussinessNo, pch); // if(fdbi!=null){ // fdbi.setTdmx_sfzc(0); // fdbi.setTdmx_zccph(""); // bsiper.update(fdbi); // } // } // // //修改车辆信息 // List> bsill=bsper.getbsibyNo(bussinessNo); // if(bsill==null||bsill.size()<=0){ // fdv.setStatus(VehicleStatus.已进厂); // vhper.update(fdv); // } // } catch (Exception e) { // throw new // Exception(StringUtils.isEmpty(e.getMessage())?"分单系统批量删除装车出错!":e.getMessage()); // } orr.setCode(0); orr.setItem(true); return orr; } @Override public void changeMxWlgs(List fdMxWlgsList) throws Exception { // if(1==1) throw new Exception("就是一个提示!---"); if(fdMxWlgsList!=null) { List updateFd_XSTDMX = new ArrayList<>(); String tdmx_tdfls = fdMxWlgsList.stream().map(FdMxWlgs::getTdmxTdfl).collect(Collectors.joining("','")); List fd_xstdmxes = null; // 提单流水为主键的Map,存放去掉的数量和重量,需要还回去 Map> tdlsMap = new HashedMap(); if(StringUtils.isNotBlank(tdmx_tdfls)) { // 根据单号查找已派车的业务单,判断业务单是否发卡,已发卡不能修改,返回错误;前端应该也做限制 tdmx_tdfls = "'" + tdmx_tdfls + "'"; fd_xstdmxes = fd_xstdmxMapper.gets(tdmx_tdfls); String fdywbhs = fd_xstdmxes.stream().map(Fd_XSTDMX::getTdmx_fdywbh).collect(Collectors.joining("','")); if(StringUtils.isNotBlank(fdywbhs) && !"'null'".equals(fdywbhs)) { fdywbhs = "'" + fdywbhs + "'"; // 如果已经发卡,请联系一卡通 Map map = businessMapper.existsIssueCardByNos(fdywbhs); if (map != null) { throw new Exception("存在已发卡单,请刷新页面后重试!"); } } // 删了单,要把重量和数量还回去;在此遍历一下,下面在session中统一更新 fd_xstdmxes.forEach(fd_xstdmx -> { // 装车标志都是 0 // if(fd_xstdmx.getTdmx_zcbz() == 0) return; // 不存在业务号,则任务没有分单;采用装车标志有问题,不采用。 if(StringUtils.isBlank(fd_xstdmx.getTdmx_fdywbh())) return; if(tdlsMap.get(fd_xstdmx.getTdmx_tdls()) == null ) { tdlsMap.put(fd_xstdmx.getTdmx_tdls(), new HashedMap()); tdlsMap.get(fd_xstdmx.getTdmx_tdls()).put("addFdsl",0); tdlsMap.get(fd_xstdmx.getTdmx_tdls()).put("addFdmz",0d); } Map map = tdlsMap.get(fd_xstdmx.getTdmx_tdls()); int addFdsl = (Integer) map.get("addFdsl"); double addFdmz = (Double) map.get("addFdmz"); addFdsl ++; addFdmz = BigDecimalfiter.addscal(addFdmz, fd_xstdmx.getTdmx_mz(), Contants.scale); map.put("addFdsl",addFdsl); map.put("addFdmz",addFdmz); }); } fdMxWlgsList.forEach(fdMxWlgs -> { Fd_XSTDMX fd_xstdmx = new Fd_XSTDMX(); fd_xstdmx.setTdmx_fdcph(null); fd_xstdmx.setTdmx_zcwlgsName(null); fd_xstdmx.setTdmx_zcphone(null); fd_xstdmx.setTdmx_zcdriver(null); fd_xstdmx.setTdmx_fdwlgsbh(null); fd_xstdmx.setTdmx_fdywbh(null); fd_xstdmx.setTdmx_fdbz(0); fd_xstdmx.setTdmx_zcbz(0); fd_xstdmx.setTdmx_tdfl(fdMxWlgs.getTdmxTdfl()); fd_xstdmx.setTdmx_fdwlgsbh(fdMxWlgs.getWlgsNo()); updateFd_XSTDMX.add(fd_xstdmx); }); try(SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false)){ // 删除明细和物流公司关系,并新增 FdMxWlgsMapper mapper = sqlSession.getMapper(FdMxWlgsMapper.class); fdMxWlgsList.forEach(fdMxWlgs -> { // 需要删除相关信息(删除该业务单、删除车辆提单) mapper.delete(fdMxWlgs.getTdmxTdfl()); mapper.insert(fdMxWlgs); }); if(updateFd_XSTDMX != null) { // 更新分单明细项为未分单 Fd_XSTDMXMapper fd_xstdmxMapper = sqlSession.getMapper(Fd_XSTDMXMapper.class); updateFd_XSTDMX.forEach(fd_xstdmx -> fd_xstdmxMapper.updateZCnoFD(fd_xstdmx)); } if(fd_xstdmxes!=null && fd_xstdmxes.size() > 0 ) { Fd_BsheetMapper fd_bsheetMapper = sqlSession.getMapper(Fd_BsheetMapper.class); VehicleXSTDMapper vehicleXSTDMapper = sqlSession.getMapper(VehicleXSTDMapper.class); for (Fd_XSTDMX fd_xstdmx : fd_xstdmxes) { // 根据车牌号和业务号删除分单车辆,如果是拼单的情况;是否是拼单,取消这个就行,其他不管。 // 如果配车数量为0可以删除,其他情况,可以-1,把重量也减掉 if(StringUtils.isNotBlank(fd_xstdmx.getTdmx_fdcph()) && StringUtils.isNotBlank(fd_xstdmx.getTdmx_fdywbh())) { List vehicleXSTDs = vehicleXSTDMapper.getlistbyVehicleIdandbsNoGp(fd_xstdmx.getTdmx_fdcph(), fd_xstdmx.getTdmx_fdywbh()); if (vehicleXSTDs != null && vehicleXSTDs.size() == 1) { Vehicle_XSTD vehicleXSTD = vehicleXSTDs.get(0); int num = vehicleXSTD.getFd_num(); if (num <= 1) { vehicleXSTDMapper.delbyVehicleId(fd_xstdmx.getTdmx_fdcph(), fd_xstdmx.getTdmx_fdywbh()); } else { vehicleXSTD.setFd_num(vehicleXSTD.getFd_num() - 1); vehicleXSTD.setFd_weight(BigDecimalfiter.subscal(vehicleXSTD.getFd_weight(), fd_xstdmx.getTdmx_mz(), Contants.scale)); vehicleXSTDMapper.updatewithIDs(vehicleXSTD); } } else { throw new Exception("出现同一辆车的同一业务单出现多个,请检查数据"); } } // vehicleXSTDMapper.delbyVehicleId(fd_xstdmx.getTdmx_fdcph(), fd_xstdmx.getTdmx_fdywbh()); Fd_Bsheet fd_bsheet = fd_bsheetMapper.getbybsNo(fd_xstdmx.getTdmx_fdywbh()); // 删除分单业务 fd_bsheetMapper.delbybsNo(fd_xstdmx.getTdmx_fdywbh()); // 远程删除数量 if(fd_bsheet!=null) { JsonObject jo = new JsonObject(); jo.addProperty("bussinessNo", fd_xstdmx.getTdmx_fdywbh()); jo.addProperty("sdepartNo", fd_bsheet.getSdepartNo()); // 通过接口删除业务单 JsonObject pfob = Wxhtmethod.postJsonStr(Contants.YKTdelYwd_url, jo.toString()); int code = JSONobj.getint(pfob, "code"); if (code != 0) { throw new Exception(JSONobj.getstring(pfob, "errmsg")); } } } // 需要更新提单的重量和数量 Fd_XSTDMapper fdXstdMapper = sqlSession.getMapper(Fd_XSTDMapper.class); tdlsMap.forEach((k, v) -> { Fd_XSTD xstd = fdXstdMapper.get(k); int addFdsl_1 = (Integer) v.get("addFdsl"); double addFdmz_1 = (Double) v.get("addFdmz"); xstd.setTd_tdls(k); xstd.setTd_wfdsl(xstd.getTd_wfdsl() + addFdsl_1); xstd.setTd_wfdzl(BigDecimalfiter.addscal(xstd.getTd_wfdzl(), addFdmz_1, Contants.scale)); fdXstdMapper.updateFD(xstd); }); } sqlSession.commit(); } } } @Resource Fd_XSTDMXMapper fd_xstdmxMapper; @Resource BusinessMapper businessMapper; }