|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zd.bottle.domain.BottleStorage;
|
|
|
import com.zd.bottle.domain.BottleStorageError;
|
|
|
import com.zd.bottle.domain.UseRecord;
|
|
|
@@ -13,7 +14,6 @@ import com.zd.bottle.mapper.UseRecordMapper;
|
|
|
import com.zd.bottle.service.BottleStorageErrorService;
|
|
|
import com.zd.bottle.service.BottleStorageService;
|
|
|
import com.zd.bottle.service.UseRecordService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zd.bottle.service.UsegasApplyService;
|
|
|
import com.zd.bottle.vo.AirAmount;
|
|
|
import com.zd.bottle.vo.UseRecordVo;
|
|
|
@@ -22,12 +22,11 @@ import com.zd.common.core.constant.HttpStatus;
|
|
|
import com.zd.common.core.constant.SecurityConstants;
|
|
|
import com.zd.common.core.domain.R;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
-import com.zd.common.core.utils.DateUtils;
|
|
|
import com.zd.common.core.utils.SecurityUtils;
|
|
|
import com.zd.common.core.utils.bean.TransferUtils;
|
|
|
import com.zd.common.security.service.TokenService;
|
|
|
-import com.zd.common.security.utils.SaveUtil;
|
|
|
import com.zd.system.api.RemoteUserService;
|
|
|
+import com.zd.system.api.domain.SysUser;
|
|
|
import com.zd.system.api.model.LoginUser;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -71,7 +70,9 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
Long storageId = u.getStorageId();
|
|
|
if (storageMap.containsKey(storageId)) {
|
|
|
BottleStorage bottleStorage = storageMap.get(storageId);
|
|
|
- u.setAirName(bottleStorage.getAirName()).setStorage(bottleStorage);
|
|
|
+ u.setAirName(bottleStorage.getAirName())
|
|
|
+ .setElectronicTag(bottleStorage.getElectronicTag()).setAirNumber(bottleStorage.getAirNumber())
|
|
|
+ .setStorage(bottleStorage);
|
|
|
}
|
|
|
});
|
|
|
return recordVos;
|
|
|
@@ -153,14 +154,15 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
}
|
|
|
//查询用户使用资格
|
|
|
LoginUser user = userInfo.getData();
|
|
|
+ SysUser sysUser = user.getSysUser();
|
|
|
Long storageId = recordDto.getStorageId();
|
|
|
LambdaQueryWrapper<UsegasApply> queryWrapper = Wrappers.lambdaQuery(UsegasApply.class);
|
|
|
- queryWrapper.eq(UsegasApply::getUserId, user.getSysUser().getUserId())
|
|
|
+ queryWrapper.eq(UsegasApply::getUserId, sysUser.getUserId())
|
|
|
.ge(UsegasApply::getEndTime, new Date())
|
|
|
//todo 气体ID待确认
|
|
|
.eq(UsegasApply::getUseGasName, recordDto.getBottleName())
|
|
|
- .eq(UsegasApply::getLeadAuditStaus,1);
|
|
|
- List <UsegasApply> list = usegasApplyService.list(queryWrapper);
|
|
|
+ .eq(UsegasApply::getLeadAuditStaus, 1);
|
|
|
+ List<UsegasApply> list = usegasApplyService.list(queryWrapper);
|
|
|
if (list.isEmpty()) {
|
|
|
result = 3;
|
|
|
}
|
|
|
@@ -174,8 +176,8 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- recordDto.setContacts(user.getSysUser().getNickName())
|
|
|
- .setPhone(user.getSysUser().getPhonenumber())
|
|
|
+ recordDto.setContacts(sysUser.getNickName())
|
|
|
+ .setPhone(sysUser.getPhonenumber())
|
|
|
.setUseTime(Calendar.getInstance().getTime());
|
|
|
UseRecord useRecord = new UseRecord();
|
|
|
BeanUtils.copyProperties(recordDto, useRecord);
|
|
|
@@ -186,7 +188,7 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
}
|
|
|
|
|
|
LambdaUpdateWrapper<BottleStorage> updateWrapper = Wrappers.lambdaUpdate(BottleStorage.class);
|
|
|
- updateWrapper.eq(BottleStorage::getId, useRecord.getStorageId()).set(BottleStorage::getStorageStatus,2);
|
|
|
+ updateWrapper.eq(BottleStorage::getId, useRecord.getStorageId()).set(BottleStorage::getStorageStatus, 2);
|
|
|
Integer isSurplus = recordDto.getIsSurplus();
|
|
|
if (isSurplus == 1) {
|
|
|
// 修改库存中气瓶余量标记
|
|
|
@@ -201,8 +203,8 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
throw new ServiceException("入库数据异常");
|
|
|
}
|
|
|
//设置其他公共字段
|
|
|
- useRecord.setUserId(user.getSysUser().getUserId());
|
|
|
- useRecord.setCommonValue(user.getSysUser().getUserName());
|
|
|
+ useRecord.setUserId(sysUser.getUserId());
|
|
|
+ useRecord.setCommonValue(sysUser.getUserName(),sysUser.getUserId(),sysUser.getDeptId());
|
|
|
if (save(useRecord)) {
|
|
|
return result;
|
|
|
}
|
|
|
@@ -211,11 +213,15 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
|
|
|
@Override
|
|
|
public Integer updateUseRecord(UseRecord useRecord) {
|
|
|
+ R<LoginUser> userInfo = userService.getUserInfo(SecurityUtils.getUsername(), SecurityConstants.INNER);
|
|
|
+ if (userInfo.getCode()!=HttpStatus.SUCCESS || userInfo.getData()==null){
|
|
|
+ throw new ServiceException("未登录或登录失效");
|
|
|
+ }
|
|
|
Long storageId = useRecord.getStorageId();
|
|
|
LambdaQueryWrapper<UseRecord> queryWrapper = Wrappers.lambdaQuery(UseRecord.class);
|
|
|
- queryWrapper.eq(UseRecord::getStorageId,storageId).isNull(UseRecord::getBackTime);
|
|
|
+ queryWrapper.eq(UseRecord::getStorageId, storageId).isNull(UseRecord::getBackTime);
|
|
|
UseRecord temp = getOne(queryWrapper);
|
|
|
- if (temp==null) {
|
|
|
+ if (temp == null) {
|
|
|
throw new ServiceException("数据异常");
|
|
|
}
|
|
|
BigDecimal afterUse = useRecord.getAfterUse();
|
|
|
@@ -235,7 +241,8 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
storageService.updateById(storage);
|
|
|
|
|
|
useRecord.setId(temp.getId());
|
|
|
- useRecord.setCommonValue(SecurityUtils.getUsername());
|
|
|
+ SysUser sysUser = userInfo.getData().getSysUser();
|
|
|
+ useRecord.setCommonValue(sysUser.getUserName(),sysUser.getUserId(),sysUser.getDeptId());
|
|
|
return baseMapper.updateById(useRecord);
|
|
|
}
|
|
|
|
|
|
@@ -243,7 +250,7 @@ public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord
|
|
|
public List<UseRecord> getByUserId(UseRecord useRecord) {
|
|
|
Long userId = tokenService.getLoginUser().getSysUser().getUserId();
|
|
|
LambdaQueryWrapper<UseRecord> queryWrapper = Wrappers.lambdaQuery(UseRecord.class);
|
|
|
- queryWrapper.eq(UseRecord::getUserId,userId);
|
|
|
+ queryWrapper.eq(UseRecord::getUserId, userId);
|
|
|
return list(queryWrapper);
|
|
|
}
|
|
|
|