模具管理客户要求修正
This commit is contained in:
parent
452722632c
commit
88005bf0d4
@ -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:
|
||||
# 从数据源开关/默认关闭
|
||||
|
||||
@ -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<MoldInfo> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MoldInfo::getMoldCode, query.moldCode);
|
||||
MoldInfo moldInfo = moldInfoMapper.selectOne(wrapper);
|
||||
if (moldInfo.getStatus().equals('2')) {
|
||||
throw new RuntimeException("生产中的模具不允许修改状态!");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<MoldWarehouseLocationLive> 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<MoldInfo>().eq(MoldInfo::getMoldCode, query.moldCode)) == null) {
|
||||
throw new RuntimeException("没有此模具,请输入正确的模具号!");
|
||||
}
|
||||
LambdaUpdateWrapper<MoldInfo> moldInfoWrapper = new LambdaUpdateWrapper<>();
|
||||
moldInfoWrapper.set(MoldInfo::getStatus, query.status).eq(MoldInfo::getMoldCode, query.moldCode.trim());
|
||||
moldInfoMapper.update(null, moldInfoWrapper);
|
||||
|
||||
// 更新库位实况
|
||||
LambdaUpdateWrapper<MoldWarehouseLocationLive> 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<MoldWarehouseLocationLive>().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)).getStatus().equals('1')) {
|
||||
|
||||
} else {
|
||||
LambdaQueryWrapper<MoldWarehouseLocationLive> 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<MoldWarehouseLocationLive>().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)).getStatus().equals(query.status)) {
|
||||
throw new RuntimeException("不允许将状态设置为原状态!");
|
||||
}
|
||||
String positionCode = liveMapper.selectOne(new LambdaQueryWrapper<MoldWarehouseLocationLive>().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)).getPositionCode();
|
||||
MoldWarehouseLocation location = locationMapper.selectOne(new LambdaQueryWrapper<MoldWarehouseLocation>().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<MoldWarehouseLocation
|
||||
>().eq(MoldWarehouseLocation::getPositionCode, positionCode));
|
||||
|
||||
// 更新库位实况
|
||||
if (liveMapper.selectOne(new LambdaQueryWrapper<MoldWarehouseLocationLive>().eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode)) == null) {
|
||||
throw new RuntimeException("库位里没有此模具!");
|
||||
}
|
||||
LambdaUpdateWrapper<MoldWarehouseLocationLive> liveWrapper = new LambdaUpdateWrapper<>();
|
||||
liveWrapper.eq(MoldWarehouseLocationLive::getMoldCode, query.moldCode).set(MoldWarehouseLocationLive::getStatus, query.status);
|
||||
liveMapper.update(liveWrapper);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -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<MoldInfo>().eq(MoldInfo::getMoldCode, query.moldCode)) == null) {
|
||||
throw new RuntimeException("没有此模具!请输入正确的模具");
|
||||
}
|
||||
if (locationMapper.selectOne(new LambdaQueryWrapper<MoldWarehouseLocation>().eq(MoldWarehouseLocation::getPositionCode, query.positionCode)) == null) {
|
||||
throw new RuntimeException("没有此库位!请输入正确的库位");
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
@ -150,7 +157,12 @@ public class MoldInventoryChangeServiceImpl implements IMoldInventoryChangeServi
|
||||
/**
|
||||
* 修改库存实况
|
||||
*/
|
||||
liveMapper.delete(liveWrapper);
|
||||
LambdaUpdateWrapper<MoldWarehouseLocationLive> 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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user