|
|
@ -1,9 +1,33 @@ |
|
|
|
package com.yxt.anrui.buscenter.biz.bushandover; |
|
|
|
|
|
|
|
import com.yxt.anrui.buscenter.api.bushandover.BusHandover; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.base.api.commoncontract.CommonContract; |
|
|
|
import com.yxt.anrui.base.api.commoncontract.CommonContractFeign; |
|
|
|
import com.yxt.anrui.base.common.enums.DictCommonEnum; |
|
|
|
import com.yxt.anrui.buscenter.api.bushandover.*; |
|
|
|
import com.yxt.anrui.buscenter.api.bushandoveritems.BusHanItemDto; |
|
|
|
import com.yxt.anrui.buscenter.api.bushandoveritems.BusHandoverItems; |
|
|
|
import com.yxt.anrui.buscenter.api.bushandoveritems.BusItemDto; |
|
|
|
import com.yxt.anrui.buscenter.biz.bushandoveritems.BusHandoverItemsService; |
|
|
|
import com.yxt.anrui.buscenter.biz.bushandoverwait.BusHandoverWaitService; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: anrui-buscenter(业务中心) <br/> |
|
|
|
* File: BusHandoverService.java <br/> |
|
|
@ -19,6 +43,117 @@ import org.springframework.stereotype.Service; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class BusHandoverService extends MybatisBaseService<BusHandoverMapper, BusHandover> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private BusHandoverItemsService busHandoverItemsService; |
|
|
|
@Autowired |
|
|
|
private CommonContractFeign commonContractFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private BusHandoverWaitService busHandoverWaitService; |
|
|
|
|
|
|
|
public ResultBean<List<BusHandoverListVo>> saveDeliverybill(BusHandoverDto dto) { |
|
|
|
ResultBean<List<BusHandoverListVo>> rb = ResultBean.fireFail(); |
|
|
|
BusHandover busHandover = new BusHandover(); |
|
|
|
BeanUtil.copyProperties(dto, busHandover, "sid"); |
|
|
|
String userSid = dto.getUserSid(); |
|
|
|
//根据机构sid查询分公司sid
|
|
|
|
String orgPath = dto.getOrgPath(); |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
busHandover.setUseOrgSid(useOrgSid); |
|
|
|
busHandover.setCreateBySid(userSid); |
|
|
|
busHandover.setHandoverStateKey(DictCommonEnum.HandoverType.WJX.getCode()); |
|
|
|
busHandover.setHandoverStateValue(DictCommonEnum.HandoverType.WJX.getRemarks()); |
|
|
|
//根据合同编号查询订单sid以及客户名称、客户sid
|
|
|
|
ResultBean<CommonContract> commonContractResultBean = commonContractFeign.selectByNo(dto.getContractNo()); |
|
|
|
CommonContract commonContract = commonContractResultBean.getData(); |
|
|
|
if (commonContract != null) { |
|
|
|
busHandover.setContractNo(commonContract.getContractNo()); |
|
|
|
busHandover.setCustomerName(commonContract.getPartyB()); |
|
|
|
busHandover.setCustomerSid(commonContract.getCustomerSid()); |
|
|
|
} |
|
|
|
//根据用户sid获取staffSid
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(dto.getUserSid()); |
|
|
|
SysUserVo sysUserVo = userVoResultBean.getData(); |
|
|
|
if (sysUserVo != null) { |
|
|
|
busHandover.setStaffSid(sysUserVo.getStaffSid()); |
|
|
|
} |
|
|
|
List<BusHanItemDto> busHanItemDtos = dto.getVinList(); |
|
|
|
busHanItemDtos.removeAll(Collections.singleton(null)); |
|
|
|
if (!busHanItemDtos.isEmpty()) { |
|
|
|
for (BusHanItemDto busHanItemDto : busHanItemDtos) { |
|
|
|
//根据合同编号、车辆sid逻辑删除待交车中的
|
|
|
|
busHandoverWaitService.deleteByVinSid(dto.getContractNo(), busHanItemDto.getVinSid()); |
|
|
|
BusHandoverItems busHandoverItems = new BusHandoverItems(); |
|
|
|
busHandoverItems.setHandoverSid(busHandover.getSid()); |
|
|
|
busHandoverItems.setVinNo(busHanItemDto.getVinNo()); |
|
|
|
busHandoverItems.setVinSid(busHanItemDto.getVinSid()); |
|
|
|
if(commonContract != null){ |
|
|
|
busHandoverItems.setModelName(commonContract.getModelName()); |
|
|
|
busHandoverItems.setModelSid(commonContract.getModelSid()); |
|
|
|
} |
|
|
|
List<BusItemDto> lists = busHanItemDto.getManifest(); |
|
|
|
List<String> itemKeyList = new ArrayList<>(); |
|
|
|
List<String> itemValueList = new ArrayList<>(); |
|
|
|
for (BusItemDto busItemDto : lists) { |
|
|
|
if (busItemDto.isState()) { |
|
|
|
itemValueList.add(busItemDto.getName()); |
|
|
|
itemKeyList.add(busItemDto.getItemKey()); |
|
|
|
} |
|
|
|
} |
|
|
|
String itemKey = String.join(",", itemKeyList); |
|
|
|
String itemValue = String.join(",", itemValueList); |
|
|
|
busHandoverItems.setItemKey(itemKey); |
|
|
|
busHandoverItems.setItemValue(itemValue); |
|
|
|
busHandoverItemsService.save(busHandoverItems); |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.insert(busHandover); |
|
|
|
List<BusHandoverListVo> list = new ArrayList<>(); |
|
|
|
BusHandoverListVo vo = new BusHandoverListVo(); |
|
|
|
vo.setName("<<接收车辆确认书>>"); |
|
|
|
list.add(vo); |
|
|
|
vo = new BusHandoverListVo(); |
|
|
|
vo.setName("<<出门证>>"); |
|
|
|
list.add(vo); |
|
|
|
vo = new BusHandoverListVo(); |
|
|
|
vo.setName("<<交车资料确认单>>"); |
|
|
|
list.add(vo); |
|
|
|
return rb.success().setData(list); |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<BusHandoverVo> pagerList(PagerQuery<BusHandoverQuery> pagerQuery) { |
|
|
|
IPage<BusHandover> page = PagerUtil.queryToPage(pagerQuery); |
|
|
|
BusHandoverQuery params = pagerQuery.getParams(); |
|
|
|
QueryWrapper<BusHandover> qw = new QueryWrapper<>(); |
|
|
|
if (params != null) { |
|
|
|
String orgPath = params.getOrgPath(); |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
orgPath = sysStaffOrgFeign.getOrgSidByPath(params.getOrgPath()).getData(); |
|
|
|
qw.eq("bh.useOrgSid", orgPath); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(params.getUserSid())) { |
|
|
|
qw.eq("bh.createBySid", params.getUserSid()); |
|
|
|
} |
|
|
|
} |
|
|
|
IPage<BusHandoverVo> pagging = baseMapper.selectPageVo(page, qw, params.getName()); |
|
|
|
List<BusHandoverVo> recordsList = pagging.getRecords(); |
|
|
|
recordsList.removeAll(Collections.singleton(null)); |
|
|
|
if (!recordsList.isEmpty()) { |
|
|
|
for (BusHandoverVo record : recordsList) { |
|
|
|
if (DictCommonEnum.HandoverType.YJC.getCode().equals(record.getHandoverStateKey())) { |
|
|
|
record.setShowUpdate(false); |
|
|
|
} else { |
|
|
|
record.setShowUpdate(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<BusHandoverVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
/*@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
|
|
|
@ -189,12 +324,12 @@ public class BusHandoverService extends MybatisBaseService<BusHandoverMapper, Bu |
|
|
|
// }
|
|
|
|
|
|
|
|
*//**
|
|
|
|
* 根据 单据类型编号+部门编码+日期 查询 |
|
|
|
* @param billsType |
|
|
|
* @param date |
|
|
|
* @param orgSid |
|
|
|
* @return |
|
|
|
*//*
|
|
|
|
* 根据 单据类型编号+部门编码+日期 查询 |
|
|
|
* @param billsType |
|
|
|
* @param date |
|
|
|
* @param orgSid |
|
|
|
* @return |
|
|
|
*//*
|
|
|
|
public int selectCountByOrgSid(String billsType, String date, String orgSid) { |
|
|
|
return baseMapper.selectCountByOrgSid(billsType, date, orgSid); |
|
|
|
}*/ |
|
|
|