功能重构开发0130
This commit is contained in:
@@ -3,6 +3,7 @@ package com.zg.project.wisdom.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.zg.project.wisdom.domain.dto.BorrowReturnDTO;
|
||||
import com.zg.project.wisdom.domain.dto.RkBillCreateDTO;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -42,8 +43,11 @@ public class RkBillController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('wisdom:bill:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo list(@RequestBody RkBill rkBill) {
|
||||
startPage();
|
||||
|
||||
PageHelper.startPage(rkBill.getPageNum(), rkBill.getPageSize());
|
||||
|
||||
List<RkBill> list = rkBillService.selectRkBillList(rkBill);
|
||||
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,8 @@ public class RkInfoController extends BaseController
|
||||
*/
|
||||
@PostMapping("/statistic")
|
||||
public AjaxResult statistic(@RequestBody RkInfo query) {
|
||||
return AjaxResult.success(rkInfoService.getStockStatistic(query));
|
||||
StockStatisticVO stockStatistic = rkInfoService.getStockStatistic(query);
|
||||
return AjaxResult.success(stockStatistic);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@ public class RkBill extends BaseEntity {
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 当前页 */
|
||||
private Integer pageNum;
|
||||
|
||||
/** 每页条数 */
|
||||
private Integer pageSize;
|
||||
|
||||
/** 物资类型 */
|
||||
@Excel(name = "物资类型")
|
||||
private String wlType;
|
||||
@@ -46,7 +52,7 @@ public class RkBill extends BaseEntity {
|
||||
@Excel(name = "单据号")
|
||||
private String billNo;
|
||||
|
||||
/** 原字段:出入库类型 */
|
||||
/** 出入库类型 */
|
||||
@Excel(name = "出入库类型")
|
||||
private String operationType;
|
||||
|
||||
@@ -103,29 +109,14 @@ public class RkBill extends BaseEntity {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date returnTime;
|
||||
|
||||
/** 借用方项目号(借用方项目) */
|
||||
/** 借用方项目号 */
|
||||
@Excel(name = "借用方项目号")
|
||||
private String xmNoCk;
|
||||
|
||||
/** 借用方项目描述(借用方项目描述) */
|
||||
/** 借用方项目描述 */
|
||||
@Excel(name = "借用方项目描述")
|
||||
private String xmMsCk;
|
||||
|
||||
|
||||
/** 创建人 */
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新人 */
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/** 是否删除(0正常,1删除) */
|
||||
private String isDelete;
|
||||
|
||||
@@ -143,256 +134,96 @@ public class RkBill extends BaseEntity {
|
||||
|
||||
// ================= getter / setter =================
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Integer getPageNum() { return pageNum; }
|
||||
public void setPageNum(Integer pageNum) { this.pageNum = pageNum; }
|
||||
|
||||
public String getWlType() {
|
||||
return wlType;
|
||||
}
|
||||
public Integer getPageSize() { return pageSize; }
|
||||
public void setPageSize(Integer pageSize) { this.pageSize = pageSize; }
|
||||
|
||||
public void setWlType(String wlType) {
|
||||
this.wlType = wlType;
|
||||
}
|
||||
public String getWlType() { return wlType; }
|
||||
public void setWlType(String wlType) { this.wlType = wlType; }
|
||||
|
||||
public String getWlTypeName() {
|
||||
return wlTypeName;
|
||||
}
|
||||
public String getWlTypeName() { return wlTypeName; }
|
||||
public void setWlTypeName(String wlTypeName) { this.wlTypeName = wlTypeName; }
|
||||
|
||||
public void setWlTypeName(String wlTypeName) {
|
||||
this.wlTypeName = wlTypeName;
|
||||
}
|
||||
public String getCangku() { return cangku; }
|
||||
public void setCangku(String cangku) { this.cangku = cangku; }
|
||||
|
||||
public String getCangku() {
|
||||
return cangku;
|
||||
}
|
||||
public String getWarehouseName() { return warehouseName; }
|
||||
public void setWarehouseName(String warehouseName) { this.warehouseName = warehouseName; }
|
||||
|
||||
public void setCangku(String cangku) {
|
||||
this.cangku = cangku;
|
||||
}
|
||||
public String getParentWarehouseName() { return parentWarehouseName; }
|
||||
public void setParentWarehouseName(String parentWarehouseName) { this.parentWarehouseName = parentWarehouseName; }
|
||||
|
||||
public String getWarehouseName() {
|
||||
return warehouseName;
|
||||
}
|
||||
public String getBillNo() { return billNo; }
|
||||
public void setBillNo(String billNo) { this.billNo = billNo; }
|
||||
|
||||
public void setWarehouseName(String warehouseName) {
|
||||
this.warehouseName = warehouseName;
|
||||
}
|
||||
public String getOperationType() { return operationType; }
|
||||
public void setOperationType(String operationType) { this.operationType = operationType; }
|
||||
|
||||
public String getParentWarehouseName() {
|
||||
return parentWarehouseName;
|
||||
}
|
||||
public String getOperationTypeName() { return operationTypeName; }
|
||||
public void setOperationTypeName(String operationTypeName) { this.operationTypeName = operationTypeName; }
|
||||
|
||||
public void setParentWarehouseName(String parentWarehouseName) {
|
||||
this.parentWarehouseName = parentWarehouseName;
|
||||
}
|
||||
public String getBizType() { return bizType; }
|
||||
public void setBizType(String bizType) { this.bizType = bizType; }
|
||||
|
||||
public String getBillNo() {
|
||||
return billNo;
|
||||
}
|
||||
public List<String> getBizTypeList() { return bizTypeList; }
|
||||
public void setBizTypeList(List<String> bizTypeList) { this.bizTypeList = bizTypeList; }
|
||||
|
||||
public void setBillNo(String billNo) {
|
||||
this.billNo = billNo;
|
||||
}
|
||||
public Date getOperationTime() { return operationTime; }
|
||||
public void setOperationTime(Date operationTime) { this.operationTime = operationTime; }
|
||||
|
||||
public String getOperationType() {
|
||||
return operationType;
|
||||
}
|
||||
public String getExecStatus() { return execStatus; }
|
||||
public void setExecStatus(String execStatus) { this.execStatus = execStatus; }
|
||||
|
||||
public void setOperationType(String operationType) {
|
||||
this.operationType = operationType;
|
||||
}
|
||||
public Integer getOperator() { return operator; }
|
||||
public void setOperator(Integer operator) { this.operator = operator; }
|
||||
|
||||
public String getOperationTypeName() {
|
||||
return operationTypeName;
|
||||
}
|
||||
public String getOperatorName() { return operatorName; }
|
||||
public void setOperatorName(String operatorName) { this.operatorName = operatorName; }
|
||||
|
||||
public void setOperationTypeName(String operationTypeName) {
|
||||
this.operationTypeName = operationTypeName;
|
||||
}
|
||||
public String getTeamCode() { return teamCode; }
|
||||
public void setTeamCode(String teamCode) { this.teamCode = teamCode; }
|
||||
|
||||
public String getBizType() {
|
||||
return bizType;
|
||||
}
|
||||
public String getTeamName() { return teamName; }
|
||||
public void setTeamName(String teamName) { this.teamName = teamName; }
|
||||
|
||||
public void setBizType(String bizType) {
|
||||
this.bizType = bizType;
|
||||
}
|
||||
public String getIsDelivery() { return isDelivery; }
|
||||
public void setIsDelivery(String isDelivery) { this.isDelivery = isDelivery; }
|
||||
|
||||
public List<String> getBizTypeList() {
|
||||
return bizTypeList;
|
||||
}
|
||||
public Date getBorrowTime() { return borrowTime; }
|
||||
public void setBorrowTime(Date borrowTime) { this.borrowTime = borrowTime; }
|
||||
|
||||
public void setBizTypeList(List<String> bizTypeList) {
|
||||
this.bizTypeList = bizTypeList;
|
||||
}
|
||||
public Date getReturnTime() { return returnTime; }
|
||||
public void setReturnTime(Date returnTime) { this.returnTime = returnTime; }
|
||||
|
||||
public Date getOperationTime() {
|
||||
return operationTime;
|
||||
}
|
||||
public String getXmNoCk() { return xmNoCk; }
|
||||
public void setXmNoCk(String xmNoCk) { this.xmNoCk = xmNoCk; }
|
||||
|
||||
public void setOperationTime(Date operationTime) {
|
||||
this.operationTime = operationTime;
|
||||
}
|
||||
public String getXmMsCk() { return xmMsCk; }
|
||||
public void setXmMsCk(String xmMsCk) { this.xmMsCk = xmMsCk; }
|
||||
|
||||
public String getExecStatus() {
|
||||
return execStatus;
|
||||
}
|
||||
public String getIsDelete() { return isDelete; }
|
||||
public void setIsDelete(String isDelete) { this.isDelete = isDelete; }
|
||||
|
||||
public void setExecStatus(String execStatus) {
|
||||
this.execStatus = execStatus;
|
||||
}
|
||||
public Date getStartDate() { return startDate; }
|
||||
public void setStartDate(Date startDate) { this.startDate = startDate; }
|
||||
|
||||
public Integer getOperator() {
|
||||
return operator;
|
||||
}
|
||||
public Date getEndDate() { return endDate; }
|
||||
public void setEndDate(Date endDate) { this.endDate = endDate; }
|
||||
|
||||
public void setOperator(Integer operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public String getOperatorName() {
|
||||
return operatorName;
|
||||
}
|
||||
|
||||
public void setOperatorName(String operatorName) {
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
|
||||
public String getTeamCode() {
|
||||
return teamCode;
|
||||
}
|
||||
|
||||
public void setTeamCode(String teamCode) {
|
||||
this.teamCode = teamCode;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public String getIsDelivery() {
|
||||
return isDelivery;
|
||||
}
|
||||
|
||||
public void setIsDelivery(String isDelivery) {
|
||||
this.isDelivery = isDelivery;
|
||||
}
|
||||
|
||||
public Date getBorrowTime() {
|
||||
return borrowTime;
|
||||
}
|
||||
|
||||
public void setBorrowTime(Date borrowTime) {
|
||||
this.borrowTime = borrowTime;
|
||||
}
|
||||
|
||||
public Date getReturnTime() {
|
||||
return returnTime;
|
||||
}
|
||||
|
||||
public void setReturnTime(Date returnTime) {
|
||||
this.returnTime = returnTime;
|
||||
}
|
||||
|
||||
public void setXmNoCk(String xmNoCk)
|
||||
{
|
||||
this.xmNoCk = xmNoCk;
|
||||
}
|
||||
|
||||
public String getXmNoCk()
|
||||
{
|
||||
return xmNoCk;
|
||||
}
|
||||
|
||||
public void setXmMsCk(String xmMsCk)
|
||||
{
|
||||
this.xmMsCk = xmMsCk;
|
||||
}
|
||||
|
||||
public String getXmMsCk()
|
||||
{
|
||||
return xmMsCk;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
// ================= toString =================
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", id)
|
||||
.append("pageNum", pageNum)
|
||||
.append("pageSize", pageSize)
|
||||
.append("wlType", wlType)
|
||||
.append("wlTypeName", wlTypeName)
|
||||
.append("cangku", cangku)
|
||||
@@ -411,16 +242,11 @@ public class RkBill extends BaseEntity {
|
||||
.append("isDelivery", isDelivery)
|
||||
.append("borrowTime", borrowTime)
|
||||
.append("returnTime", returnTime)
|
||||
.append("xmNoCk", getXmNoCk())
|
||||
.append("xmMsCk", getXmMsCk())
|
||||
.append("createBy", createBy)
|
||||
.append("createTime", createTime)
|
||||
.append("updateBy", updateBy)
|
||||
.append("updateTime", updateTime)
|
||||
.append("isDelete", isDelete)
|
||||
.append("remark", remark)
|
||||
.append("xmNoCk", xmNoCk)
|
||||
.append("xmMsCk", xmMsCk)
|
||||
.append("startDate", startDate)
|
||||
.append("endDate", endDate)
|
||||
.append("remark", remark)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ public class RkInfo extends BaseEntity
|
||||
private Long sid;
|
||||
|
||||
/** 是否需要配送(0否,1是,2配送中,3配送完成) */
|
||||
@Excel(name = "是否需要配送", readConverterExp = "0否,1是,2配送中,3配送完成")
|
||||
private String isDelivery;
|
||||
|
||||
/** 封样编号1 */
|
||||
|
||||
@@ -146,4 +146,7 @@ public interface RkRecordMapper
|
||||
* 查询某个单据下仍为预入库状态的记录数量
|
||||
*/
|
||||
int countPreInRecordByBillNo(@Param("billNo") String billNo);
|
||||
|
||||
int countPreOutRecordByBillNo(@Param("billNo") String billNo);
|
||||
|
||||
}
|
||||
|
||||
@@ -655,23 +655,23 @@ public class RkRecordServiceImpl implements IRkRecordService
|
||||
throw new ServiceException("出库记录ID不能为空");
|
||||
}
|
||||
|
||||
// ================== 1. 查询 rk_record ==================
|
||||
/* ================== 1️⃣ 查询 rk_record ================== */
|
||||
List<RkRecord> recordList = rkRecordMapper.selectRkRecordByIds(recordIds);
|
||||
if (recordList == null || recordList.isEmpty()) {
|
||||
throw new ServiceException("出库记录不存在");
|
||||
}
|
||||
|
||||
// ================== 2. 只保留「预出库」记录 ==================
|
||||
/* ================== 2️⃣ 仅保留【预出库】记录 ================== */
|
||||
List<RkRecord> preOutList = recordList.stream()
|
||||
.filter(r -> "1".equals(r.getBizType())) // 出库
|
||||
.filter(r -> "0".equals(r.getExecStatus())) // 预出库
|
||||
.filter(r -> "1".equals(r.getBizType())) // 出库
|
||||
.filter(r -> "0".equals(r.getExecStatus())) // 预出库
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (preOutList.isEmpty()) {
|
||||
throw new ServiceException("所选出库记录均已完成出库");
|
||||
}
|
||||
|
||||
// ================== 3. 库存校验 + 扣减 ==================
|
||||
/* ================== 3️⃣ 库存校验 + 扣减 ================== */
|
||||
for (RkRecord record : preOutList) {
|
||||
|
||||
Long rkInfoId = record.getRkInfoId();
|
||||
@@ -697,24 +697,24 @@ public class RkRecordServiceImpl implements IRkRecordService
|
||||
|
||||
BigDecimal newQty = remainQty.subtract(outQty);
|
||||
|
||||
// 扣库存
|
||||
// ① 扣库存数量
|
||||
rkInfoMapper.updateRealQtyById(rkInfoId, newQty);
|
||||
|
||||
// 同步出库状态
|
||||
// ② 若扣完,同步库存出库状态
|
||||
if (newQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||
rkInfoMapper.updateIsChukuById(rkInfoId, "1");
|
||||
}
|
||||
}
|
||||
|
||||
// ================== 4. 推进状态 ==================
|
||||
/* ================== 4️⃣ 状态推进 ================== */
|
||||
|
||||
// ① rk_record.exec_status = 1
|
||||
List<Long> preOutIds = preOutList.stream()
|
||||
// ① rk_record.exec_status = 1(仅本次完成的)
|
||||
List<Long> finishedRecordIds = preOutList.stream()
|
||||
.map(RkRecord::getId)
|
||||
.collect(Collectors.toList());
|
||||
rkRecordMapper.updateExecStatusByIds(preOutIds, "1");
|
||||
rkRecordMapper.updateExecStatusByIds(finishedRecordIds, "1");
|
||||
|
||||
// ② rk_info.exec_status = 1
|
||||
// ② rk_info.exec_status = 1(涉及到的库存)
|
||||
List<Long> rkInfoIds = preOutList.stream()
|
||||
.map(RkRecord::getRkInfoId)
|
||||
.filter(Objects::nonNull)
|
||||
@@ -724,17 +724,26 @@ public class RkRecordServiceImpl implements IRkRecordService
|
||||
rkInfoMapper.updateExecStatusByIds(rkInfoIds, "1");
|
||||
}
|
||||
|
||||
// ③ rk_bill.exec_status = 1
|
||||
// 只有当【该单据下不存在任何预出库记录】才允许完成
|
||||
List<String> billNos = preOutList.stream()
|
||||
.map(RkRecord::getBillNo)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String billNo : billNos) {
|
||||
|
||||
// 判断该出库单下是否还存在预出库记录
|
||||
int preOutCount = rkRecordMapper.countPreOutRecordByBillNo(billNo);
|
||||
if (preOutCount > 0) {
|
||||
// 只要还有一条预出库,整单不能完成
|
||||
continue;
|
||||
}
|
||||
|
||||
rkBillMapper.updateExecStatusByBillNo(billNo, "1");
|
||||
}
|
||||
|
||||
return preOutIds.size();
|
||||
return finishedRecordIds.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -194,9 +194,9 @@
|
||||
resultType="com.zg.project.wisdom.domain.vo.StockStatisticVO">
|
||||
|
||||
SELECT
|
||||
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS total_amount,
|
||||
COUNT(DISTINCT ri.pcode) AS location_count,
|
||||
IFNULL(SUM(ri.real_qty), 0) AS total_quantity
|
||||
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS totalAmount,
|
||||
COUNT(DISTINCT ri.pcode) AS locationCount,
|
||||
IFNULL(SUM(ri.real_qty), 0) AS totalQuantity
|
||||
FROM rk_info ri
|
||||
<where>
|
||||
ri.exec_status = 1
|
||||
|
||||
@@ -96,9 +96,9 @@
|
||||
-- 小仓
|
||||
wh.warehouse_name AS warehouse_name,
|
||||
|
||||
-- 大仓
|
||||
pwh.warehouse_code AS parent_warehouse_code,
|
||||
pwh.warehouse_name AS parent_warehouse_name,
|
||||
-- ✅ 大仓(直接取小仓行里的父仓字段)
|
||||
wh.parent_warehouse_code AS parent_warehouse_code,
|
||||
wh.parent_warehouse_name AS parent_warehouse_name,
|
||||
|
||||
ct.team_name AS team_name
|
||||
|
||||
@@ -108,12 +108,8 @@
|
||||
LEFT JOIN stock_in_type sit ON rr.operation_type = sit.type_code
|
||||
LEFT JOIN stock_out_type sot ON rr.operation_type = sot.type_code
|
||||
|
||||
-- 小仓
|
||||
LEFT JOIN warehouse_info wh ON rr.cangku = wh.warehouse_code
|
||||
|
||||
-- 大仓
|
||||
LEFT JOIN warehouse_info pwh ON wh.parent_warehouse_code = pwh.warehouse_code
|
||||
|
||||
LEFT JOIN construction_team ct
|
||||
ON rr.team_code = ct.team_code
|
||||
AND ct.is_delete = '0'
|
||||
@@ -670,6 +666,17 @@
|
||||
AND is_delete = '0'
|
||||
</select>
|
||||
|
||||
<select id="countPreOutRecordByBillNo"
|
||||
parameterType="java.lang.String"
|
||||
resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM rk_record
|
||||
WHERE bill_no = #{billNo}
|
||||
AND biz_type = '1' <!-- 仅统计出库记录 -->
|
||||
AND exec_status = '0' <!-- 预出库 -->
|
||||
AND is_delete = '0'
|
||||
</select>
|
||||
|
||||
<update id="updateBorrowReturnRecordById">
|
||||
UPDATE rk_record
|
||||
SET
|
||||
|
||||
Reference in New Issue
Block a user