@@ -1,12 +1,11 @@ | |||
package cn.com.taiji.core.entity.invw; | |||
import cn.com.taiji.common.entity.StringPropertyUUIDEntity; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import javax.persistence.Column; | |||
import javax.persistence.Entity; | |||
import javax.persistence.Table; | |||
import javax.persistence.*; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import javax.validation.constraints.Size; | |||
@@ -39,7 +38,8 @@ public class InvwWarehouse extends StringPropertyUUIDEntity { | |||
private Integer warehouseLevel;//仓库层级1-3 | |||
@NotNull | |||
@Column(name = "STATUS") | |||
private Integer status;//库存状态0-删除 1-正常 | |||
@Enumerated(EnumType.STRING) | |||
private EnableStatus status;//库存状态0-删除 1-正常 | |||
@Column(name = "UPDATE_TIME") | |||
private LocalDateTime updateTime;//更新时间 | |||
@NotNull |
@@ -1,6 +1,7 @@ | |||
package cn.com.taiji.core.repo.jpa.invw; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import cn.com.taiji.core.entity.invw.InvwWarehouse; | |||
import org.springframework.data.jpa.repository.Query; | |||
@@ -10,43 +11,43 @@ public interface InvwWarehouseRepo extends AbstractJpaRepo<InvwWarehouse, String | |||
//根据id查询 | |||
@Query(value = "from InvwWarehouse where id = ?1 and status = ?2") | |||
InvwWarehouse findByIdAndStatus(String id, Integer status); | |||
InvwWarehouse findByIdAndStatus(String id, EnableStatus status); | |||
//根据code查询 | |||
@Query(value = "from InvwWarehouse where code = ?1 and status = ?2") | |||
InvwWarehouse findByCodeAndStatus(String code, Integer status); | |||
InvwWarehouse findByCodeAndStatus(String code, EnableStatus status); | |||
//查询父级仓库 | |||
@Query(value = "from InvwWarehouse where id = ?1 and status = ?2 order by code, insertTime ") | |||
List<InvwWarehouse> findParByParentIdAndStatus(String parentId, Integer status); | |||
List<InvwWarehouse> findParByParentIdAndStatus(String parentId, EnableStatus status); | |||
//查询同级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 and status = ?2 order by code, insertTime ") | |||
List<InvwWarehouse> findBroByParentIdAndStatus(String parentId, Integer status); | |||
List<InvwWarehouse> findBroByParentIdAndStatus(String parentId, EnableStatus status); | |||
//查询子级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 and status = ?2") | |||
List<InvwWarehouse> findChiByIdAndStatus(String id, Integer status); | |||
List<InvwWarehouse> findChiByIdAndStatus(String id, EnableStatus status); | |||
//查询父、同级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 or id = ?1 and status = ?2 order by code, insertTime ") | |||
List<InvwWarehouse> findParBroByParentId(String parentId, Integer status); | |||
List<InvwWarehouse> findParBroByParentId(String parentId, EnableStatus status); | |||
//查询同、子级仓库 | |||
@Query(value = "from InvwWarehouse where parentId = ?1 or parentId = ?2 and status = ?3 order by code, insertTime ") | |||
List<InvwWarehouse> findBroChiByParentIdOrId(String parentId, String id, Integer status); | |||
List<InvwWarehouse> findBroChiByParentIdOrId(String parentId, String id, EnableStatus status); | |||
//查询父、子级仓库 | |||
@Query(value = "from InvwWarehouse where id = ?1 or parentId = ?2 and status = ?3 order by code, insertTime ") | |||
List<InvwWarehouse> findParChiByParentIdOrId(String parentId, String id, Integer status); | |||
List<InvwWarehouse> findParChiByParentIdOrId(String parentId, String id, EnableStatus status); | |||
//查询父兄子 | |||
@Query(value = "from InvwWarehouse where id = ?1 or parentId = ?2 or id = ?2 and status = ?3 order by code, insertTime ") | |||
List<InvwWarehouse> findParBroChiByParentIdOrId(String parentId, String id, Integer status); | |||
List<InvwWarehouse> findParBroChiByParentIdOrId(String parentId, String id, EnableStatus status); | |||
//查询所有仓库 | |||
@Query(value = "from InvwWarehouse where status = ?1 order by code, insertTime ") | |||
List<InvwWarehouse> findAllByStatus(Integer status); | |||
List<InvwWarehouse> findAllByStatus(EnableStatus status); | |||
//根据Id查询子仓库最大的仓库编号 | |||
@Query(value = "select max(code) from InvwWarehouse where parentId = ?1 ") | |||
@@ -57,5 +58,5 @@ public interface InvwWarehouseRepo extends AbstractJpaRepo<InvwWarehouse, String | |||
InvwWarehouse findByCode(String code); | |||
@Query(" from InvwWarehouse where status = ?1") | |||
List<InvwWarehouse> queryByStatus(Integer status); | |||
List<InvwWarehouse> queryByStatus(EnableStatus status); | |||
} |
@@ -26,7 +26,7 @@ public class InvwWarehousePageRequest extends JpaDateTimePageableDataRequest<Inv | |||
hql.append(" and agencyId =:agencyId", agencyId); | |||
hql.append(" and insertTime >=:insertTimeStart", insertTimeStart); | |||
hql.append(" and insertTime <=:insertTimeEnd", insertTimeEnd); | |||
hql.append(" and status = 1"); | |||
hql.append(" and status = 'ENABLE'"); | |||
hql.append(" order by code"); | |||
return hql; | |||
} |
@@ -1,5 +1,6 @@ | |||
package cn.com.taiji.invw.dto.warehouse; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
@@ -26,7 +27,7 @@ public class InvwWarehousePageResponseDTO { | |||
private Integer warehouseLevel;//仓库层级1-3 | |||
@ApiModelProperty(value = "仓库状态 0-删除 1-正常") | |||
private Integer status;//库存状态0-删除 1-正常 | |||
private EnableStatus status;//库存状态0-删除 1-正常 | |||
@ApiModelProperty(value = "更新时间") | |||
private LocalDateTime updateTime;//更新时间 |
@@ -4,6 +4,7 @@ import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.dict.BucketFileBus; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import cn.com.taiji.core.entity.dict.invw.InvDeviceStatus; | |||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||
import cn.com.taiji.core.entity.invw.InvwCardDetails; | |||
@@ -79,7 +80,7 @@ public class InvwCardDetailsManagerImpl extends AbstractInvwManager implements I | |||
if (!InvDeviceStatus.NEW.equals(cardDetails.getStatus())){ | |||
throw new ManagerException("设备正常在库时可移除"); | |||
} | |||
InvwWarehouse warehouse = warehouseRepo.findByCodeAndStatus(cardDetails.getStoreCode(), 1); | |||
InvwWarehouse warehouse = warehouseRepo.findByCodeAndStatus(cardDetails.getStoreCode(), EnableStatus.ENABLE); | |||
String agencyId = findAgencyIdByToken(dto.getAccessToken()); | |||
if (warehouse.getWarehouseLevel() == 1){//一级仓库设备黔通人员可操作 | |||
if(!"52010106004".equals(agencyId)){ | |||
@@ -135,7 +136,7 @@ public class InvwCardDetailsManagerImpl extends AbstractInvwManager implements I | |||
List<InvwCardDetails> cardDetails = page.getResult(InvwCardDetails.class); | |||
List<InvwCardDetailsExcelModel> excelModelList = SourceTargetMapper.INSTANCE.cardDetailsToExcelModel(cardDetails); | |||
//处理仓库名称 | |||
List<InvwWarehouse> storeList = warehouseRepo.queryByStatus(1);//查询正常的所有仓库 | |||
List<InvwWarehouse> storeList = warehouseRepo.queryByStatus(EnableStatus.ENABLE);//查询正常的所有仓库 | |||
Map<String, String> storeMap = storeList.stream().collect(Collectors.toMap(InvwWarehouse::getCode, InvwWarehouse::getName)); | |||
List<InvwCardDetailsExcelModel> excelModelList2 = excelModelList.stream().peek(t -> t.setStoreName(storeMap.get(t.getStoreCode()))).collect(Collectors.toList()); | |||
File file = EasyExcelUtil.exportExcelFile(InvwCardDetailsExcelModel.class, excelModelList2, "卡设备"); |
@@ -4,6 +4,7 @@ import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.dict.BucketFileBus; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import cn.com.taiji.core.entity.dict.basic.ObuType; | |||
import cn.com.taiji.core.entity.dict.invw.InvDeviceStatus; | |||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||
@@ -74,7 +75,7 @@ public class InvwObuDetailsManagerImpl extends AbstractInvwManager implements In | |||
public InvwObuDetailsRemoveResponseDTO remove(InvwObuDetailsRemoveRequestDTO dto) throws ManagerException { | |||
//先校验 | |||
InvwObuDetails obuDetails = repo.findById(dto.getId()).orElse(null); | |||
InvwWarehouse warehouse = warehouseRepo.findByCodeAndStatus(obuDetails.getStoreCode(), 1); | |||
InvwWarehouse warehouse = warehouseRepo.findByCodeAndStatus(obuDetails.getStoreCode(), EnableStatus.ENABLE); | |||
String agencyId = findAgencyIdByToken(dto.getAccessToken()); | |||
if (warehouse.getWarehouseLevel() == 1){//一级仓库设备黔通人员可操作 | |||
if(!"52010106004".equals(agencyId)){ | |||
@@ -150,7 +151,7 @@ public class InvwObuDetailsManagerImpl extends AbstractInvwManager implements In | |||
List<InvwObuDetails> obuDetails = page.getResult(InvwObuDetails.class); | |||
List<InvwObuDetailsExcelModel> excelModelList = SourceTargetMapper.INSTANCE.obuDetailsToExcelModel(obuDetails); | |||
//处理仓库名称 | |||
List<InvwWarehouse> storeList = warehouseRepo.queryByStatus(1);//查询正常的所有仓库 | |||
List<InvwWarehouse> storeList = warehouseRepo.queryByStatus(EnableStatus.ENABLE);//查询正常的所有仓库 | |||
Map<String, String> storeMap = storeList.stream().collect(Collectors.toMap(InvwWarehouse::getCode, InvwWarehouse::getName)); | |||
List<InvwObuDetailsExcelModel> excelModelList2 = excelModelList.stream().peek(t -> t.setStoreName(storeMap.get(t.getStoreCode()))).collect(Collectors.toList()); | |||
File file = EasyExcelUtil.exportExcelFile(InvwObuDetailsExcelModel.class, excelModelList2, "签设备"); |
@@ -3,6 +3,7 @@ package cn.com.taiji.invw.manager.stocktaking; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.dict.BucketFileBus; | |||
import cn.com.taiji.core.entity.dict.EnableStatus; | |||
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; | |||
import cn.com.taiji.core.entity.dict.invw.InvDeviceStatus; | |||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||
@@ -151,7 +152,7 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen | |||
if (stockModels == null || stockModels.size() == 0) { | |||
stockModels = new ArrayList<>(); | |||
// 查询仓库 | |||
List<InvwWarehouse> warehouses = warehouseRepo.findAllByStatus(1); | |||
List<InvwWarehouse> warehouses = warehouseRepo.findAllByStatus(EnableStatus.ENABLE); | |||
// 处理仓库 | |||
for (InvwWarehouse warehouse : warehouses) { |
@@ -2,6 +2,7 @@ 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.core.entity.dict.EnableStatus; | |||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||
import cn.com.taiji.core.entity.invw.InvwWarehouse; | |||
import cn.com.taiji.core.entity.user.Staff; | |||
@@ -63,7 +64,7 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
warehouse.setParentId(req.getParentId()); | |||
warehouse.setName(req.getName()); | |||
warehouse.setWarehouseLevel(level); | |||
warehouse.setStatus(1); | |||
warehouse.setStatus(EnableStatus.ENABLE); | |||
warehouse.setInsertTime(LocalDateTime.now()); | |||
warehouse.setUpdateTime(LocalDateTime.now()); | |||
warehouse.setAgencyId(req.getAgencyId()); | |||
@@ -136,7 +137,7 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
@Override | |||
public void edit(InvwWarehouseEditRequestDTO req) throws ManagerException { | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), 1); | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), EnableStatus.ENABLE); | |||
if (warehouse == null) { | |||
throw new ManagerException("仓库不存在"); | |||
} | |||
@@ -154,7 +155,7 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
//二级仓库 | |||
if (hasText(req.getParentId()) || hasText(req.getAgencyId())) { | |||
//查询下级仓库 | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findChiByIdAndStatus(warehouse.getId(), 1); | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findChiByIdAndStatus(warehouse.getId(), EnableStatus.ENABLE); | |||
if (warehouseList.size() > 0) { | |||
throw new ManagerException("该仓库有下级仓库,只能修改仓库名称"); | |||
} | |||
@@ -218,14 +219,14 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
@Override | |||
public void delete(InvwWarehouseDeleteRequestDTO req) throws ManagerException { | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), 1); | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), EnableStatus.ENABLE); | |||
if (warehouse == null) { | |||
throw new ManagerException("仓库不存在"); | |||
} | |||
if (warehouse.getWarehouseLevel() == 1) { | |||
throw new ManagerException("默认仓库不能删除"); | |||
} | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findChiByIdAndStatus(warehouse.getId(), 1); | |||
List<InvwWarehouse> warehouseList = warehouseRepo.findChiByIdAndStatus(warehouse.getId(), EnableStatus.ENABLE); | |||
if (warehouseList.size() > 0) { | |||
throw new ManagerException("该仓库有下级仓库,不能删除"); | |||
} | |||
@@ -237,7 +238,7 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
if (cardCount > 0) { | |||
throw new ManagerException("该仓库有设备,不能删除"); | |||
} | |||
warehouse.setStatus(0); | |||
warehouse.setStatus(EnableStatus.DISABLE); | |||
warehouse.setUpdateTime(LocalDateTime.now()); | |||
warehouseRepo.saveAndFlush(warehouse); | |||
persistOperateLog(OperateType.DELETE_WAREHOUSE, warehouse.getId(), req.getOrderSource(), findOpenIdByToken(req.getAccessToken()), "仓库删除"); | |||
@@ -245,7 +246,7 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
@Override | |||
public void check(InvwWarehouseCheckRequestDTO req) throws ManagerException { | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), 1); | |||
InvwWarehouse warehouse = warehouseRepo.findByIdAndStatus(req.getId(), EnableStatus.ENABLE); | |||
if (warehouse == null) { | |||
throw new ManagerException("仓库不存在"); | |||
} | |||
@@ -263,45 +264,45 @@ public class InvwWarehouseManagerImpl extends AbstractInvwManager implements Inv | |||
if (hasText(req.getId())) { | |||
warehouse = warehouseRepo.findById(req.getId()).orElse(null); | |||
} else { | |||
warehouseList = warehouseRepo.findAllByStatus(1); | |||
warehouseList = warehouseRepo.findAllByStatus(EnableStatus.ENABLE); | |||
} | |||
if(hasText(req.getType())) { | |||
switch (req.getType()) { | |||
case "1": | |||
warehouseList = warehouseRepo.findParByParentIdAndStatus(req.getId(), 1); | |||
warehouseList = warehouseRepo.findParByParentIdAndStatus(req.getId(), EnableStatus.ENABLE); | |||
break; | |||
case "2": | |||
if (warehouse != null) { | |||
if (hasText(warehouse.getParentId())) { | |||
warehouseList = warehouseRepo.findBroByParentIdAndStatus(warehouse.getParentId(), 1); | |||
warehouseList = warehouseRepo.findBroByParentIdAndStatus(warehouse.getParentId(), EnableStatus.ENABLE); | |||
} | |||
} | |||
break; | |||
case "3": | |||
warehouseList = warehouseRepo.findChiByIdAndStatus(req.getId(), 1); | |||
warehouseList = warehouseRepo.findChiByIdAndStatus(req.getId(), EnableStatus.ENABLE); | |||
break; | |||
case "4": | |||
if (warehouse != null) { | |||
if (hasText(warehouse.getParentId())) { | |||
warehouseList = warehouseRepo.findParBroByParentId(warehouse.getParentId(), 1); | |||
warehouseList = warehouseRepo.findParBroByParentId(warehouse.getParentId(), EnableStatus.ENABLE); | |||
} | |||
} | |||
break; | |||
case "5": | |||
if (warehouse != null) { | |||
if (hasText(warehouse.getParentId())) { | |||
warehouseList = warehouseRepo.findBroChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), 1); | |||
warehouseList = warehouseRepo.findBroChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), EnableStatus.ENABLE); | |||
} | |||
} | |||
break; | |||
case "6": | |||
if (warehouse != null) { | |||
warehouseList = warehouseRepo.findParChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), 1); | |||
warehouseList = warehouseRepo.findParChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), EnableStatus.ENABLE); | |||
} | |||
break; | |||
case "7": | |||
if (warehouse != null) { | |||
warehouseList = warehouseRepo.findParBroChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), 1); | |||
warehouseList = warehouseRepo.findParBroChiByParentIdOrId(warehouse.getParentId(), warehouse.getId(), EnableStatus.ENABLE); | |||
} | |||
break; | |||
} |