|
|
@ -28,10 +28,13 @@ package com.yxt.anrui.buscenter.biz.busadvanceginvoiceapply; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.api.R; |
|
|
|
import com.yxt.anrui.base.api.commonappendix.CommonAppendixFeign; |
|
|
|
import com.yxt.anrui.base.api.commonappendix.CommonAppendixVo; |
|
|
|
import com.yxt.anrui.base.api.commonappendix.CommonAttachTypeEnum; |
|
|
|
import com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.*; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapply.AppDeliveredApplyPageQuery; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeliveredapply.AppDeliveredApplyPageVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busginvoiceapplyvehicle.BusGinvoiceapplyVehicle; |
|
|
|
import com.yxt.anrui.buscenter.api.busginvoiceapplyvehicle.BusGinvoiceapplyVehicleDetailsVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busginvoiceapplyvehicle.BusGinvoiceapplyVehicleDto; |
|
|
@ -43,6 +46,7 @@ import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkTypeEnum; |
|
|
|
import com.yxt.anrui.flowable.api.utils.ProcDefEnum; |
|
|
|
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.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
@ -50,6 +54,7 @@ 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.apache.http.nio.pool.NIOConnFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
@ -74,261 +79,386 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class BusAdvanceGinvoiceapplyService extends MybatisBaseService<BusAdvanceGinvoiceapplyMapper, BusAdvanceGinvoiceapply> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysFormLinkFeign sysFormLinkFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableService flowableService; |
|
|
|
@Autowired |
|
|
|
private BusGinvoiceapplyVehicleService busGinvoiceapplyVehicleService; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private CommonAppendixFeign commonAppendixFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private SysFormLinkFeign sysFormLinkFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableService flowableService; |
|
|
|
@Autowired |
|
|
|
private BusGinvoiceapplyVehicleService busGinvoiceapplyVehicleService; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private CommonAppendixFeign commonAppendixFeign; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
|
|
|
|
public PagerVo<BusAdvanceGinvoiceapply> listPage(PagerQuery<BusAdvanceGinvoiceapplyQuery> pq) { |
|
|
|
BusAdvanceGinvoiceapplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
IPage<BusAdvanceGinvoiceapply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BusAdvanceGinvoiceapply> pagging = baseMapper.selectPage(page, qw); |
|
|
|
PagerVo<BusAdvanceGinvoiceapply> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
public List<BusAdvanceGinvoiceapply> listAll(BusAdvanceGinvoiceapplyQuery query) { |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
return baseMapper.selectList(qw); |
|
|
|
} |
|
|
|
private QueryWrapper<BusAdvanceGinvoiceapply> createQueryWrapper(BusAdvanceGinvoiceapplyQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = new QueryWrapper<>(); |
|
|
|
public PagerVo<BusAdvanceGinvoiceapply> listPage(PagerQuery<BusAdvanceGinvoiceapplyQuery> pq) { |
|
|
|
BusAdvanceGinvoiceapplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
IPage<BusAdvanceGinvoiceapply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BusAdvanceGinvoiceapply> pagging = baseMapper.selectPage(page, qw); |
|
|
|
PagerVo<BusAdvanceGinvoiceapply> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getContractNo())) { |
|
|
|
qw.like("contractNo", query.getContractNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCustomerName())) { |
|
|
|
qw.like("customerName", query.getCustomerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getApplyName())) { |
|
|
|
qw.like("applyName", query.getApplyName()); |
|
|
|
} |
|
|
|
String applyStartDate = query.getApplyStartDate(); |
|
|
|
String applyEndDate = query.getApplyEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(applyStartDate), "date_format (applyDate,'%Y-%m-%d') >= date_format('" + applyStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(applyEndDate), "date_format (applyDate,'%Y-%m-%d') <= date_format('" + applyEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<BusAdvanceGinvoiceapplyVo> listPageVo(PagerQuery<BusAdvanceGinvoiceapplyQuery> pq) { |
|
|
|
BusAdvanceGinvoiceapplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
IPage<BusAdvanceGinvoiceapply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BusAdvanceGinvoiceapplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
List<BusAdvanceGinvoiceapplyVo> records = pagging.getRecords(); |
|
|
|
if (records.size() != 0){ |
|
|
|
for (BusAdvanceGinvoiceapplyVo record : records) { |
|
|
|
String advGinReasonValue = record.getAdvGinReasonValue(); |
|
|
|
if (advGinReasonValue.equals("其它")){ |
|
|
|
record.setReasons(record.getOtherReasons()); |
|
|
|
}else { |
|
|
|
record.setReasons(advGinReasonValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<BusAdvanceGinvoiceapplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public List<BusAdvanceGinvoiceapplyVo> listAllVo(BusAdvanceGinvoiceapplyQuery query) { |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
return baseMapper.selectListAllVo(qw); |
|
|
|
} |
|
|
|
|
|
|
|
public List<BusAdvanceGinvoiceapplyVo> listVo() { |
|
|
|
return baseMapper.selectListVo(); |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(BusAdvanceGinvoiceapplyDto dto){ |
|
|
|
BusAdvanceGinvoiceapply entity = new BusAdvanceGinvoiceapply(); |
|
|
|
dto.fillEntity(entity); |
|
|
|
this.saveOrUpdate(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public BusAdvanceGinvoiceapplyVo fetchByIdVo(String id){ |
|
|
|
BusAdvanceGinvoiceapply entity = this.fetchById(id); |
|
|
|
BusAdvanceGinvoiceapplyVo vo = new BusAdvanceGinvoiceapplyVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
public List<BusAdvanceGinvoiceapply> listAll(BusAdvanceGinvoiceapplyQuery query) { |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
return baseMapper.selectList(qw); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveAll(BusAdvanceGinvoiceapplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<BusGinvoiceapplyVehicleDto> busGinvoiceapplyVehicleDtos = dto.getBusGinvoiceapplyVehicleDtos(); |
|
|
|
BusAdvanceGinvoiceapply busAdvanceGinvoiceapply = new BusAdvanceGinvoiceapply(); |
|
|
|
dto.fillEntity(busAdvanceGinvoiceapply); |
|
|
|
busAdvanceGinvoiceapply.setNum(busGinvoiceapplyVehicleDtos.size()); |
|
|
|
boolean save = this.save(busAdvanceGinvoiceapply); |
|
|
|
if (!save){ |
|
|
|
return rb.setMsg("保存失败"); |
|
|
|
} |
|
|
|
if (busGinvoiceapplyVehicleDtos.size() > 0){ |
|
|
|
for (BusGinvoiceapplyVehicleDto busGinvoiceapplyVehicleDto : busGinvoiceapplyVehicleDtos) { |
|
|
|
BusGinvoiceapplyVehicle busGinvoiceapplyVehicle = new BusGinvoiceapplyVehicle(); |
|
|
|
busGinvoiceapplyVehicleDto.fillEntity(busGinvoiceapplyVehicle); |
|
|
|
busGinvoiceapplyVehicle.setAdvGinSid(busAdvanceGinvoiceapply.getSid()); |
|
|
|
busGinvoiceapplyVehicleService.save(busGinvoiceapplyVehicle); |
|
|
|
} |
|
|
|
} |
|
|
|
List<CommonAppendixDto> commonAppendixVos = dto.getCommonAppendixDtos(); |
|
|
|
if (commonAppendixVos.size() > 0){ |
|
|
|
for (CommonAppendixDto commonAppendixDto : commonAppendixVos) { |
|
|
|
String filePath = commonAppendixDto.getFilePath(); |
|
|
|
if (filePath.indexOf(fileUploadComponent.getUrlPrefix()) > -1) { |
|
|
|
filePath = filePath.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
} |
|
|
|
commonAppendixDto.setLinkSid(busAdvanceGinvoiceapply.getSid()); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(dto.getStaffSid()); |
|
|
|
commonAppendixDto.setName(dto.getName()); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_GIN.getAttachType()); |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto1 = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
BeanUtil.copyProperties(commonAppendixDto,commonAppendixDto1); |
|
|
|
commonAppendixFeign.save(commonAppendixDto1); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("保存成功"); |
|
|
|
} |
|
|
|
private QueryWrapper<BusAdvanceGinvoiceapply> createQueryWrapper(BusAdvanceGinvoiceapplyQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = new QueryWrapper<>(); |
|
|
|
|
|
|
|
public ResultBean delAll(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
this.delBySids(sids); |
|
|
|
for (String sid : sids) { |
|
|
|
busGinvoiceapplyVehicleService.delByAdvGinSid(sid); |
|
|
|
} |
|
|
|
return rb.success().setMsg("删除成功"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getContractNo())) { |
|
|
|
qw.like("contractNo", query.getContractNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCustomerName())) { |
|
|
|
qw.like("customerName", query.getCustomerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getApplyName())) { |
|
|
|
qw.like("applyName", query.getApplyName()); |
|
|
|
} |
|
|
|
String applyStartDate = query.getApplyStartDate(); |
|
|
|
String applyEndDate = query.getApplyEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(applyStartDate), "date_format (applyDate,'%Y-%m-%d') >= date_format('" + applyStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(applyEndDate), "date_format (applyDate,'%Y-%m-%d') <= date_format('" + applyEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<BusAdvanceGinvoiceapplyDetailsVo> fetchAllBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BusAdvanceGinvoiceapplyDetailsVo busAdvanceGinvoiceapplyDetailsVo = baseMapper.fetchAllBySid(sid); |
|
|
|
List<BusGinvoiceapplyVehicleDetailsVo> busGinvoiceapplyVehicleDetailsVos = busGinvoiceapplyVehicleService.fetchByAdvGinSid(sid); |
|
|
|
busAdvanceGinvoiceapplyDetailsVo.setBusGinvoiceapplyVehicleDetailsVos(busGinvoiceapplyVehicleDetailsVos); |
|
|
|
ResultBean<List<CommonAppendixVo>> listResultBean = commonAppendixFeign.selByLinkSid(sid); |
|
|
|
List<CommonAppendixVo> commonAppendixVos = listResultBean.getData(); |
|
|
|
ArrayList<com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.CommonAppendixVo> commonAppendixVos1 = new ArrayList<>(); |
|
|
|
com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.CommonAppendixVo commonAppendixVo1 = new com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.CommonAppendixVo(); |
|
|
|
if (commonAppendixVos.size() > 0){ |
|
|
|
for (CommonAppendixVo commonAppendixVo : commonAppendixVos) { |
|
|
|
BeanUtil.copyProperties(commonAppendixVo,commonAppendixVo1); |
|
|
|
commonAppendixVos1.add(commonAppendixVo1); |
|
|
|
} |
|
|
|
} |
|
|
|
busAdvanceGinvoiceapplyDetailsVo.setCommonAppendixVos(commonAppendixVos1); |
|
|
|
return rb.success().setData(busAdvanceGinvoiceapplyDetailsVo); |
|
|
|
} |
|
|
|
public PagerVo<BusAdvanceGinvoiceapplyVo> listPageVo(PagerQuery<BusAdvanceGinvoiceapplyQuery> pq) { |
|
|
|
BusAdvanceGinvoiceapplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
IPage<BusAdvanceGinvoiceapply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BusAdvanceGinvoiceapplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
List<BusAdvanceGinvoiceapplyVo> records = pagging.getRecords(); |
|
|
|
if (records.size() != 0) { |
|
|
|
for (BusAdvanceGinvoiceapplyVo record : records) { |
|
|
|
String advGinReasonValue = record.getAdvGinReasonValue(); |
|
|
|
if (advGinReasonValue.equals("其它")) { |
|
|
|
record.setReasons(record.getOtherReasons()); |
|
|
|
} else { |
|
|
|
record.setReasons(advGinReasonValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<BusAdvanceGinvoiceapplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean updateAllBySid(BusAdvanceGinvoiceapplyDto dto, String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
this.updateBySid(dto.toMap(),sid); |
|
|
|
busGinvoiceapplyVehicleService.delByAdvGinSid(sid); |
|
|
|
List<BusGinvoiceapplyVehicleDto> busGinvoiceapplyVehicleDtos = dto.getBusGinvoiceapplyVehicleDtos(); |
|
|
|
if (busGinvoiceapplyVehicleDtos.size() > 0){ |
|
|
|
for (BusGinvoiceapplyVehicleDto busGinvoiceapplyVehicleDto : busGinvoiceapplyVehicleDtos) { |
|
|
|
BusGinvoiceapplyVehicle busGinvoiceapplyVehicle = new BusGinvoiceapplyVehicle(); |
|
|
|
busGinvoiceapplyVehicleDto.fillEntity(busGinvoiceapplyVehicle); |
|
|
|
busGinvoiceapplyVehicle.setAdvGinSid(sid); |
|
|
|
busGinvoiceapplyVehicleService.save(busGinvoiceapplyVehicle); |
|
|
|
} |
|
|
|
} |
|
|
|
commonAppendixFeign.deleteFiles(sid); |
|
|
|
List<CommonAppendixDto> commonAppendixVos = dto.getCommonAppendixDtos(); |
|
|
|
if (commonAppendixVos.size() > 0){ |
|
|
|
for (CommonAppendixDto commonAppendixDto : commonAppendixVos) { |
|
|
|
String filePath = commonAppendixDto.getFilePath(); |
|
|
|
if (filePath.indexOf(fileUploadComponent.getUrlPrefix()) > -1) { |
|
|
|
filePath = filePath.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
} |
|
|
|
commonAppendixDto.setLinkSid(sid); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(dto.getStaffSid()); |
|
|
|
commonAppendixDto.setName(dto.getName()); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_GIN.getAttachType()); |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto1 = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
BeanUtil.copyProperties(commonAppendixDto,commonAppendixDto1); |
|
|
|
commonAppendixFeign.save(commonAppendixDto1); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("修改成功"); |
|
|
|
} |
|
|
|
public List<BusAdvanceGinvoiceapplyVo> listAllVo(BusAdvanceGinvoiceapplyQuery query) { |
|
|
|
QueryWrapper<BusAdvanceGinvoiceapply> qw = createQueryWrapper(query); |
|
|
|
return baseMapper.selectListAllVo(qw); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitAdvanceGinvoiceaapply(BusAdvanceGinvoiceapplyDto dto) { |
|
|
|
String orgSid = checkUserOrg(dto.getUserSid()); |
|
|
|
String businessSid = ""; |
|
|
|
if (StringUtils.isBlank(orgSid)) { |
|
|
|
return new ResultBean().fail().setMsg("用户组织机构不能为空"); |
|
|
|
} |
|
|
|
// 验证
|
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
// 调用保存接口
|
|
|
|
ResultBean resultBean = saveAll(dto); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean.setMsg("提交失败"); |
|
|
|
} |
|
|
|
businessSid = resultBean.getData().toString(); |
|
|
|
} else { |
|
|
|
// 调用更新接口
|
|
|
|
ResultBean resultBean = updateAllBySid(dto, dto.getSid()); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean.setMsg("提交失败"); |
|
|
|
} |
|
|
|
businessSid = dto.getSid(); |
|
|
|
} |
|
|
|
// ???待完善(根据虚拟订单审批流程)
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
variables.put("isLoan", true); |
|
|
|
variables.put("orgSid", orgSid);//部门sid
|
|
|
|
ResultBean resultBean = flowableService.businessStart(ProcDefEnum.ADVANCEGINVOICEAPPLY.getProDefId(), dto.getUserSid(), variables); |
|
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
|
Map<String, String> map = (Map<String, String>) resultBean.getData(); |
|
|
|
saveSysFormLink(map); |
|
|
|
} |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
public List<BusAdvanceGinvoiceapplyVo> listVo() { |
|
|
|
return baseMapper.selectListVo(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查用户是否设置部门 |
|
|
|
* |
|
|
|
* @param userSid |
|
|
|
* @return 返回部门sid |
|
|
|
*/ |
|
|
|
private String checkUserOrg(String userSid) { |
|
|
|
String orgSid = ""; |
|
|
|
String staffSid = sysUserFeign.selectBySid(userSid).getData().getStaffSid(); |
|
|
|
ResultBean<String> resultBean = sysStaffOrgFeign.getSysStaffOrgSidListByStaffSid(staffSid); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
orgSid = resultBean.getData(); |
|
|
|
} |
|
|
|
return orgSid; |
|
|
|
} |
|
|
|
public void saveOrUpdateDto(BusAdvanceGinvoiceapplyDto dto) { |
|
|
|
BusAdvanceGinvoiceapply entity = new BusAdvanceGinvoiceapply(); |
|
|
|
dto.fillEntity(entity); |
|
|
|
this.saveOrUpdate(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存流程业务关联表 数据 |
|
|
|
* @param map |
|
|
|
*/ |
|
|
|
private void saveSysFormLink(Map<String, String> map) { |
|
|
|
SysFormLinkDto sysFormLinkDto = new SysFormLinkDto(); |
|
|
|
sysFormLinkDto.setBusinessSid(map.get("sid")); |
|
|
|
sysFormLinkDto.setProcInsId(map.get("procInsId")); |
|
|
|
sysFormLinkDto.setTaskDefKey(map.get("taskDefKey")); |
|
|
|
sysFormLinkDto.setNodeState(map.get("nodeState")); |
|
|
|
sysFormLinkDto.setFormType(SysFormLinkTypeEnum.ADVANCE_GINVOICEAPPLY.getCode()); |
|
|
|
public BusAdvanceGinvoiceapplyVo fetchByIdVo(String id) { |
|
|
|
BusAdvanceGinvoiceapply entity = this.fetchById(id); |
|
|
|
BusAdvanceGinvoiceapplyVo vo = new BusAdvanceGinvoiceapplyVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveAll(BusAdvanceGinvoiceapplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<BusGinvoiceapplyVehicleDto> busGinvoiceapplyVehicleDtos = dto.getBusGinvoiceapplyVehicleDtos(); |
|
|
|
BusAdvanceGinvoiceapply busAdvanceGinvoiceapply = new BusAdvanceGinvoiceapply(); |
|
|
|
dto.fillEntity(busAdvanceGinvoiceapply); |
|
|
|
busAdvanceGinvoiceapply.setNum(busGinvoiceapplyVehicleDtos.size()); |
|
|
|
boolean save = this.save(busAdvanceGinvoiceapply); |
|
|
|
if (!save) { |
|
|
|
return rb.setMsg("保存失败"); |
|
|
|
} |
|
|
|
if (busGinvoiceapplyVehicleDtos.size() > 0) { |
|
|
|
for (BusGinvoiceapplyVehicleDto busGinvoiceapplyVehicleDto : busGinvoiceapplyVehicleDtos) { |
|
|
|
BusGinvoiceapplyVehicle busGinvoiceapplyVehicle = new BusGinvoiceapplyVehicle(); |
|
|
|
busGinvoiceapplyVehicleDto.fillEntity(busGinvoiceapplyVehicle); |
|
|
|
busGinvoiceapplyVehicle.setAdvGinSid(busAdvanceGinvoiceapply.getSid()); |
|
|
|
busGinvoiceapplyVehicleService.save(busGinvoiceapplyVehicle); |
|
|
|
} |
|
|
|
} |
|
|
|
List<CommonAppendixDto> commonAppendixVos = dto.getCommonAppendixDtos(); |
|
|
|
if (commonAppendixVos.size() > 0) { |
|
|
|
for (CommonAppendixDto commonAppendixDto : commonAppendixVos) { |
|
|
|
String filePath = commonAppendixDto.getFilePath(); |
|
|
|
if (filePath.indexOf(fileUploadComponent.getUrlPrefix()) > -1) { |
|
|
|
filePath = filePath.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
} |
|
|
|
commonAppendixDto.setLinkSid(busAdvanceGinvoiceapply.getSid()); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(dto.getStaffSid()); |
|
|
|
commonAppendixDto.setName(dto.getName()); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_GIN.getAttachType()); |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto1 = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
BeanUtil.copyProperties(commonAppendixDto, commonAppendixDto1); |
|
|
|
commonAppendixFeign.save(commonAppendixDto1); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("保存成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delAll(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
this.delBySids(sids); |
|
|
|
for (String sid : sids) { |
|
|
|
busGinvoiceapplyVehicleService.delByAdvGinSid(sid); |
|
|
|
} |
|
|
|
return rb.success().setMsg("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<BusAdvanceGinvoiceapplyDetailsVo> fetchAllBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BusAdvanceGinvoiceapplyDetailsVo busAdvanceGinvoiceapplyDetailsVo = baseMapper.fetchAllBySid(sid); |
|
|
|
List<BusGinvoiceapplyVehicleDetailsVo> busGinvoiceapplyVehicleDetailsVos = busGinvoiceapplyVehicleService.fetchByAdvGinSid(sid); |
|
|
|
busAdvanceGinvoiceapplyDetailsVo.setBusGinvoiceapplyVehicleDetailsVos(busGinvoiceapplyVehicleDetailsVos); |
|
|
|
ResultBean<List<CommonAppendixVo>> listResultBean = commonAppendixFeign.selByLinkSid(sid); |
|
|
|
List<CommonAppendixVo> commonAppendixVos = listResultBean.getData(); |
|
|
|
ArrayList<com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.CommonAppendixVo> commonAppendixVos1 = new ArrayList<>(); |
|
|
|
com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.CommonAppendixVo commonAppendixVo1 = new com.yxt.anrui.buscenter.api.busadvanceginvoiceapply.CommonAppendixVo(); |
|
|
|
if (commonAppendixVos.size() > 0) { |
|
|
|
for (CommonAppendixVo commonAppendixVo : commonAppendixVos) { |
|
|
|
BeanUtil.copyProperties(commonAppendixVo, commonAppendixVo1); |
|
|
|
commonAppendixVos1.add(commonAppendixVo1); |
|
|
|
} |
|
|
|
} |
|
|
|
busAdvanceGinvoiceapplyDetailsVo.setCommonAppendixVos(commonAppendixVos1); |
|
|
|
return rb.success().setData(busAdvanceGinvoiceapplyDetailsVo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean updateAllBySid(BusAdvanceGinvoiceapplyDto dto, String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
this.updateBySid(dto.toMap(), sid); |
|
|
|
busGinvoiceapplyVehicleService.delByAdvGinSid(sid); |
|
|
|
List<BusGinvoiceapplyVehicleDto> busGinvoiceapplyVehicleDtos = dto.getBusGinvoiceapplyVehicleDtos(); |
|
|
|
if (busGinvoiceapplyVehicleDtos.size() > 0) { |
|
|
|
for (BusGinvoiceapplyVehicleDto busGinvoiceapplyVehicleDto : busGinvoiceapplyVehicleDtos) { |
|
|
|
BusGinvoiceapplyVehicle busGinvoiceapplyVehicle = new BusGinvoiceapplyVehicle(); |
|
|
|
busGinvoiceapplyVehicleDto.fillEntity(busGinvoiceapplyVehicle); |
|
|
|
busGinvoiceapplyVehicle.setAdvGinSid(sid); |
|
|
|
busGinvoiceapplyVehicleService.save(busGinvoiceapplyVehicle); |
|
|
|
} |
|
|
|
} |
|
|
|
commonAppendixFeign.deleteFiles(sid); |
|
|
|
List<CommonAppendixDto> commonAppendixVos = dto.getCommonAppendixDtos(); |
|
|
|
if (commonAppendixVos.size() > 0) { |
|
|
|
for (CommonAppendixDto commonAppendixDto : commonAppendixVos) { |
|
|
|
String filePath = commonAppendixDto.getFilePath(); |
|
|
|
if (filePath.indexOf(fileUploadComponent.getUrlPrefix()) > -1) { |
|
|
|
filePath = filePath.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
} |
|
|
|
commonAppendixDto.setLinkSid(sid); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(dto.getStaffSid()); |
|
|
|
commonAppendixDto.setName(dto.getName()); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_GIN.getAttachType()); |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto1 = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
BeanUtil.copyProperties(commonAppendixDto, commonAppendixDto1); |
|
|
|
commonAppendixFeign.save(commonAppendixDto1); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("修改成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean submitAdvanceGinvoiceaapply(BusAdvanceGinvoiceapplyDto dto) { |
|
|
|
String orgSid = checkUserOrg(dto.getUserSid()); |
|
|
|
String businessSid = ""; |
|
|
|
if (StringUtils.isBlank(orgSid)) { |
|
|
|
return new ResultBean().fail().setMsg("用户组织机构不能为空"); |
|
|
|
} |
|
|
|
// 验证
|
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
// 调用保存接口
|
|
|
|
ResultBean resultBean = saveAll(dto); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean.setMsg("提交失败"); |
|
|
|
} |
|
|
|
businessSid = resultBean.getData().toString(); |
|
|
|
} else { |
|
|
|
// 调用更新接口
|
|
|
|
ResultBean resultBean = updateAllBySid(dto, dto.getSid()); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
return resultBean.setMsg("提交失败"); |
|
|
|
} |
|
|
|
businessSid = dto.getSid(); |
|
|
|
} |
|
|
|
// ???待完善(根据虚拟订单审批流程)
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
variables.put("isLoan", true); |
|
|
|
variables.put("orgSid", orgSid);//部门sid
|
|
|
|
ResultBean resultBean = flowableService.businessStart(ProcDefEnum.ADVANCEGINVOICEAPPLY.getProDefId(), dto.getUserSid(), variables); |
|
|
|
if (resultBean.getSuccess() && resultBean.getData() != null) { |
|
|
|
Map<String, String> map = (Map<String, String>) resultBean.getData(); |
|
|
|
saveSysFormLink(map); |
|
|
|
} |
|
|
|
return resultBean; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查用户是否设置部门 |
|
|
|
* |
|
|
|
* @param userSid |
|
|
|
* @return 返回部门sid |
|
|
|
*/ |
|
|
|
private String checkUserOrg(String userSid) { |
|
|
|
String orgSid = ""; |
|
|
|
String staffSid = sysUserFeign.selectBySid(userSid).getData().getStaffSid(); |
|
|
|
ResultBean<String> resultBean = sysStaffOrgFeign.getSysStaffOrgSidListByStaffSid(staffSid); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
orgSid = resultBean.getData(); |
|
|
|
} |
|
|
|
return orgSid; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存流程业务关联表 数据 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
*/ |
|
|
|
private void saveSysFormLink(Map<String, String> map) { |
|
|
|
SysFormLinkDto sysFormLinkDto = new SysFormLinkDto(); |
|
|
|
sysFormLinkDto.setBusinessSid(map.get("sid")); |
|
|
|
sysFormLinkDto.setProcInsId(map.get("procInsId")); |
|
|
|
sysFormLinkDto.setTaskDefKey(map.get("taskDefKey")); |
|
|
|
sysFormLinkDto.setNodeState(map.get("nodeState")); |
|
|
|
sysFormLinkDto.setFormType(SysFormLinkTypeEnum.ADVANCE_GINVOICEAPPLY.getCode()); |
|
|
|
// sysFormLinkDto.setFlowState(Integer.parseInt(SysFormLinkFlowStateEnum.PROCESSING.getCode()));
|
|
|
|
sysFormLinkFeign.save(sysFormLinkDto); |
|
|
|
} |
|
|
|
sysFormLinkFeign.save(sysFormLinkDto); |
|
|
|
} |
|
|
|
|
|
|
|
public IPage<AppAdvanceInvoicePageVo> getAdvanceInvoiceList(PagerQuery<AppAdvanceInvoiceQuery> pagerQuery) { |
|
|
|
AppAdvanceInvoiceQuery params = pagerQuery.getParams(); |
|
|
|
QueryWrapper<AppAdvanceInvoiceQuery> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(params.getUserSid())) { |
|
|
|
qw.eq("createBySid", params.getUserSid()); |
|
|
|
} |
|
|
|
IPage<AppAdvanceInvoiceQuery> page = PagerUtil.queryToPage(pagerQuery); |
|
|
|
IPage<AppAdvanceInvoicePageVo> iPage = baseMapper.getAdvanceInvoiceList(page, qw, params.getName()); |
|
|
|
return iPage; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<AppAdvanceInvoiceInfoVo> initAdvanceInvoice(String contractSid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
AppAdvanceInvoiceInfoVo vo = new AppAdvanceInvoiceInfoVo(); |
|
|
|
BusAdvanceGinvoiceapply busAdvanceGinvoiceapply = fetchBySid(contractSid); |
|
|
|
BeanUtil.copyProperties(busAdvanceGinvoiceapply, vo, "sid"); |
|
|
|
List<AdCarListVo> carList = new ArrayList<>(); |
|
|
|
List<BusGinvoiceapplyVehicleDetailsVo> vinList = busGinvoiceapplyVehicleService.fetchByAdvGinSid(contractSid); |
|
|
|
for (BusGinvoiceapplyVehicleDetailsVo vehicleDetailsVo : vinList) { |
|
|
|
AdCarListVo adCarListVo = new AdCarListVo(); |
|
|
|
adCarListVo.setPrice(vehicleDetailsVo.getDealMoney()); |
|
|
|
adCarListVo.setVin(vehicleDetailsVo.getVinNo()); |
|
|
|
carList.add(adCarListVo); |
|
|
|
} |
|
|
|
vo.setCarList(carList); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
List<String> confirmFile = new ArrayList<>(); |
|
|
|
List<CommonAppendixVo> confirmFiles = commonAppendixFeign.getAppAppendixList(contractSid, CommonAttachTypeEnum.ADVANCE_KPXXQRS.getAttachType()).getData(); |
|
|
|
for (CommonAppendixVo file : confirmFiles) { |
|
|
|
confirmFile.add(urlPrefix + file.getFilePath()); |
|
|
|
} |
|
|
|
vo.setConfirmFile(confirmFile); |
|
|
|
List<String> applyFile = new ArrayList<>(); |
|
|
|
List<CommonAppendixVo> applyFiles = commonAppendixFeign.getAppAppendixList(contractSid, CommonAttachTypeEnum.ADVANCE_KHKPSQS.getAttachType()).getData(); |
|
|
|
for (CommonAppendixVo file : applyFiles) { |
|
|
|
applyFile.add(urlPrefix + file.getFilePath()); |
|
|
|
} |
|
|
|
vo.setApplyFile(applyFile); |
|
|
|
List<String> registerFile = new ArrayList<>(); |
|
|
|
List<CommonAppendixVo> registerFiles = commonAppendixFeign.getAppAppendixList(contractSid, CommonAttachTypeEnum.ADVANCE_CLDJHT.getAttachType()).getData(); |
|
|
|
for (CommonAppendixVo file : registerFiles) { |
|
|
|
registerFile.add(urlPrefix + file.getFilePath()); |
|
|
|
} |
|
|
|
vo.setRegisterFile(registerFile); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveAdvanceInvoice(AppAdvanceInvoiceDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(dto.getUserSid()).getData(); |
|
|
|
if (StringUtils.isBlank(dto.getContractSid())) { |
|
|
|
BusAdvanceGinvoiceapply busAdvanceGinvoiceapply = new BusAdvanceGinvoiceapply(); |
|
|
|
BeanUtil.copyProperties(dto, busAdvanceGinvoiceapply); |
|
|
|
save(busAdvanceGinvoiceapply); |
|
|
|
List<AdCarListVo> carList = dto.getCarList(); |
|
|
|
for (AdCarListVo adCarListVo : carList) { |
|
|
|
BusGinvoiceapplyVehicle busGinvoiceapplyVehicle = new BusGinvoiceapplyVehicle(); |
|
|
|
busGinvoiceapplyVehicle.setAdvGinSid(busAdvanceGinvoiceapply.getSid()); |
|
|
|
busGinvoiceapplyVehicle.setVinNo(adCarListVo.getVin()); |
|
|
|
busGinvoiceapplyVehicle.setDealMoney(adCarListVo.getPrice()); |
|
|
|
busGinvoiceapplyVehicleService.save(busGinvoiceapplyVehicle); |
|
|
|
} |
|
|
|
saveFile(dto.getConfirmFile(), dto.getApplyFile(), dto.getRegisterFile(), busAdvanceGinvoiceapply.getSid(), sysUserVo.getStaffSid()); |
|
|
|
} else { |
|
|
|
BusAdvanceGinvoiceapply busAdvanceGinvoiceapply = fetchBySid(dto.getContractSid()); |
|
|
|
BeanUtil.copyProperties(dto, busAdvanceGinvoiceapply); |
|
|
|
updateById(busAdvanceGinvoiceapply); |
|
|
|
busGinvoiceapplyVehicleService.delByAdvGinSid(dto.getContractSid()); |
|
|
|
List<AdCarListVo> carList = dto.getCarList(); |
|
|
|
for (AdCarListVo adCarListVo : carList) { |
|
|
|
BusGinvoiceapplyVehicle busGinvoiceapplyVehicle = new BusGinvoiceapplyVehicle(); |
|
|
|
busGinvoiceapplyVehicle.setAdvGinSid(busAdvanceGinvoiceapply.getSid()); |
|
|
|
busGinvoiceapplyVehicle.setVinNo(adCarListVo.getVin()); |
|
|
|
busGinvoiceapplyVehicle.setDealMoney(adCarListVo.getPrice()); |
|
|
|
busGinvoiceapplyVehicleService.save(busGinvoiceapplyVehicle); |
|
|
|
} |
|
|
|
commonAppendixFeign.deleteFiles(dto.getContractSid()); |
|
|
|
saveFile(dto.getConfirmFile(), dto.getApplyFile(), dto.getRegisterFile(), busAdvanceGinvoiceapply.getSid(), sysUserVo.getStaffSid()); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public void saveFile(List<String> confirmFile, List<String> applyFile, List<String> registerFile, String sid, String staffSid) { |
|
|
|
for (String s : confirmFile) { |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
String filePath = s.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
commonAppendixDto.setLinkSid(sid); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(staffSid); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_KPXXQRS.getAttachType()); |
|
|
|
commonAppendixFeign.save(commonAppendixDto); |
|
|
|
} |
|
|
|
for (String s : applyFile) { |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
String filePath = s.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
commonAppendixDto.setLinkSid(sid); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(staffSid); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_KHKPSQS.getAttachType()); |
|
|
|
commonAppendixFeign.save(commonAppendixDto); |
|
|
|
} |
|
|
|
for (String s : registerFile) { |
|
|
|
com.yxt.anrui.base.api.commonappendix.CommonAppendixDto commonAppendixDto = new com.yxt.anrui.base.api.commonappendix.CommonAppendixDto(); |
|
|
|
String filePath = s.replace(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
commonAppendixDto.setLinkSid(sid); |
|
|
|
commonAppendixDto.setFilePath(filePath); |
|
|
|
commonAppendixDto.setCreateBySid(staffSid); |
|
|
|
commonAppendixDto.setAttachType(CommonAttachTypeEnum.ADVANCE_CLDJHT.getAttachType()); |
|
|
|
commonAppendixFeign.save(commonAppendixDto); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean deleteAdvanceInvoice(String contractSid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BusAdvanceGinvoiceapply busAdvanceGinvoiceapply = fetchBySid(contractSid); |
|
|
|
if (StringUtils.isNotBlank(busAdvanceGinvoiceapply.getNodeState())) { |
|
|
|
return rb.setMsg("该申请已提交,删除失败"); |
|
|
|
} |
|
|
|
deleteBySid(contractSid); |
|
|
|
busGinvoiceapplyVehicleService.delByAdvGinSid(contractSid); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |