Browse Source

修复订单BUG

wanghui 7 years ago
parent
commit
28a6f75056

+ 6 - 8
src/main/java/com/goafanti/common/dao/ContractMapper.java

@@ -106,12 +106,10 @@ public interface ContractMapper {
 	 * @param taskDistribution
 	 * @return
 	 */
-	int updateRepairData(@Param("orderNo")String orderNo,@Param("taskDistribution") int taskDistribution);
-	
-	/**
-	 * 判断项目单分配情况
-	 * @param orderNo
-	 * @return
-	 */
-	TmpTable selectTaskDistribution(@Param("orderNo") String orderNo);
+	int updateRepairData(@Param("contractId")String contractId,@Param("taskDistribution") int taskDistribution);
+
+
+	int selectTaskAllCount(@Param("contractId")String contractId);
+
+	int selectTaskDisCount(@Param("contractId")String contractId);
 }

+ 22 - 7
src/main/java/com/goafanti/common/mapper/ContractMapper.xml

@@ -764,14 +764,29 @@
    </insert>
    
    <update id="updateRepairData">
-		update contract set task_distribution = #{taskDistribution,jdbcType=VARCHAR} where order_no = #{orderNo,jdbcType=VARCHAR} 
+		update contract set task_distribution = #{taskDistribution,jdbcType=VARCHAR} where id = #{contractId,jdbcType=VARCHAR} 
    </update>
+  
+   <select id="selectTaskAllCount" parameterType="java.lang.String"  resultType="java.lang.Integer">
+		select
+			count( 0 ) as all_count
+		from
+			contract_task a left join contract b on
+			a.contract_id = b.id
+		where
+			a.deleted_sign <![CDATA[ <> ]]> 1
+			and a.contract_id = #{contractId,jdbcType=VARCHAR}	
+   </select>
    
-   <select id="selectTaskDistribution" parameterType="java.lang.String" resultType="com.goafanti.common.model.TmpTable">
-		select x.order_no as orderNO,x.all_count as allCount,y.dis_count as disCount from (
-			select b.order_no,count(0) as all_count from contract_task a left join contract b on a.contract_id = b.id where a.deleted_sign <![CDATA[ <> ]]> 1 group by b.order_no) x 
-		inner join (
-			select b.order_no,count(0) as dis_count from contract_task a left join contract b on a.contract_id = b.id where a.deleted_sign <![CDATA[ <> ]]> 1 and a.task_status = 1 group by b.order_no)y
-		on x.order_no = y.order_no and x.order_no = #{orderNo,jdbcType=VARCHAR}
+   <select id="selectTaskDisCount" parameterType="java.lang.String"  resultType="java.lang.Integer">
+		select
+			count( 0 ) as dis_count
+		from
+			contract_task a left join contract b on
+			a.contract_id = b.id
+		where
+			a.deleted_sign <![CDATA[ <> ]]> 1
+			and a.task_status <![CDATA[ <> ]]> 0
+			and a.contract_id = #{contractId,jdbcType=VARCHAR}
    </select>
 </mapper>

+ 4 - 3
src/main/java/com/goafanti/customer/bo/CustomerListIn.java

@@ -78,13 +78,14 @@ public class CustomerListIn {
 	private String consultant;
 	
 	/** 专家审核状态 **/
-	private Integer expertAudit ;
+	private String expertAudit ;
 
-	public Integer getExpertAudit() {
+	
+	public String getExpertAudit() {
 		return expertAudit;
 	}
 
-	public void setExpertAudit(Integer expertAudit) {
+	public void setExpertAudit(String expertAudit) {
 		this.expertAudit = expertAudit;
 	}
 

+ 3 - 3
src/main/java/com/goafanti/customer/bo/CustomerListOut.java

@@ -17,7 +17,7 @@ public class CustomerListOut extends CustomerListIn{
 	private String adminName;
 	
 	/** 专家发布状态**/
-	private Integer releaseStatus;
+	private String releaseStatus;
 	
 	/** 审核意见**/
 	private String auditOpinion;
@@ -30,11 +30,11 @@ public class CustomerListOut extends CustomerListIn{
 		this.auditOpinion = auditOpinion;
 	}
 
-	public Integer getReleaseStatus() {
+	public String getReleaseStatus() {
 		return releaseStatus;
 	}
 
-	public void setReleaseStatus(Integer releaseStatus) {
+	public void setReleaseStatus(String releaseStatus) {
 		this.releaseStatus = releaseStatus;
 	}
 

+ 11 - 12
src/main/java/com/goafanti/techproject/service/impl/TechProjectServiceImpl.java

@@ -379,8 +379,7 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 			task.setDeletedSign(DeleteStatus.UNDELETE.getCode());
 			contractTaskMapper.insert(task);
 		}
-		Contract contract = contractMapper.selectByPrimaryKey(contractId);
-		return setTaskDistribution(contract);
+		return setTaskDistribution(contractId);
 	}
 
 	@Override
@@ -429,8 +428,7 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 				throw new BusinessException(new Error(ErrorConstants.NOT_ACCORD_WITH_NEXT, taskId, ""));
 		}
 		contractTaskMapper.deleteByPrimaryKey(taskId);
-		Contract contract = contractMapper.selectByPrimaryKey(task.getContractId());
-		return setTaskDistribution(contract);
+		return setTaskDistribution(task.getContractId());
 	}
 
 	@Override
@@ -483,16 +481,18 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 		return contractMapper.updateByPrimaryKeySelective(contract);
 	}
 
-	private int setTaskDistribution(Contract contract){
-		TmpTable tt = contractMapper.selectTaskDistribution(contract.getOrderNo());
+	private int setTaskDistribution(String contractId){
+		int allCount = contractMapper.selectTaskAllCount(contractId);
+		int disCount = contractMapper.selectTaskDisCount(contractId);
 		int taskDistribution = TaskDistributionState.NOT_DISTRIBUTION.getCode();
-		if (tt.getAllCount() == tt.getDisCount())
+		if (allCount == disCount)
 			taskDistribution = TaskDistributionState.ALL_DISTRIBUTION.getCode();
-		else if (tt.getAllCount() > tt.getDisCount() && tt.getDisCount() != 0)
+		else if (allCount > disCount && disCount != 0)
 			taskDistribution = TaskDistributionState.PART_DISTRIBUTION.getCode();
-		else if (tt.getAllCount() > tt.getDisCount() && tt.getDisCount() == 0)
+		else if (allCount > disCount && disCount == 0)
 			taskDistribution = TaskDistributionState.NOT_DISTRIBUTION.getCode();
-		return contractMapper.updateRepairData(tt.getOrderNo(), taskDistribution);
+			contractMapper.updateRepairData(contractId, taskDistribution);
+		return 1;
 	}
 
 	@Override
@@ -505,8 +505,7 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 			task.setTaskDistributionTime(new Date());
 			task.setTaskStatus(TaskState.DISTRIBUTION.getCode());
 			contractTaskMapper.updateByPrimaryKeySelective(task);
-			Contract contract = contractMapper.selectByPrimaryKey(task.getContractId());
-			return setTaskDistribution(contract);
+			return setTaskDistribution(task.getContractId());
 		}
 		return 0;
 	}