提交 fcf565e6 作者: zhangqiliang

仓库管理的查询的优化

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