|
@@ -37,25 +37,25 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
@LogRecord(type = MUSEUM_TYPE, subType = CREATE_SUB_TYPE, bizNo = "{{#sampleId.id}}",
|
|
|
success = CREATE_SUB_TYPE_SUCCESS)
|
|
|
public Integer createMuseumInfo(MuseumInfoSaveVO saveVO) {
|
|
|
- MuseumInfoDO sampleId = BeanUtils.toBean(saveVO, MuseumInfoDO.class);
|
|
|
- museumInfoMapper.insert(sampleId);
|
|
|
- LogRecordContext.putVariable("sampleId", sampleId );
|
|
|
- return sampleId.getId();
|
|
|
+ MuseumInfoDO sample = BeanUtils.toBean(saveVO, MuseumInfoDO.class);
|
|
|
+ museumInfoMapper.insert(sample);
|
|
|
+ LogRecordContext.putVariable("sample", sample );
|
|
|
+ return sample.getId();
|
|
|
}
|
|
|
/**
|
|
|
* 更新标本
|
|
|
*/
|
|
|
-
|
|
|
@LogRecord(type = MUSEUM_TYPE, subType = UPDATE_SUB_TYPE, bizNo = "{{#sampleId.id}}",
|
|
|
success = UPDATE_SUB_TYPE_SUCCESS)
|
|
|
@Override
|
|
|
public void updateSampleMuseumInfo(MuseumInfoSaveVO saveVO) {
|
|
|
- MuseumInfoDO sampleId = BeanUtils.toBean(saveVO,MuseumInfoDO.class);
|
|
|
- museumInfoMapper.updateMuseumInfo(sampleId);
|
|
|
-// museumInfoMapper.updateById(sampleId);
|
|
|
- LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(sampleId, MuseumInfoSaveVO.class));
|
|
|
- LogRecordContext.putVariable("sampleId", sampleId );
|
|
|
+ MuseumInfoDO sample = BeanUtils.toBean(saveVO,MuseumInfoDO.class);
|
|
|
+
|
|
|
+ museumInfoMapper.updateMuseumInfo(sample);
|
|
|
+ LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(sample, MuseumInfoSaveVO.class));
|
|
|
+ LogRecordContext.putVariable("sample", sample );
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 标本出库
|
|
|
*/
|
|
@@ -63,9 +63,9 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
success = OUT_MUSEUM_SUB_TYPE_SUCCESS)
|
|
|
@Override
|
|
|
public void outSampleMuseumInfo(Integer id){
|
|
|
- MuseumInfoDO sampleId = museumInfoMapper.selectMuseumInfoById(id);
|
|
|
+ MuseumInfoDO sample = museumInfoMapper.selectMuseumInfoById(id);
|
|
|
museumInfoMapper.outSampleMuseumInfo(id);
|
|
|
- LogRecordContext.putVariable("sampleId",sampleId);
|
|
|
+ LogRecordContext.putVariable("sample",sample);
|
|
|
}
|
|
|
/**
|
|
|
* 标本回库
|
|
@@ -74,9 +74,9 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
success = BACK_MUSEUM_SUB_TYPE_SUCCESS)
|
|
|
@Override
|
|
|
public void backSampleMuseumInfo(Integer id){
|
|
|
- MuseumInfoDO sampleId = museumInfoMapper.selectMuseumInfoById(id);
|
|
|
+ MuseumInfoDO sample = museumInfoMapper.selectMuseumInfoById(id);
|
|
|
museumInfoMapper.backSampleMuseumInfo(id);
|
|
|
- LogRecordContext.putVariable("sampleId",sampleId);
|
|
|
+ LogRecordContext.putVariable("sample",sample);
|
|
|
}
|
|
|
/**
|
|
|
* 删除标本
|
|
@@ -85,9 +85,9 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
@LogRecord(type = MUSEUM_TYPE, subType = DELETE_SUB_TYPE, bizNo = "{{#sampleId.id}}",
|
|
|
success = DELETE_SUB_TYPE_SUCCESS)
|
|
|
public void deleteMuseumInfo(Integer id,String reason) {
|
|
|
- MuseumInfoDO sampleId = museumInfoMapper.selectMuseumInfoById(id);
|
|
|
+ MuseumInfoDO sample = museumInfoMapper.selectMuseumInfoById(id);
|
|
|
museumInfoMapper.deleteMuseumInfo(id,reason);
|
|
|
- LogRecordContext.putVariable("sampleId", sampleId );
|
|
|
+ LogRecordContext.putVariable("sample", sample );
|
|
|
}
|
|
|
/**
|
|
|
* 查询标本id
|
|
@@ -178,6 +178,20 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
public Integer MuseumInfoByOrigin(Integer year, Integer origin) {
|
|
|
return museumInfoMapper.countMuseumInfoByOrigin(year,origin);
|
|
|
}
|
|
|
+ private Integer transformSampleType(String sampleType) {
|
|
|
+ if (sampleType==null){
|
|
|
+ return null;
|
|
|
+ }else if (sampleType.equals("矿石")){
|
|
|
+ return 1;
|
|
|
+ }else if (sampleType.equals("岩石")){
|
|
|
+ return 2;
|
|
|
+ }else if (sampleType.equals("矿物")){
|
|
|
+ return 3;
|
|
|
+ }else if (sampleType.equals("陨石")){
|
|
|
+ return 4;
|
|
|
+ }
|
|
|
+ throw new IllegalArgumentException("无效的标本类型: " + sampleType);
|
|
|
+ }
|
|
|
/**
|
|
|
* 批量导入用户
|
|
|
*
|
|
@@ -192,8 +206,8 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
MuseuminfoImportRespVO respVO = MuseuminfoImportRespVO.builder().createSampleIds(new ArrayList<>())
|
|
|
.updateSampleIds(new ArrayList<>()).failureSampleIds(new LinkedHashMap<>()).build();
|
|
|
importSamples.forEach(importSample -> {
|
|
|
-
|
|
|
- try {// 2.1.2 校验,判断是否有不符合的原因
|
|
|
+ // 2.1.2 校验,判断是否有不符合的原因
|
|
|
+ try {
|
|
|
museumInfoForCreateOrUpdate(null,importSample.getSampleId() );
|
|
|
} catch (ServiceException ex) {
|
|
|
respVO.getFailureSampleIds().put(importSample.getSampleId(), ex.getMessage());
|
|
@@ -236,30 +250,13 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
private MuseumInfoDO museumInfoForCreateOrUpdate(Integer id, String sampleId) {
|
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
return DataPermissionUtils.executeIgnore(() -> {
|
|
|
- // 校验标本存在
|
|
|
+ // 校验标本
|
|
|
MuseumInfoDO sample = museumInfoExists(id);
|
|
|
// 校验标本编号唯一
|
|
|
museumInfoSampleIdUnique(id, sampleId);
|
|
|
- // 转换标本类型
|
|
|
return sample;
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- private Integer transformSampleType(String sampleType) {
|
|
|
- if (sampleType==null){
|
|
|
- return null;
|
|
|
- }else if (sampleType.equals("矿石")){
|
|
|
- return 1;
|
|
|
- }else if (sampleType.equals("岩石")){
|
|
|
- return 2;
|
|
|
- }else if (sampleType.equals("矿物")){
|
|
|
- return 3;
|
|
|
- }else if (sampleType.equals("陨石")){
|
|
|
- return 4;
|
|
|
- }
|
|
|
- throw new IllegalArgumentException("无效的标本类型: " + sampleType);
|
|
|
- }
|
|
|
-
|
|
|
MuseumInfoDO museumInfoExists(Integer id) {
|
|
|
if (id == null) {
|
|
|
return null;
|
|
@@ -281,6 +278,7 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
return;
|
|
|
}
|
|
|
// TODO sample不为空
|
|
|
+ // 如果 id 为空,说明不用比较是否为相同 id 的标本
|
|
|
if (id == null) {
|
|
|
throw exception(SAMPLE_ID_EXISTS);
|
|
|
}
|