add countAvailable

This commit is contained in:
李宇奇 2025-02-23 20:33:09 +08:00
parent 2b6062b51c
commit 081467c514
6 changed files with 25 additions and 1 deletions

View File

@ -208,4 +208,10 @@ public class AppLocationController extends BaseController
} }
return success("创建成功。"); return success("创建成功。");
} }
@Anonymous
@GetMapping("/count")
public AjaxResult count() {
return success(appLocationService.countAvailable());
}
} }

View File

@ -114,7 +114,7 @@ public class SecurityConfig
requests.antMatchers("/login", "/register", "/captchaImage").permitAll() requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
// 静态资源可匿名访问 // 静态资源可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**","/app/pms/orderIn","/app/task/sendLocation", "/app/task/taskResult","/app/task/kk", "/system/storage/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**","/app/pms/orderIn","/app/task/sendLocation", "/app/task/taskResult","/app/task/kk", "/system/storage/**", "/app/location/count").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated(); .anyRequest().authenticated();
}) })

View File

@ -3,6 +3,7 @@ package com.ruoyi.app.mapper;
import com.ruoyi.app.domain.AppLocation; import com.ruoyi.app.domain.AppLocation;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 请填写功能名称Mapper接口 * 请填写功能名称Mapper接口
@ -66,4 +67,6 @@ public interface AppLocationMapper
* @return 结果 * @return 结果
*/ */
int deleteAppLocationByLocationIds(String[] locationIds); int deleteAppLocationByLocationIds(String[] locationIds);
Map<String, Integer> countAvailableStock();
} }

View File

@ -3,6 +3,7 @@ package com.ruoyi.app.service;
import com.ruoyi.app.domain.AppLocation; import com.ruoyi.app.domain.AppLocation;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 请填写功能名称Service接口 * 请填写功能名称Service接口
@ -75,4 +76,6 @@ public interface IAppLocationService
AppLocation requestLocation(int equipmentId); AppLocation requestLocation(int equipmentId);
String sendLocation(); String sendLocation();
Map<String, Integer> countAvailable();
} }

View File

@ -2,6 +2,7 @@ package com.ruoyi.app.service.impl;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -217,4 +218,8 @@ public class AppLocationServiceImpl implements IAppLocationService {
} }
return result; return result;
} }
public Map<String, Integer> countAvailable() {
return appLocationMapper.countAvailableStock();
}
} }

View File

@ -65,6 +65,13 @@
where location_id = #{locationId} where location_id = #{locationId}
</select> </select>
<select id="countAvailableStock" resultType="java.util.Map">
SELECT
(SELECT COUNT(*) FROM app_location) AS total_count,
(SELECT COUNT(*) FROM app_location WHERE location_status = 0) AS available_count
</select>
<insert id="insertAppLocation" parameterType="AppLocation"> <insert id="insertAppLocation" parameterType="AppLocation">
insert into app_location insert into app_location
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">