给报表增加默认有权限仓库的查询条件

This commit is contained in:
季圣华
2021-12-07 23:58:21 +08:00
parent f96f85952b
commit 9fac19502b
8 changed files with 171 additions and 60 deletions

View File

@@ -13,6 +13,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.exception.BusinessParamCheckingException;
import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.redis.RedisService;
@@ -56,6 +57,9 @@ public class DepotHeadController {
@Resource
private SupplierService supplierService;
@Resource
private DepotService depotService;
@Resource
private RedisService redisService;
@@ -101,7 +105,7 @@ public class DepotHeadController {
@RequestParam(value = "organId", required = false) Integer oId,
@RequestParam("number") String number,
@RequestParam("materialParam") String materialParam,
@RequestParam(value = "depotId", required = false) Integer depotId,
@RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
@@ -109,11 +113,22 @@ public class DepotHeadController {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Long> depotList = new ArrayList<>();
if(depotId != null) {
depotList.add(depotId);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotList.add(object.getLong("id"));
}
}
List<DepotHeadVo4InDetail> resList = new ArrayList<DepotHeadVo4InDetail>();
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
List<DepotHeadVo4InDetail> list = depotHeadService.findByAll(beginTime, endTime, type, materialParam, depotId, oId, number, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findByAllCount(beginTime, endTime, type, materialParam, depotId, oId, number);
List<DepotHeadVo4InDetail> list = depotHeadService.findByAll(beginTime, endTime, type, materialParam, depotList, oId, number, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findByAllCount(beginTime, endTime, type, materialParam, depotList, oId, number);
map.put("total", total);
//存放数据json数组
if (null != list) {
@@ -151,7 +166,7 @@ public class DepotHeadController {
@RequestParam("pageSize") Integer pageSize,
@RequestParam(value = "organId", required = false) Integer oId,
@RequestParam("materialParam") String materialParam,
@RequestParam(value = "depotId", required = false) Integer depotId,
@RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
@@ -159,11 +174,22 @@ public class DepotHeadController {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Long> depotList = new ArrayList<>();
if(depotId != null) {
depotList.add(depotId);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotList.add(object.getLong("id"));
}
}
List<DepotHeadVo4InOutMCount> resList = new ArrayList<>();
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotId, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotId, oId);
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotList, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId);
map.put("total", total);
//存放数据json数组
if (null != list) {
@@ -202,8 +228,8 @@ public class DepotHeadController {
@RequestParam("pageSize") Integer pageSize,
@RequestParam("number") String number,
@RequestParam("materialParam") String materialParam,
@RequestParam(value = "depotId", required = false) Integer depotId,
@RequestParam(value = "depotIdF", required = false) Integer depotIdF,
@RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam(value = "depotIdF", required = false) Long depotIdF,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("subType") String subType,
@@ -211,10 +237,32 @@ public class DepotHeadController {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Long> depotList = new ArrayList<>();
List<Long> depotFList = new ArrayList<>();
if(depotId != null) {
depotList.add(depotId);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotList.add(object.getLong("id"));
}
}
if(depotIdF != null) {
depotFList.add(depotIdF);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotFList.add(object.getLong("id"));
}
}
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
List<DepotHeadVo4InDetail> list = depotHeadService.findAllocationDetail(beginTime, endTime, subType, number, materialParam, depotId, depotIdF, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findAllocationDetailCount(beginTime, endTime, subType, number, materialParam, depotId, depotIdF);
List<DepotHeadVo4InDetail> list = depotHeadService.findAllocationDetail(beginTime, endTime, subType, number, materialParam, depotList, depotFList, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findAllocationDetailCount(beginTime, endTime, subType, number, materialParam, depotList, depotFList);
map.put("rows", list);
map.put("total", total);
res.code = 200;

View File

@@ -559,8 +559,19 @@ public class DepotItemController {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Long> depotList = new ArrayList<>();
if(depotId != null) {
depotList.add(depotId);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotList.add(object.getLong("id"));
}
}
String[] mpArr = mpList.split(",");
List<DepotItemStockWarningCount> list = depotItemService.findStockWarningCount((currentPage-1)*pageSize, pageSize,materialParam,depotId);
List<DepotItemStockWarningCount> list = depotItemService.findStockWarningCount((currentPage-1)*pageSize, pageSize, materialParam, depotList);
//存放数据json数组
if (null != list) {
for (DepotItemStockWarningCount disw : list) {
@@ -581,7 +592,7 @@ public class DepotItemController {
}
}
}
int total = depotItemService.findStockWarningCountTotal(materialParam,depotId);
int total = depotItemService.findStockWarningCountTotal(materialParam, depotList);
map.put("total", total);
map.put("rows", list);
res.code = 200;

View File

@@ -58,7 +58,7 @@ public interface DepotHeadMapperEx {
@Param("endTime") String endTime,
@Param("type") String type,
@Param("materialParam") String materialParam,
@Param("depotId") Integer depotId,
@Param("depotList") List<Long> depotList,
@Param("oId") Integer oId,
@Param("number") String number,
@Param("offset") Integer offset,
@@ -69,7 +69,7 @@ public interface DepotHeadMapperEx {
@Param("endTime") String endTime,
@Param("type") String type,
@Param("materialParam") String materialParam,
@Param("depotId") Integer depotId,
@Param("depotList") List<Long> depotList,
@Param("oId") Integer oId,
@Param("number") String number);
@@ -78,7 +78,7 @@ public interface DepotHeadMapperEx {
@Param("endTime") String endTime,
@Param("type") String type,
@Param("materialParam") String materialParam,
@Param("depotId") Integer depotId,
@Param("depotList") List<Long> depotList,
@Param("oId") Integer oId,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
@@ -88,7 +88,7 @@ public interface DepotHeadMapperEx {
@Param("endTime") String endTime,
@Param("type") String type,
@Param("materialParam") String materialParam,
@Param("depotId") Integer depotId,
@Param("depotList") List<Long> depotList,
@Param("oId") Integer oId);
List<DepotHeadVo4InDetail> findAllocationDetail(
@@ -97,8 +97,8 @@ public interface DepotHeadMapperEx {
@Param("subType") String subType,
@Param("number") String number,
@Param("materialParam") String materialParam,
@Param("depotId") Integer depotId,
@Param("depotIdF") Integer depotIdF,
@Param("depotList") List<Long> depotList,
@Param("depotFList") List<Long> depotFList,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
@@ -108,8 +108,8 @@ public interface DepotHeadMapperEx {
@Param("subType") String subType,
@Param("number") String number,
@Param("materialParam") String materialParam,
@Param("depotId") Integer depotId,
@Param("depotIdF") Integer depotIdF);
@Param("depotList") List<Long> depotList,
@Param("depotFList") List<Long> depotFList);
List<DepotHeadVo4StatementAccount> findStatementAccount(
@Param("beginTime") String beginTime,

View File

@@ -119,11 +119,11 @@ public interface DepotItemMapperEx {
@Param("offset") Integer offset,
@Param("rows") Integer rows,
@Param("materialParam") String materialParam,
@Param("depotId") Long depotId);
@Param("depotList") List<Long> depotList);
int findStockWarningCountTotal(
@Param("materialParam") String materialParam,
@Param("depotId") Long depotId);
@Param("depotList") List<Long> depotList);
BigDecimal getFinishNumber(
@Param("mId") Long mId,

View File

@@ -421,60 +421,62 @@ public class DepotHeadService {
}
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, String materialParam,
Integer depotId, Integer oId, String number,Integer offset, Integer rows) throws Exception{
List<Long> depotList, Integer oId, String number,Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findByAll(beginTime, endTime, type, materialParam, depotId, oId, number, offset, rows);
list =depotHeadMapperEx.findByAll(beginTime, endTime, type, materialParam, depotList, oId, number, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findByAllCount(String beginTime, String endTime, String type, String materialParam, Integer depotId, Integer oId, String number) throws Exception{
public int findByAllCount(String beginTime, String endTime, String type, String materialParam, List<Long> depotList, Integer oId, String number) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findByAllCount(beginTime, endTime, type, materialParam, depotId, oId, number);
result =depotHeadMapperEx.findByAllCount(beginTime, endTime, type, materialParam, depotList, oId, number);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, String materialParam, Integer depotId, Integer oId, Integer offset, Integer rows)throws Exception {
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, String materialParam, List<Long> depotList, Integer oId, Integer offset, Integer rows)throws Exception {
List<DepotHeadVo4InOutMCount> list = null;
try{
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotId, oId, offset, rows);
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotList, oId, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, String materialParam, Integer depotId, Integer oId)throws Exception {
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, String materialParam, List<Long> depotList, Integer oId)throws Exception {
int result = 0;
try{
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotId, oId);
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<DepotHeadVo4InDetail> findAllocationDetail(String beginTime, String endTime, String subType, String number, String materialParam, Integer depotId, Integer depotIdF, Integer offset, Integer rows) throws Exception{
public List<DepotHeadVo4InDetail> findAllocationDetail(String beginTime, String endTime, String subType, String number,
String materialParam, List<Long> depotList, List<Long> depotFList, Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findAllocationDetail(beginTime, endTime, subType, number, materialParam, depotId, depotIdF, offset, rows);
list =depotHeadMapperEx.findAllocationDetail(beginTime, endTime, subType, number, materialParam, depotList, depotFList, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findAllocationDetailCount(String beginTime, String endTime, String subType, String number, String materialParam, Integer depotId, Integer depotIdF) throws Exception{
public int findAllocationDetailCount(String beginTime, String endTime, String subType, String number,
String materialParam, List<Long> depotList, List<Long> depotFList) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findAllocationDetailCount(beginTime, endTime, subType, number, materialParam, depotId,depotIdF);
result =depotHeadMapperEx.findAllocationDetailCount(beginTime, endTime, subType, number, materialParam, depotList, depotFList);
}catch(Exception e){
JshException.readFail(logger, e);
}

View File

@@ -532,20 +532,20 @@ public class DepotItemService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public List<DepotItemStockWarningCount> findStockWarningCount(Integer offset, Integer rows, String materialParam, Long depotId) {
public List<DepotItemStockWarningCount> findStockWarningCount(Integer offset, Integer rows, String materialParam, List<Long> depotList) {
List<DepotItemStockWarningCount> list = null;
try{
list =depotItemMapperEx.findStockWarningCount(offset, rows, materialParam, depotId);
list =depotItemMapperEx.findStockWarningCount(offset, rows, materialParam, depotList);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int findStockWarningCountTotal(String materialParam, Long depotId) {
public int findStockWarningCountTotal(String materialParam, List<Long> depotList) {
int result = 0;
try{
result =depotItemMapperEx.findStockWarningCountTotal(materialParam, depotId);
result =depotItemMapperEx.findStockWarningCountTotal(materialParam, depotList);
}catch(Exception e){
JshException.readFail(logger, e);
}

View File

@@ -205,8 +205,11 @@
<if test="oId != null">
and dh.organ_id = #{oId}
</if>
<if test="depotId != null">
and di.depot_id = #{depotId}
<if test="depotList.size()>0">
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="type != null">
and dh.type=#{type}
@@ -239,8 +242,11 @@
<if test="oId != null">
and dh.organ_id = #{oId}
</if>
<if test="depotId != null">
and di.depot_id = #{depotId}
<if test="depotList.size()>0">
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="type != null">
and dh.type=#{type}
@@ -276,12 +282,25 @@
<if test="oId != null">
and dh.organ_id = #{oId}
</if>
<if test="depotId != null">
<if test="depotList.size()>0">
<if test="type == '入库'">
and ((di.depot_id = #{depotId} and dh.sub_type!='调拨') or (di.another_depot_id = #{depotId} and dh.sub_type='调拨'))
and ((
dh.sub_type!='调拨' and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
) or (
dh.sub_type='调拨' and di.another_depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
))
</if>
<if test="type == '出库'">
and di.depot_id = #{depotId}
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</if>
<if test="materialParam != null and materialParam !=''">
@@ -308,12 +327,25 @@
<if test="oId != null">
and dh.organ_id = #{oId}
</if>
<if test="depotId != null">
<if test="depotList.size()>0">
<if test="type == '入库'">
and ((di.depot_id = #{depotId} and dh.sub_type!='调拨') or (di.another_depot_id = #{depotId} and dh.sub_type='调拨'))
and ((
dh.sub_type!='调拨' and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
) or (
dh.sub_type='调拨' and di.another_depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
))
</if>
<if test="type == '出库'">
and di.depot_id = #{depotId}
and di.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</if>
<if test="materialParam != null and materialParam !=''">
@@ -335,11 +367,17 @@
<!-- 调出仓库名查询 -->
left join (select id as aid,name as SName,delete_Flag as adelete_Flag from jsh_depot ) ddd on ddd.aid=di.another_depot_id and ifnull(ddd.adelete_Flag,'0') !='1'
where dh.oper_time >=#{beginTime} and dh.oper_time &lt;=#{endTime}
<if test="depotIdF != null">
and di.depot_id = #{depotIdF}
<if test="depotFList.size()>0">
and di.depot_id in
<foreach collection="depotFList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="depotId != null">
and di.another_depot_id = #{depotId}
<if test="depotList.size()>0">
and di.another_depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="subType != null">
and dh.sub_type=#{subType}
@@ -367,11 +405,17 @@
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join (select id,name as dName,delete_Flag from jsh_depot) d on d.id=di.depot_id and ifnull(d.delete_Flag,'0') !='1'
where dh.oper_time >=#{beginTime} and dh.oper_time &lt;=#{endTime}
<if test="depotIdF != null">
and di.depot_id = #{depotIdF}
<if test="depotFList.size()>0">
and di.depot_id in
<foreach collection="depotFList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="depotId != null">
and di.another_depot_id = #{depotId}
<if test="depotList.size()>0">
and di.another_depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="subType != null">
and dh.sub_type=#{subType}

View File

@@ -441,8 +441,11 @@
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if test="depotId != null">
and mis.depot_id= #{depotId}
<if test="depotList.size()>0">
and mis.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
order by depotName asc
<if test="offset != null and rows != null">
@@ -469,8 +472,11 @@
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if test="depotId != null">
and mis.depot_id= #{depotId}
<if test="depotList.size()>0">
and mis.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
) tb
</select>