Browse Source

订单查询部门筛选BUG修复

anderx 3 years ago
parent
commit
a89f91069d

+ 38 - 26
src/main/java/com/goafanti/common/mapper/PatentNewMapper.xml

@@ -3,8 +3,8 @@
 <mapper namespace="com.goafanti.common.dao.PatentNewMapper">
 	<resultMap id="BaseResultMap"
 		type="com.goafanti.common.model.PatentNew">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		<id column="id" jdbcType="INTEGER" property="id" />
 		<result column="patent_no" jdbcType="VARCHAR"
@@ -51,8 +51,8 @@
 		<result column="end_date" jdbcType="DATE" property="endDate" />
 	</resultMap>
 	<sql id="Base_Column_List">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		id, patent_no, `name`, `type`, `status`, apply_date,
 		authorization_date, patent_amount,
@@ -64,8 +64,8 @@
 	</sql>
 	<select id="selectByPrimaryKey"
 		parameterType="java.lang.Integer" resultMap="BaseResultMap">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		select
 		<include refid="Base_Column_List" />
@@ -74,16 +74,16 @@
 	</select>
 	<delete id="deleteByPrimaryKey"
 		parameterType="java.lang.Integer">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		delete from patent_new
 		where id = #{id,jdbcType=INTEGER}
 	</delete>
 	<insert id="insert"
 		parameterType="com.goafanti.common.model.PatentNew">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		insert into patent_new (id, patent_no, `name`,
 		`type`, `status`, apply_date,
@@ -114,8 +114,8 @@
 	</insert>
 	<insert id="insertSelective"
 		parameterType="com.goafanti.common.model.PatentNew">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		insert into patent_new
 		<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -293,8 +293,8 @@
 	</insert>
 	<update id="updateByPrimaryKeySelective"
 		parameterType="com.goafanti.common.model.PatentNew">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		update patent_new
 		<set>
@@ -384,8 +384,8 @@
 	</update>
 	<update id="updateByPrimaryKey"
 		parameterType="com.goafanti.common.model.PatentNew">
-		<!-- WARNING - @mbg.generated This element is automatically generated by 
-			MyBatis Generator, do not modify. This element was generated on Mon Aug 09 
+		<!-- WARNING - @mbg.generated This element is automatically generated by
+			MyBatis Generator, do not modify. This element was generated on Mon Aug 09
 			14:41:21 CST 2021. -->
 		update patent_new
 		set patent_no = #{patentNo,jdbcType=VARCHAR},
@@ -429,7 +429,7 @@
 		a.patent_amount as patentAmount,a.delaying_amount delayingAmount ,a.recovery_amount
 		recoveryAmount, c.commodity_name projectName , c.id tid,tm.salesman_name salesmanName ,
 		c.receiver_name techName, tm.dep_name depName,ia.name inputName
-		from patent_new a left join admin b on a.aid=b.id 
+		from patent_new a left join admin b on a.aid=b.id
 		left join t_order_task c on a.tid =c.id left join t_order_mid tm on c.order_no =tm.order_no
 		left join admin ia on a.input_id =ia.id
 		<if test="shiro ==1">
@@ -475,13 +475,19 @@
 			and b.name like concat('%',#{aname},'%')
 		</if>
 		<if test="depName != null">
-			and tm.dep_name = #{depName}
+			and tm.dep_name  = #{depName}
 		</if>
 		<if test="inputDep != null">
-			and ia.department_id = #{inputDep}
+			and ia.department_id in
+			<foreach close=")" collection="inputDep" item="deps" open="(" separator=",">
+				#{deps.id}
+			</foreach>
 		</if>
 		<if test="followDep != null">
-			and b.department_id  = #{followDep}
+			and b.department_id  in
+			<foreach close=")" collection="followDep" item="f" open="(" separator=",">
+				#{f.id}
+			</foreach>
 		</if>
 		<if test="salesmanRemind !=null">
 			and a.salesman_remind= #{salesmanRemind}
@@ -540,13 +546,19 @@
 			and b.name like concat('%',#{aname},'%')
 		</if>
 		<if test="depName != null">
-			and tm.dep_name = #{depName}
+			and tm.dep_name  = #{depName}
 		</if>
 		<if test="inputDep != null">
-			and ia.department_id = #{inputDep}
+			and ia.department_id in
+			<foreach close=")" collection="inputDep" item="deps" open="(" separator=",">
+				#{deps.id}
+			</foreach>
 		</if>
 		<if test="followDep != null">
-			and b.department_id  = #{followDep}
+			and b.department_id  in
+			<foreach close=")" collection="followDep" item="f" open="(" separator=",">
+				#{f.id}
+			</foreach>
 		</if>
 		<if test="salesmanRemind !=null">
 			and a.salesman_remind= #{salesmanRemind}
@@ -623,7 +635,7 @@
 	</update>
 	<update id="updateBatchByid">
 		update patent_new
-		
+
 		<set>
 			<if test="status != null">
 				status= #{status},
@@ -631,7 +643,7 @@
 			<if test="aid != null">
 				aid= #{aid},
 			</if>
-			
+
 		</set>
 		where id in
 		<foreach item="item" collection="list" open="(" separator=","
@@ -661,4 +673,4 @@
 		a.order_no =b.order_no
 		where a.id = #{tid}
 	</select>
-</mapper>
+</mapper>

+ 19 - 2
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -969,7 +969,6 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	<foreach close=")" collection="deps" item="deps" open="(" separator=",">
 	 #{deps.id}
   	</foreach>
-
   	</if>
   	<if test="specially == 2">
   	and a.order_status in(3,5)
@@ -1005,6 +1004,12 @@ 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
@@ -1153,12 +1158,24 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
          and a.approval =2
        </if>
        <if test="approval ==4">
-         and a.approval in (1,2)
+           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

+ 5 - 6
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -634,18 +634,17 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		// 计算出所有本部门及所属部门的ID
 		List<Department> deps = new ArrayList<>();
 		if(specially==1||specially==5) {
-			deps = orderService.selectMyDeps();
-			if (StringUtils.isNotBlank(depId)) {
-				if (deps.contains(depId)){
-					deps=departmentService.getLowerDep(depId);
-				}
+			if (depId!=null){
+				deps=departmentService.selectSubDeps(depId,0,1);
+			}else {
+				deps=departmentService.selectMyDeps();
 			}
 		}else {
 			if (StringUtils.isNotBlank(depId)) {
 				deps=departmentService.getLowerDep(depId);
 			}
 		}
-
+		if (!deps.isEmpty())params.put("deps",deps);
 		if (StringUtils.isNotBlank(contractNo)) {
 			params.put("contractNo", contractNo);
 		}

+ 26 - 17
src/main/java/com/goafanti/patent/service/impl/PatentNewServiceImpl.java

@@ -12,6 +12,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import com.goafanti.admin.service.DepartmentService;
 import com.mysql.jdbc.log.Log;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
@@ -73,7 +74,9 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 	private AsyncUtils asyncUtils;
 	@Autowired
 	private AdminMapper	adminMapper;
-	
+	@Autowired
+	private DepartmentService departmentService;
+
 	private List<PatentYearPayment> patentYear=new ArrayList<PatentYearPayment>();
 
 
@@ -94,7 +97,7 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		Admin a = adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
 		PatentNew pn=patentNewMapper.selectByPrimaryKey(p.getId());
 		StringBuffer str=new StringBuffer(a.getName());
-		if (!p.getApplyDate().equals(pn.getApplyDate()) 
+		if (!p.getApplyDate().equals(pn.getApplyDate())
 				|| p.getType() != pn.getType()) {
 			p.setYears(getyear(p));
 			p.setPatentAmount(sumAmout(p.getType(),p.getTid(),p.getYears()));
@@ -107,7 +110,7 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		addPatentNewLog(p,pn,str);
 		return patentNewMapper.updateByPrimaryKeySelective(p);
 	}
-	
+
 	private void addPatentNewLog(PatentNewBo p, PatentNew pn, StringBuffer str) {
 		PatentNewLog pl = new PatentNewLog();
 		pl.setPid(p.getId());
@@ -223,12 +226,18 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		if(p.getCreateStarts()!=null)params.put("createStarts", p.getCreateStarts());
 		if(p.getCreateEnds()!=null)params.put("createEnds", p.getCreateEnds()+" 23:59:59");
 		if(p.getType()!=null)params.put("type", p.getType());
-		if(p.getDepName()!=null)params.put("depName", p.getDepName());
+		if(p.getDepName()!=null){
+			params.put("depName",  p.getDepName());
+		}
 		if(p.getAnnualFeeStatus()!=null)params.put("annualFeeStatus", p.getAnnualFeeStatus());
 		if(p.getUserName()!=null)params.put("userName", p.getUserName());
 		if(p.getSalesmanRemind()!=null)params.put("salesmanRemind", p.getSalesmanRemind());
-		if(p.getInputDep()!=null)params.put("inputDep", p.getInputDep());
-		if(p.getFollowDep()!=null)params.put("followDep", p.getFollowDep());
+		if(p.getInputDep()!=null){
+			params.put("inputDep", departmentService.getLowerDep(p.getInputDep()));
+		}
+		if(p.getFollowDep()!=null){
+			params.put("followDep", departmentService.getLowerDep(p.getFollowDep()));
+		}
 
 		if(p.getIsFollow()!=null) {
 			params.put("isFollow", p.getIsFollow());
@@ -364,7 +373,7 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 							trb.setTid(Integer.parseInt(str));
 						}
 						break;
-					
+
 			        }
 			    	} catch (Exception e) {
 			    		e.printStackTrace();
@@ -398,7 +407,7 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		        }
 		        list.add(trb);
 		        if (trb.getStatus()!=0) {
-		        	Notice n = addNotice(trb); 
+		        	Notice n = addNotice(trb);
 		        	n.setId(UUID.randomUUID().toString());
 		        	n.setCreateTime(date);
 		        	n.setReaded(0);// 未读
@@ -406,7 +415,7 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 					nl.add(n);
 				}
 		    }
-    		
+
     		List<PatentNew> list2=new ArrayList<>();
     		for (int i = 0; i < list.size(); i++) {
     			list2.add(list.get(i));
@@ -415,12 +424,12 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
     					patentNewMapper.insertBatch(list2);
     				}
     				list2.clear();
-    				
+
     			}
     		}
     		asyncUtils.addNoticeBatch(nl);
         }
-        
+
     }
 
 	private Notice addNotice(PatentNew p) {
@@ -455,7 +464,7 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		}
 		return n;
 	}
-	
+
 	private String StrToString(StringBuffer str, Date date, Integer status) {
 		//状态 0 未提醒 1 剩余90天 2剩余30天 3剩余20天 4剩余10天 5剩余3天 6剩余2天 7剩余1天
 		Integer days=0;
@@ -536,9 +545,9 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 		pd.setYears(i);
 	}
 
-	
 
-	
+
+
 
 	private BigDecimal sumAmout(Integer type,Integer tid,Integer year) {
 		if (patentYear.isEmpty()) {
@@ -656,9 +665,9 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 	@Override
 	public void updateBatchStatusByid(List<String> l2, Integer status) {
 		patentNewMapper.updateBatchByid(l2,status,null);
-		
+
 	}
-	
+
 	/**
 	 * 超过时间重置到第二年
 	 */
@@ -753,6 +762,6 @@ public class PatentNewServiceImpl  extends BaseMybatisDao<PatentNewMapper> imple
 			patentNewLogMapper.insertSelective(pl);
 			patentNewMapper.updateByPrimaryKeySelective(pn);
 		}
-		
+
 	}
 }