|
|
|
|
@ -1,15 +1,23 @@
|
|
|
|
|
package com.zbkj.modules.autogencode.controller;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.zbkj.modules.autogencode.entity.*;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.zbkj.common.request.PageParamRequest;
|
|
|
|
|
import com.zbkj.common.response.CommonResult;
|
|
|
|
|
import com.zbkj.common.page.CommonPage;
|
|
|
|
|
import com.zbkj.modules.autogencode.entity.CkBill;
|
|
|
|
|
import com.zbkj.modules.autogencode.service.CkBillService;
|
|
|
|
|
import com.zbkj.modules.autogencode.service.CkBillCargoService;
|
|
|
|
|
import com.zbkj.modules.autogencode.service.CkBillStockService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@ -19,13 +27,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.zbkj.modules.autogencode.entity.CkBillCargo;
|
|
|
|
|
import com.zbkj.modules.autogencode.service.CkBillCargoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 出入库单据明细 控制器
|
|
|
|
|
*/
|
|
|
|
|
@ -38,6 +39,9 @@ public class CkBillCargoController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private CkBillService ckBillService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CkBillStockService ckBillStockService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 条件设置
|
|
|
|
|
* 根据实体类字段自动生成查询条件
|
|
|
|
|
@ -46,239 +50,239 @@ public class CkBillCargoController {
|
|
|
|
|
if (request == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据实体类字段自动生成查询条件
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 主键
|
|
|
|
|
if (request.getId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getId, request.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 区分直接出入库,类型为1,其他出入库类型为0
|
|
|
|
|
if (StrUtil.isNotBlank(request.getSourceType())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getSourceType, request.getSourceType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单据ID
|
|
|
|
|
if (request.getBillId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getBillId, request.getBillId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单据状态 0未提交,1提交 默认1,主要用于出入库页面
|
|
|
|
|
if (StrUtil.isNotBlank(request.getBillStatus())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getBillStatus, request.getBillStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单据日期
|
|
|
|
|
if (request.getBillDate() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getBillDate, request.getBillDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单据编号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getBillNumber())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getBillNumber, request.getBillNumber());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 出入库类型
|
|
|
|
|
if (StrUtil.isNotBlank(request.getInoutType())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getInoutType, request.getInoutType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 船舶航次ID
|
|
|
|
|
if (request.getVoyageId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getVoyageId, request.getVoyageId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 航次号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getVoyageNo())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getVoyageNo, request.getVoyageNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 船舶ID
|
|
|
|
|
if (request.getVesselId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getVesselId, request.getVesselId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 船舶名称
|
|
|
|
|
if (StrUtil.isNotBlank(request.getVesselName())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getVesselName, request.getVesselName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 船舶货物ID
|
|
|
|
|
if (request.getVesselCargoId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getVesselCargoId, request.getVesselCargoId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物ID
|
|
|
|
|
if (request.getCargoId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoId, request.getCargoId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物自然序号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCargoNumber())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoNumber, request.getCargoNumber());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 商品料号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getItemNumber())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getItemNumber, request.getItemNumber());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 电子账册项号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getBookNumber())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getBookNumber, request.getBookNumber());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HS编号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getHsCode())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getHsCode, request.getHsCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物名称
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCargoName())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoName, request.getCargoName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提运单号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getBillNo())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getBillNo, request.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 规格类型品质
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCargoSpec())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoSpec, request.getCargoSpec());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 原产国
|
|
|
|
|
if (StrUtil.isNotBlank(request.getOriginCountry())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getOriginCountry, request.getOriginCountry());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计量单位
|
|
|
|
|
if (StrUtil.isNotBlank(request.getUnit())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getUnit, request.getUnit());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 第一计量单位
|
|
|
|
|
if (StrUtil.isNotBlank(request.getFirstUnit())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getFirstUnit, request.getFirstUnit());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单价
|
|
|
|
|
if (request.getUnitPrice() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getUnitPrice, request.getUnitPrice());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 币制
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCurrType())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCurrType, request.getCurrType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货主ID
|
|
|
|
|
if (request.getCustId() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCustId, request.getCustId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货主名称
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCustName())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCustName, request.getCustName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 业务性质
|
|
|
|
|
if (StrUtil.isNotBlank(request.getOpType())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getOpType, request.getOpType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 贸易性质
|
|
|
|
|
if (StrUtil.isNotBlank(request.getTradType())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getTradType, request.getTradType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物件数
|
|
|
|
|
if (request.getCargoNum() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoNum, request.getCargoNum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物重量
|
|
|
|
|
if (request.getCargoWt() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoWt, request.getCargoWt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物体积
|
|
|
|
|
if (request.getCargoVol() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoVol, request.getCargoVol());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物价值
|
|
|
|
|
if (request.getCargoValue() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoValue, request.getCargoValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 报关单号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCustomsNo())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCustomsNo, request.getCustomsNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 货物流向
|
|
|
|
|
if (StrUtil.isNotBlank(request.getCargoFlow())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCargoFlow, request.getCargoFlow());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 核注清单号
|
|
|
|
|
if (StrUtil.isNotBlank(request.getListNumber())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getListNumber, request.getListNumber());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 有效期至
|
|
|
|
|
if (request.getExpiryDate() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getExpiryDate, request.getExpiryDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 备注
|
|
|
|
|
if (StrUtil.isNotBlank(request.getRemark())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getRemark, request.getRemark());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 删除标志(0代表存在 2代表删除)
|
|
|
|
|
if (StrUtil.isNotBlank(request.getDelFlag())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getDelFlag, request.getDelFlag());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建部门
|
|
|
|
|
if (request.getCreateDept() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCreateDept, request.getCreateDept());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建人
|
|
|
|
|
if (request.getCreateBy() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCreateBy, request.getCreateBy());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建时间
|
|
|
|
|
if (request.getCreateTime() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getCreateTime, request.getCreateTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 修改人
|
|
|
|
|
if (request.getUpdateBy() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getUpdateBy, request.getUpdateBy());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 修改时间
|
|
|
|
|
if (request.getUpdateTime() != null) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getUpdateTime, request.getUpdateTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
if (StrUtil.isNotBlank(request.getTenantId())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getTenantId, request.getTenantId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 文件id
|
|
|
|
|
if (StrUtil.isNotBlank(request.getFileId())) {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getFileId, request.getFileId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -291,14 +295,85 @@ public class CkBillCargoController {
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
|
|
public CommonResult<CommonPage<CkBillCargo>> getList(@Validated CkBillCargo request, @Validated PageParamRequest pageParamRequest) {
|
|
|
|
|
LambdaQueryWrapper<CkBillCargo> queryWrapper = new LambdaQueryWrapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 应用搜索条件
|
|
|
|
|
condition(queryWrapper, request);
|
|
|
|
|
|
|
|
|
|
buildQueryWrapper(queryWrapper, request);
|
|
|
|
|
|
|
|
|
|
CommonPage<CkBillCargo> page = CommonPage.restPage(ckBillCargoService.pageList(queryWrapper, pageParamRequest));
|
|
|
|
|
|
|
|
|
|
// 查询所有的CkBillStock信息
|
|
|
|
|
List<CkBillStock> ckBillStockList = ckBillStockService.list();
|
|
|
|
|
|
|
|
|
|
// 构建映射,key为billCargoId,value为对应的CkBillStock
|
|
|
|
|
Map<Long, CkBillStock> ckBillStockMap = new HashMap<>();
|
|
|
|
|
for (CkBillStock ckBillStock : ckBillStockList) {
|
|
|
|
|
ckBillStockMap.put(ckBillStock.getBillCargoId(), ckBillStock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 为返回的数据添加仓库名称、货架名称和货位名称
|
|
|
|
|
for (CkBillCargo cargo : page.getList()) {
|
|
|
|
|
CkBillStock ckBillStock = ckBillStockMap.get(cargo.getId());
|
|
|
|
|
if (ckBillStock != null) {
|
|
|
|
|
cargo.setStockName(ckBillStock.getStockName());
|
|
|
|
|
cargo.setShelfName(ckBillStock.getShelfName());
|
|
|
|
|
cargo.setLocationName(ckBillStock.getLocationName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建查询条件
|
|
|
|
|
*/
|
|
|
|
|
private void buildQueryWrapper(LambdaQueryWrapper<CkBillCargo> queryWrapper, CkBillCargo request) {
|
|
|
|
|
if (request == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Validator.isNotEmpty(request.getInoutType())) {
|
|
|
|
|
if ("3".equals(request.getInoutType())) {
|
|
|
|
|
// 查询转场数据
|
|
|
|
|
queryWrapper.inSql(CkBillCargo::getBillId, "select id from ck_bill where bill_type = '3'");
|
|
|
|
|
} else if ("4".equals(request.getInoutType())) {
|
|
|
|
|
// 查询混配数据
|
|
|
|
|
queryWrapper.inSql(CkBillCargo::getBillId, "select id from ck_bill where bill_type = '4'");
|
|
|
|
|
} else {
|
|
|
|
|
queryWrapper.eq(CkBillCargo::getInoutType, request.getInoutType());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 应用基础搜索条件
|
|
|
|
|
condition(queryWrapper, request);
|
|
|
|
|
|
|
|
|
|
// 日期范围查询
|
|
|
|
|
if (request.getBeginDate() != null) {
|
|
|
|
|
queryWrapper.between(CkBillCargo::getBillDate, request.getBeginDate(), adjustEndDate(request.getEndDate()));
|
|
|
|
|
}
|
|
|
|
|
if (request.getBeginDateTwo() != null) {
|
|
|
|
|
queryWrapper.between(CkBillCargo::getExpiryDate, request.getBeginDateTwo(), adjustEndDate(request.getEndDateTwo()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 排序
|
|
|
|
|
queryWrapper.orderByDesc(CkBillCargo::getBillDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调整结束日期为当天结束时间
|
|
|
|
|
*/
|
|
|
|
|
private Date adjustEndDate(Date endDate) {
|
|
|
|
|
if (endDate != null) {
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
calendar.setTime(endDate);
|
|
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
|
|
calendar.set(Calendar.MINUTE, 59);
|
|
|
|
|
calendar.set(Calendar.SECOND, 59);
|
|
|
|
|
calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
return calendar.getTime();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 确认入库单据(列表页面确认)
|
|
|
|
|
*/
|
|
|
|
|
|