|
@@ -9,17 +9,23 @@ import com.ozs.common.exception.ServiceException;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
import com.ozs.common.utils.bean.BeanUtils;
|
|
|
import com.ozs.common.utils.bean.BeanValidators;
|
|
|
+import com.ozs.entity.BaseTerminal;
|
|
|
import com.ozs.entity.BaseVehicle;
|
|
|
+import com.ozs.entity.BaseVehicleTerminal;
|
|
|
+import com.ozs.entity.vo.BaseVehicleTerminalVo;
|
|
|
import com.ozs.entity.vo.BaseVehicleVo;
|
|
|
+import com.ozs.mapper.BaseTerminalMapper;
|
|
|
import com.ozs.mapper.BaseVehicleMapper;
|
|
|
import com.ozs.mapper.BaseVehicleTerminalMapper;
|
|
|
import com.ozs.service.BaseVehicleService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import javax.validation.Validator;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -35,6 +41,8 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
|
|
|
@Autowired
|
|
|
private BaseVehicleMapper baseVehicleMapper;
|
|
|
@Autowired
|
|
|
+ private BaseTerminalMapper baseTerminalMapper;
|
|
|
+ @Autowired
|
|
|
private BaseVehicleTerminalMapper baseVehicleTerminalMapper;
|
|
|
@Autowired
|
|
|
protected Validator validator;
|
|
@@ -84,7 +92,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult vehicleUpdate(BaseVehicle baseVehicle, String userId) {
|
|
|
- LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
|
|
|
+ LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<>();
|
|
|
if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
|
|
|
wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
|
|
|
}
|
|
@@ -171,7 +179,7 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
|
|
|
|
|
|
@Override
|
|
|
public List<BaseVehicle> exportBaseVehicle(BaseVehicle baseVehicle) {
|
|
|
- LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
|
|
|
+ LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<>();
|
|
|
if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleName())) {
|
|
|
wrapper.eq(BaseVehicle::getVehicleName, baseVehicle.getVehicleName());
|
|
|
}
|
|
@@ -181,4 +189,63 @@ public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseV
|
|
|
List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
|
|
|
return baseVehicles;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BaseVehicleTerminalVo> vehicleTerminal(BaseVehicleVo baseVehicleVo) {
|
|
|
+ BaseTerminal baseTerminal = baseTerminalMapper.selectTerminal(baseVehicleVo.getVehicleCode());
|
|
|
+ List<String> terminalCodeList = baseTerminalMapper.selectMountCode(baseVehicleVo.getVehicleCode());
|
|
|
+ // List<String> collect = terminalCodeList.stream().map(BaseTerminal::getTerminalCode).collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<BaseVehicleTerminal> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (!StringUtils.isEmptySunhh(terminalCodeList) && terminalCodeList.size() > 0) {
|
|
|
+ wrapper.notIn(BaseVehicleTerminal::getTerminalCode, terminalCodeList);
|
|
|
+ }
|
|
|
+// List<BaseVehicleTerminal> baseVehicleTerminalList = baseVehicleTerminalMapper.selectList(wrapper);
|
|
|
+ int pageNum = Integer.parseInt(baseVehicleVo.getPageNum().toString());
|
|
|
+ int pageSize = Integer.parseInt(baseVehicleVo.getPageSize().toString());
|
|
|
+ com.github.pagehelper.Page<BaseVehicleTerminal> page = PageHelper
|
|
|
+ .startPage(pageNum, pageSize).doSelectPage(() -> baseVehicleTerminalMapper.selectList(wrapper));
|
|
|
+ com.baomidou.mybatisplus.extension.plugins.pagination.Page<BaseVehicleTerminalVo> pageR =
|
|
|
+ new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
|
|
|
+ if (!ObjectUtils.isEmpty(page) && page.getResult().size() > 0) {
|
|
|
+ List<BaseVehicleTerminalVo> dto1 = page.getResult().stream().map(o -> {
|
|
|
+ BaseVehicleTerminalVo baseVehicleTerminalVo = new BaseVehicleTerminalVo();
|
|
|
+ BeanUtils.copyProperties(o, baseVehicleTerminalVo);
|
|
|
+ if (baseTerminal.getTerminalCode().equals(o.getTerminalCode())) {
|
|
|
+ baseVehicleTerminalVo.setIsMount("1");
|
|
|
+ } else {
|
|
|
+ baseVehicleTerminalVo.setIsMount("0");
|
|
|
+ }
|
|
|
+ return baseVehicleTerminalVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ pageR.setRecords(dto1);
|
|
|
+ }
|
|
|
+ return pageR;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult vehicleTerminalAdd(BaseTerminal baseTerminal1, String userId) {
|
|
|
+ LambdaQueryWrapper<BaseTerminal> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (!StringUtils.isEmptySunhh(baseTerminal1) && !StringUtils.isEmptySunhh(baseTerminal1.getVehicleCode())) {
|
|
|
+ wrapper.eq(BaseTerminal::getVehicleCode, baseTerminal1.getVehicleCode());
|
|
|
+ }
|
|
|
+ BaseTerminal baseTerminal = baseTerminalMapper.selectOne(wrapper);
|
|
|
+ if (StringUtils.isEmptySunhh(baseTerminal)) {
|
|
|
+ BaseTerminal baseTerminal2 = new BaseTerminal();
|
|
|
+ baseTerminal2.setVehicleCode(baseTerminal1.getVehicleCode());
|
|
|
+ baseTerminal2.setTerminalCode(baseTerminal1.getTerminalCode());
|
|
|
+ baseTerminal2.setCreateBy(userId);
|
|
|
+ baseTerminal2.setUpdateBy(userId);
|
|
|
+ Date date = new Date();
|
|
|
+ baseTerminal2.setCreateTime(date);
|
|
|
+ baseTerminal2.setUpdateTime(date);
|
|
|
+ int insert = baseTerminalMapper.insert(baseTerminal2);
|
|
|
+ } else {
|
|
|
+ baseTerminal.setUpdateBy(userId);
|
|
|
+ baseTerminal.setUpdateTime(new Date());
|
|
|
+ baseTerminal.setVehicleCode(baseTerminal1.getVehicleCode());
|
|
|
+ baseTerminal.setTerminalCode(baseTerminal1.getTerminalCode());
|
|
|
+ int updateById = baseTerminalMapper.updateById(baseTerminal);
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
}
|