提交 fcf565e6 作者: zhangqiliang

仓库管理的查询的优化

父级 a35799a4
...@@ -19,6 +19,7 @@ public class WarehouseEx extends Warehouse { ...@@ -19,6 +19,7 @@ public class WarehouseEx extends Warehouse {
private String pathCode; private String pathCode;
private String pathName; private String pathName;
private String serviceProviderName;
public Integer getParentId() { public Integer getParentId() {
return parentId; return parentId;
...@@ -43,4 +44,12 @@ public class WarehouseEx extends Warehouse { ...@@ -43,4 +44,12 @@ public class WarehouseEx extends Warehouse {
public void setPathName(String pathName) { public void setPathName(String pathName) {
this.pathName = pathName; this.pathName = pathName;
} }
public String getServiceProviderName() {
return serviceProviderName;
}
public void setServiceProviderName(String serviceProviderName) {
this.serviceProviderName = serviceProviderName;
}
} }
...@@ -77,4 +77,6 @@ public class WarehouseDTO implements Serializable { ...@@ -77,4 +77,6 @@ public class WarehouseDTO implements Serializable {
private String receivePhone; private String receivePhone;
@ApiModelProperty(value = "收件地址") @ApiModelProperty(value = "收件地址")
private String receiveAddress; private String receiveAddress;
@ApiModelProperty(value = "安装服务商团队的名字")
private String serviceProviderName;
} }
...@@ -62,6 +62,12 @@ public interface WarehouseMapper extends CoreDao { ...@@ -62,6 +62,12 @@ public interface WarehouseMapper extends CoreDao {
* @return * @return
*/ */
Warehouse selectByPrimaryKey(String id); Warehouse selectByPrimaryKey(String id);
/**
* 根据id查询上级仓库ID数量
* @param id
* @return
*/
int selectBySuperiorWarehouseId(String id);
/** /**
* updateByExampleSelective * updateByExampleSelective
......
...@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -271,6 +272,11 @@ public class WarehouseService { ...@@ -271,6 +272,11 @@ public class WarehouseService {
} else { } else {
List<WarehouseDTO> result = new ArrayList<>(); List<WarehouseDTO> result = new ArrayList<>();
for (WarehouseEx warehouseEx : warehouseList) { for (WarehouseEx warehouseEx : warehouseList) {
//获取安装服务商的名字
Supplier supplier=supplierDao.selectById(Integer.valueOf(warehouseEx.getServiceProvider()));
if (supplier != null){
warehouseEx.setServiceProviderName(supplier.getName());
}
WarehouseDTO warehouseDTO = JSONUtilsEx.deserialize(JSONUtilsEx.serialize(warehouseEx), WarehouseDTO.class); WarehouseDTO warehouseDTO = JSONUtilsEx.deserialize(JSONUtilsEx.serialize(warehouseEx), WarehouseDTO.class);
if (warehouseEx.getParentId() == null) { if (warehouseEx.getParentId() == null) {
warehouseDTO.setIsDel(0); warehouseDTO.setIsDel(0);
...@@ -700,6 +706,11 @@ public class WarehouseService { ...@@ -700,6 +706,11 @@ public class WarehouseService {
* @param id * @param id
*/ */
public void delWarehouseById(String id) { public void delWarehouseById(String id) {
//仓库有子仓库则无法删除
int countId=warehouseMapper.selectBySuperiorWarehouseId(id);
if (countId>0){
throw new ServiceException("仓库下有子仓库,无法删除");
}
List<MaterialsDTO> materialList = getStockMaterialByWId(id); List<MaterialsDTO> materialList = getStockMaterialByWId(id);
if (!materialList.isEmpty()) { if (!materialList.isEmpty()) {
BigDecimal count = materialList.stream().filter(m -> m.getRemainingNumber() != null).map(MaterialsDTO::getRemainingNumber) BigDecimal count = materialList.stream().filter(m -> m.getRemainingNumber() != null).map(MaterialsDTO::getRemainingNumber)
......
server: server:
port: 30360 port: 30350
spring: spring:
application: application:
......
server: server:
port: 30360 port: 30350
spring: spring:
application: application:
......
...@@ -99,6 +99,10 @@ ...@@ -99,6 +99,10 @@
from t_warehouse from t_warehouse
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</select> </select>
<select id="selectBySuperiorWarehouseId" parameterType="java.lang.String" resultType="int">
select count(id) from t_warehouse where superior_warehouse_id = #{id,jdbcType=VARCHAR} and status = 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" > <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from t_warehouse delete from t_warehouse
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
......
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
LEFT JOIN t_warehouse_leven twl on tw.warehouse_leven_id = twl.id LEFT JOIN t_warehouse_leven twl on tw.warehouse_leven_id = twl.id
where where
tw.status = 1 tw.status = 1
and twl.`status` = 1
and tw.appkey = #{appkey} and tw.appkey = #{appkey}
<if test="id != null and id != ''"> <if test="id != null and id != ''">
and tw.id = #{id} and tw.id = #{id}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论