新增凭证管理
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
package org.springblade.transport.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.transport.pojo.dto.VoucherManageSubmitRequest;
|
||||
import org.springblade.transport.pojo.dto.VoucherUploadDraftRequest;
|
||||
import org.springblade.transport.pojo.entity.VoucherManage;
|
||||
import org.springblade.transport.pojo.vo.VoucherManageVO;
|
||||
import org.springblade.transport.service.IVoucherManageService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@PreAuth(menu = "voucher_manage")
|
||||
@RequestMapping("/voucher-manage")
|
||||
@Tag(name = "凭证管理", description = "执行凭证批次管理")
|
||||
public class VoucherManageController extends BladeController {
|
||||
private final IVoucherManageService voucherManageService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "凭证管理分页")
|
||||
public R<IPage<VoucherManageVO>> list(VoucherManageVO voucherManage, Query query) {
|
||||
return R.data(voucherManageService.selectPage(Condition.getPage(query), voucherManage));
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "凭证详情")
|
||||
public R<VoucherManageVO> detail(@RequestParam Long id) { return R.data(voucherManageService.detail(id)); }
|
||||
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "上传凭证或更换运输批次")
|
||||
public R submit(@RequestBody VoucherManageSubmitRequest request) { voucherManageService.submit(request); return R.success("提交成功"); }
|
||||
|
||||
@PostMapping("/upload-draft")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "创建凭证上传草稿")
|
||||
public R<VoucherManage> createUploadDraft(@RequestBody VoucherUploadDraftRequest request) {
|
||||
return R.data(voucherManageService.createUploadDraft(request));
|
||||
}
|
||||
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "删除凭证")
|
||||
public R remove(@RequestParam Long id) { voucherManageService.removeVoucher(id); return R.success("删除成功"); }
|
||||
|
||||
@GetMapping("/waybill-batches")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "可关联运输批次")
|
||||
public R<List<Map<String, Object>>> waybillBatches(@RequestParam(required = false) String batchNo,
|
||||
@RequestParam(required = false) String createUser, @RequestParam(required = false) Integer waybillCount,
|
||||
@RequestParam(required = false) String createTimeStart, @RequestParam(required = false) String createTimeEnd) {
|
||||
return R.data(voucherManageService.selectableWaybillBatches(batchNo, createUser, waybillCount, createTimeStart, createTimeEnd));
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package org.springblade.transport.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.transport.pojo.entity.VoucherManage;
|
||||
|
||||
public interface VoucherManageMapper extends BaseMapper<VoucherManage> { }
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.springblade.transport.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.transport.pojo.entity.VoucherWaybillBatch;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface VoucherWaybillBatchMapper extends BaseMapper<VoucherWaybillBatch> {
|
||||
List<Map<String, Object>> selectWaybillBatches(@Param("tenantId") String tenantId, @Param("batchNo") String batchNo, @Param("createUser") String createUser,
|
||||
@Param("waybillCount") Integer waybillCount, @Param("createTimeStart") String createTimeStart, @Param("createTimeEnd") String createTimeEnd);
|
||||
List<Map<String, Object>> selectWaybillBatchesByIds(@Param("tenantId") String tenantId, @Param("ids") List<Long> ids);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.transport.mapper.VoucherWaybillBatchMapper">
|
||||
<select id="selectWaybillBatches" resultType="java.util.LinkedHashMap">
|
||||
SELECT b.id, b.batch_no AS batchNo, b.waybill_count AS waybillCount, b.create_time AS createTime,
|
||||
b.create_user AS createUser, u.real_name AS createUserName
|
||||
FROM blade_waybill_import_batch b
|
||||
LEFT JOIN blade_user u ON u.id = b.create_user
|
||||
WHERE b.is_deleted = 0 AND b.tenant_id = #{tenantId}
|
||||
<if test="batchNo != null and batchNo != ''">AND b.batch_no LIKE CONCAT('%', #{batchNo}, '%')</if>
|
||||
<if test="createUser != null and createUser != ''">AND b.create_user = #{createUser}</if>
|
||||
<if test="waybillCount != null">AND b.waybill_count = #{waybillCount}</if>
|
||||
<if test="createTimeStart != null and createTimeStart != ''">AND b.create_time <![CDATA[>=]]> #{createTimeStart}</if>
|
||||
<if test="createTimeEnd != null and createTimeEnd != ''">AND b.create_time <![CDATA[<=]]> #{createTimeEnd}</if>
|
||||
ORDER BY b.create_time DESC
|
||||
</select>
|
||||
<select id="selectWaybillBatchesByIds" resultType="java.util.LinkedHashMap">
|
||||
SELECT b.id, b.batch_no AS batchNo, b.waybill_count AS waybillCount FROM blade_waybill_import_batch b
|
||||
INNER JOIN blade_waybill w ON w.import_batch_id = b.id AND w.is_deleted = 0
|
||||
WHERE b.is_deleted = 0 AND b.tenant_id = #{tenantId} AND w.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
GROUP BY b.id, b.batch_no, b.waybill_count
|
||||
</select>
|
||||
</mapper>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.springblade.transport.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.transport.pojo.dto.VoucherManageSubmitRequest;
|
||||
import org.springblade.transport.pojo.dto.VoucherUploadDraftRequest;
|
||||
import org.springblade.transport.pojo.entity.VoucherManage;
|
||||
import org.springblade.transport.pojo.vo.VoucherManageVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IVoucherManageService extends BaseService<VoucherManage> {
|
||||
IPage<VoucherManageVO> selectPage(IPage<VoucherManage> page, VoucherManageVO query);
|
||||
VoucherManageVO detail(Long id);
|
||||
void submit(VoucherManageSubmitRequest request);
|
||||
VoucherManage createUploadDraft(VoucherUploadDraftRequest request);
|
||||
void removeVoucher(Long id);
|
||||
List<Map<String, Object>> selectableWaybillBatches(String batchNo, String createUser, Integer waybillCount, String createTimeStart, String createTimeEnd);
|
||||
}
|
||||
+13
-2
@@ -216,7 +216,8 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
CustomerArchiveVO detail = detail(id);
|
||||
prepare(detail);
|
||||
validateBase(detail);
|
||||
validateApproval(detail);
|
||||
// 临时客商审核通过时由流程转为正式客商,不要求补齐正式客商材料。
|
||||
validateApproval(detail, Objects.equals(detail.getAccessType(), ACCESS_TEMPORARY));
|
||||
CustomerArchive before = Objects.requireNonNull(BeanUtil.copyProperties(detail, CustomerArchive.class));
|
||||
CustomerArchive after = copyCustomer(before);
|
||||
after.setAccessType(ACCESS_FORMAL);
|
||||
@@ -382,7 +383,11 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
}
|
||||
|
||||
private void validateApproval(CustomerArchiveVO customer) {
|
||||
if (Objects.equals(customer.getAccessType(), ACCESS_FORMAL)) {
|
||||
validateApproval(customer, false);
|
||||
}
|
||||
|
||||
private void validateApproval(CustomerArchiveVO customer, boolean temporaryToFormal) {
|
||||
if (Objects.equals(customer.getAccessType(), ACCESS_FORMAL) && !temporaryToFormal) {
|
||||
if (Func.isEmpty(customer.getQualificationAttachments())) {
|
||||
throw new ServiceException("正式客商提交审核前必须上传客商材料");
|
||||
}
|
||||
@@ -459,6 +464,12 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
if (Func.isEmpty(invoiceVO.getInvoiceTitle()) && Func.isEmpty(invoiceVO.getTaxNo())) {
|
||||
continue;
|
||||
}
|
||||
if (Func.isEmpty(invoiceVO.getInvoiceType())) {
|
||||
throw new ServiceException("发票类型不能为空");
|
||||
}
|
||||
if (!List.of("增值税专用发票", "普通发票").contains(invoiceVO.getInvoiceType())) {
|
||||
throw new ServiceException("发票类型不合法");
|
||||
}
|
||||
invoiceVO.setRegisteredAddress(buildAddress(invoiceVO.getRegisteredRegionName(), invoiceVO.getRegisteredDetailAddress(), invoiceVO.getRegisteredAddress()));
|
||||
invoiceVO.setReceiverAddress(buildAddress(invoiceVO.getReceiverRegionName(), invoiceVO.getReceiverDetailAddress(), invoiceVO.getReceiverAddress()));
|
||||
CustomerInvoiceInfo invoice = Objects.requireNonNull(BeanUtil.copyProperties(invoiceVO, CustomerInvoiceInfo.class));
|
||||
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
package org.springblade.transport.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.transport.mapper.VoucherManageMapper;
|
||||
import org.springblade.transport.mapper.VoucherWaybillBatchMapper;
|
||||
import org.springblade.transport.pojo.dto.VoucherManageSubmitRequest;
|
||||
import org.springblade.transport.pojo.dto.VoucherUploadDraftRequest;
|
||||
import org.springblade.transport.pojo.entity.VoucherManage;
|
||||
import org.springblade.transport.pojo.entity.VoucherWaybillBatch;
|
||||
import org.springblade.transport.pojo.entity.ProjectApply;
|
||||
import org.springblade.transport.pojo.vo.VoucherManageVO;
|
||||
import org.springblade.transport.service.IVoucherManageService;
|
||||
import org.springblade.transport.service.IProjectApplyService;
|
||||
import org.springblade.transport.wrapper.VoucherManageWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class VoucherManageServiceImpl extends BaseServiceImpl<VoucherManageMapper, VoucherManage> implements IVoucherManageService {
|
||||
|
||||
private final VoucherWaybillBatchMapper voucherWaybillBatchMapper;
|
||||
private final IProjectApplyService projectApplyService;
|
||||
|
||||
public VoucherManageServiceImpl(VoucherWaybillBatchMapper voucherWaybillBatchMapper, IProjectApplyService projectApplyService) {
|
||||
this.voucherWaybillBatchMapper = voucherWaybillBatchMapper;
|
||||
this.projectApplyService = projectApplyService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<VoucherManageVO> selectPage(IPage<VoucherManage> page, VoucherManageVO query) {
|
||||
return VoucherManageWrapper.build().pageVO(page(page, buildQuery(query)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoucherManageVO detail(Long id) {
|
||||
VoucherManage record = getById(id);
|
||||
if (record == null || Objects.equals(record.getIsDeleted(), 1)) throw new ServiceException("凭证批次不存在");
|
||||
return VoucherManageWrapper.build().entityVO(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public VoucherManage createUploadDraft(VoucherUploadDraftRequest request) {
|
||||
if (Func.isEmpty(request.getProjectId())) throw new ServiceException("请先选择项目名称");
|
||||
if (Func.isEmpty(request.getFileName())) throw new ServiceException("文件名称不能为空");
|
||||
ProjectApply project = projectApplyService.getById(request.getProjectId());
|
||||
if (project == null || !List.of("approved", "change_approved").contains(project.getApprovalStatus())) {
|
||||
throw new ServiceException("仅允许选择审核通过或变更审核通过的项目");
|
||||
}
|
||||
VoucherManage voucher = new VoucherManage();
|
||||
voucher.setProjectId(project.getId());
|
||||
voucher.setProjectName(project.getProjectName());
|
||||
voucher.setVoucherBatchNo(nextCode());
|
||||
voucher.setFileName(request.getFileName());
|
||||
voucher.setFileUrl("");
|
||||
voucher.setUploadSource("内部");
|
||||
voucher.setProcessStatus("上传中");
|
||||
voucher.setAuditStatus("-");
|
||||
voucher.setVoucherCount(0);
|
||||
voucher.setRelatedWaybillCount(0);
|
||||
voucher.setUnRelatedWaybillCount(0);
|
||||
save(voucher);
|
||||
return voucher;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void submit(VoucherManageSubmitRequest request) {
|
||||
if (Func.isEmpty(request.getProjectId())) throw new ServiceException("请选择项目名称");
|
||||
if (Func.isEmpty(request.getFileName()) || Func.isEmpty(request.getFileUrl())) throw new ServiceException("请上传执行凭证压缩包");
|
||||
if (Func.isEmpty(request.getWaybillImportBatchIds())) throw new ServiceException("请至少关联一个运输批次");
|
||||
VoucherManage voucher = Func.isEmpty(request.getId()) ? new VoucherManage() : getById(request.getId());
|
||||
if (voucher == null) throw new ServiceException("凭证批次不存在");
|
||||
ProjectApply project = projectApplyService.getById(request.getProjectId());
|
||||
if (project == null || !List.of("approved", "change_approved").contains(project.getApprovalStatus())) throw new ServiceException("仅允许选择审核通过或变更审核通过的项目");
|
||||
voucher.setProjectId(project.getId());
|
||||
voucher.setProjectName(project.getProjectName());
|
||||
voucher.setFileName(request.getFileName());
|
||||
voucher.setFileUrl(request.getFileUrl());
|
||||
voucher.setFileTaskId(request.getFileTaskId());
|
||||
voucher.setUploadSource("内部");
|
||||
voucher.setProcessStatus("上传中");
|
||||
voucher.setAuditStatus("-");
|
||||
voucher.setVoucherCount(0);
|
||||
voucher.setRelatedWaybillCount(0);
|
||||
voucher.setUnRelatedWaybillCount(0);
|
||||
if (Func.isEmpty(voucher.getVoucherBatchNo())) voucher.setVoucherBatchNo(nextCode());
|
||||
saveOrUpdate(voucher);
|
||||
voucherWaybillBatchMapper.delete(Wrappers.<VoucherWaybillBatch>lambdaQuery().eq(VoucherWaybillBatch::getVoucherId, voucher.getId()));
|
||||
List<Map<String, Object>> batches = selectableWaybillBatchesByIds(request.getWaybillImportBatchIds());
|
||||
if (batches.size() != request.getWaybillImportBatchIds().size()) throw new ServiceException("存在无效的运输批次");
|
||||
List<VoucherWaybillBatch> relations = new ArrayList<>();
|
||||
for (Map<String, Object> batch : batches) {
|
||||
VoucherWaybillBatch relation = new VoucherWaybillBatch();
|
||||
relation.setVoucherId(voucher.getId());
|
||||
relation.setWaybillImportBatchId(((Number) batch.get("id")).longValue());
|
||||
relation.setWaybillBatchNo((String) batch.get("batchNo"));
|
||||
relation.setWaybillCount(((Number) batch.get("waybillCount")).intValue());
|
||||
relations.add(relation);
|
||||
}
|
||||
relations.forEach(voucherWaybillBatchMapper::insert);
|
||||
voucher.setWaybillBatchNo(relations.stream().map(VoucherWaybillBatch::getWaybillBatchNo).collect(Collectors.joining(",")));
|
||||
int total = relations.stream().mapToInt(VoucherWaybillBatch::getWaybillCount).sum();
|
||||
voucher.setRelatedWaybillCount(total);
|
||||
voucher.setUnRelatedWaybillCount(0);
|
||||
updateById(voucher);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeVoucher(Long id) {
|
||||
VoucherManage voucher = getById(id);
|
||||
if (voucher == null) throw new ServiceException("凭证批次不存在");
|
||||
deleteLogic(List.of(id));
|
||||
voucherWaybillBatchMapper.delete(Wrappers.<VoucherWaybillBatch>lambdaQuery().eq(VoucherWaybillBatch::getVoucherId, id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> selectableWaybillBatches(String batchNo, String createUser, Integer waybillCount, String createTimeStart, String createTimeEnd) {
|
||||
return voucherWaybillBatchMapper.selectWaybillBatches(AuthUtil.getTenantId(), batchNo, createUser, waybillCount, createTimeStart, createTimeEnd);
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> selectableWaybillBatchesByIds(List<Long> ids) {
|
||||
if (Func.isEmpty(ids)) return List.of();
|
||||
return voucherWaybillBatchMapper.selectWaybillBatchesByIds(AuthUtil.getTenantId(), ids);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<VoucherManage> buildQuery(VoucherManageVO query) {
|
||||
LambdaQueryWrapper<VoucherManage> wrapper = Wrappers.<VoucherManage>lambdaQuery().eq(VoucherManage::getIsDeleted, 0)
|
||||
.like(Func.isNotEmpty(query.getVoucherBatchNo()), VoucherManage::getVoucherBatchNo, query.getVoucherBatchNo())
|
||||
.eq(Func.isNotEmpty(query.getAuditStatus()), VoucherManage::getAuditStatus, query.getAuditStatus())
|
||||
.eq(Func.isNotEmpty(query.getProcessStatus()), VoucherManage::getProcessStatus, query.getProcessStatus())
|
||||
.like(Func.isNotEmpty(query.getWaybillBatchNo()), VoucherManage::getWaybillBatchNo, query.getWaybillBatchNo())
|
||||
.eq(Func.isNotEmpty(query.getUploadSource()), VoucherManage::getUploadSource, query.getUploadSource())
|
||||
.like(Func.isNotEmpty(query.getCarrierName()), VoucherManage::getCarrierName, query.getCarrierName());
|
||||
if (query.getCreateTimeStart() != null) wrapper.ge(VoucherManage::getCreateTime, query.getCreateTimeStart());
|
||||
if (query.getCreateTimeEnd() != null) wrapper.le(VoucherManage::getCreateTime, query.getCreateTimeEnd());
|
||||
return wrapper.orderByDesc(VoucherManage::getCreateTime);
|
||||
}
|
||||
|
||||
private synchronized String nextCode() {
|
||||
String prefix = "PZ" + java.time.LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "-";
|
||||
long count = count(Wrappers.<VoucherManage>lambdaQuery().likeRight(VoucherManage::getVoucherBatchNo, prefix));
|
||||
return prefix + String.format("%03d", count + 1);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.springblade.transport.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.transport.pojo.entity.VoucherManage;
|
||||
import org.springblade.transport.pojo.vo.VoucherManageVO;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class VoucherManageWrapper extends BaseEntityWrapper<VoucherManage, VoucherManageVO> {
|
||||
public static VoucherManageWrapper build() { return new VoucherManageWrapper(); }
|
||||
@Override
|
||||
public VoucherManageVO entityVO(VoucherManage entity) {
|
||||
VoucherManageVO vo = Objects.requireNonNull(BeanUtil.copyProperties(entity, VoucherManageVO.class));
|
||||
vo.setCreateUserName(UserCache.getUserRealName(entity.getCreateUser()));
|
||||
vo.setUpdateUserName(UserCache.getUserRealName(entity.getUpdateUser()));
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user