Compare commits

...

18 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
54c9486a88 Merge remote-tracking branch 'origin/master' 2026-02-13 10:32:12 +08:00
56e4514ee8 导出文件格式问题以及查询出入库问题 2026-02-13 10:32:00 +08:00
b84fd1e046 Merge remote-tracking branch 'origin/master' 2026-02-13 09:47:21 +08:00
7b4965ff7a 配送系统相关逻辑修改 2026-02-13 09:47:05 +08:00
219e23c194 配送系统同步修改的内容 2026-02-06 14:49:42 +08:00
8fa2c1c52d 清楚测试逻辑代码 2026-02-05 16:58:14 +08:00
27a105b4f6 新增库存列表接口,根据订单编号排序
追加入库接口逻辑修改
2026-02-05 16:25:28 +08:00
33 changed files with 1132 additions and 168 deletions

View File

@@ -1244,6 +1244,25 @@ public class ExcelUtil<T>
} }
else else
{ {
if (value instanceof String)
{
String str = (String) value;
if ("sapNo".equals(field.getName() )
&& str.matches("^\\d{1,15}$"))
{
cell.setCellValue(Double.parseDouble(str));
// 设置为数字格式
CellStyle numStyle = wb.createCellStyle();
numStyle.cloneStyleFrom(cell.getCellStyle());
numStyle.setDataFormat(wb.createDataFormat().getFormat("0"));
cell.setCellStyle(numStyle);
addStatisticsData(column, str, attr);
return cell;
}
}
// 设置列类型 // 设置列类型
setCellVo(value, attr, cell); setCellVo(value, attr, cell);
} }

View File

@@ -38,7 +38,6 @@ public class PcdeDetailController extends BaseController
public TableDataInfo list(PcdeDetail pcdeDetail) public TableDataInfo list(PcdeDetail pcdeDetail)
{ {
startPage(); startPage();
System.out.printf("111111");
List<PcdeDetail> list = pcdeDetailService.selectPcdeDetailList(pcdeDetail); List<PcdeDetail> list = pcdeDetailService.selectPcdeDetailList(pcdeDetail);
return getDataTable(list); return getDataTable(list);
} }

View File

@@ -68,6 +68,14 @@ public interface PcdeDetailMapper
*/ */
PcdeDetail selectByPcode(String pcode); PcdeDetail selectByPcode(String pcode);
/**
* 根据仓库编码和库位编码查询库位信息
* @param pcode
* @return
*/
PcdeDetail selectByPcodeAndWarehouse(@Param("pcode") String pcode,
@Param("warehouseCode") String warehouseCode);
/** /**
* 根据仓库编码查询库位编码 * 根据仓库编码查询库位编码
* @param pcode * @param pcode

View File

@@ -81,6 +81,24 @@ public class AutoInventoryController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 极简盘点匹配(只按仓库+场景)
*/
@PostMapping("/matchPure")
@ApiOperation("极简盘点匹配")
public AjaxResult matchPure(@RequestBody QueryDTO dto) {
if (dto.getScanType() != null && dto.getScanType() == 1) {
rfidService.stopScan(dto.getDeviceId());
}
dto.setScanType(1);
rkInfoService.matchPure(dto);
return AjaxResult.success();
}
/** /**
* 匹配后图表统计 * 匹配后图表统计
*/ */

View File

@@ -1,20 +1,34 @@
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.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.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 io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static com.zg.common.utils.PageUtils.startPage; import static com.zg.common.utils.PageUtils.startPage;
@@ -25,7 +39,10 @@ public class InventoryMatchScanController extends BaseController {
@Autowired @Autowired
private InventoryMatchScanService inventoryMatchScanService; private InventoryMatchScanService inventoryMatchScanService;
@Autowired
private IRkInfoService rkInfoService;
@Autowired
private RkInfoMapper rkInfoMapper;
/** /**
* 分页查询盘点结果 * 分页查询盘点结果
* @param matchScan * @param matchScan
@@ -40,9 +57,63 @@ public class InventoryMatchScanController extends BaseController {
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, InventoryMatchScan criteria) { public void export(HttpServletResponse response, InventoryMatchScan criteria) {
List<InventoryMatchScan> list = inventoryMatchScanService.selectInventoryMatchScanList(criteria);
ExcelUtil<InventoryMatchScan> util = new ExcelUtil<>(InventoryMatchScan.class); // 1⃣ 查盘点结果
util.exportExcel(response, list, "盘点匹配结果"); List<InventoryMatchScan> list =
inventoryMatchScanService.selectInventoryMatchScanList(criteria);
if (list == null || list.isEmpty()) {
new ExcelUtil<>(RkInventoryExportVO.class)
.exportExcel(response, new ArrayList<>(), "盘点匹配结果");
return;
}
// 2⃣ 收集所有 pcode去重
Set<String> pcodes = list.stream()
.map(InventoryMatchScan::getPcode)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
// 3⃣ 一次性查所有货物
List<RkInfo> allInfos =
rkInfoService.listRkInfoByPcodes(new ArrayList<>(pcodes));
// 4⃣ 按 pcode 分组
Map<String, List<RkInfo>> infoMap = allInfos.stream()
.collect(Collectors.groupingBy(RkInfo::getPcode));
// 5⃣ 组装
List<RkInventoryExportVO> exportList = new ArrayList<>();
for (InventoryMatchScan scan : list) {
List<RkInfo> rkInfos = infoMap.get(scan.getPcode());
if (rkInfos == null || rkInfos.isEmpty()) {
RkInventoryExportVO vo = new RkInventoryExportVO();
BeanUtils.copyProperties(scan, vo);
exportList.add(vo);
} else {
for (RkInfo info : rkInfos) {
RkInventoryExportVO vo = new RkInventoryExportVO();
BeanUtils.copyProperties(info, vo);
BeanUtils.copyProperties(scan, vo);
exportList.add(vo);
}
}
}
// 6⃣ 导出
ExcelUtil<RkInventoryExportVO> util =
new ExcelUtil<>(RkInventoryExportVO.class);
util.exportExcel(response, exportList, "盘点匹配结果");
} }
/** /**
@@ -77,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

@@ -33,4 +33,11 @@ public interface InventoryMatchScanMapper {
List<RkInfoMatchVO> selectOnlyFromMatchScan(InventoryMatchScan param); List<RkInfoMatchVO> selectOnlyFromMatchScan(InventoryMatchScan param);
List<RkInfoMatchVO> selectJoinRkInfo(InventoryMatchScan param); List<RkInfoMatchVO> selectJoinRkInfo(InventoryMatchScan param);
/**
* 查询指定仓库下未被扫描的库位
* @param param
* @return
*/
List<RkInfoMatchVO> selectUnscanFromMatchScan(InventoryMatchScan param);
} }

View File

@@ -58,20 +58,24 @@ public class InventoryMatchScanServiceImpl implements InventoryMatchScanService
@Override @Override
public List<RkInfoMatchVO> selectMatchScanCountList(InventoryMatchScan param) { public List<RkInfoMatchVO> selectMatchScanCountList(InventoryMatchScan param) {
// 状态=2只查扫描表中的数据
// ========== 1. 已扫描异常 ==========
if ("2".equals(param.getStatus())) { if ("2".equals(param.getStatus())) {
return mapper.selectOnlyFromMatchScan(param); return mapper.selectOnlyFromMatchScan(param);
} }
// 状态=1查询指定仓库下未被扫描的库位
// ========== 2. ❗未扫到(你要的逻辑)==========
else if ("1".equals(param.getStatus())) { else if ("1".equals(param.getStatus())) {
// ✅ 根据任务ID取 sceneId再按 scene 查询“未被扫描”的库位
String sceneId = taskMapper.getSceneByTaskId(param.getTaskId()); // 👉 只查扫描表!没有就是空!
return rkInfoMapper.getUnscannedPcodeByScene(sceneId, param.getTaskId()); return mapper.selectUnscanFromMatchScan(param);
} }
// 其它情况:返回扫描表和库存表的关联数据
// ========== 3. 正常匹配 ==========
else { else {
return mapper.selectJoinRkInfo(param); return mapper.selectJoinRkInfo(param);
} }
} }
} }

View File

@@ -16,18 +16,18 @@ public class HdInventoryController {
@Autowired @Autowired
private IRkInfoService rkInfoService; private IRkInfoService rkInfoService;
// @ApiModelProperty("开始匹配") @ApiModelProperty("开始匹配")
// @PostMapping("/match") @PostMapping("/match")
// public AjaxResult match(@RequestBody QueryDTO dto) { public AjaxResult match(@RequestBody QueryDTO dto) {
//
// dto.setScanType(0);
//
//// dto.setDeviceId("0");
//
// rkInfoService.matchWithStatus(dto);
//
// return AjaxResult.success();
// } dto.setScanType(0);
// dto.setDeviceId("0");
rkInfoService.matchPure(dto);
return AjaxResult.success();
}
} }

View File

@@ -94,4 +94,5 @@ public interface InventoryTaskMapper
* @return * @return
*/ */
String selectSceneIdById(String taskId); String selectSceneIdById(String taskId);
} }

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

@@ -16,7 +16,7 @@ public class InventoryMatchScan extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键ID */ /** 主键ID */
@Excel(name = "主键ID") // @Excel(name = "主键ID")
private Long id; private Long id;
/** 设备ID */ /** 设备ID */
@@ -28,7 +28,7 @@ public class InventoryMatchScan extends BaseEntity {
private String taskId; private String taskId;
/** 扫描标签ID货品码ID */ /** 扫描标签ID货品码ID */
@Excel(name = "扫描标签ID") @Excel(name = "库位号")
private String pcode; private String pcode;
/** 系统入库时间 */ /** 系统入库时间 */
@@ -44,7 +44,7 @@ public class InventoryMatchScan extends BaseEntity {
private String status; private String status;
/** 匹配到的真实货品码 */ /** 匹配到的真实货品码 */
@Excel(name = "库位号") // @Excel(name = "库位号")
private String rkPcode; private String rkPcode;
@Excel(name = "盘点任务名称") @Excel(name = "盘点任务名称")
@@ -115,6 +115,13 @@ public class InventoryMatchScan extends BaseEntity {
public void setRkPcode(String rkPcode) { public void setRkPcode(String rkPcode) {
this.rkPcode = rkPcode; this.rkPcode = rkPcode;
} }
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
@Override @Override
@@ -128,6 +135,7 @@ public class InventoryMatchScan extends BaseEntity {
.append("scanType", getScanType()) .append("scanType", getScanType())
.append("status", getStatus()) .append("status", getStatus())
.append("rkPcode", getRkPcode()) .append("rkPcode", getRkPcode())
.append("taskName", getTaskName())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

View File

@@ -0,0 +1,129 @@
package com.zg.project.inventory.domain.vo;
import com.zg.framework.aspectj.lang.annotation.Excel;
import com.zg.project.wisdom.domain.RkInfo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@Data
public class RkInventoryExportVO extends RkInfo {
private static final long serialVersionUID = 1L;
/** 主键ID */
@Excel(name = "主键ID")
private Long id;
/** 设备ID */
@Excel(name = "设备ID")
private String deviceId;
/** 盘点任务ID */
@Excel(name = "盘点任务ID")
private String taskId;
/** 扫描标签ID货品码ID */
@Excel(name = "库位号")
private String pcode;
/** 系统入库时间 */
@Excel(name = "系统入库时间")
private String tme;
/** 盘点类型0=手动盘点1=自动盘点) */
@Excel(name = "盘点类型", readConverterExp = "0=手动盘点,1=自动盘点")
private Integer scanType;
/** 匹配状态0=正常, 1=未扫到, 2=误扫) */
@Excel(name = "匹配状态", readConverterExp = "0=正常,1=未扫到,2=误扫")
private String status;
/** 匹配到的真实货品码 */
@Excel(name = "库位号")
private String rkPcode;
@Excel(name = "盘点任务名称")
private String taskName;
// ---------- Getter/Setter ----------
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getPcode() {
return pcode;
}
public void setPcode(String pcode) {
this.pcode = pcode;
}
public String getTme() {
return tme;
}
public void setTme(String tme) {
this.tme = tme;
}
public Integer getScanType() {
return scanType;
}
public void setScanType(Integer scanType) {
this.scanType = scanType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getRkPcode() {
return rkPcode;
}
public void setRkPcode(String rkPcode) {
this.rkPcode = rkPcode;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("deviceId", getDeviceId())
.append("taskId", getTaskId())
.append("pcode", getPcode())
.append("tme", getTme())
.append("scanType", getScanType())
.append("status", getStatus())
.append("rkPcode", getRkPcode())
.toString();
}
}

View File

@@ -48,6 +48,18 @@ public class RkInfoController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 查询库存单据明细列表(按订单编号排序)
*/
@PreAuthorize("@ss.hasPermi('wisdom:stock:list')")
@GetMapping("/listByBillNo")
public TableDataInfo listByBillNo(RkInfo rkInfo)
{
startPage();
List<RkInfo> list = rkInfoService.selectRkInfoListOrderByBillNo(rkInfo);
return getDataTable(list);
}
/** /**
* 导出库存单据明细列表 * 导出库存单据明细列表
*/ */

View File

@@ -179,7 +179,6 @@ public class RkRecordController extends BaseController
* 更新配送状态 * 更新配送状态
*/ */
@PostMapping("/updateDeliveryStatus") @PostMapping("/updateDeliveryStatus")
@Log(title = "更新配送状态", businessType = BusinessType.UPDATE)
public AjaxResult updateDeliveryStatus(@RequestBody RkDeliveryUpdateDTO dto) { public AjaxResult updateDeliveryStatus(@RequestBody RkDeliveryUpdateDTO dto) {
if (dto.getIds() == null || dto.getIds().isEmpty()) { if (dto.getIds() == null || dto.getIds().isEmpty()) {
@@ -190,6 +189,7 @@ public class RkRecordController extends BaseController
} }
int rows = rkRecordService.updateDeliveryStatus(dto.getIds(), dto.getIsDelivery()); int rows = rkRecordService.updateDeliveryStatus(dto.getIds(), dto.getIsDelivery());
return AjaxResult.success(rows); return AjaxResult.success(rows);
} }
} }

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

@@ -226,7 +226,7 @@ public class RkInfo extends BaseEntity
private Long sid; private Long sid;
/** 配送状态0否 1是 2待接单 3配送中 4配送完成 */ /** 配送状态0否 1是 2待接单 3配送中 4配送完成 */
@Excel(name = "是否需要配送", readConverterExp = "0否,1是,2配送,3配送完成") @Excel(name = "是否需要配送", readConverterExp = "0=否,1=是,2=待配送,3=配送中,4=配送完成")
private String isDelivery; private String isDelivery;
/** 封样编号1 */ /** 封样编号1 */
@@ -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

@@ -239,14 +239,14 @@ public class RkRecord extends BaseEntity
private Long sid; private Long sid;
/** 配送状态0否 1是 2待接单 3配送中 4配送完成 */ /** 配送状态0否 1是 2待接单 3配送中 4配送完成 */
@Excel(name = "是否需要配送", readConverterExp = "0=否,1=是,2=已接单,3=配送中,4=配送完成") @Excel(name = "是否需要配送", readConverterExp = "0=否,1=是,2=待配送,3=配送中,4=配送完成")
private String isDelivery; private String isDelivery;
/** 封样编号1 */ /** 封样编号1 */
// @Excel(name = "封样编号1") // @Excel(name = "封样编号1")
private String fycde1; private String fycde1;
/** 封样编号2 */ /** 封样编号2 */
// @Excel(name = "封样编号2") // @Excel(name = "封样编号2")2
private String fycde2; private String fycde2;
/** 1已更新 */ /** 1已更新 */

View File

@@ -1,6 +1,7 @@
package com.zg.project.wisdom.mapper; package com.zg.project.wisdom.mapper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -155,4 +156,31 @@ public interface RkInfoMapper
int countGetByWh(@org.apache.ibatis.annotations.Param("warehouse") String warehouse); int countGetByWh(@org.apache.ibatis.annotations.Param("warehouse") String warehouse);
List<RkInfo> listRkInfoByPcode(String pcode); List<RkInfo> listRkInfoByPcode(String pcode);
/**
* 查询库存单据明细列表(按单据号排序)
*/
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
/**
* 根据仓库和场景查询库存单据明细
*/
List<RkInfo> getByWarehouseAndScene(
@Param("warehouseCode") String warehouseCode,
@Param("sceneId") String sceneId
);
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

@@ -166,5 +166,21 @@ public interface RkRecordMapper
*/ */
int countDifferentDeliveryStatus(@Param("billNo") String billNo, int countDifferentDeliveryStatus(@Param("billNo") String billNo,
@Param("isDelivery") Integer isDelivery); @Param("isDelivery") Integer isDelivery);
/**
* 根据 billNo 批量更新 record 明细
*/
int updateRecordByBillNo(RkRecord record);
/**
* 查询bill最小配送状态
*/
Integer selectMinDeliveryStatusByBillNo(
@Param("billNo") String billNo);
/**
* 更新单位
*/
int updateDw(@Param("sapNo") String sapNo,
@Param("wlNo") String wlNo,
@Param("xmNo") String xmNo,
@Param("dw") String dw);
} }

View File

@@ -1,5 +1,6 @@
package com.zg.project.wisdom.service; package com.zg.project.wisdom.service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zg.project.inventory.domain.dto.QueryDTO; import com.zg.project.inventory.domain.dto.QueryDTO;
@@ -76,6 +77,13 @@ public interface IRkInfoService
*/ */
void matchWithStatus(QueryDTO dto); void matchWithStatus(QueryDTO dto);
/**
* 盘点开始匹配(纯数据)
* @param dto
* @return
*/
void matchPure(QueryDTO dto);
/** /**
* 图表统计:每个库位有多少个货物 * 图表统计:每个库位有多少个货物
* @param dto * @param dto
@@ -96,4 +104,16 @@ public interface IRkInfoService
* @return * @return
*/ */
List<RkInfo> listRkInfoByPcode(String pcode); List<RkInfo> listRkInfoByPcode(String pcode);
/**
* 查询库存单据明细列表(按单据号排序)
*/
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
/**
* 按多个pcode查询
* @param strings
* @return
*/
List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings);
} }

View File

@@ -20,6 +20,7 @@ import com.zg.project.wisdom.mapper.AgvWcsMapper;
import com.zg.project.wisdom.mapper.DdTaskMapper; import com.zg.project.wisdom.mapper.DdTaskMapper;
import com.zg.project.wisdom.mapper.WcsTaskResultMapper; import com.zg.project.wisdom.mapper.WcsTaskResultMapper;
import com.zg.project.wisdom.service.IDdTaskService; import com.zg.project.wisdom.service.IDdTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -27,13 +28,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import static com.zg.framework.datasource.DynamicDataSourceContextHolder.log;
/** /**
* 调度任务 Service 实现类 * 调度任务 Service 实现类
* *
* @author zg * @author zg
*/ */
@Slf4j
@Service @Service
public class DdTaskServiceImpl implements IDdTaskService { public class DdTaskServiceImpl implements IDdTaskService {

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,14 +133,20 @@ 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.selectByPcode(info.getPcode()); PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
info.getPcode(),
bill.getCangku()
);
if (pcde == null) { if (pcde == null) {
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
@@ -156,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);
@@ -331,38 +337,54 @@ public class RkBillServiceImpl implements IRkBillService
throw new ServiceException("单据不存在:" + billNo); throw new ServiceException("单据不存在:" + billNo);
} }
/* ================== 2执行状态规则 ================== */ /* ================== 2取前端选择仓库 ================== */
String frontCangku = dto.getRkBill().getCangku();
if (StringUtils.isBlank(frontCangku)) {
frontCangku = bill.getCangku();
}
/* ================== 3⃣ 执行状态 ================== */
String execStatus = dto.getRkBill().getExecStatus(); String execStatus = dto.getRkBill().getExecStatus();
if (StringUtils.isBlank(execStatus)) { if (StringUtils.isBlank(execStatus)) {
execStatus = bill.getExecStatus(); execStatus = bill.getExecStatus();
} }
// 标记:本次是否包含预入库
boolean hasPreIn = false; boolean hasPreIn = false;
List<RkInfo> rkInfoList = dto.getRkInfoList(); List<RkInfo> rkInfoList = dto.getRkInfoList();
/* ================== 3️⃣ 追加前:供应计划【批量】校验 ================== */ /* ================== 4️⃣ 供应计划校验 ================== */
checkGysJhQtyBeforeInStockBatch(rkInfoList); checkGysJhQtyBeforeInStockBatch(rkInfoList);
/* ================== 4️⃣ 插入明细 & 事件 ================== */ /* ================== 5️⃣ 追加明细 ================== */
for (RkInfo info : rkInfoList) { for (RkInfo info : rkInfoList) {
/* 4.1 库位校验 */ /* 5.1 库位校验 → 用【前端仓库】 */
if (StringUtils.isNotBlank(info.getPcode())) { if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
info.getPcode(),
frontCangku
);
if (pcde == null) { if (pcde == null) {
throw new ServiceException("库位不存在:" + info.getPcode()); throw new ServiceException(
} "库位不存在或不属于当前仓库:"
info.setPcodeId(pcde.getEncodedId()); + info.getPcode()
+ ",仓库:" + frontCangku
);
} }
/* 4.2 继承主单字段 */ info.setPcodeId(pcde.getEncodedId());
info.setScene(pcde.getScene());
}
/* 5.2 继承主单字段 */
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());
info.setCangku(bill.getCangku());
info.setCangku(frontCangku);
info.setOperationTime(now); info.setOperationTime(now);
info.setOperator(bill.getOperator()); info.setOperator(bill.getOperator());
@@ -376,36 +398,36 @@ public class RkBillServiceImpl implements IRkBillService
info.setHasMoved("0"); info.setHasMoved("0");
info.setIsBorrowed("0"); info.setIsBorrowed("0");
/* 4.3 备注兜底 */
String finalRemark = StringUtils.isNotBlank(info.getRemark()) String finalRemark = StringUtils.isNotBlank(info.getRemark())
? info.getRemark() ? info.getRemark()
: bill.getRemark(); : bill.getRemark();
info.setRemark(finalRemark); info.setRemark(finalRemark);
/* 4.4 审计字段 */
info.setCreateTime(now); info.setCreateTime(now);
info.setCreateBy(bill.getCreateBy()); info.setCreateBy(bill.getCreateBy());
info.setIsDelete("0"); info.setIsDelete("0");
/* 4.5 插入 rk_info */ /* 5.3 插入 rk_info */
rkInfoMapper.insertRkInfo(info); rkInfoMapper.insertRkInfo(info);
/* 4.6 插入 rk_record */ /* 5.4 插入 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());
record.setPcodeId(info.getPcodeId()); record.setPcodeId(info.getPcodeId());
record.setRemark(finalRemark); record.setRemark(finalRemark);
record.setCangku(frontCangku);
rkRecordMapper.insertRkRecord(record); rkRecordMapper.insertRkRecord(record);
} }
/* ================== 5️⃣ 追加后:供应计划【仅完成入库】 ================== */ /* ================== 6️⃣ 供应计划回写 ================== */
if ("1".equals(execStatus)) { if ("1".equals(execStatus)) {
handleGysJhAfterInStockBatch(rkInfoList); handleGysJhAfterInStockBatch(rkInfoList);
} }
/* ================== 6️⃣ 同步回退主单状态 ================== */ /* ================== 7️⃣ 主单状态回退 ================== */
if (hasPreIn && !"0".equals(bill.getExecStatus())) { if (hasPreIn && !"0".equals(bill.getExecStatus())) {
rkBillMapper.updateExecStatusByBillNo(billNo, "0"); rkBillMapper.updateExecStatusByBillNo(billNo, "0");
} }
@@ -420,11 +442,35 @@ public class RkBillServiceImpl implements IRkBillService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateRkBill(RkBill rkBill) @Transactional(rollbackFor = Exception.class)
{ public int updateRkBill(RkBill rkBill) {
return rkBillMapper.updateRkBill(rkBill);
if (rkBill == null || StringUtils.isBlank(rkBill.getBillNo())) {
throw new ServiceException("单据号不能为空");
} }
// ====================== 1. 更新主单 rk_bill ======================
int rows = rkBillMapper.updateRkBill(rkBill);
// ====================== 2. 同步更新对应 record 明细 ======================
RkRecord updateRecord = new RkRecord();
// 以 billNo 为条件
updateRecord.setBillNo(rkBill.getBillNo());
// ---- 需要同步的关键字段 ----
updateRecord.setOperationType(rkBill.getOperationType());
updateRecord.setTeamCode(rkBill.getTeamCode());
updateRecord.setOperator(rkBill.getOperator());
updateRecord.setIsDelivery(rkBill.getIsDelivery());
// 执行批量更新
rkRecordMapper.updateRecordByBillNo(updateRecord);
return rows;
}
/** /**
* 批量删除库存单据 * 批量删除库存单据
* *
@@ -496,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

@@ -14,6 +14,7 @@ import com.zg.project.inventory.AutoInventory.mapper.InventoryMatchScanMapper;
import com.zg.project.inventory.Task.mapper.InventoryTaskMapper; import com.zg.project.inventory.Task.mapper.InventoryTaskMapper;
import com.zg.project.inventory.domain.dto.QueryDTO; import com.zg.project.inventory.domain.dto.QueryDTO;
import com.zg.project.inventory.domain.entity.InventoryMatchScan; import com.zg.project.inventory.domain.entity.InventoryMatchScan;
import com.zg.project.inventory.domain.entity.InventoryTask;
import com.zg.project.inventory.domain.vo.ChartDataVO; import com.zg.project.inventory.domain.vo.ChartDataVO;
import com.zg.project.inventory.domain.vo.PcdeCntVO; import com.zg.project.inventory.domain.vo.PcdeCntVO;
import com.zg.project.wisdom.domain.vo.StockStatisticVO; import com.zg.project.wisdom.domain.vo.StockStatisticVO;
@@ -234,6 +235,79 @@ public class RkInfoServiceImpl implements IRkInfoService
return record; return record;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void matchPure(QueryDTO dto) {
/* ================== 1. 取任务信息 ================== */
String taskId = dto.getTaskId();
InventoryTask task = taskMapper.selectInventoryTaskById(Long.valueOf(taskId));
if (task == null) {
throw new ServiceException("任务不存在");
}
String sceneId = task.getSceneId();
String warehouseCode = task.getWarehouseCode();
if (StringUtils.isBlank(sceneId)) {
throw new ServiceException("缺少场景ID");
}
if (StringUtils.isBlank(warehouseCode)) {
throw new ServiceException("缺少仓库信息");
}
int scanType = dto.getScanType() != null ? dto.getScanType() : 0;
String deviceId = dto.getDeviceId();
if (scanType == 1 && StringUtils.isBlank(deviceId)) {
throw new ServiceException("自动盘点必须传递设备ID");
}
/* =====================================================
* 2. 🚀 核心逻辑(你要求的口径)
* → 只查 rk_info
* → 不再做任何 pcodeId 匹配
* ===================================================== */
List<RkInfo> normalAll =
rkInfoMapper.getByWarehouseAndScene(warehouseCode, sceneId);
/* 全部视为正常 */
String tmeStr =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
List<InventoryMatchScan> toSave = new ArrayList<>();
for (RkInfo r : normalAll) {
InventoryMatchScan scan = new InventoryMatchScan();
scan.setTaskId(taskId);
scan.setPcode(r.getPcode());
// 全部都是正常
scan.setStatus("0");
scan.setDeviceId(deviceId);
scan.setTme(tmeStr);
scan.setScanType(scanType);
toSave.add(scan);
}
/* 批量写入 */
if (!toSave.isEmpty()) {
matchScanMapper.insertBatch(toSave);
}
/* ================== 5. 完成任务 ================== */
taskMapper.updateStatus(taskId, "1");
}
/** /**
* 图表统计:每个库位有多少个货物 * 图表统计:每个库位有多少个货物
* @param dto * @param dto
@@ -270,4 +344,17 @@ public class RkInfoServiceImpl implements IRkInfoService
public List<RkInfo> listRkInfoByPcode(String pcode) { public List<RkInfo> listRkInfoByPcode(String pcode) {
return rkInfoMapper.listRkInfoByPcode(pcode); return rkInfoMapper.listRkInfoByPcode(pcode);
} }
@Override
public List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo)
{
return rkInfoMapper.selectRkInfoListOrderByBillNo(rkInfo);
}
@Override
public List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings) {
return rkInfoMapper.listRkInfoByPcodes(strings);
}
} }

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. 更新库存表 ====================== */
@@ -804,35 +826,57 @@ public class RkRecordServiceImpl implements IRkRecordService
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int updateDeliveryStatus(List<Long> ids, Integer isDelivery) { public int updateDeliveryStatus(List<Long> ids, Integer isDelivery)
{
if (ids == null || ids.isEmpty()) { if (ids == null || ids.isEmpty()) {
return 0; return 0;
} }
// 1. 先更新 record // ===============================
int rows = rkRecordMapper.updateDeliveryStatus(ids, isDelivery); // 1. 更新 record 状态
// ===============================
int rows =
rkRecordMapper.updateDeliveryStatus(ids, isDelivery);
// ===============================
// 2. 查询受影响 billNo
// ===============================
List<String> billNos =
rkRecordMapper.selectBillNosByRecordIds(ids);
// 2. 找到受影响的 billNo
List<String> billNos = rkRecordMapper.selectBillNosByRecordIds(ids);
if (billNos == null || billNos.isEmpty()) { if (billNos == null || billNos.isEmpty()) {
return rows; return rows;
} }
// 3. 对每个 bill 判断是否可以更新
for (String billNo : billNos) {
// 3.1 查询该 bill 下是否还存在“不同状态”的 record // ===============================
int diffCount = rkRecordMapper.countDifferentDeliveryStatus(billNo, isDelivery); // 3. 更新 bill 状态
// 规则:
//
// bill状态 = MIN(record.is_delivery)
//
// 示例:
//
// 2,4,4 → 2
// 3,4 → 3
// 4,4 → 4
//
// ===============================
for (String billNo : billNos)
{
Integer billStatus =
rkRecordMapper.selectMinDeliveryStatusByBillNo(billNo);
// 只有“全部一致”时才改 bill if (billStatus != null)
if (diffCount == 0) { {
rkBillMapper.updateDeliveryStatusByBillNo(billNo, isDelivery); rkBillMapper.updateDeliveryStatusByBillNo(
billNo,
billStatus
);
} }
// 否则:保持原状态(不动)
} }
return rows; return rows;
} }
} }

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

@@ -77,6 +77,7 @@ spring:
# 数据库索引 # 数据库索引
database: 0 database: 0
# 密码 # 密码
# password: shzg
password: password:
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s

View File

@@ -273,4 +273,17 @@
ORDER BY MAX(r.create_time) DESC ORDER BY MAX(r.create_time) DESC
</select> </select>
<select id="selectUnscanFromMatchScan"
resultType="com.zg.project.inventory.domain.vo.RkInfoMatchVO">
SELECT
pcode AS rkPcode,
0 AS realQty,
status
FROM inventory_match_scan
WHERE task_id = #{taskId}
AND status = '1'
</select>
</mapper> </mapper>

View File

@@ -140,6 +140,33 @@
AND is_delete = '0' AND is_delete = '0'
</select> </select>
<!-- 根据 pcode + 小仓编码 精准定位 -->
<select id="selectByPcodeAndWarehouse"
resultType="com.zg.project.information.domain.PcdeDetail">
SELECT
id,
pcode,
scene,
parent_warehouse_code AS parentWarehouseCode,
parent_warehouse_name AS parentWarehouseName,
warehouse_code AS warehouseCode,
warehouse_name AS warehouseName,
encoded_id AS encodedId,
tag,
is_delete AS isDelete,
created_by AS createdBy,
created_at AS createdAt,
updated_by AS updatedBy,
updated_at AS updatedAt,
remark
FROM pcde_detail
WHERE pcode = #{pcode}
AND warehouse_code = #{warehouseCode}
AND is_delete = '0'
LIMIT 1
</select>
<!-- 根据库位编码查编码后ID --> <!-- 根据库位编码查编码后ID -->
<select id="selectEncodedIdByPcode" <select id="selectEncodedIdByPcode"
resultType="java.lang.String" resultType="java.lang.String"

View File

@@ -104,7 +104,6 @@
<select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult"> <select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult">
<include refid="selectRkBillVo"/> <include refid="selectRkBillVo"/>
<where> <where>
AND rb.is_delivery ='1'
<if test="wlType != null and wlType != ''"> <if test="wlType != null and wlType != ''">
AND rb.wl_type = #{wlType} AND rb.wl_type = #{wlType}
</if> </if>
@@ -121,7 +120,7 @@
AND rb.operation_type = #{operationType} AND rb.operation_type = #{operationType}
</if> </if>
<if test="bizTypeList != null and bizTypeList.size > 0"> <if test="bizTypeList != null and bizTypeList.size() > 0">
AND rb.biz_type IN AND rb.biz_type IN
<foreach collection="bizTypeList" item="bt" open="(" separator="," close=")"> <foreach collection="bizTypeList" item="bt" open="(" separator="," close=")">
#{bt} #{bt}

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,
@@ -101,53 +107,75 @@
ri.exec_status = 1 ri.exec_status = 1
AND ri.is_chuku = 0 AND ri.is_chuku = 0
AND ri.is_delete = 0 AND ri.is_delete = 0
<if test="operationType != null and operationType != ''"> <if test="operationType != null and operationType != ''">
AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%') AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%')
</if> </if>
<if test="sapNo != null and sapNo != ''"> <if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%') AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if> </if>
<if test="xmNo != null and xmNo != ''"> <if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%') AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if> </if>
<if test="xmMs != null and xmMs != ''"> <if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%') AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if> </if>
<if test="wlNo != null and wlNo != ''"> <if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%') AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if> </if>
<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="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>
<if test="pcode != null and pcode != ''"> <if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%') AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
</if> </if>
<if test="bizType != null and bizType != ''"> <if test="bizType != null and bizType != ''">
AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%') AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
</if> </if>
<if test="wlType != null and wlType != ''"> <if test="wlType != null and wlType != ''">
AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%') AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
</if> </if>
<if test="cangku != null and cangku != ''"> <if test="cangku != null and cangku != ''">
AND ri.cangku LIKE CONCAT('%', #{cangku}, '%') AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
</if> </if>
<if test="billNo != null and billNo != ''"> <if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%') AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if> </if>
<!-- ★★★ 新增:按备注模糊搜索 ★★★ -->
<if test="remark != null and remark != ''">
AND ri.remark LIKE CONCAT('%', #{remark}, '%')
</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>
<!-- 出入库时间范围 -->
<if test="startDate != null"> <if test="startDate != null">
AND ri.operation_time &gt;= #{startDate} AND ri.operation_time &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
AND ri.operation_time &lt;= #{endDate} AND ri.operation_time &lt;= #{endDate}
</if> </if>
</where> </where>
ORDER BY ri.operation_time DESC ORDER BY ri.operation_time DESC
</select> </select>
@@ -220,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>
@@ -278,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},
@@ -296,7 +327,7 @@
#{isDelivery}, #{isDelivery},
#{fycde1}, #{fycde2}, #{fycde1}, #{fycde2},
#{isUpdate}, #{isUpdate},
#{createBy}, #{createTime}, #{isDelete} #{createBy}, #{createTime}, #{isDelete},#{scene}
) )
</insert> </insert>
@@ -352,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>
@@ -500,4 +532,139 @@
ORDER BY t.operation_time DESC, t.id DESC ORDER BY t.operation_time DESC, t.id DESC
</select> </select>
<!-- ========================= 按单据号排序查询列表 ========================= -->
<select id="selectRkInfoListOrderByBillNo" parameterType="RkInfo" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
<where>
ri.exec_status = 1
AND ri.is_chuku = 0
AND ri.is_delete = 0
<if test="operationType != null and 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 test="bizType != null and bizType != ''">
AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
</if>
<if test="wlType != null and wlType != ''">
AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
</if>
<if test="cangku != null and cangku != ''">
AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
</if>
<if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if>
<if test="isDelete != null and 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>
</where>
ORDER BY
/* 1. 纯数字优先 */
(ri.sap_no REGEXP '^[0-9]+$') DESC,
/* 2. 纯数字按【从小到大】 */
CASE
WHEN ri.sap_no REGEXP '^[0-9]+$'
THEN CAST(ri.sap_no AS UNSIGNED)
ELSE 999999999999
END ASC,
/* 3. 字母混合按字符串 */
ri.sap_no ASC
</select>
<select id="getByWarehouseAndScene" resultMap="RkInfoResult">
SELECT
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
LEFT JOIN stock_in_type sit ON ri.operation_type = sit.type_code
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
AND ri.is_delete = '0'
AND ri.is_chuku = '0'
AND ri.cangku = #{warehouseCode}
AND pd.scene = #{sceneId}
</select>
<select id="listRkInfoByPcodes"
resultMap="RkInfoResult"
parameterType="java.util.ArrayList">
SELECT *
FROM rk_info
WHERE is_delete = 0
AND is_chuku = 0
AND pcode IN
<foreach collection="list" item="p" open="(" separator="," close=")">
#{p}
</foreach>
</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.operation_time DESC
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">
@@ -598,37 +606,141 @@
IFNULL(SUM(rr.real_qty), 0) AS totalQuantity IFNULL(SUM(rr.real_qty), 0) AS totalQuantity
FROM rk_record rr FROM rk_record rr
<where> <where>
rr.is_delete = 0
AND rr.exec_status = 1
<!-- 已修复String 不可用 size() --> AND rr.exec_status = '1'
<if test="operationType != null and operationType != ''"> <if test="operationType != null and operationType != ''">
AND rr.operation_type = #{operationType} AND rr.operation_type = #{operationType}
</if> </if>
<if test="xmNo != null and xmNo != ''"> <!-- 多 bizType -->
AND rr.xm_no LIKE CONCAT('%', #{xmNo}, '%') <if test="bizTypeList != null and bizTypeList.size > 0">
AND rr.biz_type IN
<foreach collection="bizTypeList"
item="bt"
open="("
separator=","
close=")">
#{bt}
</foreach>
</if> </if>
<if test="wlNo != null and wlNo != ''"> <if test="bizType != null and bizType != ''">
AND rr.wl_no LIKE CONCAT('%', #{wlNo}, '%') AND rr.biz_type = #{bizType}
</if> </if>
<if test="pcode != null and pcode != ''"> <if test="pcode != null and pcode != ''">
AND rr.pcode LIKE CONCAT('%', #{pcode}, '%') AND rr.pcode = #{pcode}
</if>
<if test="wlType != null and wlType != ''">
AND rr.wl_type = #{wlType}
</if> </if>
<if test="cangku != null and cangku != ''"> <if test="cangku != null and cangku != ''">
AND rr.cangku LIKE CONCAT('%', #{cangku}, '%') AND rr.cangku = #{cangku}
</if> </if>
<if test="operator != null and operator != ''">
AND rr.operator = #{operator}
</if>
<if test="isChuku != null and isChuku != ''">
AND rr.is_chuku = #{isChuku}
</if>
<if test="status != null and status != ''">
AND rr.status = #{status}
</if>
<if test="execStatus != null and execStatus != ''">
AND rr.exec_status = #{execStatus}
</if>
<if test="billNo != null and billNo != ''">
AND rr.bill_no = #{billNo}
</if>
<if test="isDelivery != null and isDelivery != ''">
AND rr.is_delivery = #{isDelivery}
</if>
<!-- 项目 -->
<if test="xmNo != null and xmNo != ''">
AND rr.xm_no LIKE concat('%', #{xmNo}, '%')
</if>
<if test="xmMs != null and xmMs != ''">
AND rr.xm_ms LIKE concat('%', #{xmMs}, '%')
</if>
<!-- 订单 -->
<if test="sapNo != null and sapNo != ''">
AND rr.sap_no LIKE concat('%', #{sapNo}, '%')
</if>
<!-- 供应商 -->
<if test="gysMc != null and gysMc != ''">
AND rr.gys_mc LIKE concat('%', #{gysMc}, '%')
</if>
<if test="wlNo != null and wlNo != ''">
AND rr.wl_no LIKE concat('%', #{wlNo}, '%')
</if>
<if test="wlMs != null and wlMs != ''">
AND rr.wl_ms LIKE concat('%', #{wlMs}, '%')
</if>
<!-- 是否借料 -->
<if test="isBorrowed != null and isBorrowed != ''">
AND rr.is_borrowed = #{isBorrowed}
</if>
<!-- 删除标识 -->
<if test="isDelete == null">
AND (rr.is_delete = '0' OR rr.is_delete = 0 OR rr.is_delete IS NULL)
</if>
<if test="isDelete != null and isDelete != ''">
AND rr.is_delete = #{isDelete}
</if>
<!-- ================= 时间条件(最终正确版) ================= -->
<if test="startDate != null or endDate != null">
AND (
<!-- 普通入库 / 出库:精确到时分秒 -->
(
rr.biz_type IN ('0','1')
<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>
)
OR
<!-- 借料出库:按 borrow_time按天 -->
(
rr.biz_type = '2'
<if test="startDate != null">
AND rr.borrow_time &gt;= DATE(#{startDate})
</if>
<if test="endDate != null">
AND rr.borrow_time &lt; DATE_ADD(DATE(#{endDate}), INTERVAL 1 DAY)
</if>
)
OR
<!-- 还料入库:按 return_time按天 -->
(
rr.biz_type = '3'
<if test="startDate != null">
AND rr.return_time &gt;= DATE(#{startDate})
</if>
<if test="endDate != null">
AND rr.return_time &lt; DATE_ADD(DATE(#{endDate}), INTERVAL 1 DAY)
</if>
)
)
</if>
</where> </where>
</select> </select>
@@ -752,6 +864,7 @@
ON rr.cangku = wh.warehouse_code ON rr.cangku = wh.warehouse_code
WHERE rr.bill_no = #{billNo} WHERE rr.bill_no = #{billNo}
AND rr.is_delete = '0' AND rr.is_delete = '0'
AND rr.is_delivery = '1'
</select> </select>
@@ -787,4 +900,51 @@
AND is_delivery != #{isDelivery} AND is_delivery != #{isDelivery}
</select> </select>
<!-- 查询bill最小配送状态 -->
<select id="selectMinDeliveryStatusByBillNo"
resultType="int">
SELECT MIN(is_delivery)
FROM rk_record
WHERE bill_no = #{billNo}
AND is_delete = '0'
AND is_delivery >= 2
</select>
<update id="updateRecordByBillNo" parameterType="com.zg.project.wisdom.domain.RkRecord">
UPDATE rk_record
<set>
<if test="operationType != null">
operation_type = #{operationType},
</if>
<if test="teamCode != null">
team_code = #{teamCode},
</if>
<if test="operator != null">
operator = #{operator},
</if>
<if test="isDelivery != null">
is_delivery = #{isDelivery},
</if>
update_time = NOW()
</set>
WHERE bill_no = #{billNo}
AND is_delete = '0'
</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

@@ -233,81 +233,66 @@
UNION ALL UNION ALL
SELECT
'应到未到[全部未到]' AS type,
COUNT(DISTINCT g.xm_no) AS projectCnt,
ROUND(
COALESCE(
SUM(g.jh_qty),
0
),
3
) AS totalQty,
ROUND(
COALESCE(
SUM(g.jh_qty * g.ht_dj),
0
),
3
) AS totalAmt
FROM gys_jh g
WHERE g.is_delete = '0'
AND g.status = '0'
UNION ALL
SELECT SELECT
'应出未出[全部未出]' AS type, '应出未出[全部未出]' AS type,
COUNT(DISTINCT g.xm_no) AS projectCnt, COUNT(DISTINCT ri.xm_no) AS projectCnt,
ROUND( ROUND(
COALESCE( COALESCE(SUM(ri.real_qty), 0),
SUM(g.real_qty),
0
),
3 3
) AS totalQty, ) AS totalQty,
ROUND( ROUND(
COALESCE( COALESCE(SUM(ri.real_qty * ri.ht_dj), 0),
SUM(g.real_qty * g.ht_dj),
0
),
3 3
) AS totalAmt ) AS totalAmt
FROM gys_jh g FROM rk_info ri
WHERE g.is_delete = '0' WHERE ri.is_delete = '0'
AND g.status = '1'; AND ri.is_chuku = '0'
AND TIMESTAMPDIFF(DAY, ri.operation_time, NOW()) > 30;
]]> ]]>
</select> </select>
<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[