Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -81,6 +81,24 @@ public class AutoInventoryController extends BaseController {
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配后图表统计
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zg.project.inventory.AutoInventory.controller;
|
||||
|
||||
import com.zg.common.utils.StringUtils;
|
||||
import com.zg.common.utils.poi.ExcelUtil;
|
||||
import com.zg.framework.web.controller.BaseController;
|
||||
import com.zg.framework.web.domain.AjaxResult;
|
||||
@@ -9,12 +10,20 @@ import com.zg.project.inventory.domain.dto.MatchScanPageDTO;
|
||||
import com.zg.project.inventory.domain.entity.InventoryMatchScan;
|
||||
import com.zg.project.inventory.domain.vo.InventoryMatchScanVO;
|
||||
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.service.IRkInfoService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
|
||||
@@ -25,6 +34,8 @@ public class InventoryMatchScanController extends BaseController {
|
||||
@Autowired
|
||||
private InventoryMatchScanService inventoryMatchScanService;
|
||||
|
||||
@Autowired
|
||||
private IRkInfoService rkInfoService;
|
||||
|
||||
/**
|
||||
* 分页查询盘点结果
|
||||
@@ -40,9 +51,63 @@ public class InventoryMatchScanController extends BaseController {
|
||||
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InventoryMatchScan criteria) {
|
||||
List<InventoryMatchScan> list = inventoryMatchScanService.selectInventoryMatchScanList(criteria);
|
||||
ExcelUtil<InventoryMatchScan> util = new ExcelUtil<>(InventoryMatchScan.class);
|
||||
util.exportExcel(response, list, "盘点匹配结果");
|
||||
|
||||
// 1️⃣ 查盘点结果
|
||||
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, "盘点匹配结果");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,4 +33,11 @@ public interface InventoryMatchScanMapper {
|
||||
List<RkInfoMatchVO> selectOnlyFromMatchScan(InventoryMatchScan param);
|
||||
|
||||
List<RkInfoMatchVO> selectJoinRkInfo(InventoryMatchScan param);
|
||||
|
||||
/**
|
||||
* 查询指定仓库下未被扫描的库位
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<RkInfoMatchVO> selectUnscanFromMatchScan(InventoryMatchScan param);
|
||||
}
|
||||
|
||||
@@ -58,20 +58,24 @@ public class InventoryMatchScanServiceImpl implements InventoryMatchScanService
|
||||
|
||||
@Override
|
||||
public List<RkInfoMatchVO> selectMatchScanCountList(InventoryMatchScan param) {
|
||||
// 状态=2:只查扫描表中的数据
|
||||
|
||||
// ========== 1. 已扫描异常 ==========
|
||||
if ("2".equals(param.getStatus())) {
|
||||
return mapper.selectOnlyFromMatchScan(param);
|
||||
}
|
||||
// 状态=1:查询指定仓库下未被扫描的库位
|
||||
|
||||
// ========== 2. ❗未扫到(你要的逻辑)==========
|
||||
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 {
|
||||
return mapper.selectJoinRkInfo(param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@ public class HdInventoryController {
|
||||
@Autowired
|
||||
private IRkInfoService rkInfoService;
|
||||
|
||||
// @ApiModelProperty("开始匹配")
|
||||
// @PostMapping("/match")
|
||||
// public AjaxResult match(@RequestBody QueryDTO dto) {
|
||||
//
|
||||
// dto.setScanType(0);
|
||||
//
|
||||
//// dto.setDeviceId("0");
|
||||
//
|
||||
// rkInfoService.matchWithStatus(dto);
|
||||
//
|
||||
// return AjaxResult.success();
|
||||
@ApiModelProperty("开始匹配")
|
||||
@PostMapping("/match")
|
||||
public AjaxResult match(@RequestBody QueryDTO dto) {
|
||||
|
||||
// }
|
||||
dto.setScanType(0);
|
||||
|
||||
// dto.setDeviceId("0");
|
||||
|
||||
rkInfoService.matchPure(dto);
|
||||
|
||||
return AjaxResult.success();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,4 +94,5 @@ public interface InventoryTaskMapper
|
||||
* @return
|
||||
*/
|
||||
String selectSceneIdById(String taskId);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class InventoryMatchScan extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@Excel(name = "主键ID")
|
||||
// @Excel(name = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 设备ID */
|
||||
@@ -28,7 +28,7 @@ public class InventoryMatchScan extends BaseEntity {
|
||||
private String taskId;
|
||||
|
||||
/** 扫描标签ID(货品码ID) */
|
||||
@Excel(name = "扫描标签ID")
|
||||
@Excel(name = "库位号")
|
||||
private String pcode;
|
||||
|
||||
/** 系统入库时间 */
|
||||
@@ -44,7 +44,7 @@ public class InventoryMatchScan extends BaseEntity {
|
||||
private String status;
|
||||
|
||||
/** 匹配到的真实货品码 */
|
||||
@Excel(name = "库位号")
|
||||
// @Excel(name = "库位号")
|
||||
private String rkPcode;
|
||||
|
||||
@Excel(name = "盘点任务名称")
|
||||
@@ -115,6 +115,13 @@ public class InventoryMatchScan extends BaseEntity {
|
||||
public void setRkPcode(String rkPcode) {
|
||||
this.rkPcode = rkPcode;
|
||||
}
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -128,6 +135,7 @@ public class InventoryMatchScan extends BaseEntity {
|
||||
.append("scanType", getScanType())
|
||||
.append("status", getStatus())
|
||||
.append("rkPcode", getRkPcode())
|
||||
.append("taskName", getTaskName())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,6 @@ public class RkRecordController extends BaseController
|
||||
* 更新配送状态
|
||||
*/
|
||||
@PostMapping("/updateDeliveryStatus")
|
||||
@Log(title = "更新配送状态", businessType = BusinessType.UPDATE)
|
||||
public AjaxResult updateDeliveryStatus(@RequestBody RkDeliveryUpdateDTO dto) {
|
||||
|
||||
if (dto.getIds() == null || dto.getIds().isEmpty()) {
|
||||
@@ -190,6 +189,7 @@ public class RkRecordController extends BaseController
|
||||
}
|
||||
|
||||
int rows = rkRecordService.updateDeliveryStatus(dto.getIds(), dto.getIsDelivery());
|
||||
|
||||
return AjaxResult.success(rows);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class RkInfo extends BaseEntity
|
||||
private Long sid;
|
||||
|
||||
/** 配送状态:0否 1是 2待接单 3配送中 4配送完成 */
|
||||
@Excel(name = "是否需要配送", readConverterExp = "0否,1是,2配送中,3配送完成")
|
||||
@Excel(name = "是否需要配送", readConverterExp = "0=否,1=是,2=待配送,3=配送中,4=配送完成")
|
||||
private String isDelivery;
|
||||
|
||||
/** 封样编号1 */
|
||||
|
||||
@@ -239,14 +239,14 @@ public class RkRecord extends BaseEntity
|
||||
private Long sid;
|
||||
|
||||
/** 配送状态:0否 1是 2待接单 3配送中 4配送完成 */
|
||||
@Excel(name = "是否需要配送", readConverterExp = "0=否,1=是,2=已接单,3=配送中,4=配送完成")
|
||||
@Excel(name = "是否需要配送", readConverterExp = "0=否,1=是,2=待配送,3=配送中,4=配送完成")
|
||||
private String isDelivery;
|
||||
/** 封样编号1 */
|
||||
// @Excel(name = "封样编号1")
|
||||
private String fycde1;
|
||||
|
||||
/** 封样编号2 */
|
||||
// @Excel(name = "封样编号2")
|
||||
// @Excel(name = "封样编号2")2
|
||||
private String fycde2;
|
||||
|
||||
/** 1已更新 */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zg.project.wisdom.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -160,4 +161,15 @@ public interface RkInfoMapper
|
||||
* 查询库存单据明细列表(按单据号排序)
|
||||
*/
|
||||
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
|
||||
|
||||
/**
|
||||
* 根据仓库和场景查询库存单据明细
|
||||
*/
|
||||
List<RkInfo> getByWarehouseAndScene(
|
||||
@Param("warehouseCode") String warehouseCode,
|
||||
@Param("sceneId") String sceneId
|
||||
);
|
||||
|
||||
|
||||
List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings);
|
||||
}
|
||||
|
||||
@@ -166,5 +166,14 @@ public interface RkRecordMapper
|
||||
*/
|
||||
int countDifferentDeliveryStatus(@Param("billNo") String billNo,
|
||||
@Param("isDelivery") Integer isDelivery);
|
||||
/**
|
||||
* 根据 billNo 批量更新 record 明细
|
||||
*/
|
||||
int updateRecordByBillNo(RkRecord record);
|
||||
|
||||
/**
|
||||
* 查询bill最小配送状态
|
||||
*/
|
||||
Integer selectMinDeliveryStatusByBillNo(
|
||||
@Param("billNo") String billNo);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zg.project.wisdom.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zg.project.inventory.domain.dto.QueryDTO;
|
||||
@@ -76,6 +77,13 @@ public interface IRkInfoService
|
||||
*/
|
||||
void matchWithStatus(QueryDTO dto);
|
||||
|
||||
/**
|
||||
* 盘点开始匹配(纯数据)
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
void matchPure(QueryDTO dto);
|
||||
|
||||
/**
|
||||
* 图表统计:每个库位有多少个货物
|
||||
* @param dto
|
||||
@@ -101,4 +109,11 @@ public interface IRkInfoService
|
||||
* 查询库存单据明细列表(按单据号排序)
|
||||
*/
|
||||
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
|
||||
|
||||
/**
|
||||
* 按多个pcode查询
|
||||
* @param strings
|
||||
* @return
|
||||
*/
|
||||
List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.zg.project.wisdom.mapper.AgvWcsMapper;
|
||||
import com.zg.project.wisdom.mapper.DdTaskMapper;
|
||||
import com.zg.project.wisdom.mapper.WcsTaskResultMapper;
|
||||
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.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -27,13 +28,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.zg.framework.datasource.DynamicDataSourceContextHolder.log;
|
||||
|
||||
/**
|
||||
* 调度任务 Service 实现类
|
||||
*
|
||||
* @author zg
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DdTaskServiceImpl implements IDdTaskService {
|
||||
|
||||
|
||||
@@ -438,11 +438,35 @@ public class RkBillServiceImpl implements IRkBillService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRkBill(RkBill rkBill)
|
||||
{
|
||||
return rkBillMapper.updateRkBill(rkBill);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateRkBill(RkBill 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除库存单据
|
||||
*
|
||||
|
||||
@@ -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.domain.dto.QueryDTO;
|
||||
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.PcdeCntVO;
|
||||
import com.zg.project.wisdom.domain.vo.StockStatisticVO;
|
||||
@@ -234,6 +235,79 @@ public class RkInfoServiceImpl implements IRkInfoService
|
||||
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
|
||||
@@ -276,4 +350,11 @@ public class RkInfoServiceImpl implements IRkInfoService
|
||||
{
|
||||
return rkInfoMapper.selectRkInfoListOrderByBillNo(rkInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RkInfo> listRkInfoByPcodes(ArrayList<String> strings) {
|
||||
return rkInfoMapper.listRkInfoByPcodes(strings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -804,35 +804,57 @@ public class RkRecordServiceImpl implements IRkRecordService
|
||||
|
||||
@Override
|
||||
@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()) {
|
||||
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()) {
|
||||
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 (diffCount == 0) {
|
||||
rkBillMapper.updateDeliveryStatusByBillNo(billNo, isDelivery);
|
||||
if (billStatus != null)
|
||||
{
|
||||
rkBillMapper.updateDeliveryStatusByBillNo(
|
||||
billNo,
|
||||
billStatus
|
||||
);
|
||||
}
|
||||
// 否则:保持原状态(不动)
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ spring:
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码
|
||||
# password: shzg
|
||||
password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
|
||||
@@ -273,4 +273,17 @@
|
||||
ORDER BY MAX(r.create_time) DESC
|
||||
</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>
|
||||
|
||||
@@ -101,53 +101,73 @@
|
||||
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="remark != null and remark != ''">
|
||||
AND ri.remark LIKE CONCAT('%', #{remark}, '%')
|
||||
</if>
|
||||
|
||||
<if test="isDelete != null and isDelete != ''">
|
||||
AND ri.is_delete = #{isDelete}
|
||||
</if>
|
||||
<!-- 出入库时间范围 -->
|
||||
|
||||
<if test="startDate != null">
|
||||
AND ri.operation_time >= #{startDate}
|
||||
</if>
|
||||
|
||||
<if test="endDate != null">
|
||||
AND ri.operation_time <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
ORDER BY ri.operation_time DESC
|
||||
</select>
|
||||
|
||||
@@ -571,4 +591,32 @@
|
||||
ri.sap_no ASC
|
||||
</select>
|
||||
|
||||
<select id="getByWarehouseAndScene" resultMap="RkInfoResult">
|
||||
SELECT
|
||||
ri.*
|
||||
FROM rk_info ri
|
||||
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>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -282,7 +282,7 @@
|
||||
<include refid="selectRkRecordVo"/>
|
||||
WHERE rr.bill_no = #{billNo}
|
||||
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
|
||||
</select>
|
||||
|
||||
<select id="selectRkRecordByIds" resultMap="RkRecordResult">
|
||||
@@ -892,4 +892,43 @@
|
||||
AND is_delivery != #{isDelivery}
|
||||
</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>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user