/**
  * 修改派车单主表
  *
  * @param Tpactionhead,Tpactionline
  * @return 0
  */
 @Override
 public void updateTpactionhead(
     IFWUserInfo userInfo, Tpactionhead tpactionhead, Tpactionline tpactionline) {
   if (tpactionhead != null && tpactionline != null) {
     String macttypeID = tpactionline.getMacttypeID();
     Tpactionline dbtpactionline =
         tpactionlineBusiness.getTpactionlineByID(userInfo, tpactionline.getMguid());
     String dbmacttypeId = dbtpactionline.getMacttypeID();
     Tptrplanline tptrplanline =
         tptrplanlineBusiness.getTptrplanlineByID(userInfo, tpactionline.getMsguid());
     double prplanqty = 0.00;
     if (tptrplanline != null) {
       prplanqty = tptrplanline.getMexecqty();
     }
     if ((dbmacttypeId.equals(HConstants.PLAN) && macttypeID.equals(HConstants.PLANSA))
         || (dbmacttypeId.equals(HConstants.PLAN) && macttypeID.equals(HConstants.OUTPLAN))) {
       // 运输计划修改为经营协议或者手动填写
       Tptrplanline updateLine = new Tptrplanline();
       updateLine.setMexecqty(tpactionline.getMplanqty());
       updateLine.setMguid(tpactionline.getMtrplnbysguid());
       updateLine.setMexecstate(HConstants.ZERO);
       tptrplanlineBusiness.updateTptrplaneStatus(userInfo, updateLine);
     } else if ((dbmacttypeId.equals(HConstants.OUTPLAN) && macttypeID.equals(HConstants.PLAN))
         || (dbmacttypeId.equals(HConstants.PLANSA) && macttypeID.equals(HConstants.PLAN))
         || (dbmacttypeId.equals(macttypeID))) {
       // 经营协议或者手动填写修改为运输计划
       if (HConstants.PLAN.equals(macttypeID)) {
         Tptrplanline updateLine = new Tptrplanline();
         updateLine.setMexecqty(tpactionline.getMplanqty());
         updateLine.setMguid(tpactionline.getMsguid());
         updateLine.setMexecstate(HConstants.ONE);
         tptrplanlineBusiness.updateTptrplaneStatus(userInfo, updateLine);
       }
     }
     tpactionhead.setMmodifydate(PublicMethod.now());
     tpactionhead.setMactdate(PublicMethod.now());
     tpactionhead.setMmodifyempID(userInfo.getUserID());
     tpactionline.setMmodifydate(PublicMethod.now());
     tpactionline.setMmodifyempID(userInfo.getUserID());
     tpactionlineMapper.update(tpactionline);
     tpactionheadMapper.update(tpactionhead);
   } else if (tpactionhead != null && tpactionline == null) {
     tpactionhead.setMmodifydate(PublicMethod.now());
     tpactionhead.setMactdate(PublicMethod.now());
     tpactionhead.setMmodifyempID(userInfo.getUserID());
     tpactionheadMapper.update(tpactionhead);
   }
 }
 /**
  * 添加派车单主表
  *
  * @param Tpactionhead
  * @return 0
  */
 @Override
 public void saveTpactionhead(
     IFWUserInfo userInfo,
     Tpactionhead tpactionhead,
     Tpactionline tpactionline,
     SerialnumInfo serialnumInfo) {
   if (tpactionhead != null) {
     if (serialnumInfo != null) {
       serialnumBusiness.updateSerialnum(userInfo, serialnumInfo);
     }
     tpactionhead.setMcreatedate(PublicMethod.now());
     tpactionhead.setMactdate(PublicMethod.now());
     tpactionhead.setMcreateempID(userInfo.getUserID());
     tpactionhead.setMmodifydate(PublicMethod.now());
     tpactionhead.setMmodifyempID(userInfo.getUserID());
     tpactionhead.setMdtype(HConstants.P);
     tpactionheadMapper.insert(tpactionhead);
   }
   if (tpactionline != null) {
     String macttypeID = tpactionline.getMacttypeID();
     Tptrplanline trplanline =
         tptrplanlineBusiness.getTptrplanlineByID(userInfo, tpactionline.getMsguid());
     double prplanqty = 0.00;
     if (trplanline != null) {
       prplanqty = trplanline.getMexecqty();
     }
     if (HConstants.PLAN.equals(macttypeID)) {
       Tptrplanline updateLine = new Tptrplanline();
       updateLine.setMexecqty(tpactionline.getMplanqty() + prplanqty);
       updateLine.setMguid(tpactionline.getMsguid());
       updateLine.setMexecstate(HConstants.ONE);
       tptrplanlineBusiness.updateTptrplaneStatus(userInfo, updateLine);
     }
     tpactionline.setMdtype(HConstants.P);
     tpactionline.setMcreatedate(PublicMethod.now());
     tpactionline.setMcreateempID(userInfo.getUserID());
     tpactionline.setMmodifydate(PublicMethod.now());
     tpactionline.setMmodifyempID(userInfo.getUserID());
     tpactionlineMapper.insert(tpactionline);
   }
 }
 /**
  * 逻辑删除派车单主表
  *
  * @param String guid
  * @return 0
  */
 @Override
 public int removeTpactionhead(IFWUserInfo userInfo, String guid) {
   // TODO Auto-generated method stub
   return tpactionheadMapper.fakeDelete(guid);
 }
 /**
  * 查看总个数
  *
  * @param Tpactionhead
  * @return count
  */
 @Override
 public int findTpactionheadcount(IFWUserInfo userInfo, Tpactionhead tpactionhead) {
   return tpactionheadMapper.count(tpactionhead);
 }
 /**
  * 通过单据号查看派车单主表
  *
  * @param String mactcode
  * @return Tpactionhead
  */
 @Override
 public Tpactionhead getTpactionheadByActcode(IFWUserInfo userInfo, String mactcode) {
   return tpactionheadMapper.getTpactionheadByActcode(mactcode);
 }
 /**
  * 通过id查看派车单主表
  *
  * @param String guid
  * @return Tpactionhead
  */
 @Override
 public Tpactionhead getTpheadByID(IFWUserInfo userInfo, String guid) {
   return tpactionheadMapper.get(guid);
 }
 /**
  * 通过id查看派车单主表
  *
  * @param String guid
  * @return Tpactionhead
  */
 @Override
 public Tpactionhead getTpactionheadByID(IFWUserInfo userInfo, String guid, String mactres) {
   return tpactionheadMapper.getTpactionheadByID(guid, mactres);
 }
 /**
  * 分页查询全部派车单主表
  *
  * @param Tpactionhead
  * @return List<Tpactionhead>
  */
 @Override
 public List<Tpactionhead> findTpactionheadByPage(
     IFWUserInfo userInfo, Tpactionhead tpactionhead) {
   return tpactionheadMapper.selectByPage(tpactionhead);
 }
 public int findBasecusacccount(Tpactionhead tpactionhead) {
   return tpactionheadMapper.count(tpactionhead);
 }