Browse Source

为出入库查询添加多层仓库查询

lwx_dev
erdanergou 3 years ago
parent
commit
c43a7055a1
  1. 20
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 48
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  3. 10
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  4. 3
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java

20
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -849,6 +849,16 @@ public class DepositoryRecordController {
List<ApplicationInRecordP> list = new ArrayList<>(); List<ApplicationInRecordP> list = new ArrayList<>();
Integer recordPCount = 0; Integer recordPCount = 0;
Integer maindeparment = userToken.getMaindeparment(); Integer maindeparment = userToken.getMaindeparment();
if (map.containsKey("depositoryId")) {
// 如果包含仓库id
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId"));
// 获取当前仓库下所有可见的仓库
List<Integer> allChildDepositoryById = depositoryService.findAllChildDepositoryById(depositoryId, userToken);
if (allChildDepositoryById.size() > 0) {
map.put("depositoryIdList", allChildDepositoryById);
map.remove("depositoryId");
}
}
if (PublicConfig.roleAdminorgList.contains(maindeparment)) { if (PublicConfig.roleAdminorgList.contains(maindeparment)) {
list = depositoryRecordService.findApplicationInRecordPByCondition(map, userToken, userKey, token); list = depositoryRecordService.findApplicationInRecordPByCondition(map, userToken, userKey, token);
recordPCount = depositoryRecordService.findApplicationInRecordPCountByCondition(map); recordPCount = depositoryRecordService.findApplicationInRecordPCountByCondition(map);
@ -1010,6 +1020,16 @@ public class DepositoryRecordController {
List<ApplicationOutRecordP> list = new ArrayList<>(); List<ApplicationOutRecordP> list = new ArrayList<>();
Integer countBy = 0; Integer countBy = 0;
Integer maindeparment = userByPort.getMaindeparment(); Integer maindeparment = userByPort.getMaindeparment();
if (map.containsKey("depositoryId")) {
// 如果包含仓库id
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId"));
// 获取当前仓库下所有可见的仓库
List<Integer> allChildDepositoryById = depositoryService.findAllChildDepositoryById(depositoryId, userByPort);
if (allChildDepositoryById.size() > 0) {
map.put("depositoryIdList", allChildDepositoryById);
map.remove("depositoryId");
}
}
if (PublicConfig.roleAdminorgList.contains(maindeparment)) { if (PublicConfig.roleAdminorgList.contains(maindeparment)) {
list = depositoryRecordService.findApplicationOutRecordPByCondition(map, userByPort, userKey, token); list = depositoryRecordService.findApplicationOutRecordPByCondition(map, userByPort, userKey, token);
countBy = depositoryRecordService.findApplicationOutRecordPCountByCondition(map); countBy = depositoryRecordService.findApplicationOutRecordPCountByCondition(map);

48
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -490,7 +490,7 @@
<if test="depositoryIdList != null"> <if test="depositoryIdList != null">
and did in and did in
<foreach collection="depositoryIdList" index="index" item="id" open="(" separator="," close=")"> <foreach collection="depositoryIdList" index="index" item="id" open="(" separator="," close=")">
#{did} #{id}
</foreach> </foreach>
</if> </if>
<if test="depositoryId != null and depositoryId != ''"> <if test="depositoryId != null and depositoryId != ''">
@ -535,9 +535,20 @@
<if test="applicantId != null and applicantId != ''"> <if test="applicantId != null and applicantId != ''">
and applicantId = #{applicantId} and applicantId = #{applicantId}
</if> </if>
<if test="depositoryId != null and depositoryId != ''"> <if test="depositoryIdList != null">
and depositoryId = #{depositoryId} and ( depositoryId
in
<foreach collection="depositoryIdList" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="depositoryIdList == null">
<if test="applicantId != null and applicantId != ''">
and applicantId = #{applicantId}
</if>
</if> </if>
<if test="mid != null and mid != ''"> <if test="mid != null and mid != ''">
and mid = #{mid} and mid = #{mid}
</if> </if>
@ -852,7 +863,7 @@
</if> </if>
<if test="depositoryIdList != null"> <if test="depositoryIdList != null">
and did in and did in
<foreach collection="depositoryIdList" index="index" item="id" open="(" separator="," close=")"> <foreach collection="depositoryIdList" index="index" item="did" open="(" separator="," close=")">
#{did} #{did}
</foreach> </foreach>
</if> </if>
@ -877,9 +888,20 @@
<if test="applicantId != null and applicantId != ''"> <if test="applicantId != null and applicantId != ''">
and applicantId = #{applicantId} and applicantId = #{applicantId}
</if> </if>
<if test="depositoryId != null and depositoryId != ''"> <if test="depositoryIdList != null">
and depositoryId = #{depositoryId} and ( depositoryId
in
<foreach collection="depositoryIdList" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if> </if>
<if test="depositoryIdList == null">
<if test="applicantId != null and applicantId != ''">
and applicantId = #{applicantId}
</if>
</if>
<if test="mid != null and mid != ''"> <if test="mid != null and mid != ''">
and mid = #{mid} and mid = #{mid}
</if> </if>
@ -916,22 +938,30 @@
<if test="depositoryManagerTime != null and depositoryManagerTime != null"> <if test="depositoryManagerTime != null and depositoryManagerTime != null">
and depositoryManagerTime >= #{depositoryManagerTime} and depositoryManagerTime >= #{depositoryManagerTime}
</if> </if>
<if test="depositoryManagerMessage != null and depositoryManagerMessage != null"> <if test="depositoryManagerMessage != null and depositoryManagerMessage != ''">
and depositoryManagerMessage like CONCAT('%', #{depositoryManagerMessage}, '%') and depositoryManagerMessage like CONCAT('%', #{depositoryManagerMessage}, '%')
</if> </if>
<if test="aorstate != null and aorstate != null"> <if test="aorstate != null and aorstate != ''">
and aorstate like CONCAT('%', #{state}, '%') and aorstate like CONCAT('%', #{state}, '%')
</if> </if>
<if test="istransfer != null and istransfer != ''"> <if test="istransfer != null and istransfer != ''">
and istransfer = #{istransfer} and istransfer = #{istransfer}
</if> </if>
<if test="version != null and version != ''">
and mversion = #{version}
</if>
<if test="code != null and code != ''">
and mcode = #{code}
</if>
<if test="placeId != null">
and placeId = #{placeId}
</if>
<if test="adminorgid != null and adminorgid != ''"> <if test="adminorgid != null and adminorgid != ''">
and adminorgid = #{adminorgid} and adminorgid = #{adminorgid}
</if> </if>
<if test="constructionunitid != null and constructionunitid != ''"> <if test="constructionunitid != null and constructionunitid != ''">
and constructionunitid = #{constructionunitid} and constructionunitid = #{constructionunitid}
</if> </if>
</select> </select>

10
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -4330,7 +4330,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
if (map.containsKey("depositoryId")) { if (map.containsKey("depositoryId")) {
depositoryIdList.add(ObjectFormatUtil.toInteger(map.get("depositoryId"))); depositoryIdList.add(ObjectFormatUtil.toInteger(map.get("depositoryId")));
} else { } else if (!map.containsKey("depositoryIdList")) {
List<RoleAndDepository> depositoryAndRole = roleService.findDepositoryAndRole(userByPort.getId()); List<RoleAndDepository> depositoryAndRole = roleService.findDepositoryAndRole(userByPort.getId());
depositoryAndRole.addAll(roleService.findDepositoryAndRole(userByPort.getPosition())); depositoryAndRole.addAll(roleService.findDepositoryAndRole(userByPort.getPosition()));
for (RoleAndDepository depository : depositoryAndRole for (RoleAndDepository depository : depositoryAndRole
@ -4340,10 +4340,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (depositoryIdList.size() == 0) { if (depositoryIdList.size() == 0) {
depositoryIdList = null; depositoryIdList = null;
} }
map.put("depositoryIdList", depositoryIdList);
} }
map.put("depositoryIdList", depositoryIdList);
List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByUser(map); List<ApplicationOutRecord> list = depositoryRecordMapper.findApplicationOutRecordPByUser(map);
List<ApplicationOutRecordP> result = new ArrayList<>(); List<ApplicationOutRecordP> result = new ArrayList<>();
for (ApplicationOutRecord record : list) { for (ApplicationOutRecord record : list) {
@ -4376,7 +4374,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
if (map.containsKey("depositoryId")) { if (map.containsKey("depositoryId")) {
depositoryIdList.add(ObjectFormatUtil.toInteger(map.get("depositoryId"))); depositoryIdList.add(ObjectFormatUtil.toInteger(map.get("depositoryId")));
} else { } else if(!map.containsKey("depositoryIdList")){
List<RoleAndDepository> depositoryAndRole = roleService.findDepositoryAndRole(userByPort.getId()); List<RoleAndDepository> depositoryAndRole = roleService.findDepositoryAndRole(userByPort.getId());
depositoryAndRole.addAll(roleService.findDepositoryAndRole(userByPort.getPosition())); depositoryAndRole.addAll(roleService.findDepositoryAndRole(userByPort.getPosition()));
@ -4387,9 +4385,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (depositoryIdList.size() == 0) { if (depositoryIdList.size() == 0) {
depositoryIdList = null; depositoryIdList = null;
} }
map.put("depositoryIdList", depositoryIdList);
} }
map.put("depositoryIdList", depositoryIdList);
return depositoryRecordMapper.findApplicationOutRecordPCountByUser(map); return depositoryRecordMapper.findApplicationOutRecordPCountByUser(map);
} }

3
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java

@ -433,6 +433,9 @@ public class DepositoryServiceImpl implements DepositoryService {
depositoryIdList.add(depository.getId()); depositoryIdList.add(depository.getId());
} }
} }
if(PublicConfig.roleAdminorgList.contains(userByPort.getMaindeparment())){
return depositoryIdList;
}
//用于查询当前用户所拥有及所管理的仓库 //用于查询当前用户所拥有及所管理的仓库
List<Integer> depositoryIdForUserHas = roleService.findDepositoryIdForUserHas(userByPort); List<Integer> depositoryIdForUserHas = roleService.findDepositoryIdForUserHas(userByPort);
depositoryIdList = (List<Integer>) CollectionUtils.intersection(depositoryIdList, depositoryIdForUserHas); depositoryIdList = (List<Integer>) CollectionUtils.intersection(depositoryIdList, depositoryIdForUserHas);

Loading…
Cancel
Save