Compare commits

...

11 Commits

Author SHA1 Message Date
8ceaeb03ef sql逻辑修改 2026-03-06 16:11:26 +08:00
8323ae3cd9 出库 2026-03-06 15:38:31 +08:00
15a4053cab 出库 2026-03-06 15:21:45 +08:00
a892cdd03d 出库 2026-03-06 08:42:46 +08:00
ac45b0c79b 供应计划更新单位 2026-03-05 15:38:03 +08:00
0c23b61cbb 追加入库逻辑修改 2026-03-05 15:37:28 +08:00
dbc2bada83 盘点内容以及单据号规则 2026-02-28 09:42:05 +08:00
8f802a8738 库位使用统计sql优化 2026-02-28 08:51:23 +08:00
d29b336252 库存表新增字段以及存值 2026-02-25 16:53:28 +08:00
2183528894 库存表新增字段以及存值 2026-02-25 15:25:48 +08:00
367dd00008 库存表新增字段以及存值 2026-02-25 11:05:38 +08:00
14 changed files with 278 additions and 56 deletions

View File

@@ -1,17 +1,22 @@
package com.zg.project.inventory.AutoInventory.controller; package com.zg.project.inventory.AutoInventory.controller;
import com.github.pagehelper.PageHelper;
import com.zg.common.utils.StringUtils; import com.zg.common.utils.StringUtils;
import com.zg.common.utils.poi.ExcelUtil; import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.controller.BaseController; import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult; import com.zg.framework.web.domain.AjaxResult;
import com.zg.framework.web.page.TableDataInfo; import com.zg.framework.web.page.TableDataInfo;
import com.zg.project.inventory.AutoInventory.service.InventoryMatchScanService; import com.zg.project.inventory.AutoInventory.service.InventoryMatchScanService;
import com.zg.project.inventory.domain.dto.InventoryDTO;
import com.zg.project.inventory.domain.dto.MatchScanPageDTO; import com.zg.project.inventory.domain.dto.MatchScanPageDTO;
import com.zg.project.inventory.domain.entity.InventoryMatchScan; import com.zg.project.inventory.domain.entity.InventoryMatchScan;
import com.zg.project.inventory.domain.vo.InventoryMatchScanVO; import com.zg.project.inventory.domain.vo.InventoryMatchScanVO;
import com.zg.project.inventory.domain.vo.RkInfoMatchVO; import com.zg.project.inventory.domain.vo.RkInfoMatchVO;
import com.zg.project.inventory.domain.vo.RkInventoryExportVO; import com.zg.project.inventory.domain.vo.RkInventoryExportVO;
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.vo.StockStatisticVO;
import com.zg.project.wisdom.mapper.RkInfoMapper;
import com.zg.project.wisdom.service.IRkInfoService; import com.zg.project.wisdom.service.IRkInfoService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@@ -36,7 +41,8 @@ public class InventoryMatchScanController extends BaseController {
@Autowired @Autowired
private IRkInfoService rkInfoService; private IRkInfoService rkInfoService;
@Autowired
private RkInfoMapper rkInfoMapper;
/** /**
* 分页查询盘点结果 * 分页查询盘点结果
* @param matchScan * @param matchScan
@@ -142,4 +148,27 @@ public class InventoryMatchScanController extends BaseController {
return AjaxResult.success(getDataTable(list)); return AjaxResult.success(getDataTable(list));
} }
@PostMapping("/inventoryList")
public TableDataInfo inventoryList(@RequestBody InventoryDTO query) {
PageHelper.startPage(query.getPageNum(), query.getPageSize());
String warehouseCode = query.getWarehouseCode();
String sceneId = query.getSceneId();
List<RkInfo> normalAll =
rkInfoMapper.getByWarehouseAndScene(warehouseCode, sceneId);
return getDataTable(normalAll);
}
/**
* 出入库统计,返回总数
*/
@PostMapping("/statistics")
public AjaxResult statistics(@RequestBody InventoryDTO query) {
RkInfo rkInfo = new RkInfo();
rkInfo.setScene(query.getSceneId());
rkInfo.setCangku(query.getWarehouseCode());
StockStatisticVO stockStatistic = rkInfoMapper.selectStockStatisticByCondition(rkInfo);
return AjaxResult.success(stockStatistic);
}
} }

View File

@@ -0,0 +1,14 @@
package com.zg.project.inventory.domain.dto;
import lombok.Data;
@Data
public class InventoryDTO {
private String warehouseCode;
private String sceneId;
/** 当前页 */
private Integer pageNum;
/** 每页条数 */
private Integer pageSize;
}

View File

@@ -70,6 +70,7 @@ public class RkStatisticsController {
List<TodoStatVO> list = rkStatisticsService.selectTodoStat(); List<TodoStatVO> list = rkStatisticsService.selectTodoStat();
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/** /**
* 小仓库位使用情况统计(总库位/已使用/未使用) * 小仓库位使用情况统计(总库位/已使用/未使用)
*/ */
@@ -78,6 +79,7 @@ public class RkStatisticsController {
List<WarehouseSlotStatVO> list = rkStatisticsService.selectWarehouseSlotStat(); List<WarehouseSlotStatVO> list = rkStatisticsService.selectWarehouseSlotStat();
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/** /**
* 库龄>=30天明细导出分组>30天 / >60天 * 库龄>=30天明细导出分组>30天 / >60天
*/ */

View File

@@ -251,6 +251,12 @@ public class RkInfo extends BaseEntity
@DateTimeFormat(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") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endDate; private Date endDate;
/** 场景 */
@Excel(name = "场景",readConverterExp = "HJ=货架,DC=堆场")
private String scene;
private String sceneName;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@@ -796,6 +802,24 @@ public class RkInfo extends BaseEntity
this.endDate = endDate; this.endDate = endDate;
} }
public void setScene(String scene)
{
this.scene = scene;
}
public String getScene()
{
return scene;
}
public void setSceneName(String sceneName)
{
this.sceneName = sceneName;
}
public String getSceneName()
{
return sceneName;
}
@Override @Override
public String toString() { public String toString() {
@@ -861,6 +885,7 @@ public class RkInfo extends BaseEntity
.append("startDate", startDate) .append("startDate", startDate)
.append("endDate", endDate) .append("endDate", endDate)
.append("totalAmount", totalAmount) .append("totalAmount", totalAmount)
.append("scene", getScene())
.toString(); .toString();
} }
} }

View File

@@ -172,4 +172,15 @@ public interface RkInfoMapper
List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings); List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings);
/**
* 查询今日最大单号
* */
String selectTodayMaxBillNo(String prefix, String date);
/**
* 更新单位
* */
int updateDw(@Param("sapNo") String sapNo,
@Param("wlNo") String wlNo,
@Param("xmNo") String xmNo,
@Param("dw") String dw);
} }

View File

@@ -176,4 +176,11 @@ public interface RkRecordMapper
*/ */
Integer selectMinDeliveryStatusByBillNo( Integer selectMinDeliveryStatusByBillNo(
@Param("billNo") String billNo); @Param("billNo") String billNo);
/**
* 更新单位
*/
int updateDw(@Param("sapNo") String sapNo,
@Param("wlNo") String wlNo,
@Param("xmNo") String xmNo,
@Param("dw") String dw);
} }

View File

@@ -10,6 +10,8 @@ import com.zg.common.utils.SecurityUtils;
import com.zg.common.utils.StringUtils; import com.zg.common.utils.StringUtils;
import com.zg.framework.web.domain.AjaxResult; import com.zg.framework.web.domain.AjaxResult;
import com.zg.project.wisdom.domain.dto.ExcelFieldMapping; import com.zg.project.wisdom.domain.dto.ExcelFieldMapping;
import com.zg.project.wisdom.mapper.RkInfoMapper;
import com.zg.project.wisdom.mapper.RkRecordMapper;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -30,7 +32,11 @@ public class GysJhServiceImpl implements IGysJhService
{ {
@Autowired @Autowired
private GysJhMapper gysJhMapper; private GysJhMapper gysJhMapper;
@Autowired
private RkInfoMapper rkInfoMapper;
@Autowired
private RkRecordMapper rkRecordMapper;
/** /**
* 查询供应计划 * 查询供应计划
* *
@@ -78,7 +84,24 @@ public class GysJhServiceImpl implements IGysJhService
public int updateGysJh(GysJh gysJh) public int updateGysJh(GysJh gysJh)
{ {
gysJh.setUpdateTime(DateUtils.getNowDate()); gysJh.setUpdateTime(DateUtils.getNowDate());
return gysJhMapper.updateGysJh(gysJh); int rows = gysJhMapper.updateGysJh(gysJh);
// 2⃣ 同步更新 rk_info
rkInfoMapper.updateDw(
gysJh.getSapNo(),
gysJh.getWlNo(),
gysJh.getXmNo(),
gysJh.getDw()
);
// 3⃣ 同步更新 rk_record
rkRecordMapper.updateDw(
gysJh.getSapNo(),
gysJh.getWlNo(),
gysJh.getXmNo(),
gysJh.getDw()
);
return rows;
} }
/** /**

View File

@@ -102,7 +102,7 @@ public class RkBillServiceImpl implements IRkBillService
throw new RuntimeException("入库明细不能为空"); throw new RuntimeException("入库明细不能为空");
} }
String billNo = BillNoUtil.generateTodayBillNo("RK", null); String billNo = BillNoUtil.generateTodayBillNo("RK", rkInfoMapper);
Date now = DateUtils.getNowDate(); Date now = DateUtils.getNowDate();
String userId = String.valueOf(SecurityUtils.getUserId()); String userId = String.valueOf(SecurityUtils.getUserId());
@@ -133,7 +133,7 @@ public class RkBillServiceImpl implements IRkBillService
for (RkInfo info : rkInfoList) { for (RkInfo info : rkInfoList) {
info.setExecStatus(bill.getExecStatus()); info.setExecStatus(bill.getExecStatus());
String scene = "";
// 库位校验 // 库位校验
if (StringUtils.isNotBlank(info.getPcode())) { if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse( PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
@@ -144,6 +144,9 @@ public class RkBillServiceImpl implements IRkBillService
throw new RuntimeException("库位不存在:" + info.getPcode()); throw new RuntimeException("库位不存在:" + info.getPcode());
} }
info.setPcodeId(pcde.getEncodedId()); info.setPcodeId(pcde.getEncodedId());
if(StringUtils.isNotBlank(pcde.getScene())){
scene = pcde.getScene();
}
} }
// rk_info // rk_info
@@ -159,7 +162,7 @@ public class RkBillServiceImpl implements IRkBillService
info.setHasMoved("0"); info.setHasMoved("0");
info.setIsBorrowed("0"); info.setIsBorrowed("0");
info.setIsDelete("0"); info.setIsDelete("0");
info.setScene(scene);
info.setCreateTime(now); info.setCreateTime(now);
info.setCreateBy(userId); info.setCreateBy(userId);
@@ -372,6 +375,7 @@ public class RkBillServiceImpl implements IRkBillService
} }
info.setPcodeId(pcde.getEncodedId()); info.setPcodeId(pcde.getEncodedId());
info.setScene(pcde.getScene());
} }
/* 5.2 继承主单字段 */ /* 5.2 继承主单字段 */
@@ -538,7 +542,7 @@ public class RkBillServiceImpl implements IRkBillService
throw new RuntimeException("出库明细不能为空"); throw new RuntimeException("出库明细不能为空");
} }
String billNo = BillNoUtil.generateTodayBillNo("CK", null); String billNo = BillNoUtil.generateTodayBillNo("CK", rkInfoMapper);
Date now = DateUtils.getNowDate(); Date now = DateUtils.getNowDate();
String userId = String.valueOf(SecurityUtils.getUserId()); String userId = String.valueOf(SecurityUtils.getUserId());

View File

@@ -288,7 +288,7 @@ public class RkInfoServiceImpl implements IRkInfoService
scan.setTaskId(taskId); scan.setTaskId(taskId);
scan.setPcode(r.getPcode()); scan.setPcode(r.getPcode());
// 👉 你要求:全部都是正常 // 全部都是正常
scan.setStatus("0"); scan.setStatus("0");
scan.setDeviceId(deviceId); scan.setDeviceId(deviceId);

View File

@@ -7,6 +7,8 @@ import java.util.stream.Collectors;
import com.zg.common.exception.ServiceException; 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.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.vo.RecordStatisticVO; import com.zg.project.wisdom.domain.vo.RecordStatisticVO;
@@ -43,6 +45,8 @@ public class RkRecordServiceImpl implements IRkRecordService
@Autowired @Autowired
private GysJhMapper gysJhMapper; private GysJhMapper gysJhMapper;
@Autowired
private PcdeDetailMapper pcdeDetailMapper;
/** /**
* 查询出入库记录 * 查询出入库记录
* *
@@ -199,6 +203,22 @@ public class RkRecordServiceImpl implements IRkRecordService
} }
/* ---------- 同步库存(明确字段,禁止 BeanUtils ---------- */ /* ---------- 同步库存(明确字段,禁止 BeanUtils ---------- */
String scene = "";
// 库位校验
if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
rkRecord.getPcode(),
rkRecord.getCangku()
);
if (pcde == null) {
throw new RuntimeException("库位不存在:" + info.getPcode());
}
info.setPcodeId(pcde.getEncodedId());
if(StringUtils.isNotBlank(pcde.getScene())){
scene = pcde.getScene();
info.setScene(scene);
}
}
info.setRealQty(newInQty); info.setRealQty(newInQty);
info.setWlNo(rkRecord.getWlNo()); info.setWlNo(rkRecord.getWlNo());
info.setWlMs(rkRecord.getWlMs()); info.setWlMs(rkRecord.getWlMs());
@@ -210,6 +230,7 @@ public class RkRecordServiceImpl implements IRkRecordService
info.setHtDj(rkRecord.getHtDj()); info.setHtDj(rkRecord.getHtDj());
info.setCangku(rkRecord.getCangku()); info.setCangku(rkRecord.getCangku());
info.setPcode(rkRecord.getPcode()); info.setPcode(rkRecord.getPcode());
info.setRemark(rkRecord.getRemark());
info.setIsChuku("0"); info.setIsChuku("0");
} }
@@ -246,6 +267,7 @@ public class RkRecordServiceImpl implements IRkRecordService
info.setHtDj(rkRecord.getHtDj()); info.setHtDj(rkRecord.getHtDj());
info.setCangku(rkRecord.getCangku()); info.setCangku(rkRecord.getCangku());
info.setPcode(rkRecord.getPcode()); info.setPcode(rkRecord.getPcode());
info.setRemark(rkRecord.getRemark());
} }
/* ====================== 4. 更新库存表 ====================== */ /* ====================== 4. 更新库存表 ====================== */

View File

@@ -1,6 +1,7 @@
package com.zg.project.wisdom.utils; package com.zg.project.wisdom.utils;
import com.zg.project.wisdom.mapper.RkInfoMapper; import com.zg.project.wisdom.mapper.RkInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@@ -22,6 +23,8 @@ public class BillNoUtil {
private static final String DEFAULT_PREFIX = "RK"; private static final String DEFAULT_PREFIX = "RK";
/** /**
* 生成单据号(短号,不查数据库) * 生成单据号(短号,不查数据库)
* 格式PREFIX + yyMMdd + HHmmss + 2位随机数 * 格式PREFIX + yyMMdd + HHmmss + 2位随机数
@@ -32,20 +35,25 @@ public class BillNoUtil {
*/ */
public static synchronized String generateTodayBillNo(String prefix, RkInfoMapper rkInfoMapper) { public static synchronized String generateTodayBillNo(String prefix, RkInfoMapper rkInfoMapper) {
// 前缀处理 // 日期 yyMMdd
final String p = (prefix == null || prefix.trim().isEmpty()) String date = new SimpleDateFormat("yyMMdd").format(new Date());
? DEFAULT_PREFIX
: prefix.trim().toUpperCase();
// 时间到秒yyMMddHHmmss12位 // 查询今日最大单号
String time = new SimpleDateFormat("yyMMddHHmmss").format(new Date()); String maxBillNo = rkInfoMapper.selectTodayMaxBillNo(prefix, date);
// 2位随机数10~99避免同一秒内多次点击撞号 int seq = 1;
int rnd = ThreadLocalRandom.current().nextInt(10, 100);
return p + time + rnd; if (maxBillNo != null && maxBillNo.length() > 8) {
// 取最后8位流水号
String seqStr = maxBillNo.substring(prefix.length() + date.length());
seq = Integer.parseInt(seqStr) + 1;
} }
// 8位补零
String seqFormat = String.format("%08d", seq);
return prefix + date + seqFormat;
}
/** /**
* 需要更短的版本(可选) * 需要更短的版本(可选)
* 格式PREFIX + yyMMdd + 4位随机数 * 格式PREFIX + yyMMdd + 4位随机数

View File

@@ -66,13 +66,19 @@
<result property="fycde1" column="fycde_1"/> <result property="fycde1" column="fycde_1"/>
<result property="fycde2" column="fycde_2"/> <result property="fycde2" column="fycde_2"/>
<result property="isUpdate" column="is_update"/> <result property="isUpdate" column="is_update"/>
<result property="scene" column="scene"/>
<result property="sceneName" column="sceneName"/>
</resultMap> </resultMap>
<!-- ========================= 公共查询 SQL联表完整版 ========================= --> <!-- ========================= 公共查询 SQL联表完整版 ========================= -->
<sql id="selectRkInfoVo"> <sql id="selectRkInfoVo">
SELECT SELECT
ri.*, ri.*,
CASE
WHEN ri.scene = 'HJ' THEN '货架'
WHEN ri.scene = 'DC' THEN '堆场'
ELSE ri.scene
END AS sceneName,
/* ===== 新增:计算总金额 ===== */ /* ===== 新增:计算总金额 ===== */
ri.real_qty * ri.ht_dj AS total_amount, ri.real_qty * ri.ht_dj AS total_amount,
@@ -154,7 +160,9 @@
<if test="remark != null and remark != ''"> <if test="remark != null and remark != ''">
AND ri.remark LIKE CONCAT('%', #{remark}, '%') AND ri.remark LIKE CONCAT('%', #{remark}, '%')
</if> </if>
<if test="scene != null and scene != ''">
AND ri.scene LIKE CONCAT('%', #{scene}, '%')
</if>
<if test="isDelete != null and isDelete != ''"> <if test="isDelete != null and isDelete != ''">
AND ri.is_delete = #{isDelete} AND ri.is_delete = #{isDelete}
</if> </if>
@@ -240,6 +248,9 @@
<if test="wlMs != null and wlMs != ''"> <if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%') AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if> </if>
<if test="scene != null and scene != ''">
AND ri.scene LIKE CONCAT('%', #{scene}, '%')
</if>
<if test="gysMc != null and gysMc != ''"> <if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%') AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if> </if>
@@ -298,7 +309,7 @@
is_delivery, is_delivery,
fycde_1, fycde_2, fycde_1, fycde_2,
is_update, is_update,
create_by, create_time, is_delete create_by, create_time, is_delete,scene
) )
VALUES ( VALUES (
#{operationType}, #{bizType}, #{wlType}, #{cangku}, #{operationTime}, #{operator}, #{operationType}, #{bizType}, #{wlType}, #{cangku}, #{operationTime}, #{operator},
@@ -316,7 +327,7 @@
#{isDelivery}, #{isDelivery},
#{fycde1}, #{fycde2}, #{fycde1}, #{fycde2},
#{isUpdate}, #{isUpdate},
#{createBy}, #{createTime}, #{isDelete} #{createBy}, #{createTime}, #{isDelete},#{scene}
) )
</insert> </insert>
@@ -372,6 +383,7 @@
<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> <if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="scene != null">scene = #{scene}</if>
</trim> </trim>
WHERE id = #{id} WHERE id = #{id}
</update> </update>
@@ -593,10 +605,34 @@
<select id="getByWarehouseAndScene" resultMap="RkInfoResult"> <select id="getByWarehouseAndScene" resultMap="RkInfoResult">
SELECT SELECT
ri.* ri.*,
CASE
WHEN pd.scene = 'HJ' THEN '货架'
WHEN pd.scene = 'DC' THEN '堆场'
ELSE pd.scene
END AS sceneName,
sit.type_name AS operationTypeName,
/* ===== 新增:计算总金额 ===== */
ri.real_qty * ri.ht_dj AS total_amount,
COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
mt.type_name AS wl_type_name,
wh.warehouse_name,
wh.parent_warehouse_code,
wh.parent_warehouse_name,
su.nick_name AS operator_name,
DATEDIFF(CURRENT_DATE, ri.operation_time) AS stock_age
FROM rk_info ri FROM rk_info ri
JOIN pcde_detail pd LEFT JOIN stock_in_type sit ON ri.operation_type = sit.type_code
ON pd.pcode = ri.pcode LEFT JOIN stock_out_type sot ON ri.operation_type = sot.type_code
LEFT JOIN material_type mt ON ri.wl_type = mt.type_code
LEFT JOIN warehouse_info wh ON ri.cangku = wh.warehouse_code
LEFT JOIN sys_user su ON ri.operator = su.user_id
LEFT JOIN pcde_detail pd ON pd.pcode = ri.pcode
WHERE ri.exec_status = 1 WHERE ri.exec_status = 1
AND ri.is_delete = '0' AND ri.is_delete = '0'
AND ri.is_chuku = '0' AND ri.is_chuku = '0'
@@ -618,5 +654,17 @@
</select> </select>
<select id="selectTodayMaxBillNo" resultType="java.lang.String">
SELECT MAX(bill_no)
FROM rk_record
WHERE bill_no LIKE CONCAT(#{prefix}, #{date}, '%')
</select>
<update id="updateDw">
UPDATE rk_info
SET dw = #{dw}
WHERE sap_no = #{sapNo}
AND wl_no = #{wlNo}
AND xm_no = #{xmNo}
</update>
</mapper> </mapper>

View File

@@ -92,31 +92,35 @@
<sql id="selectRkRecordVo"> <sql id="selectRkRecordVo">
SELECT SELECT
rr.*, rr.*,
COALESCE(rr.real_qty, 0) * COALESCE(rr.ht_dj, 0) AS total_amount,
/* ===== 新增:统一计算总金额 ===== */
rr.real_qty * rr.ht_dj AS total_amount,
su.nick_name AS operator_name, su.nick_name AS operator_name,
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,
-- 小仓
wh.warehouse_name AS warehouse_name, wh.warehouse_name AS warehouse_name,
-- 大仓
wh.parent_warehouse_code AS parent_warehouse_code, wh.parent_warehouse_code AS parent_warehouse_code,
wh.parent_warehouse_name AS parent_warehouse_name, wh.parent_warehouse_name AS parent_warehouse_name,
ct.team_name AS team_name,
ct.team_name AS team_name (
SELECT MIN(gj.id)
FROM gys_jh gj
WHERE gj.sap_no = rr.sap_no
AND gj.wl_no = rr.wl_no
AND gj.xm_no = rr.xm_no
AND gj.is_delete = '0'
) AS gys_jh_id
FROM rk_record rr FROM rk_record rr
LEFT JOIN sys_user su ON rr.operator = su.user_id LEFT JOIN sys_user su
LEFT JOIN material_type mt ON rr.wl_type = mt.type_code ON rr.operator = su.user_id
LEFT JOIN stock_in_type sit ON rr.operation_type = sit.type_code LEFT JOIN material_type mt
LEFT JOIN stock_out_type sot ON rr.operation_type = sot.type_code ON rr.wl_type = mt.type_code
LEFT JOIN stock_in_type sit
LEFT JOIN warehouse_info wh ON rr.cangku = wh.warehouse_code 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 construction_team ct LEFT JOIN construction_team ct
ON rr.team_code = ct.team_code ON rr.team_code = ct.team_code
AND ct.is_delete = '0' AND ct.is_delete = '0'
@@ -282,7 +286,11 @@
<include refid="selectRkRecordVo"/> <include refid="selectRkRecordVo"/>
WHERE rr.bill_no = #{billNo} WHERE rr.bill_no = #{billNo}
AND (rr.is_delete = '0' OR rr.is_delete = 0 OR rr.is_delete IS NULL) AND (rr.is_delete = '0' OR rr.is_delete = 0 OR rr.is_delete IS NULL)
ORDER BY rr.exec_status = '0' DESC, rr.create_time ASC
ORDER BY
rr.exec_status = '0' DESC,
rr.create_time ASC,
gj.gys_jh_id ASC
</select> </select>
<select id="selectRkRecordByIds" resultMap="RkRecordResult"> <select id="selectRkRecordByIds" resultMap="RkRecordResult">
@@ -930,5 +938,13 @@
AND is_delete = '0' AND is_delete = '0'
</update> </update>
<update id="updateDw">
UPDATE rk_record
SET dw = #{dw}
WHERE sap_no = #{sapNo}
AND wl_no = #{wlNo}
AND xm_no = #{xmNo}
</update>
</mapper> </mapper>

View File

@@ -254,32 +254,45 @@
<select id="selectWarehouseSlotStat" <select id="selectWarehouseSlotStat"
resultType="com.zg.project.wisdom.domain.vo.WarehouseSlotStatVO"> resultType="com.zg.project.wisdom.domain.vo.WarehouseSlotStatVO">
<![CDATA[ <![CDATA[
SELECT SELECT
p.warehouse_code AS cangkuCode, p.warehouse_code AS cangkuCode,
p.warehouse_name AS cangkuName, p.warehouse_name AS cangkuName,
COUNT(DISTINCT p.pcode) AS totalSlot, COUNT(p.pcode) AS totalSlot,
COUNT(DISTINCT CASE WHEN r.id IS NOT NULL THEN p.pcode END) AS usedSlot, COUNT(u.pcode) AS usedSlot,
COUNT(DISTINCT p.pcode) COUNT(p.pcode) - COUNT(u.pcode) AS unusedSlot
- COUNT(DISTINCT CASE WHEN r.id IS NOT NULL THEN p.pcode END) AS unusedSlot
FROM pcde_detail p FROM pcde_detail p
LEFT JOIN rk_info r
ON r.pcode = p.pcode LEFT JOIN (
AND r.cangku = p.warehouse_code SELECT DISTINCT
AND r.is_delete = '0' pcode,
AND r.is_chuku = '0' cangku
FROM rk_info
WHERE is_delete = '0'
AND is_chuku = '0'
AND exec_status = '1'
) u
ON u.pcode = p.pcode
AND u.cangku = p.warehouse_code
WHERE p.is_delete = '0' WHERE p.is_delete = '0'
AND p.warehouse_name IS NOT NULL AND p.warehouse_name IS NOT NULL
AND TRIM(p.warehouse_name) <> '' AND TRIM(p.warehouse_name) <> ''
GROUP BY p.warehouse_code, p.warehouse_name GROUP BY
ORDER BY p.warehouse_code p.warehouse_code,
p.warehouse_name
ORDER BY
p.warehouse_code
]]> ]]>
</select> </select>
<select id="selectStockAgeExport30" <select id="selectStockAgeExport30"
resultType="com.zg.project.wisdom.domain.vo.StockAgeExportVO"> resultType="com.zg.project.wisdom.domain.vo.StockAgeExportVO">
<![CDATA[ <![CDATA[