中控批量入库:SN与编码判重
This commit is contained in:
parent
7801e20d4b
commit
7a84f80e84
@ -4,6 +4,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.model.vo.EbikeEcuInfoBatchVo;
|
||||
import com.cdzy.operations.model.vo.EbikeEcuInfoVo;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cdzy.operations.model.entity.EbikeEcuInfo;
|
||||
import com.cdzy.operations.mapper.EbikeEcuInfoMapper;
|
||||
@ -14,6 +15,8 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
||||
|
||||
/**
|
||||
* 中控基本信息 服务层实现。
|
||||
*
|
||||
@ -35,6 +38,13 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
.ecuBrand(ebikeEcuInfo.getEcuBrand())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_ECU_INFO.ECU_SN.eq(ebikeEcuInfo.getEcuSn()))
|
||||
.or(EBIKE_ECU_INFO.ECU_CODE.eq(ebikeEcuInfo.getEcuCode()));
|
||||
EbikeEcuInfo ecuInfo = ebikeEcuInfoMapper.selectOneByQuery(queryWrapper);
|
||||
if (ecuInfo != null) {
|
||||
throw new EbikeException("中控信息存在重复");
|
||||
}
|
||||
ebikeEcuInfoMapper.insert(ebikeEcuInfoEntity);
|
||||
}
|
||||
|
||||
@ -47,6 +57,9 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
if (ecuCodes.size() != ecuSns.size()) {
|
||||
throw new EbikeException("中控编号与中控SN码数量不对应");
|
||||
}
|
||||
if (ecuCodes.isEmpty()) {
|
||||
throw new EbikeException("中控编号与中控SN码不能为空");
|
||||
}
|
||||
List<EbikeEcuInfo> list = new ArrayList<>();
|
||||
for (int i = 0; i < ecuCodes.size(); i++) {
|
||||
EbikeEcuInfo ebikeEcuInfoEntity = EbikeEcuInfo.builder()
|
||||
@ -58,6 +71,13 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
.build();
|
||||
list.add(ebikeEcuInfoEntity);
|
||||
}
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_ECU_INFO.ECU_SN.in(ecuSns))
|
||||
.or(EBIKE_ECU_INFO.ECU_CODE.in(ecuCodes));
|
||||
long count = ebikeEcuInfoMapper.selectCountByQuery(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new EbikeException("中控信息存在重复");
|
||||
}
|
||||
saveBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class EbikeInventoryServiceImpl extends ServiceImpl<EbikeInventoryMapper,
|
||||
recordMapper.insert(inventoryRecord);
|
||||
//该类型值存入字典
|
||||
if (ebikeInventory.getInventoryType() == 1){
|
||||
//TODO:二维码生产,
|
||||
//电池二维码生产,
|
||||
EbikeBatteryInfoVo ebikeBatteryInfoVo =EbikeBatteryInfoVo.builder()
|
||||
.operatorId(ebikeInventory.getOperatorId())
|
||||
.batteryNum(ebikeInventory.getInventoryNum())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user