|
|
@ -30,22 +30,27 @@ import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.base.api.basevehicle.BaseVehicle; |
|
|
|
import com.yxt.anrui.base.api.basevehicle.BaseVehicleFeign; |
|
|
|
import com.yxt.anrui.base.api.commoncontract.CommonContract; |
|
|
|
import com.yxt.anrui.base.api.commoncontract.CommonContractFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapply.*; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapplydetails.AppCarListDto; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapplydetails.AppCarListVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapplydetails.BusDeliveredApplyDetails; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapplydetails.BusDeliveredApplyDetailsDto; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapplydetails.BusDeliveredApplyDetailsVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busdelivereddetailsdiscount.BusDeliveredDetailsDiscount; |
|
|
|
import com.yxt.anrui.buscenter.api.busdelivereddetailsdiscount.BusDeliveredDetailsDiscountsVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredusemessage.AppUseInfoVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredusemessage.BusDeliveredUseMessage; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredusemessage.BusDeliveredUseMessageVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredusemessage.BusDeliveredUseMessagesVo; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.app.order.AppOrderDetailsVo; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesordersubmit.SubmitVo; |
|
|
|
import com.yxt.anrui.buscenter.biz.busdelivered.BusDeliveredService; |
|
|
|
import com.yxt.anrui.buscenter.biz.busdeliveredapplydetails.BusDeliveredApplyDetailsService; |
|
|
|
import com.yxt.anrui.buscenter.biz.busdelivereddetailsdiscount.BusDeliveredDetailsDiscountService; |
|
|
|
import com.yxt.anrui.buscenter.biz.busdeliveredusemessage.BusDeliveredUseMessageService; |
|
|
|
import com.yxt.anrui.buscenter.biz.bussalesorder.BusSalesOrderService; |
|
|
|
import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempFeign; |
|
|
|
import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempVo; |
|
|
|
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|
|
@ -55,6 +60,7 @@ import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
@ -72,6 +78,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -117,6 +124,8 @@ public class BusDeliveredApplyService extends MybatisBaseService<BusDeliveredApp |
|
|
|
private MessageFeign messageFeign; |
|
|
|
@Autowired |
|
|
|
private BusDeliveredDetailsDiscountService busDeliveredDetailsDiscountService; |
|
|
|
@Autowired |
|
|
|
private BusSalesOrderService busSalesOrderService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造出库申请的查询条件 |
|
|
@ -728,16 +737,235 @@ public class BusDeliveredApplyService extends MybatisBaseService<BusDeliveredApp |
|
|
|
} else { |
|
|
|
orgSid = sysStaffOrgFeign.getPathSidByUserSid(pagerQuery.getParams().getUserSid()).getData(); |
|
|
|
} |
|
|
|
qw.eq("orgSid", orgSid); |
|
|
|
qw.eq("useOrgSid", orgSid); |
|
|
|
qw.eq("applySid",pagerQuery.getParams().getUserSid()); |
|
|
|
IPage<AppDeliveredApplyPageQuery> page = PagerUtil.queryToPage(pagerQuery); |
|
|
|
IPage<AppDeliveredApplyPageVo> iPage = baseMapper.getRetrievalApplyList(page, qw, pagerQuery.getParams().getName()); |
|
|
|
return iPage; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean saveRetrievalApplyInfo(AppDeliveredApplyDto appDeliveredApplyDto) { |
|
|
|
public ResultBean saveRetrievalApplyInfo(AppDeliveredApplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String dtoSid = appDeliveredApplyDto.getSid(); |
|
|
|
String sid = dto.getSid(); |
|
|
|
String orgPath = dto.getOrgPath(); |
|
|
|
String contractNo = dto.getContractId(); |
|
|
|
if (StringUtils.isBlank(sid)) { |
|
|
|
//根据合同编号查询销售订单
|
|
|
|
//根据orgPath以及用户sid查询申请人
|
|
|
|
String userSid = dto.getUserSid(); |
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
} |
|
|
|
//根据用户sid查询人员姓名
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(userSid); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
BusDeliveredApply busDeliveredApply = new BusDeliveredApply(); |
|
|
|
BeanUtil.copyProperties(dto, busDeliveredApply, "sid"); |
|
|
|
busDeliveredApply.setContractNo(contractNo); |
|
|
|
busDeliveredApply.setApplySid(userSid); |
|
|
|
busDeliveredApply.setCreateBySid(userSid); |
|
|
|
busDeliveredApply.setApplyName(userVoResultBean.getData().getName()); |
|
|
|
busDeliveredApply.setStaffDeptName(deptName); |
|
|
|
busDeliveredApply.setApplyDept(deptName); |
|
|
|
busDeliveredApply.setApplyDeptSid(deptSid); |
|
|
|
busDeliveredApply.setStaffDeptSid(deptSid); |
|
|
|
busDeliveredApply.setStaffUserSid(userSid); |
|
|
|
busDeliveredApply.setStaffName(userVoResultBean.getData().getName()); |
|
|
|
//根据合同编号查询销售订单的信息
|
|
|
|
ResultBean<AppOrderDetailsVo> resultBean = busSalesOrderService.getSaleOrderDetailsByContractNo(contractNo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
log.error("获取销售订单详情出错啦!!!"); |
|
|
|
return rb; |
|
|
|
} |
|
|
|
AppOrderDetailsVo appOrderDetailsVo = resultBean.getData(); |
|
|
|
//销售类型
|
|
|
|
busDeliveredApply.setPaymentMethod(appOrderDetailsVo.getPayType()); |
|
|
|
busDeliveredApply.setPaymentMethodKey(appOrderDetailsVo.getPayTypeKey()); |
|
|
|
//中介人
|
|
|
|
SubmitVo intermediary1 = appOrderDetailsVo.getIntermediary1(); |
|
|
|
if (intermediary1 != null) { |
|
|
|
String agencyFee = intermediary1.getAgencyFee(); |
|
|
|
if (StringUtils.isNotBlank(agencyFee)) { |
|
|
|
busDeliveredApply.setDistributorPrice(agencyFee); |
|
|
|
} |
|
|
|
busDeliveredApply.setDistributorName(intermediary1.getIntermediaryName()); |
|
|
|
} |
|
|
|
//中介人2
|
|
|
|
SubmitVo intermediary2 = appOrderDetailsVo.getIntermediary2(); |
|
|
|
if (intermediary2 != null) { |
|
|
|
String agencyFee = intermediary2.getAgencyFee(); |
|
|
|
if (StringUtils.isNotBlank(agencyFee)) { |
|
|
|
busDeliveredApply.setDistributorPriceTwo(agencyFee); |
|
|
|
} |
|
|
|
busDeliveredApply.setDistributorNameTwo(intermediary2.getIntermediaryName()); |
|
|
|
} |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
busDeliveredApply.setUseOrgSid(useOrgSid); |
|
|
|
//车辆列表
|
|
|
|
List<AppCarListVo> carList = dto.getCarList(); |
|
|
|
for (int i = 0; i < carList.size(); i++) { |
|
|
|
AppCarListVo appCarListVo = carList.get(i); |
|
|
|
BusDeliveredApplyDetails busDeliveredApplyDetails = new BusDeliveredApplyDetails(); |
|
|
|
busDeliveredApplyDetails.setSingleCarDiscountPrice(appCarListVo.getDiscount()); |
|
|
|
busDeliveredApplyDetails.setVinSid(appCarListVo.getVinSid()); |
|
|
|
busDeliveredApplyDetails.setApplySid(busDeliveredApply.getSid()); |
|
|
|
BusDeliveredUseMessagesVo busDeliveredUseMessagesVo = appCarListVo.getRealBuyer(); |
|
|
|
busDeliveredApplyDetails.setVinNo(busDeliveredUseMessagesVo.getVin()); |
|
|
|
//赠送套餐
|
|
|
|
BigDecimal discountAll = BigDecimal.ZERO; |
|
|
|
StringBuilder discountRemarks = new StringBuilder(); |
|
|
|
List<BusDeliveredDetailsDiscountsVo> discountUse = appCarListVo.getDiscountUse(); |
|
|
|
for (int j = 0; j < discountUse.size(); j++) { |
|
|
|
BusDeliveredDetailsDiscountsVo busDeliveredDetailsDiscountsVo = discountUse.get(j); |
|
|
|
BusDeliveredDetailsDiscount busDeliveredDetailsDiscount = new BusDeliveredDetailsDiscount(); |
|
|
|
//出库申请sid
|
|
|
|
busDeliveredDetailsDiscount.setApplySid(busDeliveredApply.getSid()); |
|
|
|
//出库车辆表sid
|
|
|
|
busDeliveredDetailsDiscount.setDetailsSid(busDeliveredApplyDetails.getSid()); |
|
|
|
//优惠包名称
|
|
|
|
busDeliveredDetailsDiscount.setName(busDeliveredDetailsDiscountsVo.getDiscountName()); |
|
|
|
//价值
|
|
|
|
busDeliveredDetailsDiscount.setPrice(busDeliveredDetailsDiscountsVo.getDiscountPrice()); |
|
|
|
//优惠包项目说明
|
|
|
|
busDeliveredDetailsDiscount.setDiscountExplain(busDeliveredDetailsDiscountsVo.getDiscountInfo()); |
|
|
|
//数量
|
|
|
|
busDeliveredDetailsDiscount.setNum(busDeliveredDetailsDiscountsVo.getTotalNum()); |
|
|
|
//本次赠送数量
|
|
|
|
busDeliveredDetailsDiscount.setGiveNum(busDeliveredDetailsDiscountsVo.getDiscountNum()); |
|
|
|
//销售订单中主车优惠的sid
|
|
|
|
busDeliveredDetailsDiscount.setDiscountSid(busDeliveredDetailsDiscountsVo.getDiscountSid()); |
|
|
|
busDeliveredDetailsDiscountService.insert(busDeliveredDetailsDiscount); |
|
|
|
discountAll = discountAll.add(new BigDecimal(busDeliveredDetailsDiscount.getPrice()).multiply(new BigDecimal(busDeliveredDetailsDiscount.getGiveNum()))); |
|
|
|
if (j == 0 || j == discountUse.size() - 1) { |
|
|
|
String disInfo = busDeliveredDetailsDiscountsVo.getDiscountInfo() + "X" + busDeliveredDetailsDiscount.getGiveNum(); |
|
|
|
discountRemarks = discountRemarks.append(disInfo).append(","); |
|
|
|
} else { |
|
|
|
String disInfo = busDeliveredDetailsDiscountsVo.getDiscountInfo() + "X" + busDeliveredDetailsDiscount.getGiveNum(); |
|
|
|
discountRemarks = discountRemarks.append(disInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
busDeliveredApplyDetails.setDiscountAll(discountAll.toString()); |
|
|
|
busDeliveredApplyDetails.setRemarks(discountRemarks.toString()); |
|
|
|
//使用人信息
|
|
|
|
BusDeliveredUseMessage busDeliveredUseMessage = new BusDeliveredUseMessage(); |
|
|
|
BeanUtil.copyProperties(busDeliveredUseMessagesVo, busDeliveredUseMessage); |
|
|
|
busDeliveredUseMessage.setApplySid(busDeliveredApply.getSid()); |
|
|
|
busDeliveredUseMessageService.insert(busDeliveredUseMessage); |
|
|
|
busDeliveredApplyDetails.setUseMessageSid(busDeliveredUseMessage.getSid()); |
|
|
|
busDeliveredApplyDetailsService.insert(busDeliveredApplyDetails); |
|
|
|
} |
|
|
|
baseMapper.insert(busDeliveredApply); |
|
|
|
|
|
|
|
} else { |
|
|
|
//根据出库申请sid查询出库申请是否存在
|
|
|
|
BusDeliveredApply busDeliveredApply = fetchBySid(sid); |
|
|
|
if (busDeliveredApply == null) { |
|
|
|
return rb.setMsg("该出库申请不存在"); |
|
|
|
} |
|
|
|
BeanUtil.copyProperties(dto, busDeliveredApply, "sid"); |
|
|
|
//根据合同编号查询销售订单的信息
|
|
|
|
ResultBean<AppOrderDetailsVo> resultBean = busSalesOrderService.getSaleOrderDetailsByContractNo(contractNo); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
log.error("获取销售订单详情出错啦!!!"); |
|
|
|
return rb; |
|
|
|
} |
|
|
|
AppOrderDetailsVo appOrderDetailsVo = resultBean.getData(); |
|
|
|
//中介人
|
|
|
|
SubmitVo intermediary1 = appOrderDetailsVo.getIntermediary1(); |
|
|
|
if (intermediary1 != null) { |
|
|
|
String agencyFee = intermediary1.getAgencyFee(); |
|
|
|
if (StringUtils.isNotBlank(agencyFee)) { |
|
|
|
busDeliveredApply.setDistributorPrice(agencyFee); |
|
|
|
} |
|
|
|
busDeliveredApply.setDistributorName(intermediary1.getIntermediaryName()); |
|
|
|
} |
|
|
|
//中介人2
|
|
|
|
SubmitVo intermediary2 = appOrderDetailsVo.getIntermediary2(); |
|
|
|
if (intermediary2 != null) { |
|
|
|
String agencyFee = intermediary2.getAgencyFee(); |
|
|
|
if (StringUtils.isNotBlank(agencyFee)) { |
|
|
|
busDeliveredApply.setDistributorPriceTwo(agencyFee); |
|
|
|
} |
|
|
|
busDeliveredApply.setDistributorNameTwo(intermediary2.getIntermediaryName()); |
|
|
|
} |
|
|
|
//删除
|
|
|
|
busDeliveredApplyDetailsService.deleteByApplySid(sid); |
|
|
|
busDeliveredUseMessageService.deleteByApplySid(sid); |
|
|
|
busDeliveredDetailsDiscountService.deleteByApplySid(sid); |
|
|
|
//车辆列表
|
|
|
|
List<AppCarListVo> carList = dto.getCarList(); |
|
|
|
for (int i = 0; i < carList.size(); i++) { |
|
|
|
AppCarListVo appCarListVo = carList.get(i); |
|
|
|
BusDeliveredApplyDetails busDeliveredApplyDetails = new BusDeliveredApplyDetails(); |
|
|
|
busDeliveredApplyDetails.setSingleCarDiscountPrice(appCarListVo.getDiscount()); |
|
|
|
busDeliveredApplyDetails.setVinSid(appCarListVo.getVinSid()); |
|
|
|
busDeliveredApplyDetails.setApplySid(busDeliveredApply.getSid()); |
|
|
|
BusDeliveredUseMessagesVo busDeliveredUseMessagesVo = appCarListVo.getRealBuyer(); |
|
|
|
busDeliveredApplyDetails.setVinNo(busDeliveredUseMessagesVo.getVin()); |
|
|
|
//赠送套餐
|
|
|
|
BigDecimal discountAll = BigDecimal.ZERO; |
|
|
|
StringBuilder discountRemarks = new StringBuilder(); |
|
|
|
List<BusDeliveredDetailsDiscountsVo> discountUse = appCarListVo.getDiscountUse(); |
|
|
|
for (int j = 0; j < discountUse.size(); j++) { |
|
|
|
BusDeliveredDetailsDiscountsVo busDeliveredDetailsDiscountsVo = discountUse.get(j); |
|
|
|
BusDeliveredDetailsDiscount busDeliveredDetailsDiscount = new BusDeliveredDetailsDiscount(); |
|
|
|
//出库申请sid
|
|
|
|
busDeliveredDetailsDiscount.setApplySid(busDeliveredApply.getSid()); |
|
|
|
//出库车辆表sid
|
|
|
|
busDeliveredDetailsDiscount.setDetailsSid(busDeliveredApplyDetails.getSid()); |
|
|
|
//优惠包名称
|
|
|
|
busDeliveredDetailsDiscount.setName(busDeliveredDetailsDiscountsVo.getDiscountName()); |
|
|
|
//价值
|
|
|
|
busDeliveredDetailsDiscount.setPrice(busDeliveredDetailsDiscountsVo.getDiscountPrice()); |
|
|
|
//优惠包项目说明
|
|
|
|
busDeliveredDetailsDiscount.setDiscountExplain(busDeliveredDetailsDiscountsVo.getDiscountInfo()); |
|
|
|
//数量
|
|
|
|
busDeliveredDetailsDiscount.setNum(busDeliveredDetailsDiscountsVo.getTotalNum()); |
|
|
|
//本次赠送数量
|
|
|
|
busDeliveredDetailsDiscount.setGiveNum(busDeliveredDetailsDiscountsVo.getDiscountNum()); |
|
|
|
//销售订单中主车优惠的sid
|
|
|
|
busDeliveredDetailsDiscount.setDiscountSid(busDeliveredDetailsDiscountsVo.getDiscountSid()); |
|
|
|
busDeliveredDetailsDiscountService.insert(busDeliveredDetailsDiscount); |
|
|
|
discountAll = discountAll.add(new BigDecimal(busDeliveredDetailsDiscount.getPrice()).multiply(new BigDecimal(busDeliveredDetailsDiscount.getGiveNum()))); |
|
|
|
if (j == 0 || j == discountUse.size() - 1) { |
|
|
|
String disInfo = busDeliveredDetailsDiscountsVo.getDiscountInfo() + "X" + busDeliveredDetailsDiscount.getGiveNum(); |
|
|
|
discountRemarks = discountRemarks.append(disInfo).append(","); |
|
|
|
} else { |
|
|
|
String disInfo = busDeliveredDetailsDiscountsVo.getDiscountInfo() + "X" + busDeliveredDetailsDiscount.getGiveNum(); |
|
|
|
discountRemarks = discountRemarks.append(disInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
busDeliveredApplyDetails.setDiscountAll(discountAll.toString()); |
|
|
|
busDeliveredApplyDetails.setRemarks(discountRemarks.toString()); |
|
|
|
//使用人信息
|
|
|
|
BusDeliveredUseMessage busDeliveredUseMessage = new BusDeliveredUseMessage(); |
|
|
|
BeanUtil.copyProperties(busDeliveredUseMessagesVo, busDeliveredUseMessage); |
|
|
|
busDeliveredUseMessage.setApplySid(busDeliveredApply.getSid()); |
|
|
|
busDeliveredUseMessageService.insert(busDeliveredUseMessage); |
|
|
|
busDeliveredApplyDetails.setUseMessageSid(busDeliveredUseMessage.getSid()); |
|
|
|
busDeliveredApplyDetailsService.insert(busDeliveredApplyDetails); |
|
|
|
} |
|
|
|
baseMapper.updateById(busDeliveredApply); |
|
|
|
} |
|
|
|
/*String dtoSid = appDeliveredApplyDto.getSid(); |
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(appDeliveredApplyDto.getUserSid()).getData(); |
|
|
|
BaseVehicle baseVehicle = null; |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
@ -787,33 +1015,34 @@ public class BusDeliveredApplyService extends MybatisBaseService<BusDeliveredApp |
|
|
|
} |
|
|
|
updateById(busDeliveredApply); |
|
|
|
return rb.success().setData(busDeliveredApply.getSid()); |
|
|
|
}*/ |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<AppDeliveredApplyInfoVo> getRetrievalApplyInfoBySid(String sid) { |
|
|
|
ResultBean<AppDeliveredApplyInfoVo> rb = ResultBean.fireFail(); |
|
|
|
AppDeliveredApplyInfoVo vo = new AppDeliveredApplyInfoVo(); |
|
|
|
BusDeliveredApply busDeliveredApply = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(busDeliveredApply, vo); |
|
|
|
public ResultBean<AppDeliveredApplyInfoVo> getRetrievalApplyInfoBySid (String sid){ |
|
|
|
ResultBean<AppDeliveredApplyInfoVo> rb = ResultBean.fireFail(); |
|
|
|
AppDeliveredApplyInfoVo vo = new AppDeliveredApplyInfoVo(); |
|
|
|
BusDeliveredApply busDeliveredApply = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(busDeliveredApply, vo); |
|
|
|
|
|
|
|
if (vo.getIsTerminal() == 1) { |
|
|
|
//根据出库申请单的sid查询需要出库的车辆信息
|
|
|
|
List<AppCarListVo> voList = busDeliveredApplyDetailsService.appDetailsList(sid); |
|
|
|
voList.removeAll(Collections.singleton(null)); |
|
|
|
if (!voList.isEmpty()) { |
|
|
|
for (AppCarListVo v : voList) { |
|
|
|
String contractNo = vo.getContractNo(); |
|
|
|
CommonContract commonContract = commonContractFeign.selectByNo(contractNo).getData(); |
|
|
|
AppUseInfoVo appUseInfoVo = null; |
|
|
|
if (vo.getIsTerminal() == 1) { |
|
|
|
//根据出库申请单的sid查询需要出库的车辆信息
|
|
|
|
List<AppCarListVo> voList = busDeliveredApplyDetailsService.appDetailsList(sid); |
|
|
|
voList.removeAll(Collections.singleton(null)); |
|
|
|
if (!voList.isEmpty()) { |
|
|
|
for (AppCarListVo v : voList) { |
|
|
|
String contractNo = vo.getContractNo(); |
|
|
|
CommonContract commonContract = commonContractFeign.selectByNo(contractNo).getData(); |
|
|
|
AppUseInfoVo appUseInfoVo = null; |
|
|
|
// v.setUseInfo(appUseInfoVo);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setCarList(voList); |
|
|
|
vo.setCarList(voList); |
|
|
|
|
|
|
|
} else if (vo.getIsTerminal() == 0) { |
|
|
|
//根据出库申请单的sid查询需要出库的车辆信息
|
|
|
|
List<AppCarListVo> voList = busDeliveredApplyDetailsService.appDetailsList(sid); |
|
|
|
for (int i = 0; i < voList.size(); i++) { |
|
|
|
} else if (vo.getIsTerminal() == 0) { |
|
|
|
//根据出库申请单的sid查询需要出库的车辆信息
|
|
|
|
List<AppCarListVo> voList = busDeliveredApplyDetailsService.appDetailsList(sid); |
|
|
|
for (int i = 0; i < voList.size(); i++) { |
|
|
|
/* BusDeliveredUseMessage busDeliveredUseMessage = busDeliveredUseMessageService.fetchBySid(voList.get(i).getUseMessageSid()); |
|
|
|
AppUseInfoVo appUseInfoVo = new AppUseInfoVo(); |
|
|
|
appUseInfoVo.setMobile(busDeliveredUseMessage.getMobile()); |
|
|
@ -824,126 +1053,127 @@ public class BusDeliveredApplyService extends MybatisBaseService<BusDeliveredApp |
|
|
|
appUseInfoVo.setCity(busDeliveredUseMessage.getCity()); |
|
|
|
appUseInfoVo.setCounty(busDeliveredUseMessage.getCounty()); |
|
|
|
voList.get(i).setUseInfo(appUseInfoVo);*/ |
|
|
|
} |
|
|
|
vo.setCarList(voList); |
|
|
|
} |
|
|
|
vo.setCarList(voList); |
|
|
|
vo.setSid(sid); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
vo.setSid(sid); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitAppDeliveredApply(AppSubmitDeliveredApplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//根据用户sid获取staffSid
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(dto.getUserSid()); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
//根据staffSid获取用户的组织全路径
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(userVoResultBean.getData().getStaffSid()); |
|
|
|
if (!staffOrgResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(staffOrgResultBean.getMsg()); |
|
|
|
} |
|
|
|
//用户的组织全路径
|
|
|
|
String orgSidPath = staffOrgResultBean.getData().getOrgSidPath(); |
|
|
|
BusDeliveredApply busDeliveredApply = fetchBySid(dto.getSid()); |
|
|
|
int r = submitAppBusinessData(dto, busDeliveredApply); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
//新增修改保存
|
|
|
|
ResultBean<String> resultBean = saveRetrievalApplyInfo(dto); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
String sid = resultBean.getData(); |
|
|
|
//更改状态
|
|
|
|
List<String> stringList = busDeliveredApplyDetailsService.selectVinByApplySid(sid); |
|
|
|
for (int i = 0; i < stringList.size(); i++) { |
|
|
|
String vinNo = stringList.get(i); |
|
|
|
busDeliveredService.updateState(vinNo, 0); |
|
|
|
} |
|
|
|
baseMapper.updateStateBySid(2, sid); |
|
|
|
String businessSid = resultBean.getData(); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
//流程中的参数赋值
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//用户的部门全路径sid
|
|
|
|
bv.setOrgSidPath(orgSidPath); |
|
|
|
//业务sid
|
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
//用户sid
|
|
|
|
bv.setUserSid(dto.getUserSid()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
//若app移动端有此功能,则传递appMap参数
|
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
//需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.BUSDELIVEREDAPPLY.getProDefId()); |
|
|
|
if (r == 1) { |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
//极光推送
|
|
|
|
busDeliveredApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("出库申请"); |
|
|
|
messageFlowableQuery.setMsgContent(busDeliveredApply.getApplyName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("出库申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
return voResultBean; |
|
|
|
} |
|
|
|
if (r == 2) { |
|
|
|
// ToDo:驳回到发起人后再次提交
|
|
|
|
if (StringUtils.isBlank(dto.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
public ResultBean submitAppDeliveredApply (AppSubmitDeliveredApplyDto dto){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//根据用户sid获取staffSid
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(dto.getUserSid()); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
bv.setTaskId(busDeliveredApply.getTaskId()); |
|
|
|
bv.setTaskDefKey(busDeliveredApply.getTaskDefKey()); |
|
|
|
bv.setComment(StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|
|
|
bv.setInstanceId(dto.getInstanceId()); |
|
|
|
return complete(bv); |
|
|
|
//根据staffSid获取用户的组织全路径
|
|
|
|
ResultBean<SysStaffOrg> staffOrgResultBean = sysStaffOrgFeign.getOrgByStaffSid(userVoResultBean.getData().getStaffSid()); |
|
|
|
if (!staffOrgResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(staffOrgResultBean.getMsg()); |
|
|
|
} |
|
|
|
//用户的组织全路径
|
|
|
|
String orgSidPath = staffOrgResultBean.getData().getOrgSidPath(); |
|
|
|
BusDeliveredApply busDeliveredApply = fetchBySid(dto.getSid()); |
|
|
|
int r = submitAppBusinessData(dto, busDeliveredApply); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
//新增修改保存
|
|
|
|
ResultBean<String> resultBean = saveRetrievalApplyInfo(dto); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
String sid = resultBean.getData(); |
|
|
|
//更改状态
|
|
|
|
List<String> stringList = busDeliveredApplyDetailsService.selectVinByApplySid(sid); |
|
|
|
for (int i = 0; i < stringList.size(); i++) { |
|
|
|
String vinNo = stringList.get(i); |
|
|
|
busDeliveredService.updateState(vinNo, 0); |
|
|
|
} |
|
|
|
baseMapper.updateStateBySid(2, sid); |
|
|
|
String businessSid = resultBean.getData(); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
//流程中的参数赋值
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//用户的部门全路径sid
|
|
|
|
bv.setOrgSidPath(orgSidPath); |
|
|
|
//业务sid
|
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
//用户sid
|
|
|
|
bv.setUserSid(dto.getUserSid()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
//若app移动端有此功能,则传递appMap参数
|
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
//需和移动端沟通业务sid保存的属性具体值:appMap中sid不是固定的。移动端提供具体字段。
|
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.BUSDELIVEREDAPPLY.getProDefId()); |
|
|
|
if (r == 1) { |
|
|
|
ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv); |
|
|
|
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|
|
|
//极光推送
|
|
|
|
busDeliveredApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("出库申请"); |
|
|
|
messageFlowableQuery.setMsgContent(busDeliveredApply.getApplyName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("出库申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
return voResultBean; |
|
|
|
} |
|
|
|
if (r == 2) { |
|
|
|
// ToDo:驳回到发起人后再次提交
|
|
|
|
if (StringUtils.isBlank(dto.getInstanceId())) { |
|
|
|
return rb.setMsg("参数错误:instanceId"); |
|
|
|
} |
|
|
|
bv.setTaskId(busDeliveredApply.getTaskId()); |
|
|
|
bv.setTaskDefKey(busDeliveredApply.getTaskDefKey()); |
|
|
|
bv.setComment(StringUtils.isNotBlank(dto.getComment()) ? dto.getComment() : "重新提交"); |
|
|
|
bv.setInstanceId(dto.getInstanceId()); |
|
|
|
return complete(bv); |
|
|
|
} |
|
|
|
return rb; |
|
|
|
} |
|
|
|
return rb; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断提交的流程是否被允许 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private synchronized int submitAppBusinessData(AppSubmitDeliveredApplyDto dto, BusDeliveredApply busDeliveredApply) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (busDeliveredApply != null) { |
|
|
|
String businessTaskId = busDeliveredApply.getTaskId(); |
|
|
|
if (StringUtils.isBlank(businessTaskId) && StringUtils.isBlank(dto.getTaskId())) { |
|
|
|
//新提交
|
|
|
|
r = 1; |
|
|
|
} else if (StringUtils.isNotBlank(businessTaskId) && businessTaskId.equals(dto.getTaskId())) { |
|
|
|
//二次提交//只有数据一致的时候才能进行下一步
|
|
|
|
r = 2; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 判断提交的流程是否被允许 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private synchronized int submitAppBusinessData (AppSubmitDeliveredApplyDto dto, BusDeliveredApply |
|
|
|
busDeliveredApply){ |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
r = 3; |
|
|
|
} |
|
|
|
if (busDeliveredApply != null) { |
|
|
|
String businessTaskId = busDeliveredApply.getTaskId(); |
|
|
|
if (StringUtils.isBlank(businessTaskId) && StringUtils.isBlank(dto.getTaskId())) { |
|
|
|
//新提交
|
|
|
|
r = 1; |
|
|
|
} else if (StringUtils.isNotBlank(businessTaskId) && businessTaskId.equals(dto.getTaskId())) { |
|
|
|
//二次提交//只有数据一致的时候才能进行下一步
|
|
|
|
r = 2; |
|
|
|
} |
|
|
|
} else { |
|
|
|
r = 3; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return r; |
|
|
|
} |
|
|
|
return r; |
|
|
|
} |
|
|
|
|
|
|
|
// public ResultBean<AppDeliveredApplyInfoVo> getRetrievalDetail(String contractSid) {
|
|
|
|
// ResultBean<AppDeliveredApplyInfoVo> rb = ResultBean.fireFail();
|
|
|
@ -983,4 +1213,4 @@ public class BusDeliveredApplyService extends MybatisBaseService<BusDeliveredApp |
|
|
|
// }
|
|
|
|
// return rb.success().setData(vo);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |