Browse Source

新增营销员所负责的订单关联项目的查询

anderx 7 years ago
parent
commit
bba0b850a6

+ 4 - 0
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -38,6 +38,10 @@ public class AFTConstants {
 	public static final String	COPYRIGHT							= "软著申请管理";
 
 	public static final String	TECHPROJECT							= "科技项目申报管理";
+	
+	public static final String	DEFAULT_INITIATOR					= "管理员";
+	
+	public static final String	CONSULTANT_MANAGER					= "刘扶桑";
 
 	public static final int		KEYWORDLENTH						= 16;
 

+ 181 - 10
src/main/java/com/goafanti/common/mapper/TechProjectMapper.xml

@@ -764,7 +764,7 @@ from
 		a.task_receiver = b.id
 	where a.contract_id = #{contractId,jdbcType=VARCHAR}
   </select>
-  <select id="selectProjectTaskByPage" resultType="com.goafanti.techproject.bo.TaskListBo">
+  <select id="selectMyProjectTaskByPage" resultType="com.goafanti.techproject.bo.TaskListBo">
 			select
 			a.id as taskId,
 			a.commodity_id as commodityId,
@@ -783,10 +783,7 @@ from
 			e.nickname as buyerName,
 			f.name as taskReceiverName
 		from
-			(select *
-		from contract_task_log
-		where task_receiver= #{taskReceiver,jdbcType=VARCHAR}) x left join contract_task a on 
-			x.contract_task_id=a.id	left join business_project b on
+			contract_task a left join business_project b on
 			a.commodity_id = b.id left join business_varieties c on
 			b.cid = c.id left join contract d on
 			a.contract_id = d.id left join user e on
@@ -829,14 +826,11 @@ from
 		</if>
   </select>
   
-  <select id="selectProjectTaskCount" resultType="java.lang.Integer">
+  <select id="selectMyProjectTaskCount" resultType="java.lang.Integer">
   		select
 			count(0)
 		from
-			(select *
-		from contract_task_log
-		where task_receiver= #{taskReceiver,jdbcType=VARCHAR}) x left join contract_task a on 
-			x.contract_task_id=a.id	left join business_project b on
+			contract_task a left join business_project b on
 			a.commodity_id = b.id left join business_varieties c on
 			b.cid = c.id left join contract d on
 			a.contract_id = d.id left join user e on
@@ -873,6 +867,41 @@ from
 		<if test="categoryId != null and categoryId != ''">
 			and c.id = #{categoryId,jdbcType=VARCHAR}
 		</if>
+		
+		<if test="taskReceiverId != null and taskReceiverId != ''">
+			and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
+		</if>
+		<if test="deleteSign != null">
+			and a.deleted_sign = #{deleteSign,jdbcType=VARCHAR}
+		</if>
+		<if test="publishStatus != null">
+			and a.publish_status = #{publishStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="taskStatus != null">
+			and a.task_status = #{taskStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="startDate != null">
+			and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="endDate != null">
+			and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="projectNo != null and projectNo != ''">
+			and d.serial_number = #{projectNo,jdbcType=VARCHAR}
+		</if>
+		<if test="buyerName != null and buyerName != ''">
+			and e.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="taskReceiverName != null and taskReceiverName != ''">
+			and f.name = #{taskReceiverName,jdbcType=VARCHAR}
+		</if>
+		<if test="categoryId != null and categoryId != ''">
+			and c.id = #{categoryId,jdbcType=VARCHAR}
+		</if>
+			order by a.task_distribution_time desc
+		<if test="page_sql != null">
+			${page_sql}
+		</if>
   </select>
   
   
@@ -998,4 +1027,146 @@ from
 		and g.name = #{principalName,jdbcType=VARCHAR}
 	</if>
   </select>
+  
+  <select id="selectProjectTaskByPage" resultType="com.goafanti.techproject.bo.TaskListBo">
+			select
+			a.id as taskId,
+			a.commodity_id as commodityId,
+			a.serial_number as taskNo,
+			a.task_status as taskStatus,
+			a.deleted_sign as deleteSign,
+			date_format(a.task_distribution_time,'%Y-%m-%d %H:%i:%S') as taskDistributionTimes,
+			a.task_comment as taskComment,
+			a.publish_status as publishStatus,
+			b.bname as commodityName ,
+			c.cname as categoryName,
+			c.id as categoryId,
+			d.serial_number as projectNo,
+			d.status,
+			d.deleted_sign as deletedSign,
+			e.nickname as buyerName,
+			f.name as taskReceiverName
+		from
+			(select *
+		from contract_task_log
+		where task_receiver=#{taskReceiver,jdbcType=VARCHAR}) x left join contract_task a on 
+			x.contract_task_id=a.id	left join business_project b on
+			a.commodity_id = b.id left join business_varieties c on
+			b.cid = c.id left join contract d on
+			a.contract_id = d.id left join user e on
+			d.uid = e.id left join admin f on 
+			a.task_receiver = f.id
+		where 1=1
+		<if test="taskReceiverId != null and taskReceiverId != ''">
+			and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
+		</if>
+		<if test="deleteSign != null">
+			and a.deleted_sign = #{deleteSign,jdbcType=VARCHAR}
+		</if>
+		<if test="publishStatus != null">
+			and a.publish_status = #{publishStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="taskStatus != null">
+			and a.task_status = #{taskStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="startDate != null">
+			and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="endDate != null">
+			and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="projectNo != null and projectNo != ''">
+			and d.serial_number = #{projectNo,jdbcType=VARCHAR}
+		</if>
+		<if test="buyerName != null and buyerName != ''">
+			and e.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="taskReceiverName != null and taskReceiverName != ''">
+			and f.name = #{taskReceiverName,jdbcType=VARCHAR}
+		</if>
+		<if test="categoryId != null and categoryId != ''">
+			and c.id = #{categoryId,jdbcType=VARCHAR}
+		</if>
+			order by a.task_distribution_time desc
+		<if test="page_sql != null">
+			${page_sql}
+		</if>
+  </select>
+  
+  <select id="selectProjectTaskCount" resultType="java.lang.Integer">
+  		select
+			count(0)
+		from
+			(select *
+		from contract_task_log
+		where task_receiver=#{taskReceiver,jdbcType=VARCHAR}) x left join contract_task a on  
+			x.contract_task_id=a.id	left join business_project b on
+			a.commodity_id = b.id left join business_varieties c on
+			b.cid = c.id left join contract d on
+			a.contract_id = d.id left join user e on
+			d.uid = e.id left join admin f on 
+			a.task_receiver = f.id
+		where 1=1
+		<if test="taskReceiverId != null and taskReceiverId != ''">
+			and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
+		</if>
+		<if test="deleteSign != null">
+			and a.deleted_sign = #{deleteSign,jdbcType=VARCHAR}
+		</if>
+		<if test="publishStatus != null">
+			and a.publish_status = #{publishStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="taskStatus != null">
+			and a.task_status = #{taskStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="startDate != null">
+			and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="endDate != null">
+			and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="projectNo != null and projectNo != ''">
+			and d.serial_number = #{projectNo,jdbcType=VARCHAR}
+		</if>
+		<if test="buyerName != null and buyerName != ''">
+			and e.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="taskReceiverName != null and taskReceiverName != ''">
+			and f.name = #{taskReceiverName,jdbcType=VARCHAR}
+		</if>
+		<if test="categoryId != null and categoryId != ''">
+			and c.id = #{categoryId,jdbcType=VARCHAR}
+		</if>
+		
+		<if test="taskReceiverId != null and taskReceiverId != ''">
+			and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
+		</if>
+		<if test="deleteSign != null">
+			and a.deleted_sign = #{deleteSign,jdbcType=VARCHAR}
+		</if>
+		<if test="publishStatus != null">
+			and a.publish_status = #{publishStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="taskStatus != null">
+			and a.task_status = #{taskStatus,jdbcType=VARCHAR}
+		</if>
+		<if test="startDate != null">
+			and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="endDate != null">
+			and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
+		</if>
+		<if test="projectNo != null and projectNo != ''">
+			and d.serial_number = #{projectNo,jdbcType=VARCHAR}
+		</if>
+		<if test="buyerName != null and buyerName != ''">
+			and e.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
+		</if>
+		<if test="taskReceiverName != null and taskReceiverName != ''">
+			and f.name = #{taskReceiverName,jdbcType=VARCHAR}
+		</if>
+		<if test="categoryId != null and categoryId != ''">
+			and c.id = #{categoryId,jdbcType=VARCHAR}
+		</if>
+	 </select>
 </mapper>

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

@@ -1582,10 +1582,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		contract.setTaskDistribution(TaskDistributionState.NOT_DISTRIBUTION.getCode());
 		contractMapper.insert(contract);
 		for(TOrderDetail orderDetail: detailList){
-			
-			Admin aa=adminMapper.selectAdminName("管理员");
-			Admin ab=adminMapper.selectAdminName("刘扶桑");
-			
+			Admin aa=adminMapper.selectAdminName(AFTConstants.DEFAULT_INITIATOR);
+			Admin ab=adminMapper.selectAdminName(AFTConstants.CONSULTANT_MANAGER);
 			for(int i=0; i<orderDetail.getCommodityQuantity();i++){
 				task = new ContractTask();
 				task.setId(UUID.randomUUID().toString().replace("-", ""));
@@ -1927,8 +1925,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 	@Override
 	public void addContractTaskLog() {
 		List<ContractTask> list=contractTaskMapper.selectlistContractTask();
-		Admin aa=adminMapper.selectAdminName("管理员");
-		Admin ab=adminMapper.selectAdminName("刘扶桑");
+		Admin aa=adminMapper.selectAdminName(AFTConstants.DEFAULT_INITIATOR);
+		Admin ab=adminMapper.selectAdminName("AFTConstants.CONSULTANT_MANAGER");
 		for (ContractTask ct : list) {
 			ContractTaskLog c=new ContractTaskLog();
 			c.setId(UUID.randomUUID().toString());

+ 1 - 1
src/main/java/com/goafanti/techproject/controller/AdminTechProjectApiController.java

@@ -779,7 +779,7 @@ public class AdminTechProjectApiController extends CertifyApiController {
 	public Result listMyTask(String projectNo,String buyerName,String startDate,String endDate,String publishStatus, Integer taskStatus,String categoryId,
 			Integer pageNo, Integer pageSize){
 		Result res = new Result();
-		res.setData(techProjectService.selectProjectTask(projectNo, buyerName, TokenManager.getAdminId(), "", 
+		res.setData(techProjectService.selectMyProjectTask(projectNo, buyerName, TokenManager.getAdminId(), "", 
 				startDate, endDate, taskStatus, categoryId,null,publishStatus, pageNo, pageSize));
 		return res;
 	}

+ 4 - 0
src/main/java/com/goafanti/techproject/service/TechProjectService.java

@@ -176,4 +176,8 @@ public interface TechProjectService {
 	Pagination<ProjectListBo> salesmanListProject(ProjectListBo bo, String depId, String orderStartDate, String orderEndDate,
 			String setUpStartDate, String setUpEndDate, Integer pageNo, Integer pageSize);
 
+	Pagination<TaskListBo> selectMyProjectTask(String projectNo, String buyerName, String taskReceiverId,
+			String taskReceiverName, String startDate, String endDate, Integer taskStatus, String categoryId,
+			String deleteSign, String publishStatus, Integer pageNo, Integer pageSize);
+	
 }

+ 39 - 3
src/main/java/com/goafanti/techproject/service/impl/TechProjectServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.ContractLogMapper;
 import com.goafanti.common.dao.ContractMapper;
 import com.goafanti.common.dao.ContractTaskLogMapper;
@@ -75,6 +76,8 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 	private ContractTaskMapper 		contractTaskMapper;
 	@Autowired
 	private ContractTaskLogMapper	contractTaskLogMapper;
+	@Autowired
+	AdminMapper		adminMapper;
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<TechProjectClientListBo> listClientTechProject(String uid, Integer pageNo, Integer pageSize) {
@@ -387,6 +390,16 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 			task.setTaskComment(taskComment);
 			task.setDeletedSign(DeleteStatus.UNDELETE.getCode());
 			contractTaskMapper.insert(task);
+			//项目任务日志流转
+			Admin a=adminMapper.selectAdminName(AFTConstants.CONSULTANT_MANAGER); 
+			ContractTaskLog c=new ContractTaskLog();
+			c.setId(UUID.randomUUID().toString());
+			c.setContractTaskId(task.getId());
+			c.setTaskReceiver(a.getId());
+			c.setTaskAllocator(TokenManager.getAdminId());
+			c.setCreateTime(new Date());
+			contractTaskLogMapper.insert(c);
+			contractTaskMapper.updateByPrimaryKeySelective(task);
 		}
 		return setTaskDistribution(contractId);
 	}
@@ -412,7 +425,7 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<TaskListBo> selectProjectTask(String projectNo, String buyerName, String taskReceiverId, String taskReceiverName,
+	public Pagination<TaskListBo> selectMyProjectTask(String projectNo, String buyerName, String taskReceiverId, String taskReceiverName,
 			String startDate,String endDate, Integer taskStatus, String categoryId,String deleteSign,String publishStatus, Integer pageNo, Integer pageSize) {
 		Map<String,Object> params = new HashMap<String,Object>();
 		if(StringUtils.isNotBlank(projectNo)) params.put("projectNo", projectNo);
@@ -430,8 +443,7 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 		if(StringUtils.isNotBlank(deleteSign)) params.put("deleteSign", deleteSign);
 		if(StringUtils.isNotBlank(publishStatus)) params.put("publishStatus", publishStatus);
 		if(taskStatus != null) params.put("taskStatus", taskStatus);
-		 params.put("taskReceiver", TokenManager.getAdminId());
-		return (Pagination<TaskListBo>)findPage("selectProjectTaskByPage", "selectProjectTaskCount", params, pageNo, pageSize);
+		return (Pagination<TaskListBo>)findPage("selectMyProjectTaskByPage", "selectMyProjectTaskCount", params, pageNo, pageSize);
 	}
 
 	@Override
@@ -565,4 +577,28 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 		}
 		return (Pagination<ProjectListBo>)findPage("salesmanListProjectByPage", "salesmanListProjectCount", params, pageNo, pageSize);
 	}
+	
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<TaskListBo> selectProjectTask(String projectNo, String buyerName, String taskReceiverId, String taskReceiverName,
+			String startDate,String endDate, Integer taskStatus, String categoryId,String deleteSign,String publishStatus, Integer pageNo, Integer pageSize) {
+		Map<String,Object> params = new HashMap<String,Object>();
+		if(StringUtils.isNotBlank(projectNo)) params.put("projectNo", projectNo);
+		if(StringUtils.isNotBlank(buyerName)) params.put("buyerName", buyerName);
+		if(StringUtils.isNotBlank(taskReceiverId)) params.put("taskReceiverId", taskReceiverId);
+		if(StringUtils.isNotBlank(taskReceiverName)) params.put("taskReceiverName", taskReceiverName);
+		try {
+			if (StringUtils.isNotBlank(startDate))
+				params.put("startDate", DateUtils.parseDate(startDate + " 00:00:00", AFTConstants.YYYYMMDDHHMMSS));
+			if (StringUtils.isNotBlank(endDate))
+				params.put("endDate", DateUtils.parseDate(endDate + " 23:59:59", AFTConstants.YYYYMMDDHHMMSS));
+			} catch (ParseException e) {
+		}
+		if(StringUtils.isNotBlank(categoryId)) params.put("categoryId", categoryId);
+		if(StringUtils.isNotBlank(deleteSign)) params.put("deleteSign", deleteSign);
+		if(StringUtils.isNotBlank(publishStatus)) params.put("publishStatus", publishStatus);
+		if(taskStatus != null) params.put("taskStatus", taskStatus);
+		params.put("taskReceiver", TokenManager.getAdminId()); 
+		return (Pagination<TaskListBo>)findPage("selectProjectTaskByPage", "selectProjectTaskCount", params, pageNo, pageSize);
+	}
 }