@@ -16,7 +16,35 @@ public interface InvwWarehouseRepo extends AbstractJpaRepo<InvwWarehouse, String | |||
@Query(value = "from InvwWarehouse where code = ?1 and status = ?2") | |||
InvwWarehouse findByCodeAndStatus(String code, Integer status); | |||
//根据id查询下级仓库 | |||
//查询父级仓库 | |||
@Query(value = "from InvwWarehouse where id = ?1 and status = ?2") | |||
List<InvwWarehouse> findParByParentIdAndStatus(String parentId, Integer status); | |||
//查询同级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 and status = ?2") | |||
List<InvwWarehouse> findByParentIdAndStatus(String parentId, Integer status); | |||
List<InvwWarehouse> findBroByParentIdAndStatus(String parentId, Integer status); | |||
//查询子级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 and status = ?2") | |||
List<InvwWarehouse> findChiByIdAndStatus(String id, Integer status); | |||
//查询父、同级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 or id = ?1 and status = ?2") | |||
List<InvwWarehouse> findParBroByParentId(String parentId, Integer status); | |||
//查询同、子级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 or parentId = ?2 and status = ?3") | |||
List<InvwWarehouse> findBroChiByParentIdOrId(String parentId, String id, Integer status); | |||
//查询父、子级仓库 | |||
@Query(value = "from InvwWarehouse where id = ?1 or parentId = ?2 and status = ?3") | |||
List<InvwWarehouse> findParChiByParentIdOrId(String parentId, String id, Integer status); | |||
//查询父兄子 | |||
@Query(value = "from InvwWarehouse where id = ?1 or parentId = ?2 or id = ?2 and status = ?3") | |||
List<InvwWarehouse> findParBroChiByParentIdOrId(String parentId, String id, Integer status); | |||
//查询所有仓库 | |||
@Query(value = "from InvwWarehouse where status = ?1") | |||
List<InvwWarehouse> findAllByStatus(Integer status); | |||
} |
@@ -4,10 +4,7 @@ import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.invw.api.MyValidController; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseAddDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseDeleteDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseEditDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehousePageRequestDTO; | |||
import cn.com.taiji.invw.dto.warehouse.*; | |||
import cn.com.taiji.invw.manager.warehouse.InvwWarehouseManager; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@@ -18,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import javax.validation.Valid; | |||
import java.util.List; | |||
@Api(tags = {"005-仓库管理"}) | |||
@RestController | |||
@@ -35,22 +33,35 @@ public class InvwWarehouseController extends MyValidController { | |||
@ApiOperation(value = "02-仓库新增") | |||
@PostMapping("/add") | |||
public ApiResponse add(@Valid @RequestBody InvwWarehouseAddDTO req) throws ManagerException { | |||
public ApiResponse add(@Valid @RequestBody InvwWarehouseAddRequestDTO req) throws ManagerException { | |||
manager.add(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "03-仓库修改") | |||
@PostMapping("/edit") | |||
public ApiResponse edit(@Valid @RequestBody InvwWarehouseEditDTO req) throws ManagerException { | |||
public ApiResponse edit(@Valid @RequestBody InvwWarehouseEditRequestDTO req) throws ManagerException { | |||
manager.edit(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "04-仓库删除") | |||
@PostMapping("/delete") | |||
public ApiResponse delete(@Valid @RequestBody InvwWarehouseDeleteDTO req) throws ManagerException { | |||
public ApiResponse delete(@Valid @RequestBody InvwWarehouseDeleteRequestDTO req) throws ManagerException { | |||
manager.delete(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "05-库存校验") | |||
@PostMapping("/check") | |||
public ApiResponse check(@Valid @RequestBody InvwWarehouseCheckRequestDTO req) throws ManagerException { | |||
manager.check(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "06-仓库ID名称集合") | |||
@PostMapping("/getWarehouseIdNames") | |||
public ApiResponse<InvwWarehouseIdNameResponseDTO> getWarehouseIdNames(@Valid @RequestBody InvwWarehouseIdNameRequestDTO req) { | |||
return ApiResponse.of(manager.getWarehouseIdNames(req)); | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
package cn.com.taiji.invw.dto.card; | |||
import cn.com.taiji.common.model.finals.SysFinals; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.invw.dto.AbstractBizPageRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -12,7 +12,7 @@ import lombok.experimental.Accessors; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwQryCardBatchPageRequestDTO extends AbstractBizRequestDTO { | |||
public class InvwQryCardBatchPageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "批次号") | |||
private String batchNo; // 批次号 | |||
@ApiModelProperty(value = "卡片厂商代码") | |||
@@ -30,8 +30,4 @@ public class InvwQryCardBatchPageRequestDTO extends AbstractBizRequestDTO { | |||
// @ApiModelProperty(value = "结束卡号") | |||
// private String lastUpdateTimeEnd; // 最新更新日期结束 | |||
@ApiModelProperty(value = "页码") | |||
private Integer pageNo = SysFinals.DEFAULT_PAGE_NUM; | |||
@ApiModelProperty(value = "每页数量") | |||
private Integer pageSize = SysFinals.DEFAULT_PAGE_SIZE; | |||
} |
@@ -1,7 +1,7 @@ | |||
package cn.com.taiji.invw.dto.card; | |||
import cn.com.taiji.common.model.finals.SysFinals; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.invw.dto.AbstractBizPageRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -12,7 +12,7 @@ import lombok.experimental.Accessors; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwQryCardsPageRequestDTO extends AbstractBizRequestDTO { | |||
public class InvwQryCardsPageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "批次号") | |||
private String batchNo; // 批次号 | |||
@ApiModelProperty(value = "卡号") | |||
@@ -33,9 +33,4 @@ public class InvwQryCardsPageRequestDTO extends AbstractBizRequestDTO { | |||
// private String formatTimeStart; // 格式化日期 | |||
// @ApiModelProperty(value = "结束时间") | |||
// private String formatTimeEnd; // 格式化日期 | |||
@ApiModelProperty(value = "页码") | |||
private Integer pageNo = SysFinals.DEFAULT_PAGE_NUM; | |||
@ApiModelProperty(value = "每页数量") | |||
private Integer pageSize = SysFinals.DEFAULT_PAGE_SIZE; | |||
} |
@@ -1,7 +1,7 @@ | |||
package cn.com.taiji.invw.dto.obu; | |||
import cn.com.taiji.common.model.finals.SysFinals; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.invw.dto.AbstractBizPageRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -12,7 +12,7 @@ import lombok.experimental.Accessors; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwQryObuBatchPageRequestDTO extends AbstractBizRequestDTO { | |||
public class InvwQryObuBatchPageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "批次号") | |||
private String batchNo; // 批次号 | |||
@ApiModelProperty(value = "卡片厂商代码") | |||
@@ -25,10 +25,4 @@ public class InvwQryObuBatchPageRequestDTO extends AbstractBizRequestDTO { | |||
private String applyDateStart; // 申请时间开始 | |||
@ApiModelProperty(value = "申请时间结束") | |||
private String applyDateEnd; // 申请时间结束 | |||
@ApiModelProperty(value = "页码") | |||
private Integer pageNo = SysFinals.DEFAULT_PAGE_NUM; | |||
@ApiModelProperty(value = "每页数量") | |||
private Integer pageSize = SysFinals.DEFAULT_PAGE_SIZE; | |||
} |
@@ -1,7 +1,7 @@ | |||
package cn.com.taiji.invw.dto.obu; | |||
import cn.com.taiji.common.model.finals.SysFinals; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.invw.dto.AbstractBizPageRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -12,7 +12,7 @@ import lombok.experimental.Accessors; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwQryObusPageRequestDTO extends AbstractBizRequestDTO { | |||
public class InvwQryObusPageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "批次号") | |||
private String batchNo; // 批次号 | |||
@ApiModelProperty(value = "OBU合同序列号") | |||
@@ -29,10 +29,4 @@ public class InvwQryObusPageRequestDTO extends AbstractBizRequestDTO { | |||
// private String formatTimeStart; // 格式化日期 | |||
// @ApiModelProperty(value = "结束时间") | |||
// private String formatTimeEnd; // 格式化日期 | |||
@ApiModelProperty(value = "页码") | |||
private Integer pageNo = SysFinals.DEFAULT_PAGE_NUM; | |||
@ApiModelProperty(value = "每页数量") | |||
private Integer pageSize = SysFinals.DEFAULT_PAGE_SIZE; | |||
} |
@@ -13,7 +13,7 @@ import javax.validation.constraints.NotBlank; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwWarehouseAddDTO extends AbstractBizRequestDTO { | |||
public class InvwWarehouseAddRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "仓库编号", required = true) | |||
@NotBlank(message = "仓库编号不能为空") |
@@ -0,0 +1,26 @@ | |||
package cn.com.taiji.invw.dto.warehouse; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.IntegerConstant; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.StringConstant; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
import javax.validation.constraints.NotBlank; | |||
@ApiModel(description = "仓库校验") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwWarehouseCheckRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "仓库ID") | |||
@NotBlank(message = "id不能为空") | |||
private String id; | |||
@ApiModelProperty(value = "是否开启库存校验 0-否,1-是") | |||
@StringConstant(values = "0,1", message = "是否开启库存校验错误!") | |||
@NotBlank(message = "isCheck不能为空") | |||
private String isCheck; | |||
} |
@@ -13,7 +13,7 @@ import javax.validation.constraints.NotBlank; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwWarehouseDeleteDTO extends AbstractBizRequestDTO { | |||
public class InvwWarehouseDeleteRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "仓库ID") | |||
@NotBlank(message = "id不能为空") | |||
private String id; |
@@ -13,7 +13,7 @@ import javax.validation.constraints.NotBlank; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwWarehouseEditDTO extends AbstractBizRequestDTO { | |||
public class InvwWarehouseEditRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "仓库ID") | |||
@NotBlank(message = "id不能为空") |
@@ -0,0 +1,14 @@ | |||
package cn.com.taiji.invw.dto.warehouse; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
@Data | |||
public class InvwWarehouseIdNameModel { | |||
@ApiModelProperty(value = "仓库ID") | |||
private String id; | |||
@ApiModelProperty(value = "仓库名称") | |||
private String name; | |||
@ApiModelProperty(value = "仓库层级") | |||
private Integer warehouseLevel; | |||
} |
@@ -0,0 +1,20 @@ | |||
package cn.com.taiji.invw.dto.warehouse; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "仓库ID名称查询") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwWarehouseIdNameRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "仓库ID 空-查所有") | |||
private String id; | |||
@ApiModelProperty(value = "查询类型 id为空查所有 1-查父 2-查兄 3-查子 4-查父兄 5-查兄子 6-查父子 7-查父兄子") | |||
private String type; | |||
} |
@@ -0,0 +1,12 @@ | |||
package cn.com.taiji.invw.dto.warehouse; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.util.List; | |||
@Data | |||
public class InvwWarehouseIdNameResponseDTO { | |||
@ApiModelProperty(value = "仓库ID名称集合") | |||
private List<InvwWarehouseIdNameModel> idNames; | |||
} |
@@ -1,7 +1,7 @@ | |||
package cn.com.taiji.invw.dto.warehouse; | |||
import cn.com.taiji.common.model.finals.SysFinals; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.invw.dto.AbstractBizPageRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -14,7 +14,7 @@ import java.time.LocalDateTime; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwWarehousePageRequestDTO extends AbstractBizRequestDTO { | |||
public class InvwWarehousePageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "仓库编号") | |||
private String code;//仓库编号 | |||
@@ -27,9 +27,4 @@ public class InvwWarehousePageRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "创建时间结束") | |||
private LocalDateTime insertTimeEnd;//创建时间结束 | |||
@ApiModelProperty(value = "页码") | |||
private Integer pageNo = SysFinals.DEFAULT_PAGE_NUM; | |||
@ApiModelProperty(value = "每页数量") | |||
private Integer pageSize = SysFinals.DEFAULT_PAGE_SIZE; | |||
} |
@@ -4,7 +4,7 @@ import cn.com.taiji.core.entity.invw.InvwWarehouse; | |||
import lombok.Data; | |||
@Data | |||
public class InvwWarehousePageResponseVO { | |||
public class InvwWarehousePageResponseDTO { | |||
private InvwWarehouse warehouse; | |||
private InvwWarehouse parentWarehouse; | |||
} |
@@ -2,17 +2,20 @@ package cn.com.taiji.invw.manager.warehouse; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseAddDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseDeleteDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseEditDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehousePageRequestDTO; | |||
import cn.com.taiji.invw.dto.warehouse.*; | |||
import java.util.List; | |||
public interface InvwWarehouseManager { | |||
Pagination page(InvwWarehousePageRequestDTO request); | |||
void add(InvwWarehouseAddDTO req) throws ManagerException; | |||
void add(InvwWarehouseAddRequestDTO req) throws ManagerException; | |||
void edit(InvwWarehouseEditRequestDTO req) throws ManagerException; | |||
void delete(InvwWarehouseDeleteRequestDTO req) throws ManagerException; | |||
void edit(InvwWarehouseEditDTO req) throws ManagerException; | |||
void check(InvwWarehouseCheckRequestDTO req) throws ManagerException; | |||
void delete(InvwWarehouseDeleteDTO req) throws ManagerException; | |||
InvwWarehouseIdNameResponseDTO getWarehouseIdNames(InvwWarehouseIdNameRequestDTO req); | |||
} |
@@ -11,21 +11,19 @@ import cn.com.taiji.core.repo.jpa.invw.InvwCardDetailsRepo; | |||
import cn.com.taiji.core.repo.jpa.invw.InvwObuDetailsRepo; | |||
import cn.com.taiji.core.repo.jpa.invw.InvwWarehouseRepo; | |||
import cn.com.taiji.core.repo.request.invw.InvwWarehousePageRequest; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseAddDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseDeleteDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseEditDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehousePageRequestDTO; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehousePageResponseVO; | |||
import cn.com.taiji.invw.dto.warehouse.*; | |||
import cn.com.taiji.invw.manager.AbstractCommManager; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.time.LocalDateTime; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
@Service | |||
public class InvwWarehouseManagerImpl extends AbstractCommManager implements InvwWarehouseManager, ResultConverter<InvwWarehouse, InvwWarehousePageResponseVO> { | |||
public class InvwWarehouseManagerImpl extends AbstractCommManager implements InvwWarehouseManager, ResultConverter<InvwWarehouse, InvwWarehousePageResponseDTO> { | |||
@Autowired | |||
private InvwWarehouseRepo warehouseRepo; | |||
@@ -42,7 +40,7 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
} | |||
@Override | |||
public void add(InvwWarehouseAddDTO req) throws ManagerException { | |||
public void add(InvwWarehouseAddRequestDTO req) throws ManagerException { | |||
InvwWarehouse parentWarehouse = warehouseRepo.findById(req.getParentId()).orElse(null); | |||
if (parentWarehouse == null) { | |||
throw new ManagerException("上级仓库不存在"); | |||
@@ -66,6 +64,7 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
warehouse.setInsertTime(LocalDateTime.now()); | |||
warehouse.setUpdateTime(LocalDateTime.now()); | |||
warehouse.setAgencyId(req.getAgencyId()); | |||
warehouse.setIsCheck(0); | |||
if (StringTools.hasText(req.getWarehouseChannelId())) { | |||
warehouse.setChannelId(req.getWarehouseChannelId()); | |||
} | |||
@@ -74,7 +73,7 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
} | |||
@Override | |||
public void edit(InvwWarehouseEditDTO req) throws ManagerException { | |||
public void edit(InvwWarehouseEditRequestDTO req) throws ManagerException { | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), 1); | |||
if (warehouse == null) { | |||
throw new ManagerException("仓库不存在"); | |||
@@ -93,7 +92,7 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
//二级仓库 | |||
if (StringTools.hasText(req.getParentId()) || StringTools.hasText(req.getAgencyId())) { | |||
//查询下级仓库 | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findByParentIdAndStatus(warehouse.getId(), 1); | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findChiByIdAndStatus(warehouse.getId(), 1); | |||
if (warehouseList.size() > 0) { | |||
throw new ManagerException("该仓库有下级仓库,只能修改仓库名称"); | |||
} | |||
@@ -107,7 +106,7 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
} | |||
if (StringTools.hasText(req.getParentId())) { | |||
InvwWarehouse parentWarehouse = warehouseRepo.findById(req.getParentId()).orElse(null); | |||
if(parentWarehouse == null){ | |||
if (parentWarehouse == null) { | |||
throw new ManagerException("上级仓库不存在"); | |||
} | |||
warehouse.setWarehouseLevel(parentWarehouse.getWarehouseLevel() + 1); | |||
@@ -136,7 +135,7 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
} | |||
if (StringTools.hasText(req.getParentId())) { | |||
InvwWarehouse parentWarehouse = warehouseRepo.findById(req.getParentId()).orElse(null); | |||
if(parentWarehouse == null){ | |||
if (parentWarehouse == null) { | |||
throw new ManagerException("上级仓库不存在"); | |||
} | |||
warehouse.setWarehouseLevel(parentWarehouse.getWarehouseLevel() + 1); | |||
@@ -155,15 +154,15 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
} | |||
@Override | |||
public void delete(InvwWarehouseDeleteDTO req) throws ManagerException { | |||
public void delete(InvwWarehouseDeleteRequestDTO req) throws ManagerException { | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), 1); | |||
if (warehouse == null) { | |||
throw new ManagerException("仓库不存在"); | |||
} | |||
if(warehouse.getWarehouseLevel() == 1){ | |||
throw new ManagerException("默认仓库不能删除"); | |||
if (warehouse.getWarehouseLevel() == 1) { | |||
throw new ManagerException("默认仓库不能删除"); | |||
} | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findByParentIdAndStatus(warehouse.getId(), 1); | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findChiByIdAndStatus(warehouse.getId(), 1); | |||
if (warehouseList.size() > 0) { | |||
throw new ManagerException("该仓库有下级仓库,不能删除"); | |||
} | |||
@@ -181,8 +180,82 @@ public class InvwWarehouseManagerImpl extends AbstractCommManager implements Inv | |||
} | |||
@Override | |||
public InvwWarehousePageResponseVO convert(InvwWarehouse warehouse) { | |||
InvwWarehousePageResponseVO vo = new InvwWarehousePageResponseVO(); | |||
public void check(InvwWarehouseCheckRequestDTO req) throws ManagerException { | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), 1); | |||
if (warehouse == null) { | |||
throw new ManagerException("仓库不存在"); | |||
} | |||
warehouse.setIsCheck(Integer.valueOf(req.getIsCheck())); | |||
warehouse.setUpdateTime(LocalDateTime.now()); | |||
warehouseRepo.saveAndFlush(warehouse); | |||
} | |||
@Override | |||
public InvwWarehouseIdNameResponseDTO getWarehouseIdNames(InvwWarehouseIdNameRequestDTO req) { | |||
List<InvwWarehouseIdNameModel> idNames = new ArrayList<>(); | |||
List<InvwWarehouse> warehouseList = new ArrayList<>(); | |||
InvwWarehouseIdNameResponseDTO response = new InvwWarehouseIdNameResponseDTO(); | |||
InvwWarehouse warehouse = null; | |||
if (StringTools.hasText(req.getId())) { | |||
warehouse = warehouseRepo.findById(req.getId()).orElse(null); | |||
} else { | |||
warehouseList = warehouseRepo.findAllByStatus(1); | |||
} | |||
switch (req.getType()) { | |||
case "1": | |||
warehouseList = warehouseRepo.findParByParentIdAndStatus(req.getId(), 1); | |||
break; | |||
case "2": | |||
if (warehouse != null) { | |||
if (StringTools.hasText(warehouse.getParentId())) { | |||
warehouseList = warehouseRepo.findBroByParentIdAndStatus(warehouse.getParentId(), 1); | |||
} | |||
} | |||
break; | |||
case "3": | |||
warehouseList = warehouseRepo.findChiByIdAndStatus(req.getId(), 1); | |||
break; | |||
case "4": | |||
if (warehouse != null) { | |||
if (StringTools.hasText(warehouse.getParentId())) { | |||
warehouseList = warehouseRepo.findParBroByParentId(warehouse.getParentId(), 1); | |||
} | |||
} | |||
break; | |||
case "5": | |||
if (warehouse != null) { | |||
if (StringTools.hasText(warehouse.getParentId())) { | |||
warehouseList = warehouseRepo.findBroChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), 1); | |||
} | |||
} | |||
break; | |||
case "6": | |||
if (warehouse != null) { | |||
warehouseList = warehouseRepo.findParChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), 1); | |||
} | |||
break; | |||
case "7": | |||
if (warehouse != null) { | |||
warehouseList = warehouseRepo.findParBroChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), 1); | |||
} | |||
break; | |||
} | |||
if (!isEmpty(warehouseList)) { | |||
for (InvwWarehouse warehouseLists : warehouseList) { | |||
InvwWarehouseIdNameModel idName = new InvwWarehouseIdNameModel(); | |||
idName.setId(warehouseLists.getId()); | |||
idName.setName(warehouseLists.getName()); | |||
idName.setWarehouseLevel(warehouseLists.getWarehouseLevel()); | |||
idNames.add(idName); | |||
} | |||
} | |||
response.setIdNames(idNames); | |||
return response; | |||
} | |||
@Override | |||
public InvwWarehousePageResponseDTO convert(InvwWarehouse warehouse) { | |||
InvwWarehousePageResponseDTO vo = new InvwWarehousePageResponseDTO(); | |||
vo.setWarehouse(warehouse); | |||
String parentId = warehouse.getParentId(); | |||
// 查询父级仓库 |