diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/KilnInfoServiceImpl.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/KilnInfoServiceImpl.java index 6271560..9ab98a4 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/KilnInfoServiceImpl.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/KilnInfoServiceImpl.java @@ -1,6 +1,7 @@ package com.mt.wms.basic.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mt.wms.basic.params.KilnInfoParam; import com.mt.wms.basic.params.KilnInfoQueryParam; import com.mt.wms.basic.service.KilnInfoService; @@ -14,6 +15,7 @@ import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -51,21 +53,42 @@ public class KilnInfoServiceImpl extends BaseService implements KilnInfoService @Override public R> page(KilnInfoQueryParam kilnInfoQueryParam) { - return null; + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(KilnInfo.VALID,1); + Page page = kilnInfoServiceBiz.page(new Page<>(kilnInfoQueryParam.getCurrent(), kilnInfoQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page,KilnInfoVo.class)); } @Override public R add(KilnInfoParam kilnInfoParam) { - return null; + QueryWrapper wrapper=new QueryWrapper<>(); + + KilnInfo kilnInfo=new KilnInfo(); + BeanUtils.copyProperties(kilnInfoParam,kilnInfo); + setCommonField(kilnInfo); + kilnInfoServiceBiz.save(kilnInfo); + return successful(IdVo.builder().id(kilnInfo.getId()).build()); } @Override public R update(KilnInfoParam kilnInfoParam) { - return null; + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnInfoParam.getId()); + if (!kilnInfoParam.getKilnName().equals(kilnInfo.getKilnName())){ + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(KilnInfo.KILN_NAME,kilnInfoParam.getKilnName()); + wrapper.eq(KilnInfo.VALID,1); + Assert.eqZero(kilnInfoServiceBiz.count(wrapper),"车辆名称已存在!"); + } + KilnInfo updatewKilnInfo=new KilnInfo(); + BeanUtils.copyProperties(kilnInfoParam,updatewKilnInfo); + setUpdateCommonField(updatewKilnInfo); + kilnInfoServiceBiz.updateById(updatewKilnInfo); + return successful(IdVo.builder().id(updatewKilnInfo.getId()).build()); } @Override public R delete(IdParam idParam) { - return null; + kilnInfoServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(idParam.getId()).build()); } } diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/LocationInfoServiceImpl.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/LocationInfoServiceImpl.java index 6b7512b..ba836a9 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/LocationInfoServiceImpl.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/LocationInfoServiceImpl.java @@ -1,6 +1,7 @@ package com.mt.wms.basic.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mt.wms.basic.params.LocationInfoParam; import com.mt.wms.basic.params.LocationInfoQueryParam; import com.mt.wms.basic.service.LocationInfoService; @@ -54,21 +55,42 @@ public class LocationInfoServiceImpl extends BaseService implements LocationInfo @Override public R> page(LocationInfoQueryParam locationInfoQueryParam) { - return null; + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(Location.VALID,1); + Page page = locationServiceBiz.page(new Page<>(locationInfoQueryParam.getCurrent(), locationInfoQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page,LocationInfoVo.class)); } @Override public R add(LocationInfoParam locationInfoParam) { - return null; + QueryWrapper wrapper=new QueryWrapper<>(); + + Location location=new Location(); + BeanUtils.copyProperties(locationInfoParam,location); + setCommonField(location); + locationServiceBiz.save(location); + return successful(IdVo.builder().id(location.getId()).build()); } @Override public R update(LocationInfoParam locationInfoParam) { - return null; + Location location = locationServiceBiz.getById(locationInfoParam.getId()); + if (!locationInfoParam.getCode().equals(location.getCode())){ + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(Location.CODE,locationInfoParam.getCode()); + wrapper.eq(Location.VALID,1); + Assert.eqZero(locationServiceBiz.count(wrapper),"库位编码已存在!"); + } + Location updateLocation=new Location(); + BeanUtils.copyProperties(locationInfoParam,updateLocation); + setUpdateCommonField(updateLocation); + locationServiceBiz.updateById(updateLocation); + return successful(IdVo.builder().id(updateLocation.getId()).build()); } @Override public R delete(IdParam idParam) { - return null; + locationServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(idParam.getId()).build()); } } diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/VehicleServiceImpl.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/VehicleServiceImpl.java index c6adfb4..987843f 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/VehicleServiceImpl.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/VehicleServiceImpl.java @@ -1,6 +1,7 @@ package com.mt.wms.basic.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mt.wms.basic.params.VehicleParam; import com.mt.wms.basic.params.VehicleQueryParam; import com.mt.wms.basic.service.VehicleService; @@ -54,21 +55,42 @@ public class VehicleServiceImpl extends BaseService implements VehicleService { @Override public R> page(VehicleQueryParam vehicleQueryParam) { - return null; + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(VehicleInfo.VALID,1); + Page page = vehicleInfoServiceBiz.page(new Page<>(vehicleQueryParam.getCurrent(), vehicleQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page,VehicleVo.class)); } @Override public R add(VehicleParam vehicleParam) { - return null; + QueryWrapper wrapper=new QueryWrapper<>(); + + VehicleInfo vehicleInfo=new VehicleInfo(); + BeanUtils.copyProperties(vehicleParam,vehicleInfo); + setCommonField(vehicleInfo); + vehicleInfoServiceBiz.save(vehicleInfo); + return successful(IdVo.builder().id(vehicleInfo.getId()).build()); } @Override public R update(VehicleParam vehicleParam) { - return null; + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleParam.getId()); + if (!vehicleParam.getCode().equals(vehicleInfo.getCode())){ + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(VehicleInfo.CODE,vehicleParam.getCode()); + wrapper.eq(VehicleInfo.VALID,1); + Assert.eqZero(vehicleInfoServiceBiz.count(wrapper),"车辆编码已存在!"); + } + VehicleInfo updateVehicleInfo=new VehicleInfo(); + BeanUtils.copyProperties(vehicleParam,updateVehicleInfo); + setUpdateCommonField(updateVehicleInfo); + vehicleInfoServiceBiz.updateById(updateVehicleInfo); + return successful(IdVo.builder().id(updateVehicleInfo.getId()).build()); } @Override public R delete(IdParam idParam) { - return null; + vehicleInfoServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(idParam.getId()).build()); } }