From 88005bf0d437029a839d2a0faad88df722e9936a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=99=93=E4=B8=9C?= <17363321594@163.com> Date: Tue, 14 Oct 2025 15:08:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=85=B7=E7=AE=A1=E7=90=86=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=A6=81=E6=B1=82=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 6 + .../impl/mold/MoldInfoServiceImpl.java | 103 ++++++++++++++---- .../mold/MoldInventoryChangeServiceImpl.java | 20 +++- .../impl/mold/MoldScreenServiceImpl.java | 6 +- 4 files changed, 111 insertions(+), 24 deletions(-) diff --git a/shgx-admin/src/main/resources/application-druid.yml b/shgx-admin/src/main/resources/application-druid.yml index ee463a4..c6e0a1a 100644 --- a/shgx-admin/src/main/resources/application-druid.yml +++ b/shgx-admin/src/main/resources/application-druid.yml @@ -6,9 +6,15 @@ spring: druid: # 主库数据源 master: + # 内网数据库 url: jdbc:mysql://192.168.1.48:3306/shgx_injection_web?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + # 外网数据库 +# url: jdbc:mysql://139.224.232.211:3308/shgx_injection_web?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root + # 内网数据库 password: 123456 + # 外网数据库 +# password: doantech123 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInfoServiceImpl.java b/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInfoServiceImpl.java index c680f85..f807fee 100644 --- a/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInfoServiceImpl.java +++ b/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInfoServiceImpl.java @@ -3,19 +3,18 @@ package com.shgx.system.service.impl.mold; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.shgx.common.utils.DateUtils; +import com.shgx.common.utils.SecurityUtils; import com.shgx.system.domain.dto.mold.LocationQueryDto; import com.shgx.system.domain.dto.mold.MoldQueryDto; -import com.shgx.system.domain.mold.MoldStatusLog; -import com.shgx.system.domain.mold.MoldWarehouseLocationLive; -import com.shgx.system.mapper.mold.MoldStatusLogMapper; -import com.shgx.system.mapper.mold.MoldWarehouseLocationLiveMapper; +import com.shgx.system.domain.mold.*; +import com.shgx.system.mapper.mold.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.shgx.system.mapper.mold.MoldInfoMapper; -import com.shgx.system.domain.mold.MoldInfo; import com.shgx.system.service.mold.IMoldInfoService; +import org.springframework.transaction.annotation.Transactional; /** * 模具基本信息Service业务层处理 @@ -29,12 +28,18 @@ public class MoldInfoServiceImpl implements IMoldInfoService @Autowired private MoldInfoMapper moldInfoMapper; + @Autowired + private MoldWarehouseLocationMapper locationMapper; + @Autowired private MoldWarehouseLocationLiveMapper liveMapper; @Autowired private MoldStatusLogMapper statusLogMapper; + @Autowired + private MoldInventoryChangeLogMapper changeLogMapper; + /** * 查询模具基本信息 * @@ -116,24 +121,26 @@ public class MoldInfoServiceImpl implements IMoldInfoService * @param query 参数 * @return 结果 */ + @Transactional @Override public int updateStatus(MoldQueryDto.MoldStatusChangeQueryDto query) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(MoldInfo::getMoldCode, query.moldCode); - MoldInfo moldInfo = moldInfoMapper.selectOne(wrapper); - if (moldInfo.getStatus().equals('2')) { - throw new RuntimeException("生产中的模具不允许修改状态!"); - } + + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode); + MoldWarehouseLocationLive live = liveMapper.selectOne(lqw); + + // TODO 有可能不在库 +// if (live.getMoldCode().equals(query.moldCode)) { +// throw new RuntimeException(""); +// } // 更新模具信息表 + if (moldInfoMapper.selectOne(new LambdaQueryWrapper().eq(MoldInfo::getMoldCode, query.moldCode)) == null) { + throw new RuntimeException("没有此模具,请输入正确的模具号!"); + } LambdaUpdateWrapper moldInfoWrapper = new LambdaUpdateWrapper<>(); - moldInfoWrapper.set(MoldInfo::getStatus, query.status).eq(MoldInfo::getMoldCode, query.moldCode.trim()); - moldInfoMapper.update(null, moldInfoWrapper); - - // 更新库位实况 - LambdaUpdateWrapper liveWrapper = new LambdaUpdateWrapper<>(); - liveWrapper.set(MoldWarehouseLocationLive::getMoldCode, query.moldCode).eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode.trim()); - liveMapper.update(null, liveWrapper); + moldInfoWrapper.eq(MoldInfo::getMoldCode, query.moldCode).set(MoldInfo::getStatus, query.status); + moldInfoMapper.update(moldInfoWrapper); // 插入模具状态日志 MoldStatusLog log = new MoldStatusLog(); @@ -142,6 +149,64 @@ public class MoldInfoServiceImpl implements IMoldInfoService log.setChangeTime(DateUtils.getNowDate()); statusLogMapper.insert(log); + // 插入出入库日志 + if (!liveMapper.selectOne(new LambdaQueryWrapper().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)).getStatus().equals('1')) { + + } else { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode); + MoldWarehouseLocationLive live1 = liveMapper.selectOne(wrapper); + MoldInventoryChangeLog changeLog = new MoldInventoryChangeLog(); + changeLog.setMoldCode(query.moldCode); + changeLog.setChangeTime(DateUtils.getNowDate()); + changeLog.setCreateTime(DateUtils.getNowDate()); + changeLog.setCreateBy(SecurityUtils.getUsername()); + + if (query.status == '1') { + changeLog.setChangeType('1'); + changeLog.setToLocation(live1.getPositionCode()); + } + if (query.status == '2' || query.status == '3' || query.status == '4') { + changeLog.setChangeType('2'); + changeLog.setFromLocation(live1.getPositionCode()); + } + changeLogMapper.insert(changeLog); + } + // 更新库位表 + if (liveMapper.selectOne(new LambdaQueryWrapper().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)).getStatus().equals(query.status)) { + throw new RuntimeException("不允许将状态设置为原状态!"); + } + String positionCode = liveMapper.selectOne(new LambdaQueryWrapper().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)).getPositionCode(); + MoldWarehouseLocation location = locationMapper.selectOne(new LambdaQueryWrapper().eq(MoldWarehouseLocation::getPositionCode, positionCode)); + if (query.status == '1') { + if (location.getCapacity().equals(location.getCurrentQuantity())) { + throw new RuntimeException("库位里位置已满!不允许修改状态!"); + } + location.setCurrentQuantity(location.getCurrentQuantity() + 1); + if (location.getCapacity().equals(location.getCurrentQuantity())) { + location.setLocationStatus('2'); + } + } + else { + if (location.getCapacity() == 0) { + location.setCapacity(0L); + } + location.setCurrentQuantity(location.getCurrentQuantity() - 1); + if (!location.getCapacity().equals(location.getCurrentQuantity())) { + location.setLocationStatus('1'); + } + } + locationMapper.update(location, new LambdaQueryWrapper().eq(MoldWarehouseLocation::getPositionCode, positionCode)); + + // 更新库位实况 + if (liveMapper.selectOne(new LambdaQueryWrapper().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)) == null) { + throw new RuntimeException("库位里没有此模具!"); + } + LambdaUpdateWrapper liveWrapper = new LambdaUpdateWrapper<>(); + liveWrapper.eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode).set(MoldWarehouseLocationLive::getStatus, query.status); + liveMapper.update(liveWrapper); + return 1; } diff --git a/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInventoryChangeServiceImpl.java b/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInventoryChangeServiceImpl.java index 6fcf4ed..adeac5a 100644 --- a/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInventoryChangeServiceImpl.java +++ b/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldInventoryChangeServiceImpl.java @@ -1,6 +1,7 @@ package com.shgx.system.service.impl.mold; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.shgx.common.utils.DateUtils; import com.shgx.common.utils.SecurityUtils; import com.shgx.system.domain.dto.mold.LocationQueryDto; @@ -41,12 +42,18 @@ public class MoldInventoryChangeServiceImpl implements IMoldInventoryChangeServi public int locationChange(LocationQueryDto.LocationChangeQueryDto query) { /** - * 校验核心参数非空 + * 校验核心参数 */ Assert.notNull(query, "参数query不能为空"); Assert.hasText(query.moldCode, "模具编码moldCode不能为空且不能为空格"); Assert.notNull(query.changeType, "模具状态changeType不能为空"); Assert.notNull(query.status, "模具状态status不能为空"); + if (moldInfoMapper.selectOne(new LambdaQueryWrapper().eq(MoldInfo::getMoldCode, query.moldCode)) == null) { + throw new RuntimeException("没有此模具!请输入正确的模具"); + } + if (locationMapper.selectOne(new LambdaQueryWrapper().eq(MoldWarehouseLocation::getPositionCode, query.positionCode)) == null) { + throw new RuntimeException("没有此库位!请输入正确的库位"); + } /** * 构建查询条件 @@ -150,7 +157,12 @@ public class MoldInventoryChangeServiceImpl implements IMoldInventoryChangeServi /** * 修改库存实况 */ - liveMapper.delete(liveWrapper); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode) + .set(MoldWarehouseLocationLive::getStatus, query.status) + .set(MoldWarehouseLocationLive::getUpdateTime, DateUtils.getNowDate()) + .set(MoldWarehouseLocationLive::getUpdateBy, SecurityUtils.getUsername()); + liveMapper.update(live, updateWrapper); return 1; } @@ -204,6 +216,9 @@ public class MoldInventoryChangeServiceImpl implements IMoldInventoryChangeServi * 库位状态修改 */ // 入库后库位当前存放模具数量+1 + if (location.getCurrentQuantity().equals(location.getCapacity())) { + throw new RuntimeException("库位已满请入其他库"); + } location.setCurrentQuantity(location.getCurrentQuantity() + 1); location.setLocationStatus('1'); // 入库后库位状态判断 @@ -234,6 +249,7 @@ public class MoldInventoryChangeServiceImpl implements IMoldInventoryChangeServi newLive.setStatus(query.status); newLive.setCreateTime(DateUtils.getNowDate()); liveMapper.insert(newLive); + return 1; } diff --git a/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldScreenServiceImpl.java b/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldScreenServiceImpl.java index 4c8cc60..3d376cb 100644 --- a/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldScreenServiceImpl.java +++ b/shgx-system/src/main/java/com/shgx/system/service/impl/mold/MoldScreenServiceImpl.java @@ -156,12 +156,12 @@ public class MoldScreenServiceImpl implements IMoldScreenService { result.monthInNumber = countByTimeAndStatus(monthStart, monthEnd, inStatus); result.monthOutNumber = countByTimeAndStatus(monthStart, monthEnd, outStatus); - resultList.add(result.todayInNumber); resultList.add(result.todayOutNumber); - resultList.add(result.weekInNumber); + resultList.add(result.todayInNumber); resultList.add(result.weekOutNumber); - resultList.add(result.monthInNumber); + resultList.add(result.weekInNumber); resultList.add(result.monthOutNumber); + resultList.add(result.monthInNumber); return resultList; }