0729接口逻辑修改

This commit is contained in:
2025-07-29 16:18:53 +08:00
parent 0696040874
commit 20f6be7790
17 changed files with 225 additions and 686 deletions

View File

@@ -8,16 +8,11 @@ import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.Base64; import java.util.Base64;
import java.util.UUID; import java.util.UUID;
import java.util.Date;
/**
* MinIO 工具类(支持上传并设置 bucket 公共访问权限)
*/
@Component @Component
public class MinioUtil { public class MinioUtil {
@@ -44,29 +39,30 @@ public class MinioUtil {
} }
/** /**
* 上传文件到指定 bucket 的指定目录(自动设置公共权限) * 自动生成今日目录yyyy-MM-dd/
* */
* @param file 上传的文件 private String getTodayFolder() {
* @param bucketName bucket 名称 return DateUtils.parseDateToStr("yyyy-MM-dd", DateUtils.getNowDate()) + "/";
* @param folder 目录前缀(如 "signature/" }
* @return 返回公网可访问的 URL
* @throws Exception 异常 /**
* 上传文件到指定 bucket 和目录
*/ */
public String upload(MultipartFile file, String bucketName, String folder) throws Exception { public String upload(MultipartFile file, String bucketName, String folder) throws Exception {
String originalName = file.getOriginalFilename(); String originalName = file.getOriginalFilename();
String ext = originalName != null && originalName.contains(".") String ext = (originalName != null && originalName.contains("."))
? originalName.substring(originalName.lastIndexOf(".")) ? originalName.substring(originalName.lastIndexOf("."))
: ""; : "";
String objectName = folder + UUID.randomUUID().toString().replace("-", "") + ext; String objectName = folder + UUID.randomUUID().toString().replace("-", "") + ext;
try (InputStream in = file.getInputStream()) { try (InputStream in = file.getInputStream()) {
// 如果 bucket 不存在,则创建 // 检查或创建 bucket
boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
if (!exists) { if (!exists) {
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
} }
// 强制设置 bucket 策略为 public-read幂等 // 设置 bucket 公共策略
String policyJson = "{\n" + String policyJson = "{\n" +
" \"Version\":\"2012-10-17\",\n" + " \"Version\":\"2012-10-17\",\n" +
" \"Statement\":[\n" + " \"Statement\":[\n" +
@@ -79,14 +75,12 @@ public class MinioUtil {
" ]\n" + " ]\n" +
"}"; "}";
minioClient.setBucketPolicy( minioClient.setBucketPolicy(SetBucketPolicyArgs.builder()
SetBucketPolicyArgs.builder()
.bucket(bucketName) .bucket(bucketName)
.config(policyJson) .config(policyJson)
.build() .build());
);
// 上传文件 // 上传
minioClient.putObject(PutObjectArgs.builder() minioClient.putObject(PutObjectArgs.builder()
.bucket(bucketName) .bucket(bucketName)
.object(objectName) .object(objectName)
@@ -97,19 +91,21 @@ public class MinioUtil {
return endpoint + "/" + bucketName + "/" + objectName; return endpoint + "/" + bucketName + "/" + objectName;
} }
/**
* 上传 Base64 图片到指定 bucket 和目录
*/
public String uploadBase64(String imgStr, String bucketName, String folder) { public String uploadBase64(String imgStr, String bucketName, String folder) {
try { try {
String objectName = folder + UUID.randomUUID().toString().replace("-", "") + ".png"; String objectName = folder + UUID.randomUUID().toString().replace("-", "") + ".png";
imgStr = imgStr.replace("data:image/png;base64,", "").replace("data:image/jpeg;base64,", ""); imgStr = imgStr.replace("data:image/png;base64,", "").replace("data:image/jpeg;base64,", "");
byte[] imageBytes = Base64.getDecoder().decode(imgStr); byte[] imageBytes = Base64.getDecoder().decode(imgStr);
// 确保 bucket 存在
boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
if (!exists) { if (!exists) {
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
} }
// 设置公共访问策略(幂等)
String policyJson = "{\n" + String policyJson = "{\n" +
" \"Version\":\"2012-10-17\",\n" + " \"Version\":\"2012-10-17\",\n" +
" \"Statement\":[\n" + " \"Statement\":[\n" +
@@ -122,14 +118,11 @@ public class MinioUtil {
" ]\n" + " ]\n" +
"}"; "}";
minioClient.setBucketPolicy( minioClient.setBucketPolicy(SetBucketPolicyArgs.builder()
SetBucketPolicyArgs.builder()
.bucket(bucketName) .bucket(bucketName)
.config(policyJson) .config(policyJson)
.build() .build());
);
// 构造 InputStream 上传
try (InputStream inputStream = new java.io.ByteArrayInputStream(imageBytes)) { try (InputStream inputStream = new java.io.ByteArrayInputStream(imageBytes)) {
minioClient.putObject(PutObjectArgs.builder() minioClient.putObject(PutObjectArgs.builder()
.bucket(bucketName) .bucket(bucketName)
@@ -147,17 +140,30 @@ public class MinioUtil {
} }
/** /**
* 上传文件到默认 bucket 根目录 * 默认 bucket 上传
*/ */
public String upload(MultipartFile file) throws Exception { public String upload(MultipartFile file) throws Exception {
return upload(file, defaultBucket, ""); return upload(file, defaultBucket, "");
} }
/** /**
* 上传文件到默认 bucket 指定目录 * 默认 bucket 指定目录上传
*/ */
public String upload(MultipartFile file, String folder) throws Exception { public String upload(MultipartFile file, String folder) throws Exception {
return upload(file, defaultBucket, folder); return upload(file, defaultBucket, folder);
} }
/**
* 默认 bucket按日期目录上传MultipartFile
*/
public String uploadToDateFolder(MultipartFile file) throws Exception {
return upload(file, defaultBucket, getTodayFolder());
}
/**
* 默认 bucket按日期目录上传Base64
*/
public String uploadBase64ToDateFolder(String imgStr) {
return uploadBase64(imgStr, defaultBucket, getTodayFolder());
}
} }

View File

@@ -37,7 +37,7 @@ public class DeviceInfoController extends BaseController
/** /**
* 查询设备信息列表 * 查询设备信息列表
*/ */
// @PreAuthorize("@ss.hasPermi('information:device:list')") @PreAuthorize("@ss.hasPermi('information:device:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(DeviceInfo deviceInfo) public TableDataInfo list(DeviceInfo deviceInfo)
{ {

View File

@@ -28,7 +28,7 @@ public class GysJhController extends BaseController
@Autowired @Autowired
private IGysJhService gysJhService; private IGysJhService gysJhService;
/** /**A
* 查询供应计划列表 * 查询供应计划列表
*/ */
@PreAuthorize("@ss.hasPermi('plan:jh:list')") @PreAuthorize("@ss.hasPermi('plan:jh:list')")

View File

@@ -35,7 +35,7 @@ public class MoveRecordController extends BaseController
/** /**
* 新增移库记录 * 新增移库记录
*/ */
@PreAuthorize("@ss.hasPermi('inventory:move:add')") @PreAuthorize("@ss.hasPermi('wisdom:stock:move')")
@Log(title = "移库记录", businessType = BusinessType.INSERT) @Log(title = "移库记录", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
public AjaxResult processMove(@RequestBody MoveRequestDTO dto) { public AjaxResult processMove(@RequestBody MoveRequestDTO dto) {
@@ -47,7 +47,7 @@ public class MoveRecordController extends BaseController
/** /**
* 查询移库记录列表 * 查询移库记录列表
*/ */
@PreAuthorize("@ss.hasPermi('inventory:move:list')") @PreAuthorize("@ss.hasPermi('wisdom:move:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(MoveRecord moveRecord) public TableDataInfo list(MoveRecord moveRecord)
{ {

View File

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

View File

@@ -73,9 +73,10 @@ public interface GysJhMapper
/** /**
* 修改状态 * 修改状态
* @param gysJhId * @param gysJhId 主键ID
* @param status 状态值1=全部入库2=部分入库)
*/ */
void updateStatusById(Long gysJhId); void updateStatusById(@Param("id") Long gysJhId, @Param("status") String status);
/** /**
* 重置状态 * 重置状态

View File

@@ -175,7 +175,7 @@ public class AuditSignatureServiceImpl implements IAuditSignatureService
.collect(Collectors.toSet()); .collect(Collectors.toSet());
for (Long jhId : jhIdSet) { for (Long jhId : jhIdSet) {
gysJhMapper.updateStatusById(jhId); gysJhMapper.updateStatusById(jhId,"1");
} }
} }

View File

@@ -10,11 +10,13 @@ import com.zg.common.utils.http.HttpUtils;
import com.zg.framework.web.domain.AjaxResult; import com.zg.framework.web.domain.AjaxResult;
import com.zg.project.information.mapper.MtdMapper; import com.zg.project.information.mapper.MtdMapper;
import com.zg.project.wisdom.domain.AgvTaskResult; import com.zg.project.wisdom.domain.AgvTaskResult;
import com.zg.project.wisdom.domain.AgyWcs;
import com.zg.project.wisdom.domain.DdTask; import com.zg.project.wisdom.domain.DdTask;
import com.zg.project.wisdom.domain.WcsTaskResult; import com.zg.project.wisdom.domain.WcsTaskResult;
import com.zg.project.wisdom.domain.dto.TaskExecuteDTO; import com.zg.project.wisdom.domain.dto.TaskExecuteDTO;
import com.zg.project.wisdom.domain.vo.TaskExecuteResultVO; import com.zg.project.wisdom.domain.vo.TaskExecuteResultVO;
import com.zg.project.wisdom.mapper.AgvTaskResultMapper; import com.zg.project.wisdom.mapper.AgvTaskResultMapper;
import com.zg.project.wisdom.mapper.AgyWcsMapper;
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;
@@ -52,6 +54,9 @@ public class DdTaskServiceImpl implements IDdTaskService {
@Autowired @Autowired
private MtdMapper mtdMapper; private MtdMapper mtdMapper;
@Autowired
private AgyWcsMapper agyWcsMapper;
// //
// @Value("${agv.job.create-url}") // @Value("${agv.job.create-url}")
// private String agvJobCreateUrl; // private String agvJobCreateUrl;
@@ -126,17 +131,20 @@ public class DdTaskServiceImpl implements IDdTaskService {
return ddTaskMapper.deleteDdTaskById(id); return ddTaskMapper.deleteDdTaskById(id);
} }
/**
* 执行任务
*/
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public TaskExecuteResultVO executeTask(TaskExecuteDTO dto) { public TaskExecuteResultVO executeTask(TaskExecuteDTO dto) {
Long id = dto.getId(); Long id = dto.getId();
String targetName = dto.getTargetName(); String targetName = dto.getTargetName();
Integer materialStatus = dto.getMaterialStatus(); // Materialstatus 前端传入 Integer materialStatus = dto.getMaterialStatus();
if (StringUtils.isBlank(targetName)) { if (StringUtils.isBlank(targetName)) {
throw new ServiceException("targetName 不能为空"); throw new ServiceException("targetName 不能为空");
} }
// 1. 查询任务
DdTask task = ddTaskMapper.selectDdTaskById(id); DdTask task = ddTaskMapper.selectDdTaskById(id);
if (task == null) { if (task == null) {
throw new ServiceException("任务不存在ID = " + id); throw new ServiceException("任务不存在ID = " + id);
@@ -146,84 +154,99 @@ public class DdTaskServiceImpl implements IDdTaskService {
} }
String taskNo = task.getTaskNo(); String taskNo = task.getTaskNo();
String taskType = task.getTaskType(); // 0入库1出库2移库 String taskType = task.getTaskType();
String requestId = null; // ✅ AGV 使用 String requestId = null;
String taskIdParam = null; // ✅ WCS 使用,提前声明防作用域错误 String taskIdParam = null;
String response; String response;
int code; int code;
String msg; String msg;
String userId = SecurityUtils.getUserId().toString();
Date now = DateUtils.getNowDate();
// 2. 构造参数 if ("1".equals(taskType)) {
JSONObject param = new JSONObject(); // 出库任务:先调 WCS
param.put("owner", "wms");
param.put("type", taskType);
param.put("priority", 1);
param.put("sourceName", task.getSourceName());
param.put("targetName", targetName);
if ("0".equals(taskType) || "2".equals(taskType)) {
// ✅ 入库/移库 → AGV
requestId = taskNo + ("0".equals(taskType) ? "11" : "12"); // 拼接规则11 入库12 移库
param.put("taskNo", taskNo);
param.put("requestId", requestId);
log.info("[任务执行] 类型={}AGVrequestId={}, param={}", taskType, requestId, param);
response = HttpUtils.sendPost(agvJobCreateUrl, param.toJSONString());
} else if ("1".equals(taskType)) {
// ✅ 出库 → WCS下架不传 requestId只传 TaskID
taskIdParam = taskNo + "22"; taskIdParam = taskNo + "22";
param.put("TaskID", taskIdParam); JSONObject wcsParam = new JSONObject();
param.put("Materialstatus", materialStatus); wcsParam.put("TaskID", taskIdParam);
param.put("outBack", 1); wcsParam.put("TaskType", 2);
param.put("TrayNo", ""); wcsParam.put("Mlocation", task.getSourceName());
param.put("Mlocation", task.getSourceName()); wcsParam.put("TrayNo", "");
wcsParam.put("Materialstatus", materialStatus);
wcsParam.put("outBack", 1);
if (materialStatus == 0) { if (materialStatus == 0) {
param.put("MaterialCode", ""); wcsParam.put("MaterialCode", "");
param.put("Specification", ""); wcsParam.put("Specification", "");
param.put("Quantity", ""); wcsParam.put("Quantity", "");
} else { } else {
String materialCode = task.getMid(); String materialCode = task.getMid();
String quantity = task.getNum().toString(); String quantity = task.getNum().toString();
String specification = mtdMapper.selectWlmsByWlbh(materialCode); String specification = mtdMapper.selectWlmsByWlbh(materialCode);
param.put("MaterialCode", materialCode); wcsParam.put("MaterialCode", materialCode);
param.put("Quantity", quantity); wcsParam.put("Quantity", quantity);
param.put("Specification", specification == null ? "" : specification); wcsParam.put("Specification", specification == null ? "" : specification);
} }
log.info("[任务执行] 类型=出库WCS下架TaskID={}, param={}", taskIdParam, param); log.info("[任务执行] 出库 → 调用WCStaskId={}, param={}", taskIdParam, wcsParam);
response = HttpUtils.sendPost(wcsJobCreateUrl, param.toJSONString()); response = HttpUtils.sendPost(wcsJobCreateUrl, wcsParam.toJSONString());
} else { System.out.println("这是打印的出库时调用wcs的响应结果" + response);
throw new ServiceException("未知任务类型: " + taskType);
}
// 3. 解析响应
JSONObject respJson; JSONObject respJson;
try { try {
respJson = JSON.parseObject(response); respJson = JSON.parseObject(response);
code = respJson.getInteger("code"); code = respJson.getInteger("code");
msg = respJson.getString("msg"); msg = respJson.getString("msg");
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("响应解析失败: " + response); throw new ServiceException("WCS响应解析失败: " + response);
} }
if (code != 200) { if (code != 200) {
throw new ServiceException("任务执行失败: " + msg); throw new ServiceException("WCS任务执行失败: " + msg);
} }
// 4. 更新任务状态为已提交 // 写入 WCS 执行记录
task.setTaskStatus(1); WcsTaskResult wcs = new WcsTaskResult();
task.setDoCount(Optional.ofNullable(task.getDoCount()).orElse(0) + 1); wcs.setTaskId(taskIdParam);
task.setUpdateBy(SecurityUtils.getUserId().toString()); wcs.setTaskStatus("1");
task.setUpdateTime(DateUtils.getNowDate()); wcs.setMsg(msg);
ddTaskMapper.updateDdTask(task); wcs.setOwner("wms");
wcs.setType(taskType);
wcs.setPriority("1");
wcs.setSourceName(task.getSourceName());
wcs.setTargetName(targetName);
wcs.setIsDelete("0");
wcs.setCreateBy(userId);
wcs.setCreateTime(now);
wcs.setUpdateTime(now);
wcsTaskResultMapper.insertWcsTaskResult(wcs);
// 5. 写入执行记录 // 调用 AGV立即
String userId = SecurityUtils.getUserId().toString(); requestId = taskNo + "12";
Date now = DateUtils.getNowDate(); JSONObject agvParam = new JSONObject();
agvParam.put("owner", "wms");
agvParam.put("type", "1");
agvParam.put("priority", 1);
agvParam.put("sourceName", task.getSourceName());
agvParam.put("targetName", targetName);
agvParam.put("taskNo", taskNo);
agvParam.put("requestId", requestId);
log.info("[任务执行] 出库 → 调用AGVrequestId={}, param={}", requestId, agvParam);
response = HttpUtils.sendPost(agvJobCreateUrl, agvParam.toJSONString());
try {
respJson = JSON.parseObject(response);
code = respJson.getInteger("code");
msg = respJson.getString("msg");
} catch (Exception e) {
throw new ServiceException("AGV响应解析失败: " + response);
}
if (code != 200) {
throw new ServiceException("AGV任务执行失败: " + msg);
}
if ("0".equals(taskType) || "2".equals(taskType)) {
AgvTaskResult agv = new AgvTaskResult(); AgvTaskResult agv = new AgvTaskResult();
agv.setRequestId(requestId); agv.setRequestId(requestId);
agv.setTaskNo(taskNo); agv.setTaskNo(taskNo);
@@ -239,27 +262,61 @@ public class DdTaskServiceImpl implements IDdTaskService {
agv.setCreateTime(now); agv.setCreateTime(now);
agv.setUpdateTime(now); agv.setUpdateTime(now);
agvTaskResultMapper.insertAgvTaskResult(agv); agvTaskResultMapper.insertAgvTaskResult(agv);
} else if ("1".equals(taskType)) {
WcsTaskResult wcs = new WcsTaskResult(); // ✅ 保存 WCS 与 AGV 映射关系
wcs.setTaskId(taskIdParam); AgyWcs mapping = new AgyWcs();
wcs.setTaskStatus("1"); mapping.setRequestId(requestId);
wcs.setMsg(msg); mapping.setTaskId(taskIdParam);
wcs.setJobId(null); agyWcsMapper.insertAgyWcs(mapping);
wcs.setOwner("wms");
wcs.setType(taskType); } else {
wcs.setPriority("1"); // 入库/移库任务 → 调用 AGV
wcs.setSourceName(task.getSourceName()); requestId = taskNo + ("0".equals(taskType) ? "11" : "12");
wcs.setTargetName(targetName); JSONObject param = new JSONObject();
wcs.setIsDelete("0"); param.put("owner", "wms");
wcs.setCreateBy(userId); param.put("type", taskType);
wcs.setCreateTime(now); param.put("priority", 1);
wcs.setUpdateTime(now); param.put("sourceName", task.getSourceName());
wcsTaskResultMapper.insertWcsTaskResult(wcs); param.put("targetName", targetName);
param.put("taskNo", taskNo);
param.put("requestId", requestId);
log.info("[任务执行] 类型={}AGVrequestId={}, param={}", taskType, requestId, param);
response = HttpUtils.sendPost(agvJobCreateUrl, param.toJSONString());
JSONObject respJson = JSON.parseObject(response);
code = respJson.getInteger("code");
msg = respJson.getString("msg");
if (code != 200) {
throw new ServiceException("任务执行失败: " + msg);
} }
// 6. 返回执行结果 AgvTaskResult agv = new AgvTaskResult();
agv.setRequestId(requestId);
agv.setTaskNo(taskNo);
agv.setStatus("CREATED");
agv.setMsg(msg);
agv.setOwner("wms");
agv.setType(taskType);
agv.setPriority("1");
agv.setSourceName(task.getSourceName());
agv.setTargetName(targetName);
agv.setIsDelete("0");
agv.setCreateBy(userId);
agv.setCreateTime(now);
agv.setUpdateTime(now);
agvTaskResultMapper.insertAgvTaskResult(agv);
}
task.setTaskStatus(1);
task.setDoCount(Optional.ofNullable(task.getDoCount()).orElse(0) + 1);
task.setUpdateBy(userId);
task.setUpdateTime(now);
ddTaskMapper.updateDdTask(task);
TaskExecuteResultVO vo = new TaskExecuteResultVO(); TaskExecuteResultVO vo = new TaskExecuteResultVO();
vo.setRequestId(("0".equals(taskType) || "2".equals(taskType)) ? requestId : null); vo.setRequestId(requestId);
vo.setCode(code); vo.setCode(code);
vo.setMsg(msg); vo.setMsg(msg);
return vo; return vo;

View File

@@ -188,11 +188,13 @@ public class RkInfoServiceImpl implements IRkInfoService
(a, b) -> b (a, b) -> b
)); ));
// ✅ 第2步:查询对应供应计划 // ✅ 第2-4步若包含供应计划ID则处理计划扣减与状态更新
if (!realQtyMap.isEmpty()) {
// ✅ 查询对应供应计划
List<GysJh> jhList = gysJhMapper.selectByIds(new ArrayList<>(realQtyMap.keySet())); List<GysJh> jhList = gysJhMapper.selectByIds(new ArrayList<>(realQtyMap.keySet()));
Set<Long> idsToUpdateStatus = new HashSet<>(); Set<Long> idsToUpdateStatus = new HashSet<>();
// ✅ 第3步更新 jh_qty 和 status根据是否开启审核判断逻辑 // ✅ 更新 jh_qty 和 status根据是否开启审核判断逻辑
for (GysJh jh : jhList) { for (GysJh jh : jhList) {
Long jhId = jh.getId(); Long jhId = jh.getId();
BigDecimal planQty = BigDecimal.valueOf(jh.getJhQty()); BigDecimal planQty = BigDecimal.valueOf(jh.getJhQty());
@@ -202,19 +204,24 @@ public class RkInfoServiceImpl implements IRkInfoService
boolean isEqual = realQty.compareTo(planQty) == 0; boolean isEqual = realQty.compareTo(planQty) == 0;
if (!isEqual) { if (!isEqual) {
// 实到数量小于计划数量,执行扣减 + 设为部分入库2
gysJhMapper.decreaseJhQtyById(jhId, realQty); gysJhMapper.decreaseJhQtyById(jhId, realQty);
idsToUpdateStatus.add(jhId);
} else {
if (!needAudit) { if (!needAudit) {
idsToUpdateStatus.add(jhId); gysJhMapper.updateStatusById(jhId, "2"); // 2 = 部分入库
}
} else {
// 实到数量等于计划数量状态设为全部入库1不做扣减
if (!needAudit) {
gysJhMapper.updateStatusById(jhId, "1"); // 1 = 全部入库
} }
} }
} }
// ✅ 第4步批量更新 status = 2 // ✅ 批量更新 status = 2
if (!idsToUpdateStatus.isEmpty()) { if (!idsToUpdateStatus.isEmpty()) {
gysJhMapper.batchUpdateStatusByIds(idsToUpdateStatus); gysJhMapper.batchUpdateStatusByIds(idsToUpdateStatus);
} }
}
// ✅ 第5步构建 RkInfo 入库记录 // ✅ 第5步构建 RkInfo 入库记录
for (PcRkInfoItemDTO item : list) { for (PcRkInfoItemDTO item : list) {
@@ -299,6 +306,7 @@ public class RkInfoServiceImpl implements IRkInfoService
} }
} }
/** /**
* 新增入库单据APP * 新增入库单据APP
* @param dto * @param dto
@@ -346,13 +354,15 @@ public class RkInfoServiceImpl implements IRkInfoService
boolean isEqual = realQty.compareTo(planQty) == 0; boolean isEqual = realQty.compareTo(planQty) == 0;
if (!isEqual) { if (!isEqual) {
// 数量不相等,减数量 + 状态设为 2 // 实到数量小于计划数量,执行扣减 + 设为部分入库2
gysJhMapper.decreaseJhQtyById(jhId, realQty); gysJhMapper.decreaseJhQtyById(jhId, realQty);
idsToUpdateStatus.add(jhId);
} else {
if (!needAudit) { if (!needAudit) {
// 审核关闭且数量相等,仅更新状态 gysJhMapper.updateStatusById(jhId, "2"); // 2 = 部分入库
idsToUpdateStatus.add(jhId); }
} else {
// 实到数量等于计划数量状态设为全部入库1不做扣减
if (!needAudit) {
gysJhMapper.updateStatusById(jhId, "1"); // 1 = 全部入库
} }
} }
} }

View File

@@ -1,104 +0,0 @@
package com.zg.project.information.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zg.framework.aspectj.lang.annotation.Log;
import com.zg.framework.aspectj.lang.enums.BusinessType;
import com.zg.project.information.domain.MaterialType;
import com.zg.project.information.service.IMaterialTypeService;
import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult;
import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.page.TableDataInfo;
/**
* 物资类型Controller
*
* @author zg
* @date 2025-05-27
*/
@RestController
@RequestMapping("/information/materialtype")
public class MaterialTypeController extends BaseController
{
@Autowired
private IMaterialTypeService materialTypeService;
/**
* 查询物资类型列表
*/
@PreAuthorize("@ss.hasPermi('information:materialtype:list')")
@GetMapping("/list")
public TableDataInfo list(MaterialType materialType)
{
startPage();
List<MaterialType> list = materialTypeService.selectMaterialTypeList(materialType);
return getDataTable(list);
}
/**
* 导出物资类型列表
*/
@PreAuthorize("@ss.hasPermi('information:materialtype:export')")
@Log(title = "物资类型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MaterialType materialType)
{
List<MaterialType> list = materialTypeService.selectMaterialTypeList(materialType);
ExcelUtil<MaterialType> util = new ExcelUtil<MaterialType>(MaterialType.class);
util.exportExcel(response, list, "物资类型数据");
}
/**
* 获取物资类型详细信息
*/
@PreAuthorize("@ss.hasPermi('information:materialtype:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(materialTypeService.selectMaterialTypeById(id));
}
/**
* 新增物资类型
*/
@PreAuthorize("@ss.hasPermi('information:materialtype:add')")
@Log(title = "物资类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MaterialType materialType)
{
return toAjax(materialTypeService.insertMaterialType(materialType));
}
/**
* 修改物资类型
*/
@PreAuthorize("@ss.hasPermi('information:materialtype:edit')")
@Log(title = "物资类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MaterialType materialType)
{
return toAjax(materialTypeService.updateMaterialType(materialType));
}
/**
* 删除物资类型
*/
@PreAuthorize("@ss.hasPermi('information:materialtype:remove')")
@Log(title = "物资类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(materialTypeService.deleteMaterialTypeByIds(ids));
}
}

View File

@@ -1,132 +0,0 @@
package com.zg.project.information.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zg.framework.aspectj.lang.annotation.Excel;
import com.zg.framework.web.domain.BaseEntity;
/**
* 物资类型对象 material_type
*
* @author zg
* @date 2025-05-27
*/
public class MaterialType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 物资类型编码 */
@Excel(name = "物资类型编码")
private String typeCode;
/** 物资类型名称 */
@Excel(name = "物资类型名称")
private String typeName;
/** 状态1=启用0=禁用) */
@Excel(name = "状态", readConverterExp = "1==启用0=禁用")
private Long status;
/** 排序值 */
@Excel(name = "排序值")
private Long sort;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTypeCode(String typeCode)
{
this.typeCode = typeCode;
}
public String getTypeCode()
{
return typeCode;
}
public void setTypeName(String typeName)
{
this.typeName = typeName;
}
public String getTypeName()
{
return typeName;
}
public void setStatus(Long status)
{
this.status = status;
}
public Long getStatus()
{
return status;
}
public void setSort(Long sort)
{
this.sort = sort;
}
public Long getSort()
{
return sort;
}
public void setCreatedAt(Date createdAt)
{
this.createdAt = createdAt;
}
public Date getCreatedAt()
{
return createdAt;
}
public void setUpdatedAt(Date updatedAt)
{
this.updatedAt = updatedAt;
}
public Date getUpdatedAt()
{
return updatedAt;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("typeCode", getTypeCode())
.append("typeName", getTypeName())
.append("status", getStatus())
.append("sort", getSort())
.append("remark", getRemark())
.append("createdAt", getCreatedAt())
.append("updatedAt", getUpdatedAt())
.toString();
}
}

View File

@@ -1,61 +0,0 @@
package com.zg.project.information.mapper;
import java.util.List;
import com.zg.project.information.domain.MaterialType;
/**
* 物资类型Mapper接口
*
* @author zg
* @date 2025-05-27
*/
public interface MaterialTypeMapper
{
/**
* 查询物资类型
*
* @param id 物资类型主键
* @return 物资类型
*/
public MaterialType selectMaterialTypeById(Long id);
/**
* 查询物资类型列表
*
* @param materialType 物资类型
* @return 物资类型集合
*/
public List<MaterialType> selectMaterialTypeList(MaterialType materialType);
/**
* 新增物资类型
*
* @param materialType 物资类型
* @return 结果
*/
public int insertMaterialType(MaterialType materialType);
/**
* 修改物资类型
*
* @param materialType 物资类型
* @return 结果
*/
public int updateMaterialType(MaterialType materialType);
/**
* 删除物资类型
*
* @param id 物资类型主键
* @return 结果
*/
public int deleteMaterialTypeById(Long id);
/**
* 批量删除物资类型
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteMaterialTypeByIds(Long[] ids);
}

View File

@@ -1,61 +0,0 @@
package com.zg.project.information.service;
import java.util.List;
import com.zg.project.information.domain.MaterialType;
/**
* 物资类型Service接口
*
* @author zg
* @date 2025-05-27
*/
public interface IMaterialTypeService
{
/**
* 查询物资类型
*
* @param id 物资类型主键
* @return 物资类型
*/
public MaterialType selectMaterialTypeById(Long id);
/**
* 查询物资类型列表
*
* @param materialType 物资类型
* @return 物资类型集合
*/
public List<MaterialType> selectMaterialTypeList(MaterialType materialType);
/**
* 新增物资类型
*
* @param materialType 物资类型
* @return 结果
*/
public int insertMaterialType(MaterialType materialType);
/**
* 修改物资类型
*
* @param materialType 物资类型
* @return 结果
*/
public int updateMaterialType(MaterialType materialType);
/**
* 批量删除物资类型
*
* @param ids 需要删除的物资类型主键集合
* @return 结果
*/
public int deleteMaterialTypeByIds(Long[] ids);
/**
* 删除物资类型信息
*
* @param id 物资类型主键
* @return 结果
*/
public int deleteMaterialTypeById(Long id);
}

View File

@@ -1,93 +0,0 @@
package com.zg.project.information.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zg.project.information.mapper.MaterialTypeMapper;
import com.zg.project.information.domain.MaterialType;
import com.zg.project.information.service.IMaterialTypeService;
/**
* 物资类型Service业务层处理
*
* @author zg
* @date 2025-05-27
*/
@Service
public class MaterialTypeServiceImpl implements IMaterialTypeService
{
@Autowired
private MaterialTypeMapper materialTypeMapper;
/**
* 查询物资类型
*
* @param id 物资类型主键
* @return 物资类型
*/
@Override
public MaterialType selectMaterialTypeById(Long id)
{
return materialTypeMapper.selectMaterialTypeById(id);
}
/**
* 查询物资类型列表
*
* @param materialType 物资类型
* @return 物资类型
*/
@Override
public List<MaterialType> selectMaterialTypeList(MaterialType materialType)
{
return materialTypeMapper.selectMaterialTypeList(materialType);
}
/**
* 新增物资类型
*
* @param materialType 物资类型
* @return 结果
*/
@Override
public int insertMaterialType(MaterialType materialType)
{
return materialTypeMapper.insertMaterialType(materialType);
}
/**
* 修改物资类型
*
* @param materialType 物资类型
* @return 结果
*/
@Override
public int updateMaterialType(MaterialType materialType)
{
return materialTypeMapper.updateMaterialType(materialType);
}
/**
* 批量删除物资类型
*
* @param ids 需要删除的物资类型主键
* @return 结果
*/
@Override
public int deleteMaterialTypeByIds(Long[] ids)
{
return materialTypeMapper.deleteMaterialTypeByIds(ids);
}
/**
* 删除物资类型信息
*
* @param id 物资类型主键
* @return 结果
*/
@Override
public int deleteMaterialTypeById(Long id)
{
return materialTypeMapper.deleteMaterialTypeById(id);
}
}

View File

@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zg.project.information.mapper.MaterialTypeMapper">
<resultMap type="MaterialType" id="MaterialTypeResult">
<result property="id" column="id" />
<result property="typeCode" column="type_code" />
<result property="typeName" column="type_name" />
<result property="status" column="status" />
<result property="sort" column="sort" />
<result property="remark" column="remark" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
</resultMap>
<sql id="selectMaterialTypeVo">
select id, type_code, type_name, status, sort, remark, created_at, updated_at from material_type
</sql>
<select id="selectMaterialTypeList" parameterType="MaterialType" resultMap="MaterialTypeResult">
<include refid="selectMaterialTypeVo"/>
<where>
<if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if>
<if test="typeName != null and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
</where>
</select>
<select id="selectMaterialTypeById" parameterType="Long" resultMap="MaterialTypeResult">
<include refid="selectMaterialTypeVo"/>
where id = #{id}
</select>
<insert id="insertMaterialType" parameterType="MaterialType" useGeneratedKeys="true" keyProperty="id">
insert into material_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeCode != null and typeCode != ''">type_code,</if>
<if test="typeName != null and typeName != ''">type_name,</if>
<if test="status != null">status,</if>
<if test="sort != null">sort,</if>
<if test="remark != null">remark,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeCode != null and typeCode != ''">#{typeCode},</if>
<if test="typeName != null and typeName != ''">#{typeName},</if>
<if test="status != null">#{status},</if>
<if test="sort != null">#{sort},</if>
<if test="remark != null">#{remark},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
</trim>
</insert>
<update id="updateMaterialType" parameterType="MaterialType">
update material_type
<trim prefix="SET" suffixOverrides=",">
<if test="typeCode != null and typeCode != ''">type_code = #{typeCode},</if>
<if test="typeName != null and typeName != ''">type_name = #{typeName},</if>
<if test="status != null">status = #{status},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMaterialTypeById" parameterType="Long">
delete from material_type where id = #{id}
</delete>
<delete id="deleteMaterialTypeByIds" parameterType="String">
delete from material_type where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -90,6 +90,7 @@ spring:
# #连接池最大阻塞等待时间(使用负值表示没有限制) # #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms max-wait: -1ms
# token配置 # token配置
token: token:
# 令牌自定义标识 # 令牌自定义标识

View File

@@ -159,10 +159,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<update id="updateStatusById" parameterType="Long"> <update id="updateStatusById" parameterType="map">
update gys_jh UPDATE gys_jh
set status = '1' SET status = #{status}
where id = #{id} WHERE id = #{id}
</update> </update>
<update id="resetGysJhStatusBySapNos"> <update id="resetGysJhStatusBySapNos">