入库相关功能

This commit is contained in:
2026-01-21 19:21:07 +08:00
parent 820df3e20a
commit a1be0e4abd
20 changed files with 1051 additions and 362 deletions

View File

@@ -31,7 +31,6 @@ public class MoveRecordController extends BaseController
@Autowired @Autowired
private IMoveRecordService moveRecordService; private IMoveRecordService moveRecordService;
/** /**
* 新增移库记录 * 新增移库记录
*/ */
@@ -43,7 +42,6 @@ public class MoveRecordController extends BaseController
return AjaxResult.success("移库成功"); return AjaxResult.success("移库成功");
} }
/** /**
* 查询移库记录列表 * 查询移库记录列表
*/ */

View File

@@ -40,9 +40,8 @@ public class RkBillController extends BaseController
* 查询库存单据列表 * 查询库存单据列表
*/ */
@PreAuthorize("@ss.hasPermi('wisdom:bill:list')") @PreAuthorize("@ss.hasPermi('wisdom:bill:list')")
@GetMapping("/list") @PostMapping("/list")
public TableDataInfo list(RkBill rkBill) public TableDataInfo list(@RequestBody RkBill rkBill) {
{
startPage(); startPage();
List<RkBill> list = rkBillService.selectRkBillList(rkBill); List<RkBill> list = rkBillService.selectRkBillList(rkBill);
return getDataTable(list); return getDataTable(list);

View File

@@ -85,7 +85,7 @@ public class RkInfoController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('wisdom:stock:edit')") @PreAuthorize("@ss.hasPermi('wisdom:stock:edit')")
@Log(title = "库存单据明细", businessType = BusinessType.UPDATE) @Log(title = "库存单据明细", businessType = BusinessType.UPDATE)
@PutMapping @PostMapping("/update")
public AjaxResult edit(@RequestBody RkInfo rkInfo) public AjaxResult edit(@RequestBody RkInfo rkInfo)
{ {
return toAjax(rkInfoService.updateRkInfo(rkInfo)); return toAjax(rkInfoService.updateRkInfo(rkInfo));

View File

@@ -111,4 +111,25 @@ public class RkRecordController extends BaseController
{ {
return toAjax(rkRecordService.deleteRkRecordByIds(ids)); return toAjax(rkRecordService.deleteRkRecordByIds(ids));
} }
/**
* 撤销入库(回退为预入库)
*/
@PreAuthorize("@ss.hasPermi('wisdom:record:rollback')")
@Log(title = "入库撤销", businessType = BusinessType.UPDATE)
@PostMapping("/rollback")
public AjaxResult rollback(@RequestBody RkRecord record) {
return toAjax(rkRecordService.rollbackToPreIn(record.getIds()));
}
/**
* 一键入库(批量完成入库)
*/
@PreAuthorize("@ss.hasPermi('wisdom:record:finish')")
@Log(title = "一键入库", businessType = BusinessType.UPDATE)
@PostMapping("/finish")
public AjaxResult finish(@RequestBody RkRecord record) {
return toAjax(rkRecordService.finishIn(record.getIds()));
}
} }

View File

@@ -20,9 +20,8 @@ public class MoveRecord extends BaseEntity {
/** 主键ID */ /** 主键ID */
private Long id; private Long id;
/** 关联库存单据ID */ /** 关联库存表IDrk_info.id */
@Excel(name = "库存单据ID") private Long rkInfoId;
private Long rkId;
/** 实物ID */ /** 实物ID */
@Excel(name = "实物ID") @Excel(name = "实物ID")
@@ -59,6 +58,7 @@ public class MoveRecord extends BaseEntity {
/** 操作人 */ /** 操作人 */
private String movedBy; private String movedBy;
/** 操作人名称 */
@Excel(name = "操作人名称") @Excel(name = "操作人名称")
private String movedByName; private String movedByName;
@@ -94,76 +94,173 @@ public class MoveRecord extends BaseEntity {
@Excel(name = "供应商名称") @Excel(name = "供应商名称")
private String gysMc; private String gysMc;
// Getters and Setters // ==================== Getter / Setter ====================
public Long getId() { return id; } public Long getId() {
public void setId(Long id) { this.id = id; } return id;
}
public Long getRkId() { return rkId; } public void setId(Long id) {
public void setRkId(Long rkId) { this.rkId = rkId; } this.id = id;
}
public String getEntityId() { return entityId; } public Long getRkInfoId() {
public void setEntityId(String entityId) { this.entityId = entityId; } return rkInfoId;
}
public String getFromCangku() { return fromCangku; } public void setRkInfoId(Long rkInfoId) {
public void setFromCangku(String fromCangku) { this.fromCangku = fromCangku; } this.rkInfoId = rkInfoId;
}
public String getFromPcode() { return fromPcode; } public String getEntityId() {
public void setFromPcode(String fromPcode) { this.fromPcode = fromPcode; } return entityId;
}
public String getFromTrayCode() { return fromTrayCode; } public void setEntityId(String entityId) {
public void setFromTrayCode(String fromTrayCode) { this.fromTrayCode = fromTrayCode; } this.entityId = entityId;
}
public String getToCangku() { return toCangku; } public String getFromCangku() {
public void setToCangku(String toCangku) { this.toCangku = toCangku; } return fromCangku;
}
public String getToPcode() { return toPcode; } public void setFromCangku(String fromCangku) {
public void setToPcode(String toPcode) { this.toPcode = toPcode; } this.fromCangku = fromCangku;
}
public String getToTrayCode() { return toTrayCode; } public String getFromPcode() {
public void setToTrayCode(String toTrayCode) { this.toTrayCode = toTrayCode; } return fromPcode;
}
public String getMoveReason() { return moveReason; } public void setFromPcode(String fromPcode) {
public void setMoveReason(String moveReason) { this.moveReason = moveReason; } this.fromPcode = fromPcode;
}
public String getFromTrayCode() {
return fromTrayCode;
}
public void setFromTrayCode(String fromTrayCode) {
this.fromTrayCode = fromTrayCode;
}
public String getToCangku() {
return toCangku;
}
public void setToCangku(String toCangku) {
this.toCangku = toCangku;
}
public String getToPcode() {
return toPcode;
}
public void setToPcode(String toPcode) {
this.toPcode = toPcode;
}
public String getToTrayCode() {
return toTrayCode;
}
public void setToTrayCode(String toTrayCode) {
this.toTrayCode = toTrayCode;
}
public String getMoveReason() {
return moveReason;
}
public void setMoveReason(String moveReason) {
this.moveReason = moveReason;
}
public String getMovedBy() {
return movedBy;
}
public void setMovedBy(String movedBy) {
this.movedBy = movedBy;
}
public String getMovedBy() { return movedBy; }
public void setMovedBy(String movedBy) { this.movedBy = movedBy; }
public String getMovedByName() { public String getMovedByName() {
return movedByName; return movedByName;
} }
public void setMovedByName(String movedByName) { public void setMovedByName(String movedByName) {
this.movedByName = movedByName; this.movedByName = movedByName;
} }
public Date getMovedAt() { return movedAt; } public Date getMovedAt() {
public void setMovedAt(Date movedAt) { this.movedAt = movedAt; } return movedAt;
}
public String getIsDelete() { return isDelete; } public void setMovedAt(Date movedAt) {
public void setIsDelete(String isDelete) { this.isDelete = isDelete; } this.movedAt = movedAt;
}
public String getFromCangkuName() { return fromCangkuName; } public String getIsDelete() {
public void setFromCangkuName(String fromCangkuName) { this.fromCangkuName = fromCangkuName; } return isDelete;
}
public String getToCangkuName() { return toCangkuName; } public void setIsDelete(String isDelete) {
public void setToCangkuName(String toCangkuName) { this.toCangkuName = toCangkuName; } this.isDelete = isDelete;
}
public String getXmNo() { return xmNo; } public String getFromCangkuName() {
public void setXmNo(String xmNo) { this.xmNo = xmNo; } return fromCangkuName;
}
public String getXmMs() { return xmMs; } public void setFromCangkuName(String fromCangkuName) {
public void setXmMs(String xmMs) { this.xmMs = xmMs; } this.fromCangkuName = fromCangkuName;
}
public String getWlMs() { return wlMs; } public String getToCangkuName() {
public void setWlMs(String wlMs) { this.wlMs = wlMs; } return toCangkuName;
}
public String getGysMc() { return gysMc; } public void setToCangkuName(String toCangkuName) {
public void setGysMc(String gysMc) { this.gysMc = gysMc; } this.toCangkuName = toCangkuName;
}
public String getXmNo() {
return xmNo;
}
public void setXmNo(String xmNo) {
this.xmNo = xmNo;
}
public String getXmMs() {
return xmMs;
}
public void setXmMs(String xmMs) {
this.xmMs = xmMs;
}
public String getWlMs() {
return wlMs;
}
public void setWlMs(String wlMs) {
this.wlMs = wlMs;
}
public String getGysMc() {
return gysMc;
}
public void setGysMc(String gysMc) {
this.gysMc = gysMc;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("rkId", getRkId()) .append("rkInfoId", getRkInfoId())
.append("entityId", getEntityId()) .append("entityId", getEntityId())
.append("fromCangku", getFromCangku()) .append("fromCangku", getFromCangku())
.append("fromPcode", getFromPcode()) .append("fromPcode", getFromPcode())

View File

@@ -1,6 +1,7 @@
package com.zg.project.wisdom.domain; package com.zg.project.wisdom.domain;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -63,6 +64,9 @@ public class RkBill extends BaseEntity {
@Excel(name = "操作类型", readConverterExp = "0=入库,1=出库,2=借料出库,3=还料入库") @Excel(name = "操作类型", readConverterExp = "0=入库,1=出库,2=借料出库,3=还料入库")
private String bizType; private String bizType;
/** 业务类型列表(查询用) */
private List<String> bizTypeList;
/** 出入库时间 */ /** 出入库时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "出入库时间") @Excel(name = "出入库时间")
@@ -113,6 +117,10 @@ public class RkBill extends BaseEntity {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endDate; private Date endDate;
/** 备注 */
@Excel(name = "备注")
private String remark;
// ================= getter / setter ================= // ================= getter / setter =================
public Long getId() { public Long getId() {
@@ -195,6 +203,14 @@ public class RkBill extends BaseEntity {
this.bizType = bizType; this.bizType = bizType;
} }
public List<String> getBizTypeList() {
return bizTypeList;
}
public void setBizTypeList(List<String> bizTypeList) {
this.bizTypeList = bizTypeList;
}
public Date getOperationTime() { public Date getOperationTime() {
return operationTime; return operationTime;
} }
@@ -299,6 +315,14 @@ public class RkBill extends BaseEntity {
this.endDate = endDate; this.endDate = endDate;
} }
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
// ================= toString ================= // ================= toString =================
@Override @Override

View File

@@ -7,6 +7,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.zg.framework.aspectj.lang.annotation.Excel; import com.zg.framework.aspectj.lang.annotation.Excel;
import com.zg.framework.web.domain.BaseEntity; import com.zg.framework.web.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
/** /**
* 库存单据明细对象 rk_info * 库存单据明细对象 rk_info
@@ -22,43 +23,66 @@ public class RkInfo extends BaseEntity
private Long id; private Long id;
/** 业务操作类型0入库1出库2借料出库3还料入库 */ /** 业务操作类型0入库1出库2借料出库3还料入库 */
@Excel(name = "业务操作类型", readConverterExp = "0=入库,1=出库,2=借料出库,3=还料入库") @Excel(name = "业务类型", readConverterExp = "0=入库,1=出库,2=借料出库,3=还料入库")
private String bizType; private String bizType;
/** 出入库类型 */ /** 出入库类型 */
@Excel(name = "出入库类型") // @Excel(name = "出入库类型")
private String operationType; private String operationType;
/** 出入库类型名称(联表) */
@Excel(name = "出入库类型名称")
private String operationTypeName;
/** 执行状态0预入/预出1已完成 */ /** 执行状态0预入/预出1已完成 */
@Excel(name = "执行状态", readConverterExp = "0=预入/预出,1=已完成") @Excel(name = "执行状态", readConverterExp = "0=预入/预出,1=已完成")
private String execStatus; private String execStatus;
/** 物资类型 */ /** 物资类型 */
@Excel(name = "物资类型") // @Excel(name = "物资类型")
private String wlType; private String wlType;
/** 物资类型名称 */
@Excel(name = "物资类型名称")
private String wlTypeName;
/** 所属仓库 */ /** 所属仓库 */
@Excel(name = "所属仓库") // @Excel(name = "所属仓库")
private String cangku; private String cangku;
/** 小仓名称 */
@Excel(name = "仓库名称")
private String warehouseName;
/** 大仓编码 */
private String parentWarehouseCode;
/** 大仓名称 */
@Excel(name = "大仓名称")
private String parentWarehouseName;
/** 出入库时间 */ /** 出入库时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "出入库时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "出入库时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date operationTime; private Date operationTime;
/** 库龄(天) */ /** 库龄(天) */
@Excel(name = "库龄(天)") @Excel(name = "库龄(天)")
private Long stockAge; private Long stockAge;
/** 出入库理货员 */ /** 出入库理货员ID */
// @Excel(name = "出入库理货员")
private Integer operator; private Integer operator;
/** 出入库理货员 */
@Excel(name = "出入库理货员")
private String operatorName;
/** 是否已出库0已入库1已出库 */ /** 是否已出库0已入库1已出库 */
@Excel(name = "是否已出库", readConverterExp = "0=已入库1已出库") @Excel(name = "是否已出库", readConverterExp = "0=已入库,1=已出库")
private String isChuku; private String isChuku;
/** 0:入库待审核1已通过2已驳回3出库待审核 */ /** 审核状态(0入库待审核1已通过2已驳回3出库待审核 */
@Excel(name = "0:入库待审核1已通过2已驳回3出库待审核") @Excel(name = "审核状态", readConverterExp = "0=入库待审核,1=已通过,2=已驳回,3=出库待审核")
private String status; private String status;
/** 单据号 */ /** 单据号 */
@@ -78,11 +102,11 @@ public class RkInfo extends BaseEntity
private String xmMs; private String xmMs;
/** 出库项目号(借用方项目) */ /** 出库项目号(借用方项目) */
@Excel(name = "出库项目号", readConverterExp = "借=用方项目") @Excel(name = "出库项目号")
private String xmNoCk; private String xmNoCk;
/** 出库项目描述(借用方项目描述) */ /** 出库项目描述(借用方项目描述) */
@Excel(name = "出库项目描述", readConverterExp = "借=用方项目描述") @Excel(name = "出库项目描述")
private String xmMsCk; private String xmMsCk;
/** 物料号 */ /** 物料号 */
@@ -155,12 +179,12 @@ public class RkInfo extends BaseEntity
/** 借用时间 */ /** 借用时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "借用时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "借用时间", width = 20, dateFormat = "yyyy-MM-dd")
private Date borrowTime; private Date borrowTime;
/** 归还时间 */ /** 归还时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "归还时间", width = 20, dateFormat = "yyyy-MM-dd")
private Date returnTime; private Date returnTime;
/** 是否移库过0否 1是 */ /** 是否移库过0否 1是 */
@@ -168,45 +192,51 @@ public class RkInfo extends BaseEntity
private String hasMoved; private String hasMoved;
/** 是否借料0否,1是,2已归还 */ /** 是否借料0否,1是,2已归还 */
@Excel(name = "是否借料", readConverterExp = "0=否,1是,2已归还") @Excel(name = "是否借料", readConverterExp = "0=否,1=是,2=已归还")
private String isBorrowed; private String isBorrowed;
/** 是否删除0 表示正常1 表示已删除) */ /** 是否删除0正常1已删除 */
@Excel(name = "是否删除", readConverterExp = "0=,表=示正常1,表=示已删除") // @Excel(name = "是否删除", readConverterExp = "0=正常,1=已删除")
private String isDelete; private String isDelete;
/** 供应计划ID(对应供应计划表主键) */ /** 供应计划ID */
@Excel(name = "供应计划ID", readConverterExp = "对=应供应计划表主键") @Excel(name = "供应计划ID")
private Long gysJhId; private Long gysJhId;
/** $column.columnComment */ /** rdid */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long rdid; private Long rdid;
/** $column.columnComment */ /** rdidCk */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long rdidCk; private Long rdidCk;
/** $column.columnComment */ /** sid */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long sid; private Long sid;
/** 是否需要配送(0否,1是,2配送中,3配送完成) */ /** 是否需要配送(0否,1是,2配送中,3配送完成) */
@Excel(name = "是否需要配送(0否,1是,2配送中,3配送完成)")
private String isDelivery; private String isDelivery;
/** 封样编号1 */ /** 封样编号1 */
@Excel(name = "封样编号1")
private String fycde1; private String fycde1;
/** 封样编号2 */ /** 封样编号2 */
@Excel(name = "封样编号2")
private String fycde2; private String fycde2;
/** 1已更新 */ /** 是否已更新 */
@Excel(name = "1已更新")
private Long isUpdate; private Long isUpdate;
/** 备注 */
@Excel(name = "备注")
private String remark;
/** 查询开始时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startDate;
/** 查询结束时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endDate;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@@ -237,6 +267,14 @@ public class RkInfo extends BaseEntity
return operationType; return operationType;
} }
public String getOperationTypeName() {
return operationTypeName;
}
public void setOperationTypeName(String operationTypeName) {
this.operationTypeName = operationTypeName;
}
public String getExecStatus() { public String getExecStatus() {
return execStatus; return execStatus;
} }
@@ -256,6 +294,14 @@ public class RkInfo extends BaseEntity
return wlType; return wlType;
} }
public String getWlTypeName() {
return wlTypeName;
}
public void setWlTypeName(String wlTypeName) {
this.wlTypeName = wlTypeName;
}
public void setCangku(String cangku) public void setCangku(String cangku)
{ {
this.cangku = cangku; this.cangku = cangku;
@@ -266,6 +312,30 @@ public class RkInfo extends BaseEntity
return cangku; return cangku;
} }
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
public String getParentWarehouseCode() {
return parentWarehouseCode;
}
public void setParentWarehouseCode(String parentWarehouseCode) {
this.parentWarehouseCode = parentWarehouseCode;
}
public String getParentWarehouseName() {
return parentWarehouseName;
}
public void setParentWarehouseName(String parentWarehouseName) {
this.parentWarehouseName = parentWarehouseName;
}
public void setOperationTime(Date operationTime) public void setOperationTime(Date operationTime)
{ {
this.operationTime = operationTime; this.operationTime = operationTime;
@@ -292,6 +362,15 @@ public class RkInfo extends BaseEntity
this.operator = operator; this.operator = operator;
} }
public String getOperatorName() {
return operatorName;
}
public void setOperatorName(String operatorName) {
this.operatorName = operatorName;
}
public void setIsChuku(String isChuku) public void setIsChuku(String isChuku)
{ {
this.isChuku = isChuku; this.isChuku = isChuku;
@@ -672,18 +751,48 @@ public class RkInfo extends BaseEntity
return isUpdate; return isUpdate;
} }
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
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;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("bizType", getBizType()) .append("bizType", getBizType())
.append("operationType", getOperationType()) .append("operationType", getOperationType())
.append("operationTypeName", operationTypeName)
.append("execStatus", getExecStatus()) .append("execStatus", getExecStatus())
.append("wlType", getWlType()) .append("wlType", getWlType())
.append("wlTypeName", wlTypeName)
.append("cangku", getCangku()) .append("cangku", getCangku())
.append("warehouseName", getWarehouseName())
.append("parentWarehouseCode", getParentWarehouseCode())
.append("parentWarehouseName", getParentWarehouseName())
.append("operationTime", getOperationTime()) .append("operationTime", getOperationTime())
.append("stockAge", getStockAge()) .append("stockAge", getStockAge())
.append("operator", operator) .append("operator", operator)
.append("operatorName", operatorName)
.append("isChuku", getIsChuku()) .append("isChuku", getIsChuku())
.append("status", getStatus()) .append("status", getStatus())
.append("remark", getRemark()) .append("remark", getRemark())
@@ -727,6 +836,8 @@ public class RkInfo extends BaseEntity
.append("fycde1", getFycde1()) .append("fycde1", getFycde1())
.append("fycde2", getFycde2()) .append("fycde2", getFycde2())
.append("isUpdate", getIsUpdate()) .append("isUpdate", getIsUpdate())
.append("startDate", startDate)
.append("endDate", endDate)
.toString(); .toString();
} }
} }

View File

@@ -2,11 +2,14 @@ package com.zg.project.wisdom.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.zg.framework.aspectj.lang.annotation.Excel; import com.zg.framework.aspectj.lang.annotation.Excel;
import com.zg.framework.web.domain.BaseEntity; import com.zg.framework.web.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
/** /**
* 出入库记录对象 rk_record * 出入库记录对象 rk_record
@@ -21,10 +24,11 @@ public class RkRecord extends BaseEntity
/** 主键ID */ /** 主键ID */
private Long id; private Long id;
/** 批量操作ID集合不落库 */
private List<Long> ids;
/** 业务类型 */ /** 业务类型 */
@Excel(name = "业务类型") @Excel(name = "业务类型", readConverterExp = "0=入库,1=出库,2=借料出库,3=还料入库")
private String bizType; private String bizType;
/** 出入库类型 */ /** 出入库类型 */
// @Excel(name = "出入库类型") // @Excel(name = "出入库类型")
private String operationType; private String operationType;
@@ -33,9 +37,12 @@ public class RkRecord extends BaseEntity
@Excel(name = "出入库类型名称") @Excel(name = "出入库类型名称")
private String operationTypeName; private String operationTypeName;
/** 施工队 */
@Excel(name = "施工队")
private String teamCode;
/** 执行状态0预入/预出1已完成 */ /** 执行状态0预入/预出1已完成 */
@Excel(name = "执行状态", readConverterExp = "0=预入/预出,1=已完成") @Excel(name = "执行状态", readConverterExp = "0=预操作,1=已完成")
private String execStatus; private String execStatus;
/** 物资类型 */ /** 物资类型 */
@@ -75,7 +82,7 @@ public class RkRecord extends BaseEntity
private String operatorName; private String operatorName;
/** 是否已出库0已入库1已出库 */ /** 是否已出库0已入库1已出库 */
@Excel(name = "是否已出库", readConverterExp = "0=已入库1已出库") // @Excel(name = "是否已出库", readConverterExp = "0=已入库1已出库")
private String isChuku; private String isChuku;
/** 0:入库待审核1已通过2已驳回3出库待审核 */ /** 0:入库待审核1已通过2已驳回3出库待审核 */
@@ -174,10 +181,6 @@ public class RkRecord extends BaseEntity
@Excel(name = "实物ID") @Excel(name = "实物ID")
private String entityId; private String entityId;
/** 施工队 */
@Excel(name = "施工队")
private String teamCode;
/** 借用时间 */ /** 借用时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
// @Excel(name = "借用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") // @Excel(name = "借用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@@ -233,15 +236,19 @@ public class RkRecord extends BaseEntity
private Long isUpdate; private Long isUpdate;
/** 入库 / 出库开始时间(查询用) */ /** 入库 / 出库开始时间(查询用) */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startDate; private Date startDate;
/** 入库 / 出库结束时间(查询用) */ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endDate; private Date endDate;
/** 对应 rk_info 主键ID */ /** 对应 rk_info 主键ID */
private Long rkInfoId; private Long rkInfoId;
/** 备注 */
@Excel(name = "备注")
private String remark;
public void setId(Long id) public void setId(Long id)
{ {
@@ -253,6 +260,14 @@ public class RkRecord extends BaseEntity
return id; return id;
} }
public java.util.List<Long> getIds() {
return ids;
}
public void setIds(java.util.List<Long> ids) {
this.ids = ids;
}
public void setBizType(String bizType) { public void setBizType(String bizType) {
this.bizType = bizType; this.bizType = bizType;
} }
@@ -760,6 +775,14 @@ public class RkRecord extends BaseEntity
this.startDate = startDate; this.startDate = startDate;
} }
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Long getRkInfoId() { public Long getRkInfoId() {
return rkInfoId; return rkInfoId;
} }
@@ -767,11 +790,18 @@ public class RkRecord extends BaseEntity
public void setRkInfoId(Long rkInfoId) { public void setRkInfoId(Long rkInfoId) {
this.rkInfoId = rkInfoId; this.rkInfoId = rkInfoId;
} }
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("ids", ids)
.append("bizType", getBizType()) .append("bizType", getBizType())
.append("operationType", getOperationType()) .append("operationType", getOperationType())
.append("operationTypeName", operationTypeName) .append("operationTypeName", operationTypeName)

View File

@@ -2,6 +2,7 @@ package com.zg.project.wisdom.mapper;
import java.util.List; import java.util.List;
import com.zg.project.wisdom.domain.RkBill; import com.zg.project.wisdom.domain.RkBill;
import io.lettuce.core.dynamic.annotation.Param;
/** /**
* 库存单据Mapper接口 * 库存单据Mapper接口
@@ -65,4 +66,16 @@ public interface RkBillMapper
* @return * @return
*/ */
RkBill selectByBillNo(String billNo); RkBill selectByBillNo(String billNo);
/**
* 修改执行状态
* @param billNo
* @param execStatus
* @return
*/
void updateExecStatusByBillNo(
@Param("billNo") String billNo,
@Param("execStatus") String execStatus
);
} }

View File

@@ -2,6 +2,7 @@ package com.zg.project.wisdom.mapper;
import java.util.List; import java.util.List;
import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.domain.RkInfo;
import io.lettuce.core.dynamic.annotation.Param;
/** /**
* 库存单据明细Mapper接口 * 库存单据明细Mapper接口
@@ -58,4 +59,10 @@ public interface RkInfoMapper
* @return 结果 * @return 结果
*/ */
public int deleteRkInfoByIds(Long[] ids); public int deleteRkInfoByIds(Long[] ids);
/**
* 修改库存明细执行状态
*/
int updateExecStatusByIds(@Param("ids") List<Long> ids,
@Param("execStatus") String execStatus);
} }

View File

@@ -1,7 +1,11 @@
package com.zg.project.wisdom.mapper; package com.zg.project.wisdom.mapper;
import java.util.Date;
import java.util.List; import java.util.List;
import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.domain.RkRecord; import com.zg.project.wisdom.domain.RkRecord;
import io.lettuce.core.dynamic.annotation.Param;
/** /**
* 出入库记录Mapper接口 * 出入库记录Mapper接口
@@ -66,4 +70,29 @@ public interface RkRecordMapper
* @return 结果 * @return 结果
*/ */
public int deleteRkRecordByIds(Long[] ids); public int deleteRkRecordByIds(Long[] ids);
/**
* 修改执行状态
*
* @param ids 出入库记录主键
* @param execStatus 执行状态
* @return 结果
*/
int updateExecStatusByIds(@Param("ids") List<Long> ids,
@Param("execStatus") String execStatus);
/**
* 根据ID列表查询记录列表
*
* @param ids ID列表
* @return 记录列表
*/
List<RkRecord> selectRkRecordByIds(@Param("ids") List<Long> ids);
/**
* 根据单据ID更新记录
*
* @param rkInfo 单据信息
*/
void updateByRkInfo(RkInfo rkInfo);
} }

View File

@@ -66,4 +66,14 @@ public interface IRkRecordService
* @return 结果 * @return 结果
*/ */
public int deleteRkRecordById(Long id); public int deleteRkRecordById(Long id);
/**
* 批量将指定入库记录回退为预入库
*/
int rollbackToPreIn(List<Long> recordIds);
/**
* 批量将指定入库记录完成入库
*/
int finishIn(List<Long> ids);
} }

View File

@@ -11,11 +11,13 @@ import com.zg.common.utils.SecurityUtils;
import com.zg.project.information.domain.PcdeDetail; import com.zg.project.information.domain.PcdeDetail;
import com.zg.project.information.mapper.PcdeDetailMapper; import com.zg.project.information.mapper.PcdeDetailMapper;
import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.domain.RkRecord;
import com.zg.project.wisdom.domain.dto.MoveRequestDTO; import com.zg.project.wisdom.domain.dto.MoveRequestDTO;
import com.zg.project.wisdom.domain.dto.MoveTargetItem; import com.zg.project.wisdom.domain.dto.MoveTargetItem;
import com.zg.project.wisdom.mapper.MoveRecordMapper; import com.zg.project.wisdom.mapper.MoveRecordMapper;
import com.zg.project.wisdom.domain.MoveRecord; import com.zg.project.wisdom.domain.MoveRecord;
import com.zg.project.wisdom.mapper.RkInfoMapper; import com.zg.project.wisdom.mapper.RkInfoMapper;
import com.zg.project.wisdom.mapper.RkRecordMapper;
import com.zg.project.wisdom.service.IMoveRecordService; import com.zg.project.wisdom.service.IMoveRecordService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +39,9 @@ public class MoveRecordServiceImpl implements IMoveRecordService
@Autowired @Autowired
private RkInfoMapper rkInfoMapper; private RkInfoMapper rkInfoMapper;
@Autowired
private RkRecordMapper rkRecordMapper;
@Autowired @Autowired
private PcdeDetailMapper pcdeDetailMapper; private PcdeDetailMapper pcdeDetailMapper;
/** /**
@@ -120,7 +125,7 @@ public class MoveRecordServiceImpl implements IMoveRecordService
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void processMove(MoveRequestDTO dto) { public void processMove(MoveRequestDTO dto) {
// 0. 基本校验 // ========= 0. 基本校验 =========
if (dto == null || dto.getFromRkId() == null) { if (dto == null || dto.getFromRkId() == null) {
throw new ServiceException("原库存ID不能为空"); throw new ServiceException("原库存ID不能为空");
} }
@@ -128,128 +133,125 @@ public class MoveRecordServiceImpl implements IMoveRecordService
throw new ServiceException("目标位置列表不能为空"); throw new ServiceException("目标位置列表不能为空");
} }
// 1. 查询原库存记录 // ========= 1. 查询原库存 =========
RkInfo original = rkInfoMapper.selectRkInfoById(dto.getFromRkId()); RkInfo original = rkInfoMapper.selectRkInfoById(dto.getFromRkId());
if (original == null || "1".equals(original.getIsDelete())) { if (original == null || "1".equals(original.getIsDelete())) {
throw new ServiceException("原库存不存在或已删除"); throw new ServiceException("原库存不存在或已删除");
} }
// 2. 计算目标总数量 BigDecimal originQty = original.getRealQty();
BigDecimal totalQty = dto.getTargets().stream() if (originQty == null) {
throw new ServiceException("原库存数量为空");
}
// ========= 2. 计算移库总量 =========
BigDecimal moveTotalQty = dto.getTargets().stream()
.map(MoveTargetItem::getRealQty) .map(MoveTargetItem::getRealQty)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
// 3. 原始库存数量 if (moveTotalQty.compareTo(originQty) > 0) {
BigDecimal realQty = original.getRealQty(); throw new ServiceException("移库数量不能大于原库存数量");
if (realQty == null) {
throw new ServiceException("原库存数量为空,无法进行比较");
} }
if (totalQty.compareTo(realQty) > 0) { Long userId = SecurityUtils.getUserId();
throw new ServiceException("拆分总数量不能大于原库存数量"); String username = userId.toString();
Date now = DateUtils.getNowDate();
// ========= 3. 快照(只用于拷贝字段) =========
RkInfo snapshot = new RkInfo();
BeanUtils.copyProperties(original, snapshot);
// ========= 4. 查询原 rk_record用于同步更新 =========
RkRecord originRecord = rkRecordMapper.selectRkRecordById(original.getId());
if (originRecord == null) {
throw new ServiceException("未找到对应的出入库记录");
} }
// 4. 操作信息 // ================== 一、全量移库 ==================
String username = dto.getMovedBy(); if (dto.getTargets().size() == 1 && moveTotalQty.compareTo(originQty) == 0) {
Date now = DateUtils.parseDate(dto.getMovedAt());
// ===== 情况一:整库移库(单目标 + 数量相等)=====
if (dto.getTargets().size() == 1 && totalQty.compareTo(realQty) == 0) {
MoveTargetItem target = dto.getTargets().get(0); MoveTargetItem target = dto.getTargets().get(0);
// 移库前快照 // 1⃣ rk_info更新库位
RkInfo snapshot = new RkInfo();
BeanUtils.copyProperties(original, snapshot);
// 更新原库存位置
original.setCangku(target.getToCangku()); original.setCangku(target.getToCangku());
original.setPcode(target.getToPcode()); original.setPcode(target.getToPcode());
original.setTrayCode(target.getToTrayCode()); original.setTrayCode(target.getToTrayCode());
original.setHasMoved("1"); original.setHasMoved("1");
original.setUpdateBy(username); original.setUpdateBy(username);
original.setUpdateTime(now); original.setUpdateTime(now);
rkInfoMapper.updateRkInfo(original); rkInfoMapper.updateRkInfo(original);
// 移库记录 // 2⃣ rk_record同步更新库位
originRecord.setCangku(target.getToCangku());
originRecord.setPcode(target.getToPcode());
originRecord.setTrayCode(target.getToTrayCode());
originRecord.setHasMoved("1");
originRecord.setUpdateBy(username);
originRecord.setUpdateTime(now);
rkRecordMapper.updateRkRecord(originRecord);
// 3⃣ move_record记录移库流水绑定原 rk_info.id
moveRecordMapper.insertMoveRecord( moveRecordMapper.insertMoveRecord(
createMoveRecord(snapshot, target, dto) createMoveRecord(original, target, dto)
); );
return; return;
} }
// ===== 情况二 / 三:拆分移库 ===== // ================== 二、部分移库 ==================
List<RkInfo> insertList = new ArrayList<>();
// 来源快照(用于日志 & 新库存模板) // 1⃣ 原 rk_info 扣减数量
RkInfo fromSnapshot = new RkInfo(); original.setRealQty(originQty.subtract(moveTotalQty));
BeanUtils.copyProperties(original, fromSnapshot); original.setHasMoved("1");
original.setUpdateBy(username);
original.setUpdateTime(now);
rkInfoMapper.updateRkInfo(original);
// 情况三:部分移库(原库存减少) // 2⃣ 原 rk_record 扣减数量
if (totalQty.compareTo(realQty) < 0) { originRecord.setRealQty(
original.setRealQty(realQty.subtract(totalQty)); originRecord.getRealQty().subtract(moveTotalQty)
original.setHasMoved("1"); );
original.setUpdateBy(username); originRecord.setHasMoved("1");
original.setUpdateTime(now); originRecord.setUpdateBy(username);
rkInfoMapper.updateRkInfo(original); originRecord.setUpdateTime(now);
} else { rkRecordMapper.updateRkRecord(originRecord);
// 情况二:原库存刚好用完(但目标多个)
rkInfoMapper.deleteRkInfoById(original.getId());
}
// 新增目标库存 // 3 新增目标库存 + 新增目标记录
for (MoveTargetItem target : dto.getTargets()) { for (MoveTargetItem target : dto.getTargets()) {
// —— 新 rk_info
RkInfo newInfo = new RkInfo(); RkInfo newInfo = new RkInfo();
BeanUtils.copyProperties(snapshot, newInfo, "id");
// 以移库前快照为模板
BeanUtils.copyProperties(fromSnapshot, newInfo, "id");
newInfo.setCangku(target.getToCangku()); newInfo.setCangku(target.getToCangku());
newInfo.setPcode(target.getToPcode()); newInfo.setPcode(target.getToPcode());
newInfo.setTrayCode(target.getToTrayCode()); newInfo.setTrayCode(target.getToTrayCode());
newInfo.setRealQty(target.getRealQty()); newInfo.setRealQty(target.getRealQty());
newInfo.setHasMoved("1"); newInfo.setHasMoved("1");
newInfo.setCreateBy(username); newInfo.setCreateBy(username);
newInfo.setCreateTime(now); newInfo.setCreateTime(now);
newInfo.setUpdateBy(username); newInfo.setUpdateBy(username);
newInfo.setUpdateTime(now); newInfo.setUpdateTime(now);
rkInfoMapper.insertRkInfo(newInfo);
insertList.add(newInfo); // —— 新 rk_record
RkRecord newRecord = new RkRecord();
BeanUtils.copyProperties(originRecord, newRecord, "id");
newRecord.setCangku(target.getToCangku());
newRecord.setPcode(target.getToPcode());
newRecord.setTrayCode(target.getToTrayCode());
newRecord.setRealQty(target.getRealQty());
newRecord.setHasMoved("1");
newRecord.setCreateBy(username);
newRecord.setCreateTime(now);
newRecord.setUpdateBy(username);
newRecord.setUpdateTime(now);
rkRecordMapper.insertRkRecord(newRecord);
// 移库记录 // —— move_record绑定新生成的 rk_info.id
moveRecordMapper.insertMoveRecord( moveRecordMapper.insertMoveRecord(
createMoveRecord(fromSnapshot, target, dto) createMoveRecord(newInfo, target, dto)
); );
} }
// if (!insertList.isEmpty()) {
// rkInfoMapper.batchInsertRkInfo(insertList);
// }
}
/**
* 校验库位与仓库(小仓)关系:
* - 库位必须存在
* - 库位所属小仓 warehouse_code == 目标仓库编码 toCangku
*/
private void validatePcodeWarehouseRelation(String pcode, String warehouseCode) {
if (org.apache.commons.lang3.StringUtils.isBlank(pcode)) {
throw new ServiceException("目标库位不能为空");
}
if (org.apache.commons.lang3.StringUtils.isBlank(warehouseCode)) {
throw new ServiceException("目标仓库不能为空");
}
PcdeDetail detail = pcdeDetailMapper.selectByPcode(pcode);
if (detail == null) {
throw new ServiceException("目标库位不存在:" + pcode);
}
//
if (!warehouseCode.equals(detail.getWarehouseCode())) {
throw new ServiceException("目标库位【" + pcode + "】不属于仓库【" + warehouseCode + "】,请检查移库目标设置");
}
} }
/** /**
@@ -260,10 +262,18 @@ public class MoveRecordServiceImpl implements IMoveRecordService
* @param dto 请求参数 * @param dto 请求参数
* @return 构建后的移库记录 * @return 构建后的移库记录
*/ */
private MoveRecord createMoveRecord(RkInfo info, MoveTargetItem target, MoveRequestDTO dto) { private MoveRecord createMoveRecord(RkInfo info,
MoveTargetItem target,
MoveRequestDTO dto) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
Date now = DateUtils.getNowDate();
MoveRecord record = new MoveRecord(); MoveRecord record = new MoveRecord();
record.setRkId(info.getId());
// ★ 关键:绑定 rk_info.id
record.setRkInfoId(info.getId());
record.setEntityId(info.getEntityId()); record.setEntityId(info.getEntityId());
record.setFromCangku(info.getCangku()); record.setFromCangku(info.getCangku());
record.setFromPcode(info.getPcode()); record.setFromPcode(info.getPcode());
@@ -273,15 +283,16 @@ public class MoveRecordServiceImpl implements IMoveRecordService
record.setToTrayCode(target.getToTrayCode()); record.setToTrayCode(target.getToTrayCode());
record.setMoveReason(dto.getMoveReason()); record.setMoveReason(dto.getMoveReason());
record.setMovedBy(userId.toString()); record.setMovedBy(userId.toString());
record.setMovedAt(DateUtils.getNowDate()); record.setMovedAt(now);
record.setIsDelete("0"); record.setIsDelete("0");
record.setCreateBy(userId.toString()); record.setCreateBy(userId.toString());
record.setCreateTime(now);
record.setUpdateBy(userId.toString()); record.setUpdateBy(userId.toString());
record.setCreateTime(DateUtils.getNowDate()); record.setUpdateTime(now);
record.setUpdateTime(DateUtils.getNowDate());
return record; return record;
} }
} }

View File

@@ -8,6 +8,8 @@ import java.util.Map;
import com.zg.common.utils.DateUtils; import com.zg.common.utils.DateUtils;
import com.zg.common.utils.SecurityUtils; import com.zg.common.utils.SecurityUtils;
import com.zg.common.utils.StringUtils; import com.zg.common.utils.StringUtils;
import com.zg.project.information.domain.PcdeDetail;
import com.zg.project.information.mapper.PcdeDetailMapper;
import com.zg.project.wisdom.domain.GysJh; import com.zg.project.wisdom.domain.GysJh;
import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.domain.RkRecord; import com.zg.project.wisdom.domain.RkRecord;
@@ -47,6 +49,9 @@ public class RkBillServiceImpl implements IRkBillService
@Autowired @Autowired
private GysJhMapper gysJhMapper; private GysJhMapper gysJhMapper;
@Autowired
private PcdeDetailMapper pcdeDetailMapper;
/** /**
* 查询库存单据 * 查询库存单据
* *
@@ -102,18 +107,18 @@ public class RkBillServiceImpl implements IRkBillService
} }
bill.setBillNo(billNo); bill.setBillNo(billNo);
bill.setBizType("0"); // 入库 bill.setBizType("0"); // 入库
bill.setOperationTime(now); bill.setOperationTime(now);
bill.setCreateTime(now); bill.setCreateTime(now);
bill.setCreateBy(userId); bill.setCreateBy(userId);
bill.setIsDelete("0"); bill.setIsDelete("0");
// operator如果前端没传默认当前登录人Integer // operator默认当前登录人
if (bill.getOperator() == null) { if (bill.getOperator() == null) {
bill.setOperator(Integer.valueOf(userId)); bill.setOperator(Integer.valueOf(userId));
} }
// execStatus前端优先,默认 1 // execStatus默认已完成
if (StringUtils.isBlank(bill.getExecStatus())) { if (StringUtils.isBlank(bill.getExecStatus())) {
bill.setExecStatus("1"); bill.setExecStatus("1");
} }
@@ -123,14 +128,24 @@ public class RkBillServiceImpl implements IRkBillService
// ================== 2. 明细 + 事件 + 供应计划 ================== // ================== 2. 明细 + 事件 + 供应计划 ==================
for (RkInfo info : dto.getRkInfoList()) { for (RkInfo info : dto.getRkInfoList()) {
// ===== ① 根据 pcode 查询 pcde_detail获取 encoded_id =====
if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
if (pcde == null) {
throw new RuntimeException("库位不存在:" + info.getPcode());
}
info.setPcodeId(pcde.getEncodedId());
}
// ---------- rk_info ---------- // ---------- rk_info ----------
info.setBillNo(billNo); info.setBillNo(billNo);
info.setBizType(bill.getBizType()); info.setBizType(bill.getBizType());
info.setOperationType(bill.getOperationType()); info.setOperationType(bill.getOperationType());
info.setOperationTime(bill.getOperationTime()); info.setOperationTime(bill.getOperationTime());
info.setOperator(bill.getOperator()); // Integer info.setOperator(bill.getOperator());
info.setWlType(bill.getWlType()); info.setWlType(bill.getWlType());
info.setRemark(bill.getRemark());
info.setCangku(bill.getCangku()); info.setCangku(bill.getCangku());
info.setIsChuku("0"); info.setIsChuku("0");
@@ -147,6 +162,7 @@ public class RkBillServiceImpl implements IRkBillService
// ---------- rk_record ---------- // ---------- rk_record ----------
RkRecord record = buildInRkRecord(bill, info, now); RkRecord record = buildInRkRecord(bill, info, now);
record.setExecStatus(bill.getExecStatus()); record.setExecStatus(bill.getExecStatus());
record.setPcodeId(info.getPcodeId());
rkRecordMapper.insertRkRecord(record); rkRecordMapper.insertRkRecord(record);
@@ -194,18 +210,17 @@ public class RkBillServiceImpl implements IRkBillService
RkRecord record = new RkRecord(); RkRecord record = new RkRecord();
// ① 明细 → 事件快照 // ① 明细 → 事件快照(包含 remark
BeanUtils.copyProperties(info, record); BeanUtils.copyProperties(info, record);
record.setId(null); record.setId(null);
// ② 主单 → 事件上下文 // ② 主单 → 事件上下文(不包含 remark
record.setBillNo(bill.getBillNo()); record.setBillNo(bill.getBillNo());
record.setBizType(bill.getBizType()); record.setBizType(bill.getBizType());
record.setOperationType(bill.getOperationType()); record.setOperationType(bill.getOperationType());
record.setOperationTime(bill.getOperationTime()); record.setOperationTime(bill.getOperationTime());
record.setOperator(bill.getOperator()); // Integer record.setOperator(bill.getOperator());
record.setWlType(bill.getWlType()); record.setWlType(bill.getWlType());
record.setRemark(bill.getRemark());
record.setCangku(bill.getCangku()); record.setCangku(bill.getCangku());
// ③ 状态字段 // ③ 状态字段
@@ -241,13 +256,13 @@ public class RkBillServiceImpl implements IRkBillService
String billNo = dto.getRkBill().getBillNo(); String billNo = dto.getRkBill().getBillNo();
Date now = DateUtils.getNowDate(); Date now = DateUtils.getNowDate();
// ================== 1. 查主单(存在性校验 + 不可改字段来源) ================== // ================== 1. 查主单 ==================
RkBill bill = rkBillMapper.selectByBillNo(billNo); RkBill bill = rkBillMapper.selectByBillNo(billNo);
if (bill == null) { if (bill == null) {
throw new RuntimeException("单据不存在:" + billNo); throw new RuntimeException("单据不存在:" + billNo);
} }
// ================== 2. execStatus 以【前端传入】为准 ================== // ================== 2. execStatus 规则 ==================
String execStatus = dto.getRkBill().getExecStatus(); String execStatus = dto.getRkBill().getExecStatus();
if (StringUtils.isBlank(execStatus)) { if (StringUtils.isBlank(execStatus)) {
execStatus = bill.getExecStatus(); execStatus = bill.getExecStatus();
@@ -256,10 +271,21 @@ public class RkBillServiceImpl implements IRkBillService
// ================== 3. 追加明细 ================== // ================== 3. 追加明细 ==================
for (RkInfo info : dto.getRkInfoList()) { for (RkInfo info : dto.getRkInfoList()) {
// ===== ① 根据 pcode 查询 pcde_detail → encoded_id关键新增 =====
if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
if (pcde == null) {
throw new RuntimeException("库位不存在:" + info.getPcode());
}
info.setPcodeId(pcde.getEncodedId());
}
// ---------- 基础关联 ---------- // ---------- 基础关联 ----------
info.setBillNo(bill.getBillNo()); info.setBillNo(bill.getBillNo());
// ---------- 类型信息(不可由前端随意改 ---------- // ---------- 类型信息(来源于主单,不信前端 ----------
info.setOperationType(bill.getOperationType()); info.setOperationType(bill.getOperationType());
info.setBizType(bill.getBizType()); info.setBizType(bill.getBizType());
info.setWlType(bill.getWlType()); info.setWlType(bill.getWlType());
@@ -279,8 +305,7 @@ public class RkBillServiceImpl implements IRkBillService
info.setHasMoved("0"); info.setHasMoved("0");
info.setIsBorrowed("0"); info.setIsBorrowed("0");
// ---------- 备注(关键新增) ---------- // ---------- 备注 ----------
// 明细备注优先,其次单据备注
String finalRemark = info.getRemark(); String finalRemark = info.getRemark();
if (StringUtils.isBlank(finalRemark)) { if (StringUtils.isBlank(finalRemark)) {
finalRemark = bill.getRemark(); finalRemark = bill.getRemark();
@@ -295,24 +320,26 @@ public class RkBillServiceImpl implements IRkBillService
// ---------- 插入 rk_info ---------- // ---------- 插入 rk_info ----------
rkInfoMapper.insertRkInfo(info); rkInfoMapper.insertRkInfo(info);
// ---------- rk_record:事件流水 ---------- // ---------- rk_record ----------
RkRecord record = buildInRkRecord(bill, info, now); RkRecord record = buildInRkRecord(bill, info, now);
record.setExecStatus(execStatus); record.setExecStatus(execStatus);
record.setRkInfoId(info.getId()); record.setRkInfoId(info.getId());
// ⭐ 同步备注到事件表(非常重要) // ⭐ encoded_id 同步
record.setPcodeId(info.getPcodeId());
// ⭐ 备注同步
record.setRemark(finalRemark); record.setRemark(finalRemark);
rkRecordMapper.insertRkRecord(record); rkRecordMapper.insertRkRecord(record);
// ---------- 供应计划处理 ---------- // ---------- 供应计划 ----------
handleGysJhAfterInStock(info); handleGysJhAfterInStock(info);
} }
return 1; return 1;
} }
/** /**
* 修改库存单据 * 修改库存单据
* *

View File

@@ -2,11 +2,13 @@ package com.zg.project.wisdom.service.impl;
import java.util.List; import java.util.List;
import com.zg.common.utils.DateUtils; import com.zg.common.utils.DateUtils;
import com.zg.project.wisdom.mapper.RkRecordMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zg.project.wisdom.mapper.RkInfoMapper; import com.zg.project.wisdom.mapper.RkInfoMapper;
import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.service.IRkInfoService; import com.zg.project.wisdom.service.IRkInfoService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 库存单据明细Service业务层处理 * 库存单据明细Service业务层处理
@@ -20,6 +22,9 @@ public class RkInfoServiceImpl implements IRkInfoService
@Autowired @Autowired
private RkInfoMapper rkInfoMapper; private RkInfoMapper rkInfoMapper;
@Autowired
private RkRecordMapper rkRecordMapper;
/** /**
* 查询库存单据明细 * 查询库存单据明细
* *
@@ -64,12 +69,19 @@ public class RkInfoServiceImpl implements IRkInfoService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public int updateRkInfo(RkInfo rkInfo) public int updateRkInfo(RkInfo rkInfo)
{ {
rkInfo.setUpdateTime(DateUtils.getNowDate()); rkInfo.setUpdateTime(DateUtils.getNowDate());
return rkInfoMapper.updateRkInfo(rkInfo);
}
// ① 更新 rk_info
int rows = rkInfoMapper.updateRkInfo(rkInfo);
// ② 同步更新 rk_record按 rk_info_id
rkRecordMapper.updateByRkInfo(rkInfo);
return rows;
}
/** /**
* 批量删除库存单据明细 * 批量删除库存单据明细
* *

View File

@@ -1,12 +1,22 @@
package com.zg.project.wisdom.service.impl; package com.zg.project.wisdom.service.impl;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.zg.common.exception.ServiceException;
import com.zg.common.utils.DateUtils; import com.zg.common.utils.DateUtils;
import com.zg.common.utils.StringUtils;
import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.mapper.RkBillMapper;
import com.zg.project.wisdom.mapper.RkInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zg.project.wisdom.mapper.RkRecordMapper; import com.zg.project.wisdom.mapper.RkRecordMapper;
import com.zg.project.wisdom.domain.RkRecord; import com.zg.project.wisdom.domain.RkRecord;
import com.zg.project.wisdom.service.IRkRecordService; import com.zg.project.wisdom.service.IRkRecordService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 出入库记录Service业务层处理 * 出入库记录Service业务层处理
@@ -20,6 +30,12 @@ public class RkRecordServiceImpl implements IRkRecordService
@Autowired @Autowired
private RkRecordMapper rkRecordMapper; private RkRecordMapper rkRecordMapper;
@Autowired
private RkInfoMapper rkInfoMapper;
@Autowired
private RkBillMapper rkBillMapper;
/** /**
* 查询出入库记录 * 查询出入库记录
* *
@@ -70,12 +86,39 @@ public class RkRecordServiceImpl implements IRkRecordService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public int updateRkRecord(RkRecord rkRecord) public int updateRkRecord(RkRecord rkRecord)
{ {
// 1. 更新时间
rkRecord.setUpdateTime(DateUtils.getNowDate()); rkRecord.setUpdateTime(DateUtils.getNowDate());
return rkRecordMapper.updateRkRecord(rkRecord);
}
// 2. 更新 rk_record
int rows = rkRecordMapper.updateRkRecord(rkRecord);
if (rows <= 0) {
throw new RuntimeException("更新出入库记录失败");
}
// 3. 同步更新 rk_info
Long rkInfoId = rkRecord.getRkInfoId();
if (rkInfoId == null) {
throw new RuntimeException("rkInfoId 为空,无法同步更新库存表");
}
// 4. 将 record 中的字段映射到 info
RkInfo rkInfo = new RkInfo();
BeanUtils.copyProperties(rkRecord, rkInfo);
// ⚠️ 关键:主键必须用 rk_info.id
rkInfo.setId(rkInfoId);
rkInfo.setUpdateTime(DateUtils.getNowDate());
int infoRows = rkInfoMapper.updateRkInfo(rkInfo);
if (infoRows <= 0) {
throw new RuntimeException("同步更新库存表失败");
}
return rows;
}
/** /**
* 批量删除出入库记录 * 批量删除出入库记录
* *
@@ -99,4 +142,106 @@ public class RkRecordServiceImpl implements IRkRecordService
{ {
return rkRecordMapper.deleteRkRecordById(id); return rkRecordMapper.deleteRkRecordById(id);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public int rollbackToPreIn(List<Long> recordIds) {
if (recordIds == null || recordIds.isEmpty()) {
throw new ServiceException("撤销记录ID不能为空");
}
// 1⃣ 查 records
List<RkRecord> recordList = rkRecordMapper.selectRkRecordByIds(recordIds);
if (recordList == null || recordList.isEmpty()) {
throw new ServiceException("入库记录不存在");
}
// 2⃣ rk_record 批量回退 exec_status = 0
rkRecordMapper.updateExecStatusByIds(recordIds, "0");
// 3⃣ rk_info 批量回退 exec_status = 0
List<Long> rkInfoIds = recordList.stream()
.map(RkRecord::getRkInfoId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (!rkInfoIds.isEmpty()) {
rkInfoMapper.updateExecStatusByIds(rkInfoIds, "0");
}
// 4⃣ rk_bill保持原 Mapper 方法不变,按 billNo 去重后循环调用
List<String> billNos = recordList.stream()
.map(RkRecord::getBillNo)
.filter(StringUtils::isNotBlank)
.distinct()
.collect(Collectors.toList());
for (String billNo : billNos) {
rkBillMapper.updateExecStatusByBillNo(billNo, "0");
}
return recordIds.size();
}
@Override
@Transactional(rollbackFor = Exception.class)
public int finishIn(List<Long> recordIds) {
if (recordIds == null || recordIds.isEmpty()) {
throw new ServiceException("入库记录ID不能为空");
}
// 1⃣ 查询 rk_record
List<RkRecord> recordList =
rkRecordMapper.selectRkRecordByIds(recordIds);
if (recordList == null || recordList.isEmpty()) {
throw new ServiceException("入库记录不存在");
}
// ================== ① 只保留「预入库」记录 ==================
List<RkRecord> preRecordList = recordList.stream()
.filter(r -> "0".equals(r.getExecStatus()))
.collect(Collectors.toList());
// ================== ② 如果没有可完成的数据,才报错 ==================
if (preRecordList.isEmpty()) {
throw new ServiceException("所选入库记录均已完成,无需重复入库");
}
// ================== ③ 后续逻辑全部基于 preRecordList ==================
List<Long> preRecordIds = preRecordList.stream()
.map(RkRecord::getId)
.collect(Collectors.toList());
// 2⃣ rk_record.exec_status = 1
rkRecordMapper.updateExecStatusByIds(preRecordIds, "1");
// 3⃣ rk_info.exec_status = 1
List<Long> rkInfoIds = preRecordList.stream()
.map(RkRecord::getRkInfoId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (!rkInfoIds.isEmpty()) {
rkInfoMapper.updateExecStatusByIds(rkInfoIds, "1");
}
// 4⃣ rk_bill.exec_status = 1
List<String> billNos = preRecordList.stream()
.map(RkRecord::getBillNo)
.filter(StringUtils::isNotBlank)
.distinct()
.collect(Collectors.toList());
for (String billNo : billNos) {
rkBillMapper.updateExecStatusByBillNo(billNo, "1");
}
return preRecordIds.size();
}
} }

View File

@@ -5,10 +5,13 @@
<mapper namespace="com.zg.project.wisdom.mapper.MoveRecordMapper"> <mapper namespace="com.zg.project.wisdom.mapper.MoveRecordMapper">
<!-- 实体字段映射 --> <!-- ===================== resultMap ===================== -->
<resultMap type="com.zg.project.wisdom.domain.MoveRecord" id="MoveRecordResult"> <resultMap type="com.zg.project.wisdom.domain.MoveRecord" id="MoveRecordResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="rkId" column="rk_id"/>
<!-- 关键字段rk_info_id -->
<result property="rkInfoId" column="rk_info_id"/>
<result property="entityId" column="entity_id"/> <result property="entityId" column="entity_id"/>
<result property="fromCangku" column="from_cangku"/> <result property="fromCangku" column="from_cangku"/>
<result property="fromPcode" column="from_pcode"/> <result property="fromPcode" column="from_pcode"/>
@@ -25,25 +28,46 @@
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="isDelete" column="is_delete"/> <result property="isDelete" column="is_delete"/>
<!-- 扩展展示字段 -->
<result property="fromCangkuName" column="from_cangku_name"/> <result property="fromCangkuName" column="from_cangku_name"/>
<result property="toCangkuName" column="to_cangku_name"/> <result property="toCangkuName" column="to_cangku_name"/>
<result property="xmNo" column="xm_no"/> <result property="xmNo" column="xm_no"/>
<result property="xmMs" column="xm_ms"/> <result property="xmMs" column="xm_ms"/>
<result property="wlMs" column="wl_ms"/> <result property="wlMs" column="wl_ms"/>
<result property="gysMc" column="gys_mc"/> <result property="gysMc" column="gys_mc"/>
</resultMap> </resultMap>
<!-- ===================== 基础查询字段 ===================== -->
<sql id="selectMoveRecordVo"> <sql id="selectMoveRecordVo">
SELECT id, rk_id, entity_id, from_cangku, from_pcode, from_tray_code, SELECT
to_cangku, to_pcode, to_tray_code, move_reason, moved_by, moved_at, id,
create_by, create_time, update_by, update_time, is_delete rk_info_id,
entity_id,
from_cangku,
from_pcode,
from_tray_code,
to_cangku,
to_pcode,
to_tray_code,
move_reason,
moved_by,
moved_at,
create_by,
create_time,
update_by,
update_time,
is_delete
FROM move_record FROM move_record
</sql> </sql>
<insert id="insertMoveRecord" parameterType="com.zg.project.wisdom.domain.MoveRecord" useGeneratedKeys="true" keyProperty="id"> <!-- ===================== 新增 ===================== -->
<insert id="insertMoveRecord"
parameterType="com.zg.project.wisdom.domain.MoveRecord"
useGeneratedKeys="true"
keyProperty="id">
INSERT INTO move_record ( INSERT INTO move_record (
rk_id, rk_info_id,
entity_id, entity_id,
from_cangku, from_cangku,
from_pcode, from_pcode,
@@ -60,7 +84,7 @@
update_time, update_time,
is_delete is_delete
) VALUES ( ) VALUES (
#{rkId}, #{rkInfoId},
#{entityId}, #{entityId},
#{fromCangku}, #{fromCangku},
#{fromPcode}, #{fromPcode},
@@ -79,20 +103,20 @@
) )
</insert> </insert>
<!-- 分页列表 --> <!-- ===================== 分页列表 ===================== -->
<select id="selectMoveRecordList" resultMap="MoveRecordResult"> <select id="selectMoveRecordList" resultMap="MoveRecordResult">
SELECT SELECT
mr.*, mr.*,
su.user_name AS moved_by_name, su.user_name AS moved_by_name,
rk.xm_no, ri.xm_no,
rk.xm_ms, ri.xm_ms,
rk.wl_ms, ri.wl_ms,
rk.gys_mc, ri.gys_mc,
wi1.warehouse_name AS from_cangku_name, wi1.warehouse_name AS from_cangku_name,
wi2.warehouse_name AS to_cangku_name wi2.warehouse_name AS to_cangku_name
FROM move_record mr FROM move_record mr
LEFT JOIN sys_user su ON mr.moved_by = su.user_id LEFT JOIN sys_user su ON mr.moved_by = su.user_id
LEFT JOIN rk_info rk ON mr.rk_id = rk.id LEFT JOIN rk_info ri ON mr.rk_info_id = ri.id
LEFT JOIN warehouse_info wi1 ON mr.from_cangku = wi1.warehouse_code LEFT JOIN warehouse_info wi1 ON mr.from_cangku = wi1.warehouse_code
LEFT JOIN warehouse_info wi2 ON mr.to_cangku = wi2.warehouse_code LEFT JOIN warehouse_info wi2 ON mr.to_cangku = wi2.warehouse_code
<where> <where>
@@ -106,7 +130,7 @@
AND mr.from_cangku = #{fromCangku} AND mr.from_cangku = #{fromCangku}
</if> </if>
<if test="xmNo != null and xmNo != ''"> <if test="xmNo != null and xmNo != ''">
AND rk.xm_no = #{xmNo} AND ri.xm_no = #{xmNo}
</if> </if>
<if test="moveReason != null and moveReason != ''"> <if test="moveReason != null and moveReason != ''">
AND mr.move_reason LIKE concat('%', #{moveReason}, '%') AND mr.move_reason LIKE concat('%', #{moveReason}, '%')
@@ -115,17 +139,20 @@
ORDER BY mr.create_time DESC ORDER BY mr.create_time DESC
</select> </select>
<!-- 查询详情 --> <!-- ===================== 查询详情 ===================== -->
<select id="selectMoveRecordById" parameterType="Long" resultMap="MoveRecordResult"> <select id="selectMoveRecordById"
parameterType="Long"
resultMap="MoveRecordResult">
<include refid="selectMoveRecordVo"/> <include refid="selectMoveRecordVo"/>
WHERE id = #{id} WHERE id = #{id}
</select> </select>
<!-- 修改 --> <!-- ===================== 修改 ===================== -->
<update id="updateMoveRecord" parameterType="MoveRecord"> <update id="updateMoveRecord"
parameterType="com.zg.project.wisdom.domain.MoveRecord">
UPDATE move_record UPDATE move_record
<set> <set>
<if test="rkId != null">rk_id = #{rkId},</if> <if test="rkInfoId != null">rk_info_id = #{rkInfoId},</if>
<if test="entityId != null">entity_id = #{entityId},</if> <if test="entityId != null">entity_id = #{entityId},</if>
<if test="fromCangku != null">from_cangku = #{fromCangku},</if> <if test="fromCangku != null">from_cangku = #{fromCangku},</if>
<if test="fromPcode != null">from_pcode = #{fromPcode},</if> <if test="fromPcode != null">from_pcode = #{fromPcode},</if>
@@ -143,12 +170,11 @@
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<!-- 删除单个 --> <!-- ===================== 删除 ===================== -->
<delete id="deleteMoveRecordById" parameterType="Long"> <delete id="deleteMoveRecordById" parameterType="Long">
DELETE FROM move_record WHERE id = #{id} DELETE FROM move_record WHERE id = #{id}
</delete> </delete>
<!-- 批量删除 -->
<delete id="deleteMoveRecordByIds" parameterType="Long"> <delete id="deleteMoveRecordByIds" parameterType="Long">
DELETE FROM move_record DELETE FROM move_record
WHERE id IN WHERE id IN

View File

@@ -6,30 +6,30 @@
<!-- ==================== ResultMap ==================== --> <!-- ==================== ResultMap ==================== -->
<resultMap type="RkBill" id="RkBillResult"> <resultMap type="RkBill" id="RkBillResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="wlType" column="wl_type"/> <result property="wlType" column="wl_type"/>
<result property="wlTypeName" column="wl_type_name"/> <result property="wlTypeName" column="wl_type_name"/>
<result property="cangku" column="cangku"/> <result property="cangku" column="cangku"/>
<result property="warehouseName" column="warehouse_name"/> <result property="warehouseName" column="warehouse_name"/>
<result property="parentWarehouseName" column="parent_warehouse_name"/> <result property="parentWarehouseName" column="parent_warehouse_name"/>
<result property="billNo" column="bill_no"/> <result property="billNo" column="bill_no"/>
<result property="operationType" column="operation_type"/> <result property="operationType" column="operation_type"/>
<result property="operationTypeName" column="operation_type_name"/> <result property="operationTypeName" column="operation_type_name"/>
<result property="bizType" column="biz_type"/> <result property="bizType" column="biz_type"/>
<result property="operationTime" column="operation_time"/> <result property="operationTime" column="operation_time"/>
<result property="execStatus" column="exec_status"/> <result property="execStatus" column="exec_status"/>
<result property="operator" column="operator"/> <result property="operator" column="operator"/>
<result property="operatorName" column="operator_name"/> <result property="operatorName" column="operator_name"/>
<result property="teamCode" column="team_code"/> <result property="teamCode" column="team_code"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
<result property="isDelivery" column="is_delivery"/> <result property="isDelivery" column="is_delivery"/>
<result property="isDelete" column="is_delete"/> <result property="isDelete" column="is_delete"/>
</resultMap> </resultMap>
<!-- ==================== Base Select ==================== --> <!-- ==================== Base Select ==================== -->
@@ -49,44 +49,25 @@
rb.is_delivery, rb.is_delivery,
rb.is_delete, rb.is_delete,
-- 物资类型
mt.type_name AS wl_type_name, mt.type_name AS wl_type_name,
-- 出 / 入库类型名称
COALESCE(sit.type_name, sot.type_name) AS operation_type_name, COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
-- 操作人
su.nick_name AS operator_name, su.nick_name AS operator_name,
-- 小仓
wh.warehouse_name AS warehouse_name, wh.warehouse_name AS warehouse_name,
-- 大仓(冗余字段)
wh.parent_warehouse_name AS parent_warehouse_name wh.parent_warehouse_name AS parent_warehouse_name
FROM rk_bill rb FROM rk_bill rb
-- 仓库(小仓)
LEFT JOIN warehouse_info wh LEFT JOIN warehouse_info wh
ON rb.cangku = wh.warehouse_code ON rb.cangku = wh.warehouse_code
AND wh.status = 1 AND wh.status = 1
-- 物资类型
LEFT JOIN material_type mt LEFT JOIN material_type mt
ON rb.wl_type = mt.type_code ON rb.wl_type = mt.type_code
AND mt.status = 1 AND mt.status = 1
-- 入库类型
LEFT JOIN stock_in_type sit LEFT JOIN stock_in_type sit
ON rb.operation_type = sit.type_code ON rb.operation_type = sit.type_code
AND sit.status = 1 AND sit.status = 1
-- 出库类型
LEFT JOIN stock_out_type sot LEFT JOIN stock_out_type sot
ON rb.operation_type = sot.type_code ON rb.operation_type = sot.type_code
AND (sot.is_delete = '0' OR sot.is_delete IS NULL) AND (sot.is_delete = '0' OR sot.is_delete IS NULL)
-- 操作人
LEFT JOIN sys_user su LEFT JOIN sys_user su
ON rb.operator = su.user_id ON rb.operator = su.user_id
</sql> </sql>
@@ -95,24 +76,67 @@
<select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult"> <select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult">
<include refid="selectRkBillVo"/> <include refid="selectRkBillVo"/>
<where> <where>
<if test="wlType != null">AND rb.wl_type = #{wlType}</if>
<if test="cangku != null and cangku != ''">AND rb.cangku = #{cangku}</if> <if test="wlType != null and wlType != ''">
<if test="billNo != null and billNo != ''">AND rb.bill_no = #{billNo}</if> AND rb.wl_type = #{wlType}
<if test="operationType != null">AND rb.operation_type = #{operationType}</if> </if>
<if test="bizType != null">AND rb.biz_type = #{bizType}</if>
<if test="operationTime != null">AND rb.operation_time = #{operationTime}</if> <if test="cangku != null and cangku != ''">
<!-- 时间区间(新增) --> AND rb.cangku = #{cangku}
</if>
<if test="billNo != null and billNo != ''">
AND rb.bill_no = #{billNo}
</if>
<if test="operationType != null and operationType != ''">
AND rb.operation_type = #{operationType}
</if>
<!-- 多 bizType -->
<if test="bizTypeList != null and bizTypeList.size > 0">
AND rb.biz_type IN
<foreach collection="bizTypeList"
item="bt"
open="("
separator=","
close=")">
#{bt}
</foreach>
</if>
<if test="operationTime != null">
AND rb.operation_time = #{operationTime}
</if>
<if test="startDate != null"> <if test="startDate != null">
AND rb.operation_time &gt;= #{startDate} AND rb.operation_time &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
AND rb.operation_time &lt;= #{endDate} AND rb.operation_time &lt;= #{endDate}
</if> </if>
<if test="execStatus != null">AND rb.exec_status = #{execStatus}</if>
<if test="operator != null">AND rb.operator = #{operator}</if> <if test="execStatus != null and execStatus != ''">
<if test="teamCode != null and teamCode != ''">AND rb.team_code = #{teamCode}</if> AND rb.exec_status = #{execStatus}
<if test="isDelivery != null">AND rb.is_delivery = #{isDelivery}</if> </if>
<if test="isDelete != null">AND rb.is_delete = #{isDelete}</if>
<if test="operator != null">
AND rb.operator = #{operator}
</if>
<if test="teamCode != null and teamCode != ''">
AND rb.team_code = #{teamCode}
</if>
<if test="isDelivery != null and isDelivery != ''">
AND rb.is_delivery = #{isDelivery}
</if>
<if test="isDelete != null and isDelete != ''">
AND rb.is_delete = #{isDelete}
</if>
</where> </where>
ORDER BY rb.exec_status ASC, rb.operation_time DESC ORDER BY rb.exec_status ASC, rb.operation_time DESC
</select> </select>
@@ -150,7 +174,6 @@
LIMIT 1 LIMIT 1
</select> </select>
<!-- ==================== Insert ==================== --> <!-- ==================== Insert ==================== -->
<insert id="insertRkBill" <insert id="insertRkBill"
parameterType="com.zg.project.wisdom.domain.RkBill" parameterType="com.zg.project.wisdom.domain.RkBill"
@@ -191,22 +214,28 @@
<update id="updateRkBill" parameterType="RkBill"> <update id="updateRkBill" parameterType="RkBill">
UPDATE rk_bill UPDATE rk_bill
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="wlType != null">wl_type = #{wlType},</if> <if test="wlType != null and wlType != ''">wl_type = #{wlType},</if>
<if test="cangku != null">cangku = #{cangku},</if> <if test="cangku != null and cangku != ''">cangku = #{cangku},</if>
<if test="billNo != null and billNo != ''">bill_no = #{billNo},</if> <if test="billNo != null and billNo != ''">bill_no = #{billNo},</if>
<if test="operationType != null">operation_type = #{operationType},</if> <if test="operationType != null and operationType != ''">operation_type = #{operationType},</if>
<if test="bizType != null">biz_type = #{bizType},</if> <if test="bizType != null and bizType != ''">biz_type = #{bizType},</if>
<if test="operationTime != null">operation_time = #{operationTime},</if> <if test="operationTime != null">operation_time = #{operationTime},</if>
<if test="execStatus != null">exec_status = #{execStatus},</if> <if test="execStatus != null and execStatus != ''">exec_status = #{execStatus},</if>
<if test="operator != null">operator = #{operator},</if> <if test="operator != null">operator = #{operator},</if>
<if test="teamCode != null">team_code = #{teamCode},</if> <if test="teamCode != null and teamCode != ''">team_code = #{teamCode},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="isDelivery != null">is_delivery = #{isDelivery},</if> <if test="isDelivery != null and isDelivery != ''">is_delivery = #{isDelivery},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null and isDelete != ''">is_delete = #{isDelete},</if>
</trim> </trim>
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<update id="updateExecStatusByBillNo">
UPDATE rk_bill
SET exec_status = #{execStatus}
WHERE bill_no = #{billNo}
</update>
<!-- ==================== Delete ==================== --> <!-- ==================== Delete ==================== -->
<delete id="deleteRkBillById" parameterType="Long"> <delete id="deleteRkBillById" parameterType="Long">
DELETE FROM rk_bill WHERE id = #{id} DELETE FROM rk_bill WHERE id = #{id}

View File

@@ -2,17 +2,25 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zg.project.wisdom.mapper.RkInfoMapper"> <mapper namespace="com.zg.project.wisdom.mapper.RkInfoMapper">
<!-- ========================= resultMap ========================= --> <!-- ========================= resultMap ========================= -->
<resultMap type="RkInfo" id="RkInfoResult"> <resultMap type="RkInfo" id="RkInfoResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="operationType" column="operation_type"/> <result property="operationType" column="operation_type"/>
<result property="operationTypeName" column="operation_type_name"/>
<result property="bizType" column="biz_type"/> <result property="bizType" column="biz_type"/>
<result property="wlType" column="wl_type"/> <result property="wlType" column="wl_type"/>
<result property="wlTypeName" column="wl_type_name"/>
<result property="cangku" column="cangku"/> <result property="cangku" column="cangku"/>
<result property="warehouseName" column="warehouse_name"/>
<result property="parentWarehouseCode" column="parent_warehouse_code"/>
<result property="parentWarehouseName" column="parent_warehouse_name"/>
<result property="operationTime" column="operation_time"/> <result property="operationTime" column="operation_time"/>
<result property="stockAge" column="stock_age"/>
<result property="operator" column="operator"/> <result property="operator" column="operator"/>
<result property="operatorName" column="operator_name"/>
<result property="isChuku" column="is_chuku"/> <result property="isChuku" column="is_chuku"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="execStatus" column="exec_status"/> <result property="execStatus" column="exec_status"/>
@@ -59,116 +67,114 @@
<result property="isUpdate" column="is_update"/> <result property="isUpdate" column="is_update"/>
</resultMap> </resultMap>
<!-- ========================= 公共查询字段 ========================= --> <!-- ========================= 公共查询 SQL联表完整版 ========================= -->
<sql id="selectRkInfoVo"> <sql id="selectRkInfoVo">
select SELECT
id, ri.*,
operation_type,
biz_type, /* 出入库类型名称 */
wl_type, COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
cangku,
operation_time, /* 物资类型名称 */
operator, mt.type_name AS wl_type_name,
is_chuku,
status, /* 仓库信息 */
exec_status, wh.warehouse_name,
remark, wh.parent_warehouse_code,
bill_no, wh.parent_warehouse_name,
xj,
xm_no, /* 理货员 */
xm_ms, su.nick_name AS operator_name,
xm_no_ck,
xm_ms_ck, /* 库龄 */
wl_no, DATEDIFF(CURRENT_DATE, ri.operation_time) AS stock_age
wl_ms,
gys_no, FROM rk_info ri
gys_mc,
jh_amt, LEFT JOIN stock_in_type sit ON ri.operation_type = sit.type_code
ht_dj, LEFT JOIN stock_out_type sot ON ri.operation_type = sot.type_code
sap_no, LEFT JOIN material_type mt ON ri.wl_type = mt.type_code
xh, LEFT JOIN warehouse_info wh ON ri.cangku = wh.warehouse_code
jh_qty, LEFT JOIN sys_user su ON ri.operator = su.user_id
ht_qty,
dw,
real_qty,
pcode,
pcode_id,
tray_code,
entity_id,
team_code,
borrow_time,
return_time,
has_moved,
is_borrowed,
create_by,
create_time,
update_by,
update_time,
is_delete,
gys_jh_id,
rdid,
rdid_ck,
sid,
is_delivery,
fycde_1,
fycde_2,
is_update,
/* 新增库龄计算 */
DATEDIFF(CURRENT_DATE, operation_time) AS stock_age -- 库龄(天)
from rk_info
</sql> </sql>
<!-- ========================= 删除 ========================= --> <!-- ========================= 查询列表 ========================= -->
<delete id="deleteRkInfoById" parameterType="Long">
delete from rk_info where id = #{id}
</delete>
<delete id="deleteRkInfoByIds" parameterType="java.util.List">
delete from rk_info
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 查询列表:根据库龄进行过滤 -->
<select id="selectRkInfoList" parameterType="RkInfo" resultMap="RkInfoResult"> <select id="selectRkInfoList" parameterType="RkInfo" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/> <include refid="selectRkInfoVo"/>
<where> <where>
ri.exec_status = 1
<if test="operationType != null and operationType != ''"> <if test="operationType != null and operationType != ''">
and operation_type = #{operationType} AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%')
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
<if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
<if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
<if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
<if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
<if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
</if> </if>
<if test="bizType != null and bizType != ''"> <if test="bizType != null and bizType != ''">
and biz_type = #{bizType} AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
</if> </if>
<if test="wlType != null and wlType != ''"> <if test="wlType != null and wlType != ''">
and wl_type = #{wlType} AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
</if> </if>
<if test="cangku != null and cangku != ''"> <if test="cangku != null and cangku != ''">
and cangku = #{cangku} AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
</if>
<if test="execStatus != null and execStatus != ''">
and exec_status = #{execStatus}
</if> </if>
<if test="billNo != null and billNo != ''"> <if test="billNo != null and billNo != ''">
and bill_no = #{billNo} AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if> </if>
<if test="isDelete != null and isDelete != ''"> <if test="isDelete != null and isDelete != ''">
and is_delete = #{isDelete} AND ri.is_delete = #{isDelete}
</if>
<!-- 出入库时间范围 -->
<if test="startDate != null">
AND ri.operation_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND ri.operation_time &lt;= #{endDate}
</if> </if>
</where> </where>
ORDER BY ri.operation_time DESC
</select> </select>
<!-- ========================= 按 ID 查询 ========================= --> <!-- ========================= 按 ID 查询 ========================= -->
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult"> <select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/> <include refid="selectRkInfoVo"/>
where id = #{id} WHERE ri.id = #{id}
</select> </select>
<!-- ========================= 删除 ========================= -->
<delete id="deleteRkInfoById" parameterType="Long">
DELETE FROM rk_info WHERE id = #{id}
</delete>
<!-- 插入 rk_info --> <delete id="deleteRkInfoByIds" parameterType="java.util.List">
DELETE FROM rk_info
WHERE id IN
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- ========================= 插入 ========================= -->
<insert id="insertRkInfo" parameterType="RkInfo" useGeneratedKeys="true" keyProperty="id"> <insert id="insertRkInfo" parameterType="RkInfo" useGeneratedKeys="true" keyProperty="id">
insert into rk_info ( INSERT INTO rk_info (
operation_type, biz_type, wl_type, cangku, operation_time, operator, operation_type, biz_type, wl_type, cangku, operation_time, operator,
is_chuku, status, exec_status, remark, bill_no, is_chuku, status, exec_status, remark, bill_no,
xj, xm_no, xm_ms, xm_no_ck, xm_ms_ck, xj, xm_no, xm_ms, xm_no_ck, xm_ms_ck,
@@ -186,7 +192,7 @@
is_update, is_update,
create_by, create_time, is_delete create_by, create_time, is_delete
) )
values ( VALUES (
#{operationType}, #{bizType}, #{wlType}, #{cangku}, #{operationTime}, #{operator}, #{operationType}, #{bizType}, #{wlType}, #{cangku}, #{operationTime}, #{operator},
#{isChuku}, #{status}, #{execStatus}, #{remark}, #{billNo}, #{isChuku}, #{status}, #{execStatus}, #{remark}, #{billNo},
#{xj}, #{xmNo}, #{xmMs}, #{xmNoCk}, #{xmMsCk}, #{xj}, #{xmNo}, #{xmMs}, #{xmNoCk}, #{xmMsCk},
@@ -206,19 +212,69 @@
) )
</insert> </insert>
<!-- 更新 rk_info --> <!-- ========================= 更新 ========================= -->
<update id="updateRkInfo" parameterType="RkInfo"> <update id="updateRkInfo" parameterType="RkInfo">
update rk_info UPDATE rk_info
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="operationType != null">operation_type = #{operationType},</if> <if test="operationType != null">operation_type = #{operationType},</if>
<if test="bizType != null">biz_type = #{bizType},</if> <if test="bizType != null">biz_type = #{bizType},</if>
<if test="wlType != null">wl_type = #{wlType},</if> <if test="wlType != null">wl_type = #{wlType},</if>
<if test="cangku != null">cangku = #{cangku},</if> <if test="cangku != null">cangku = #{cangku},</if>
<if test="operationTime != null">operation_time = #{operationTime},</if>
<if test="operator != null">operator = #{operator},</if>
<if test="isChuku != null">is_chuku = #{isChuku},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="execStatus != null">exec_status = #{execStatus},</if> <if test="execStatus != null">exec_status = #{execStatus},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="billNo != null">bill_no = #{billNo},</if>
<if test="xj != null">xj = #{xj},</if>
<if test="xmNo != null">xm_no = #{xmNo},</if>
<if test="xmMs != null">xm_ms = #{xmMs},</if>
<if test="xmNoCk != null">xm_no_ck = #{xmNoCk},</if>
<if test="xmMsCk != null">xm_ms_ck = #{xmMsCk},</if>
<if test="wlNo != null">wl_no = #{wlNo},</if>
<if test="wlMs != null">wl_ms = #{wlMs},</if>
<if test="gysNo != null">gys_no = #{gysNo},</if>
<if test="gysMc != null">gys_mc = #{gysMc},</if>
<if test="jhAmt != null">jh_amt = #{jhAmt},</if>
<if test="htDj != null">ht_dj = #{htDj},</if>
<if test="sapNo != null">sap_no = #{sapNo},</if>
<if test="xh != null">xh = #{xh},</if>
<if test="jhQty != null">jh_qty = #{jhQty},</if>
<if test="htQty != null">ht_qty = #{htQty},</if>
<if test="dw != null">dw = #{dw},</if>
<if test="realQty != null">real_qty = #{realQty},</if>
<if test="pcode != null">pcode = #{pcode},</if>
<if test="pcodeId != null">pcode_id = #{pcodeId},</if>
<if test="trayCode != null">tray_code = #{trayCode},</if>
<if test="entityId != null">entity_id = #{entityId},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="borrowTime != null">borrow_time = #{borrowTime},</if>
<if test="returnTime != null">return_time = #{returnTime},</if>
<if test="hasMoved != null">has_moved = #{hasMoved},</if>
<if test="isBorrowed != null">is_borrowed = #{isBorrowed},</if>
<if test="gysJhId != null">gys_jh_id = #{gysJhId},</if>
<if test="rdid != null">rdid = #{rdid},</if>
<if test="rdidCk != null">rdid_ck = #{rdidCk},</if>
<if test="sid != null">sid = #{sid},</if>
<if test="isDelivery != null">is_delivery = #{isDelivery},</if>
<if test="fycde1 != null">fycde_1 = #{fycde1},</if>
<if test="fycde2 != null">fycde_2 = #{fycde2},</if>
<if test="isUpdate != null">is_update = #{isUpdate},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
</trim> </trim>
where id = #{id} WHERE id = #{id}
</update> </update>
<update id="updateExecStatusByIds">
UPDATE rk_info
SET exec_status = #{execStatus}
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper> </mapper>

View File

@@ -194,7 +194,6 @@
<if test="startDate != null"> <if test="startDate != null">
AND rr.operation_time &gt;= #{startDate} AND rr.operation_time &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
AND rr.operation_time &lt;= #{endDate} AND rr.operation_time &lt;= #{endDate}
</if> </if>
@@ -216,6 +215,15 @@
ORDER BY rr.operation_time ASC ORDER BY rr.operation_time ASC
</select> </select>
<select id="selectRkRecordByIds" resultMap="RkRecordResult">
SELECT *
FROM rk_record
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- ===================== 新增 ===================== --> <!-- ===================== 新增 ===================== -->
<insert id="insertRkRecord" <insert id="insertRkRecord"
parameterType="RkRecord" parameterType="RkRecord"
@@ -428,6 +436,42 @@
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<update id="updateExecStatusByIds">
UPDATE rk_record
SET exec_status = #{execStatus}
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<update id="updateByRkInfo" parameterType="com.zg.project.wisdom.domain.RkInfo">
UPDATE rk_record
<trim prefix="SET" suffixOverrides=",">
<if test="xj != null">xj = #{xj},</if>
<if test="xmNo != null">xm_no = #{xmNo},</if>
<if test="xmMs != null">xm_ms = #{xmMs},</if>
<if test="wlNo != null">wl_no = #{wlNo},</if>
<if test="wlMs != null">wl_ms = #{wlMs},</if>
<if test="gysNo != null">gys_no = #{gysNo},</if>
<if test="gysMc != null">gys_mc = #{gysMc},</if>
<if test="cangku != null">cangku = #{cangku},</if>
<if test="pcode != null">pcode = #{pcode},</if>
<if test="pcodeId != null">pcode_id = #{pcodeId},</if>
<if test="trayCode != null">tray_code = #{trayCode},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = NOW()
</trim>
WHERE rk_info_id = #{id}
</update>
<!-- ===================== 删除 ===================== --> <!-- ===================== 删除 ===================== -->
<delete id="deleteRkRecordById" parameterType="Long"> <delete id="deleteRkRecordById" parameterType="Long">
DELETE FROM rk_record WHERE id = #{id} DELETE FROM rk_record WHERE id = #{id}