package com.mandi.webservice.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.mapper.FdRepertoryNexusMapper;
|
import com.mandi.basicconfig.mapper.NczsjMapper;
|
import com.mandi.basicconfig.persist.*;
|
import com.mandi.common.JSONobj;
|
import com.mandi.common.Jacksonmethod;
|
import com.mandi.common.ParamFileter.BigDecimalfiter;
|
import com.mandi.common.SpringContext;
|
import com.mandi.common.Wxhtmethod;
|
import com.mandi.dao.common.ObjectResult;
|
import com.mandi.dao.common.PageResult;
|
import com.mandi.fendan.mapper.*;
|
import com.mandi.fendan.persist.*;
|
import com.mandi.fendan.util.Contants;
|
import com.mandi.fendan.util.ConvertTool;
|
import com.mandi.fendan.util.ThreadPoolUtil;
|
import com.mandi.fendan.util.persist.Serviceenum;
|
import com.mandi.fendan.util.persist.WaitXSTDMX;
|
import com.mandi.fendan.util.persist.Yktbsitem;
|
import com.mandi.servlet.file.impl.FileLoadImpl;
|
import com.mandi.webservice.service.IFdXSTDService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.log4j.Logger;
|
import org.springframework.context.ApplicationContext;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
@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);
|
|
public static Boolean refreshMsLedLock = false;
|
public static Boolean refreshYrLedLock = false;
|
|
@Override
|
@Transactional(rollbackFor=Exception.class)
|
public ObjectResult<Boolean> saveFd_xstd(String dataArr) throws Exception {
|
ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
|
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<Boolean> delFd_xstd(String dataArr) throws Exception {
|
ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
|
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<Boolean> closeFd_xstd(String dataArr) throws Exception {
|
ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
|
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<Boolean> openFd_xstd(String dataArr) throws Exception {
|
ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
|
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<Map<String, Object>> addZCMX(String cardID,String yktywdh, JsonArray dataArr) throws Exception {
|
PageResult<Map<String, Object>> prr=new PageResult<Map<String,Object>>();
|
List<Map<String, Object>> relist=new ArrayList<Map<String,Object>>();
|
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<String, Object> 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<String, Object> 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
|
}
|
|
String currPch="";// 当前批次号
|
//第一次添加装卸记录发送装车信息
|
int sfzc=this.fbper.getbsitembyNo(fdb.getBsNo());
|
if(sfzc<=0) {
|
//发送微信公众号提醒信息
|
String url=Contants.yktLocalAdd+"/routine/sendZcMsg.htm";
|
Map<String, String> paramMp=new HashMap<String, String>();
|
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());
|
List tdmxPchList = new ArrayList();
|
for (JsonElement je : dataArr) {
|
JsonObject jo=je.getAsJsonObject();
|
String tdmx_pch = jo.get("tdmx_pch").getAsString();
|
tdmxPchList.add(tdmx_pch);
|
}
|
if("08".equals(fdb.getSdepartNo())) { // 只是义瑞厂区有效
|
// 检查是否当前区域已经排队
|
Map paramMap = new HashMap();
|
paramMap.put("vehicleId", vehicleId);
|
paramMap.put("tdmxPchList", tdmxPchList);
|
String jsonStr = Jacksonmethod.tojson(paramMap, false);
|
JsonObject jsonObject = Wxhtmethod.postJsonStr(Contants.yr_canDoScanUrl, jsonStr);
|
if (jsonObject.get("code").getAsInt() != 0) {
|
prr.setCode(1);
|
prr.setErrmsg(jsonObject.get("errmsg").getAsString());
|
return prr;
|
}
|
}
|
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<String, Object> remp=new HashMap<String, Object>();
|
remp.put("tdmx_pch",tdmx.getTdmx_pch());
|
remp.put("td_tdls",tdmx.getTdmx_tdls());
|
remp.put("tdmx_tdfl",tdmx.getTdmx_tdfl());
|
relist.add(remp);
|
currPch = tdmx.getTdmx_pch();
|
}
|
|
if(grossNum>0) {
|
Map<String, Object> xstm=new HashMap<String, Object>();
|
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<String, String> paramMp=new HashMap<String, String>();
|
mp.put("vehicleID", vehicleId);
|
Wxhtmethod.postJson(url, paramMp);
|
}
|
}
|
|
// 此处异步触发一下明晟发车
|
if("06".equals(fdb.getSdepartNo())) {
|
final String cph = currPch;
|
final String finalVehicleId = vehicleId;
|
ThreadPoolUtil.getInstance().execute(()->{
|
synchronized (FdXSTDService.refreshMsLedLock) {
|
if (FdXSTDService.refreshMsLedLock) { // 系统繁忙
|
log.info(finalVehicleId + "" + cph + "系统繁忙!");
|
return;
|
}
|
}
|
try {
|
synchronized (FdXSTDService.refreshMsLedLock) {
|
FdXSTDService.refreshMsLedLock = true;
|
}
|
sendToMsLed(cph);
|
} catch (Exception e) {
|
log.error("出现异常:"+ e.getMessage(),e);
|
} finally {
|
synchronized (FdXSTDService.refreshMsLedLock) {
|
FdXSTDService.refreshMsLedLock = false;
|
}
|
}
|
});
|
}
|
if("08".equals(fdb.getSdepartNo())) {
|
final String cph = currPch;
|
ThreadPoolUtil.getInstance().execute(()->{
|
|
Map scanCodeParamMap = new HashMap();
|
scanCodeParamMap.put("pch",cph);
|
Wxhtmethod.post(Contants.yr_scanCodeNoticeUrl, scanCodeParamMap);
|
|
try {
|
synchronized (FdXSTDService.refreshYrLedLock) {
|
if (FdXSTDService.refreshYrLedLock) { // 系统繁忙
|
return ;
|
}
|
FdXSTDService.refreshYrLedLock = true;
|
}
|
sendToYrLed(cph);
|
} catch (Exception e) {
|
log.error(e);
|
} finally {
|
synchronized (FdXSTDService.refreshYrLedLock) {
|
FdXSTDService.refreshYrLedLock = false;
|
}
|
}
|
});
|
}
|
prr.setCode(0);
|
prr.setErrmsg("装车操作成功!");
|
prr.setList(relist);
|
return prr;
|
}
|
|
/**
|
*
|
* @param currPch 当前批次号
|
*/
|
public void sendToMsLed(String currPch){
|
//A区 76-86 + 99-1
|
//B区 14-33 + 99-2
|
//C区 53-67 + 99-3
|
log.info("LED-ABC当前扫码批次号:" + currPch);
|
List<Map> totalList = tdmxper.getHwList("06"); // 获取明晟所有在办业务单的信息
|
log.info("LED-ABC获取信息条数:" + totalList.size());
|
Map<String,List<Map>> ywbhListMap = new HashMap<>();
|
for (Map map : totalList) {
|
String ywdw = (String) map.get("tdmx_fdywbh");
|
if(ywdw == null) {
|
log.info("出现业务单号为null的情况:" + Jacksonmethod.tojson(map,false));
|
continue;
|
}
|
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 %s/%s %s/%s %s/%s\r\n";
|
// 只有1个区
|
|
Map speakParam = new HashMap(1);
|
for (Map.Entry<String, List<Map>> entry : ywbhListMap.entrySet()) {
|
// 遍历每个业务单的
|
// 当前装车A、B、C区
|
boolean currA = false,currB = false, currC = false;
|
boolean hasZcwc = false; // 保证已经完成了
|
String ywhb = entry.getKey();
|
List<Map> vehicleIdTotalList = entry.getValue();
|
Map<String, Integer> totalAbcMap = new HashMap(3); // 总计信息
|
totalAbcMap.put("A", 0);
|
totalAbcMap.put("B", 0);
|
totalAbcMap.put("C", 0);
|
Map<String, Integer> 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");
|
String pch = (String) map.get("tdmx_pch");
|
if(StringUtils.isBlank(cph)) cph = (String) map.get("tdmx_fdcph");
|
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",totalAbcMap.get("A") + 1);
|
if (zcbz != null && zcbz == 1) { // 装车完成
|
abcMap.put("A", abcMap.get("A") + 1);
|
hasZcwc = true;
|
}
|
if(pch.equals(currPch)) {
|
currA = true; currB = false;currC =false;
|
}
|
} else if (num >= 14 && num <= 33 || hw.lastIndexOf("99-2") >= 0) { // B区
|
totalAbcMap.put("B", totalAbcMap.get("B") + 1);
|
if (zcbz != null && zcbz == 1) {
|
abcMap.put("B", abcMap.get("B") + 1);
|
hasZcwc = true;
|
}
|
if(pch.equals(currPch)) {
|
currA = false; currB = true;currC =false;
|
}
|
} else if (num >= 53 && num <= 67 || hw.lastIndexOf("99-3") >= 0) { // C区
|
totalAbcMap.put("C", totalAbcMap.get("C") + 1);
|
if (zcbz != null && zcbz == 1) {
|
abcMap.put("C", abcMap.get("C") + 1);
|
hasZcwc = true;
|
}
|
if(pch.equals(currPch)) {
|
currA = false; currB = false; currC =true;
|
}
|
}
|
}
|
// if (!hasZcwc) continue; //没有装车完成的也跳过
|
/*if (!(currA || currB || currC) && abcMap.get("A") + abcMap.get("B") + abcMap.get("C") ==
|
totalAbcMap.get("A") + totalAbcMap.get("B") + totalAbcMap.get("C")) { // 非当前车牌号,已经装车完成但是未出厂
|
continue;
|
}*/
|
if(totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0 && totalAbcMap.get("A")==0) {
|
continue;
|
}
|
str2 += String.format(formatStr, cph, fillWithZero(abcMap.get("A")), fillWithZero(totalAbcMap.get("A")),
|
fillWithZero(abcMap.get("B")), fillWithZero(totalAbcMap.get("B")),
|
fillWithZero(abcMap.get("C")), fillWithZero(totalAbcMap.get("C")));
|
log.info(ywhb + "投屏准备完成,开始准备语音。");
|
// 开始准备语音
|
int total = 0;
|
if(currA && abcMap.get("A") == totalAbcMap.get("A") && totalAbcMap.get("A")>0) { // 当前车在A区装车完成
|
total = totalAbcMap.get("A");
|
}
|
if(currB && abcMap.get("B") == totalAbcMap.get("B") && totalAbcMap.get("B")>0) {// 当前车在B区装车完成
|
total = totalAbcMap.get("B");
|
}
|
if(currC && abcMap.get("C") == totalAbcMap.get("C") && totalAbcMap.get("C")>0) {// 当前车在C区装车完成
|
total = totalAbcMap.get("C");
|
}
|
try {
|
String speakTxt = startToSpeak(cph,total,abcMap,totalAbcMap);
|
if(StringUtils.isNotBlank(speakTxt)) {
|
log.info("SpeakTxt:"+ speakTxt);
|
speakParam.put("SpeakTxt", speakTxt);
|
}
|
}catch (Exception e){
|
log.error("准备语音出错!" + e.getMessage(),e);
|
}
|
|
// 准备语音结束
|
// 单辆车的单个业务单的信息结束
|
}
|
if(StringUtils.isBlank(str2)) {
|
str2 = "无车辆";
|
}
|
Map paramMap = new HashMap();
|
paramMap.put("strTitle",str1);
|
paramMap.put("strContent",str2);
|
try {
|
log.info("LED-ABC webServiceAddrss:"+Contants.msLedServiceAddr+"st1::" +str1+";;;;;str2::"+str2);
|
String re = Wxhtmethod.post(Contants.msLedServiceAddr + "/SendLED",paramMap);
|
log.info("LED-ABC result:"+re);
|
// 语音只播一条
|
String re1 = Wxhtmethod.post(Contants.msLedServiceAddr + "/Speak",speakParam);
|
}catch (Exception e){}
|
|
|
}
|
|
/**
|
* 准备语音
|
* @param cph 车牌号
|
* @param total 当前区总数
|
* @param abcMap A、B、C为key的区已装数目
|
* @param totalAbcMap A、B、C为key的区总数
|
* @return
|
*/
|
String startToSpeak(String cph, int total,Map<String,Integer> abcMap,Map<String,Integer> totalAbcMap) {
|
String speakTxt=null ;
|
if(total > 0) { // 播放语音,请离开区域
|
String speakTxtFormatStr1 = "车号%s ,装货%d件已完成,请司机清点货物后尽快驶离装货区。";
|
// 只有2个区
|
String speakTxtFormatStr2 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区装货。";
|
// 只有3个区
|
String speakTxtFormatStr3 = "车号%s,%s区装货%d件已全部扫描完成,请司机清点货物后去%s区%s区装货。";
|
|
if( (abcMap.get("A")>0 && totalAbcMap.get("B")==0 && totalAbcMap.get("C")==0) ||
|
(abcMap.get("B")>0 && totalAbcMap.get("A")==0 && totalAbcMap.get("C")==0) ||
|
(abcMap.get("C")>0 && totalAbcMap.get("B")==0 && totalAbcMap.get("D")==0)
|
) { // 只有一个区域有货物
|
speakTxt= String.format(speakTxtFormatStr1, cph, total);
|
}else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 &&
|
(totalAbcMap.get("C")==0 || totalAbcMap.get("C") == abcMap.get("C"))){ // AB都有货 C区已完或无货
|
if(totalAbcMap.get("C")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { // C装完AB未装完
|
speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B");
|
} else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("B")< totalAbcMap.get("B")) { //A完B未完
|
speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "B");
|
}else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("A")< totalAbcMap.get("A")) {//B完A未完
|
speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "A");
|
}else { // 全部装完
|
speakTxt= String.format(speakTxtFormatStr1, cph, total);
|
}
|
}else if(totalAbcMap.get("C")>0 && totalAbcMap.get("B")>0 &&
|
(totalAbcMap.get("A")==0 || totalAbcMap.get("A") == abcMap.get("A")) ){ //BC有货 A区已完或无货
|
if(totalAbcMap.get("A")>0 && abcMap.get("C")< totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // A装完BC未装完
|
speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C");
|
} else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("B")< totalAbcMap.get("B")) { // C完B未装完
|
speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "B");
|
}else if(abcMap.get("B")== totalAbcMap.get("B") && abcMap.get("C")< totalAbcMap.get("C")) {// B完C未装完
|
speakTxt = String.format(speakTxtFormatStr2, cph, "B", total, "C");
|
}else { // 全部装完
|
speakTxt= String.format(speakTxtFormatStr1, cph, total);
|
}
|
}else if (totalAbcMap.get("A")>0 && totalAbcMap.get("C")>0 &&
|
(totalAbcMap.get("B")==0 || totalAbcMap.get("B") == abcMap.get("B")) ) { //AC有货
|
if(totalAbcMap.get("B")>0 && abcMap.get("A")< totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) {
|
speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C");
|
} else if(abcMap.get("A")== totalAbcMap.get("A") && abcMap.get("C")< totalAbcMap.get("C")) { // A装完C未装完
|
speakTxt = String.format(speakTxtFormatStr2, cph, "A", total, "C");
|
}else if(abcMap.get("C")== totalAbcMap.get("C") && abcMap.get("A")< totalAbcMap.get("A")) {// C装完A未装完
|
speakTxt = String.format(speakTxtFormatStr2, cph, "C", total, "A");
|
}else { // 全部装完
|
speakTxt= String.format(speakTxtFormatStr1, cph, total);
|
}
|
}else if(totalAbcMap.get("A")>0 && totalAbcMap.get("B")>0 && totalAbcMap.get("C")>0) { // 3区都有货物,且只有一个取装完了
|
if(abcMap.get("A")>0 && abcMap.get("B")<totalAbcMap.get("B") && abcMap.get("C")<totalAbcMap.get("C")) {
|
speakTxt= String.format(speakTxtFormatStr3, cph,"A", total,"B","C");
|
} else if(abcMap.get("B")>0 && abcMap.get("C")==0 && abcMap.get("A")==0) {
|
speakTxt= String.format(speakTxtFormatStr3, cph,"B", total,"A","C");
|
} else if(abcMap.get("C")>0 && abcMap.get("A")==0 && abcMap.get("B")==0) {
|
speakTxt= String.format(speakTxtFormatStr3, cph,"C", total,"A","B");
|
} else { // 全部装完
|
speakTxt= String.format(speakTxtFormatStr1, cph, total);
|
}
|
} else {
|
speakTxt= String.format(speakTxtFormatStr1, cph, total);
|
}
|
}
|
return speakTxt;
|
}
|
|
@Override
|
public void sendToYrLed(String currPch) {
|
// 状态 一磅后,待装;PDA扫码 在装; 二次过磅后消失
|
// 装车区 两个汉字加两个英文或数字
|
String strTitle="序号 车号 装车区 状态\r\n";
|
String strContent = "";
|
String contentFormatStr = "%s %s %s %s\r\n";
|
List<Map> list = tdmxper.yRZcList("08");
|
int index = 1;
|
for (Map map : list) {
|
String numberplates = (String) map.get("numberplates"); // 车牌号
|
String zcWz = (String) map.get("zcWz"); // 装车位置
|
if(StringUtils.isNotBlank(zcWz)){
|
zcWz = zcWz.substring(0,4);
|
} else { // 空是6个位置
|
zcWz = " ";
|
}
|
String zcStatus = (String) map.get("zcStatus"); // 装车位置 在办/待办
|
strContent += String.format(contentFormatStr, fillWithZero(index++), numberplates, zcWz, zcStatus);
|
}
|
Map paramMap = new HashMap();
|
paramMap.put("strTitle",strTitle);
|
paramMap.put("strContent",strContent);
|
Wxhtmethod.post(Contants.yr_zcLedUrl + "/SendLED",paramMap);
|
log.info("yr_zcLedUrl: " + Contants.yr_zcLedUrl + ";title:" + strTitle + ",content:" + strContent);
|
}
|
|
String fillWithZero(int str){
|
String s;
|
if(str<10 && str>=0) s= "0" + str;
|
else s=String.valueOf(str);
|
return s;
|
}
|
|
@Override
|
@Transactional(rollbackFor=Exception.class)
|
public ObjectResult<Boolean> delZCMX(String cardID, String yktywdh,JsonArray dataArr) throws Exception {
|
ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
|
//根据卡号判断分单信息
|
//循环批次号 如果没有分单 修改为分单和装车
|
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<String, Object> 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<String, Object> 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<String, Object> xstm=new HashMap<String, Object>();
|
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<Map<String, Object>> getcInfo(String cardID) {
|
ObjectResult<Map<String, Object>> orr=new ObjectResult<Map<String,Object>>();
|
Map<String, Object> rem=new HashMap<String, Object>();
|
Map<String, Object> 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_Bsheet> 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<Vehicle_XSTD> vxl=this.vhxper.getlistbyVehicleId(vehicleId);
|
List<Vehicle_XSTD> vxl= this.vhxper.getlistbyVehicleIdandbsNoGp(vehicleId, businessNo);
|
List<Map<String, Object>> datamp=new ArrayList<Map<String, Object>>();
|
Map<String,Fd_XSTD> 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<String, Object> tdm=new HashMap<String, Object>();
|
if(fd_c!=null){
|
tdm.put("td_wlgs", fd_c.getName());//物流公司
|
}else{
|
tdm.put("td_wlgs", "");//物流公司
|
}
|
if(td==null){
|
continue;
|
}
|
// List<Fd_XSTDMX> tdmxl=this.tdmxper.getbytdls(td.getTd_tdls());
|
List<Fd_XSTDMX> tdmxl= tdmxper.getListByTdlsAndCph(td.getTd_tdls(),vehicleId);
|
if(tdmxl==null||tdmxl.size()<=0){
|
continue;
|
}
|
Map<String, Object> mm=new HashMap<String, Object>();
|
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<String, Object> 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<Map<String, Object>> getxstdInfo(String xstdNo) {
|
ObjectResult<Map<String, Object>> orr=new ObjectResult<Map<String,Object>>();
|
Fd_XSTD xstd=this.tdper.getbyTDBH(xstdNo);
|
if(xstd==null){
|
orr.setCode(1);
|
orr.setErrmsg("提单未找到!");
|
return orr;
|
}
|
Map<String, Object> rm=new HashMap<String, Object>();
|
List<Fd_XSTDMX> 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<Boolean> savewdControl(JsonArray dataArr)throws Exception {
|
ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
|
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;
|
}
|
|
|
|
|
}
|