Browse Source

查询BUG修改

anderx 3 years ago
parent
commit
e1b2c701a2

+ 20 - 14
src/main/java/com/goafanti/admin/service/impl/DepartmentServiceImpl.java

@@ -69,6 +69,23 @@ public class DepartmentServiceImpl extends BaseMybatisDao<WorkingHoursMapper> im
 	public List<String> selectMyDeps() {
 		return selectCurrentDep(TokenManager.getAdminId());
 	}
+	private List<String> selectCurrentDep(String managerId){
+		List<String> alldep = new ArrayList<>();
+		List<String> superData = departmentMapper.selectCurrentDeps(managerId);
+		if (!superData.isEmpty())iterationDep(alldep,superData);
+		return alldep;
+	}
+
+	private void iterationDep(List<String> alldep, List<String> superData) {
+		for (String dep : superData) {
+			if (!alldep.contains(dep)){
+				alldep.add(dep);
+				List<String> deps2 = departmentMapper.selectSubDeps(dep);
+				if (!deps2.isEmpty())iterationDep(alldep,deps2);
+			}
+
+		}
+	}
 
 
 	@Override
@@ -85,24 +102,13 @@ public class DepartmentServiceImpl extends BaseMybatisDao<WorkingHoursMapper> im
 
 	@Override
 	public 	List<Department> selectSubordinateDeps(String depId){
-		return departmentMapper.selectSubDeps(depId);
+		return departmentMapper.selectSubDepsList(depId);
 	}
 
 
-	private List<String> selectCurrentDep(String managerId){
-		List<String> alldep = new ArrayList<>();
-		List<Department> superData = departmentMapper.selectCurrentDeps(managerId);
-		if (!superData.isEmpty())iterationDep(alldep,superData);
-		return alldep;
-	}
 
-	private void iterationDep(List<String> alldep, List<Department> superData) {
-		for (Department dep : superData) {
-			alldep.add(dep.getId());
-			List<Department> deps2 = departmentMapper.selectSubDeps(dep.getId());
-			if (!deps2.isEmpty())iterationDep(alldep,deps2);
-		}
-	}
+
+
 
 
 }

+ 3 - 2
src/main/java/com/goafanti/common/dao/DepartmentMapper.java

@@ -84,7 +84,8 @@ public interface DepartmentMapper {
      * @param superIds
      * @return
      */
-    List<Department> selectSubDeps(@Param("superIds")String superIds);
+    List<String> selectSubDeps(@Param("superIds")String superIds);
+    List<Department> selectSubDepsList(@Param("superIds")String superIds);
 
     List<depCountBo> selectBysuperId(String id);
 
@@ -93,7 +94,7 @@ public interface DepartmentMapper {
      * 查询当前集合
      * @return
      */
-    List<Department> selectCurrentDeps(@Param("aid")String aid);
+    List<String> selectCurrentDeps(@Param("aid")String aid);
 
     /**
      * 查询所有部门

+ 5 - 0
src/main/java/com/goafanti/common/mapper/DepartmentMapper.xml

@@ -453,6 +453,11 @@
     select id from department where super_id in (#{superIds,jdbcType=VARCHAR})
   </select>
 
+  <!-- 查询下一层级  -->
+  <select id="selectSubDepsList"  parameterType="java.lang.String" resultType="com.goafanti.common.model.Department">
+    select id from department where super_id in (#{superIds,jdbcType=VARCHAR})
+  </select>
+
   <select id="selectBysuperId"  resultType="com.goafanti.admin.bo.depCountBo">
     select a.id ,a.name ,0 userCount,0 inputCount,0 receiveCount, 0 completeCount, 0 interviewCount
     from department a  where a.super_id= #{id}

+ 12 - 39
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -965,10 +965,6 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	</if>
   	<if test="specially == 1">
   	and a.process_status = 1  and a.order_status = 1
-  	and a.order_dep in
-  	<foreach close=")" collection="deps" item="depId" open="(" separator=",">
-	 #{depId}
-  	</foreach>
   	</if>
   	<if test="specially == 2">
   	and a.order_status in(3,5)
@@ -1004,19 +1000,13 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	<if test="specially == 4">
   	and a.process_status in (4,5,6,99)
   	and a.order_status  in(1,2,3,4,6)
-      <if test="deps!=null">
-        and a.order_dep in
-        <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-          #{deps.id}
-        </foreach>
-      </if>
-  	</if>
-  	<if test="specially == 5">
-  	and a.order_dep in
-  	<foreach close=")" collection="deps" item="deps" open="(" separator=",">
-	 #{deps.id}
-  	</foreach>
   	</if>
+    <if test="deps!=null">
+      and a.order_dep in
+      <foreach close=")" collection="deps" item="dep" open="(" separator=",">
+        #{dep}
+      </foreach>
+    </if>
   	<if test="distribution == 0">
   	and a.process_status &lt; 5
   	</if>
@@ -1124,11 +1114,6 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
     </if>
   	<if test="specially == 1">
   	and a.process_status = 1  and a.order_status = 1
-  	<!-- and c.department_id in (#{deps,jdbcType=VARCHAR}) -->
-  	and a.order_dep in
-  	<foreach close=")" collection="deps" item="depId" open="(" separator=",">
-	 #{depId}
-  	</foreach>
   	</if>
   	<if test="specially == 2">
   	and a.order_status in(3,5)
@@ -1159,30 +1144,18 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
        </if>
        <if test="approval ==4">
            and a.approval in (1,2)
-           <if test="deps!=null">
-             and a.order_dep in
-             <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-               #{deps.id}
-             </foreach>
-           </if>
        </if>
      </if>
   	<if test="specially == 4">
   	and a.process_status in (4,5,6,99)
   	and a.order_status  in(1,2,3,4,6)
-      <if test="deps!=null">
-        and a.order_dep in
-        <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-          #{deps.id}
-        </foreach>
-      </if>
-  	</if>
-  	<if test="specially == 5">
-  	and a.order_dep in
-  	<foreach close=")" collection="deps" item="deps" open="(" separator=",">
-	 #{deps.id}
-  	</foreach>
   	</if>
+     <if test="deps!=null">
+       and a.order_dep in
+       <foreach close=")" collection="deps" item="dep" open="(" separator=",">
+         #{dep}
+       </foreach>
+     </if>
   	<if test="distribution == 0">
   	and a.process_status &lt; 5
   	</if>

+ 4 - 4
src/main/java/com/goafanti/common/mapper/TOrderTaskMapper.xml

@@ -1788,8 +1788,8 @@
       </if>
     <if test="deps != null">
       and b.order_dep in
-      <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-        #{deps.id}
+      <foreach close=")" collection="deps" item="dep" open="(" separator=",">
+        #{dep}
       </foreach>
     </if>
     <if test="contractNo != null">
@@ -1855,8 +1855,8 @@
       </if>
       <if test="deps != null">
         and b.order_dep in
-        <foreach close=")" collection="deps" item="deps" open="(" separator=",">
-          #{deps.id}
+        <foreach close=")" collection="deps" item="dep" open="(" separator=",">
+          #{dep}
         </foreach>
       </if>
       <if test="contractNo != null">

+ 9 - 7
src/main/java/com/goafanti/order/bo/InputOrderNewListBo.java

@@ -11,7 +11,7 @@ public class InputOrderNewListBo {
     private Integer specially;
     private Integer approval;
     private Integer distribution;
-    private List<String> deps;
+    private String deps;
     private String contractNo;
     private Integer outsource;
     private Integer liquidationStatus;
@@ -24,6 +24,14 @@ public class InputOrderNewListBo {
     private  Integer pageNo;
     private Integer pageSize;
 
+    public String getDeps() {
+        return deps;
+    }
+
+    public void setDeps(String deps) {
+        this.deps = deps;
+    }
+
     public String getAid() {
         return aid;
     }
@@ -88,13 +96,7 @@ public class InputOrderNewListBo {
         this.distribution = distribution;
     }
 
-    public List<String> getDeps() {
-        return deps;
-    }
 
-    public void setDeps(List<String> deps) {
-        this.deps = deps;
-    }
 
     public String getContractNo() {
         return contractNo;

+ 15 - 43
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -6,14 +6,7 @@ import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 
 
 import javax.mail.MessagingException;
@@ -28,7 +21,10 @@ import com.goafanti.order.enums.*;
 import com.goafanti.order.service.OrderProjectService;
 import com.goafanti.organization.bo.*;
 import com.goafanti.common.utils.StringUtils;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
 import groovy.transform.Synchronized;
+import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -630,51 +626,28 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			params.put("name", in.getName());
 		}
 		// 计算出所有本部门及所属部门的ID
-		List<String> departmentList = new ArrayList<>();
+		List<String>ls= JSON.parseArray(in.getDeps(),String.class);
+		List<String>departmentList=new ArrayList<>();
 		if(in.getSpecially()==1||in.getSpecially()==5) {
-			if (in.getDeps()!=null){
-				departmentList=departmentService.selectSubDeps(in.getDeps());
+			if (in.getDeps()!=null&&!ls.isEmpty()){
+				departmentList=departmentService.selectSubDeps(ls);
 			}else {
 				departmentList=departmentService.selectMyDeps();
 			}
-		}
-		if (in.getDeps()!=null) {
 			params.put("deps",departmentList);
+		}else {
+			if (in.getDeps()!=null&&!ls.isEmpty()) {
+				departmentList= ls;
+				params.put("deps",departmentList);
+			}
 		}
+
 		if (StringUtils.isNotBlank(in.getContractNo())) {
 			params.put("contractNo", in.getContractNo());
 		}
 		if (null!=in.getLiquidationStatus()) {
 			params.put("liquidationStatus", in.getLiquidationStatus());
-
-			if (null !=in.getApproval()) {
-				params.put("approval", in.getApproval());
-			}
-			if(null != in.getAmountStatus()) {
-				params.put("amountStatus", in.getAmountStatus());
-			}
-			if (StringUtils.isNotBlank(in.getOrderNo())) {
-				params.put("orderNo", in.getOrderNo());
-			}
-			if (StringUtils.isNotBlank(in.getStarTime())) {
-				params.put("starTime", in.getStarTime());
-			}
-			if (StringUtils.isNotBlank(in.getEndTime())) {
-				params.put("endTime", in.getEndTime()+" 23:59:59");
-			}
-			if (StringUtils.isNotBlank(in.getContractStart())) {
-				params.put("contractStart", in.getContractStart());
-			}
-			if (StringUtils.isNotBlank(in.getContractEnd())) {
-				params.put("contractEnd", in.getContractEnd()+" 23:59:59");
-			}
-			if(null != in.getProjectType()) {
-				params.put("projectType",in.getProjectType());
-			}
-			if(null != in.getProcessStatus()) {
-				params.put("processStatus",in.getProcessStatus());
-			}
-		} else {
+		}
 			if (null !=in.getApproval()) {
 				params.put("approval", in.getApproval());
 			}
@@ -702,7 +675,6 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			if(null != in.getProcessStatus()) {
 				params.put("processStatus",in.getProcessStatus());
 			}
-		}
 		params.put("outsource", in.getOutsource());
 		Pagination<TOrderNewBo> p = (Pagination<TOrderNewBo>)findPage("selectOrderNewListByPage", "selectOrderNewListCount", params, in.getPageNo(), in.getPageSize());
 		return p;

+ 2 - 2
src/main/java/com/goafanti/order/service/impl/OrderServiceImpl.java

@@ -1206,7 +1206,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 				superIds += om.getId() + ",";
 			}
 		}
-		if(StringUtils.isNotBlank(superIds)) subData = departmentMapper.selectSubDeps(superIds.substring(0, superIds.length()-1));
+		if(StringUtils.isNotBlank(superIds)) subData = departmentMapper.selectSubDepsList(superIds.substring(0, superIds.length()-1));
 		if(subData != null && subData.size()>0) {
 			allData.addAll(subData);
 			selectSubDeps(allData,subData);
@@ -1216,7 +1216,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 
 	private List<Department> selectCurrentDep(String managerId){
 		List<Department> allData = new ArrayList<Department>();
-		List<Department> superData = departmentMapper.selectCurrentDeps(managerId);
+		List<Department> superData = departmentMapper.selectSubDepsList(managerId);
 		if(superData != null && superData.size()>0){
 			allData.addAll(superData);
 		}