【ID1000533】仪器绑定记录-换绑序列号输入1111,提示: 该序列号已经被绑定,提示有误,序列号列表都没有该序列号

master
382696293@qq.com 2 years ago
parent ae9afa472f
commit 291d008313

@ -9,11 +9,13 @@ import com.flossom.common.core.domain.req.WxUserInstrumentExportVm;
import com.flossom.common.core.enums.BindingStatusEnums; import com.flossom.common.core.enums.BindingStatusEnums;
import com.flossom.common.core.mapper.*; import com.flossom.common.core.mapper.*;
import com.flossom.common.core.utils.DateUtils; import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.security.utils.SecurityUtils;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.flossom.system.service.IWxUserInstrumentService; import com.flossom.system.service.IWxUserInstrumentService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@ -164,14 +166,15 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService
} }
@Override @Override
@Transactional
public Map<String,String> changeSerial(WxUserInstrument wxUserInstrument) { public Map<String,String> changeSerial(WxUserInstrument wxUserInstrument) {
Map<String,String> resultMap = Maps.newHashMap(); Map<String,String> resultMap = Maps.newHashMap();
// 查询序列号是否有效存在 // 查询序列号是否有效存在
WxInstrumentSerial serial = new WxInstrumentSerial(); WxInstrumentSerial serial = new WxInstrumentSerial();
serial.setSerial(wxUserInstrument.getSerial()); serial.setSerial(wxUserInstrument.getSerial());
serial.setValidStatus(1); // 有效 serial.setValidStatus(1); // 有效
List<WxInstrumentSerial> serialList = instrumentSerialMapper.selectWxInstrumentSerialList(serial); WxInstrumentSerial wxInstrumentSerial = instrumentSerialMapper.selectEntityListBySerial(serial);
if (CollectionUtils.isEmpty(serialList)) { if (wxInstrumentSerial == null) {
resultMap.put("message","序列号无效,请确定后再绑定"); resultMap.put("message","序列号无效,请确定后再绑定");
resultMap.put("code", "500"); resultMap.put("code", "500");
return resultMap; return resultMap;
@ -179,15 +182,16 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService
// 查看是否已经被绑定 // 查看是否已经被绑定
WxUserInstrument userInstrument = new WxUserInstrument(); WxUserInstrument userInstrument = new WxUserInstrument();
userInstrument.setSerial(wxUserInstrument.getSerial()); userInstrument.setSerial(wxUserInstrument.getSerial());
List<WxUserInstrument> wxUserInstrumentsList = wxUserInstrumentMapper.selectWxUserInstrumentList(userInstrument); userInstrument.setBindingStatus(BindingStatusEnums.BINDED.getCode());
if (!CollectionUtils.isEmpty(wxUserInstrumentsList)) { Integer count = wxUserInstrumentMapper.selectUiByInstrumentId(userInstrument);
if (count != null && count > 0) {
resultMap.put("message","该序列号已经被绑定"); resultMap.put("message","该序列号已经被绑定");
resultMap.put("code", "500"); resultMap.put("code", "500");
return resultMap; return resultMap;
} }
// 开始绑定 // 开始绑定
WxUserInstrument userInstrumentRecord = wxUserInstrumentMapper.selectWxUserInstrumentById(wxUserInstrument.getId()); WxUserInstrument userInstrumentRecord = wxUserInstrumentMapper.selectWxUserInstrumentById(wxUserInstrument.getId());
String oldSerial = userInstrumentRecord.getSerial();
// 操作变更日记 // 操作变更日记
// 是否已经绑定 // 是否已经绑定
if (0 == userInstrumentRecord.getBindingStatus()) { if (0 == userInstrumentRecord.getBindingStatus()) {
@ -208,7 +212,7 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService
} }
} }
// 更新信息 // 更新信息
WxInstrumentSerial instrumentSerialVo = serialList.get(0); WxInstrumentSerial instrumentSerialVo = wxInstrumentSerial;
userInstrumentRecord.setInstrumentId(instrumentSerialVo.getInstrumentId()); userInstrumentRecord.setInstrumentId(instrumentSerialVo.getInstrumentId());
userInstrumentRecord.setSerial(instrumentSerialVo.getSerial()); userInstrumentRecord.setSerial(instrumentSerialVo.getSerial());
// userInstrumentRecord.setSerialImage(userInstrument.getSerialImage()); // userInstrumentRecord.setSerialImage(userInstrument.getSerialImage());
@ -216,6 +220,24 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService
this.saveLog(userInstrumentRecord,0); this.saveLog(userInstrumentRecord,0);
// 更新绑定数据 // 更新绑定数据
WxInstrumentSerial oldUpdate = new WxInstrumentSerial();
oldUpdate.setBindingStatus(BindingStatusEnums.UN_BOUND.getCode());
oldUpdate.setUpdateBy(SecurityUtils.getUsername());
oldUpdate.setUpdateTime(DateUtils.getNowDate());
oldUpdate.setSerial(oldSerial);
instrumentSerialMapper.updateBySerial(oldUpdate);
WxInstrumentSerial newUpdate = new WxInstrumentSerial();
newUpdate.setBindingStatus(BindingStatusEnums.BINDED.getCode());
newUpdate.setUpdateBy(SecurityUtils.getUsername());
newUpdate.setUpdateTime(DateUtils.getNowDate());
newUpdate.setSerial(wxUserInstrument.getSerial());
instrumentSerialMapper.updateBySerial(newUpdate);
userInstrumentRecord.setUserId(null);
userInstrumentRecord.setInstrumentId(null);
userInstrumentRecord.setBindingStatus(BindingStatusEnums.BINDED.getCode());
wxUserInstrumentMapper.updateWxUserInstrument(userInstrumentRecord); wxUserInstrumentMapper.updateWxUserInstrument(userInstrumentRecord);
resultMap.put("message","换绑序列号成功"); resultMap.put("message","换绑序列号成功");
resultMap.put("code", "200"); resultMap.put("code", "200");

Loading…
Cancel
Save