Browse Source

项目任务后台开发

anderx 7 years ago
parent
commit
7fec5272fc

+ 5 - 0
src/main/java/com/goafanti/common/dao/TOrderTaskMapper.java

@@ -3,6 +3,7 @@ package com.goafanti.common.dao;
 import com.goafanti.common.model.TOrderTask;
 import com.goafanti.common.model.TOrderTaskExample;
 import com.goafanti.order.bo.TOrderTaskBo;
+import com.goafanti.order.bo.TOrderTaskDetailBo;
 
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
@@ -121,4 +122,8 @@ public interface TOrderTaskMapper {
     int updateByPrimaryKey(TOrderTask record);
 
 	List<TOrderTaskBo> selectOrderTask(String orderNo);
+
+	TOrderTaskDetailBo getOrderTaskDetail(String id);
+
+	TOrderTask selectBySuperId(String superId);
 }

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

@@ -657,4 +657,100 @@
   	 left join business_category c on b.cid=c.id left join admin d on a.task_receiver=d.id
   	where order_no=  #{orderNo,jdbcType=VARCHAR}
   </select>
+  
+  
+   <select id="selectOrderTaskListByPage" resultType="com.goafanti.order.bo.TOrderTaskListBo">
+  	 select  a.id,a.commodity_name as taskName,a.order_no as orderNo,c.cname,d.name as receiverName,
+    a.project_status as projectStatus,a.task_status as taskStatus,date_format(a.task_distribution_time,'%Y-%m-%d') as taskDate,
+    a.commodity_quantity as commodityQuantity,f.nickname as userName
+  	from t_order_task a left join business_project b on a.commodity_id=b.id
+  	left join business_category c on b.cid=c.id
+    left join admin d on a.task_receiver=d.id
+    left join t_order_new e on a.order_no=e.order_no
+    left join user f on e.buyer_id=f.id
+    where e.delete_sign=0 
+    <if test="specially == 0">
+    and a.task_receiver= #{aid,jdbcType=VARCHAR}
+    and a.commodity_quantity =1
+    </if>
+    <if test="specially == 1">
+    and a.super_id is null
+    </if>
+    <if test="orderNo != null">
+  	and a.order_no= #{orderNo,jdbcType=VARCHAR}
+  	</if>
+    <if test="name != null">
+  	and a.commodity_name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="orderNo != null">
+  	and a.order_no= #{orderNo,jdbcType=VARCHAR}
+  	</if>
+  	<if test="taskId != null">
+  	and a.id= #{taskId,jdbcType=VARCHAR}
+  	</if>
+  	<if test="taskStatus != null">
+  	and a.task_status= #{taskStatus,jdbcType=INTEGER}
+  	</if>
+  	<if test="adminName != null">
+  	and d.name like CONCAT('%', #{adminName,jdbcType=VARCHAR},'%')
+  	</if>
+  	order by a.task_distribution_time desc
+  	<if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
+  
+   <select id="selectOrderTaskListCount" resultType="java.lang.Integer">
+  	select  count(*)
+  	from t_order_task a 
+    left join admin d on a.task_receiver=d.id
+    left join t_order_new e on a.order_no=e.order_no
+    where e.delete_sign=0 
+    <if test="specially == 0">
+    and a.task_receiver= #{aid,jdbcType=VARCHAR}
+    and a.commodity_quantity =1<!-- 不看父任务 -->
+    </if>
+    <if test="specially == 1">
+    and a.super_id is null<!-- 不看子任务 -->
+    </if>
+    <if test="orderNo != null">
+  	and a.order_no= #{orderNo,jdbcType=VARCHAR}
+  	</if>
+    <if test="name != null">
+  	and a.commodity_name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+  	</if>
+  	<if test="orderNo != null">
+  	and a.order_no= #{orderNo,jdbcType=VARCHAR}
+  	</if>
+  	<if test="taskId != null">
+  	and a.id= #{taskId,jdbcType=VARCHAR}
+  	</if>
+  	<if test="taskStatus != null">
+  	and a.task_status= #{taskStatus,jdbcType=INTEGER}
+  	</if>
+  	<if test="adminName != null">
+  	and d.name like CONCAT('%', #{adminName,jdbcType=VARCHAR},'%')
+  	</if>
+  </select>
+  <select id="getOrderTaskDetail" resultType="com.goafanti.order.bo.TOrderTaskDetailBo">
+  select  
+	a.id,a.commodity_name as taskName,a.order_no as orderNo,c.cname,d.name as receiverName,a.task_comment as taskComment,
+    a.project_status as projectStatus,a.task_status as taskStatus,e.contacts,a.attachment_url as attachmentUrl,
+	f.nickname as userName,g.name as salesmanName,date_format(a.task_start_time,'%Y-%m-%d') as startDate,
+	date_format(a.task_end_time,'%Y-%m-%d') as endDate,date_format(a.accept_time,'%Y-%m-%d') as acceptDate,
+	date_format(a.review_time,'%Y-%m-%d') as reviewDate,date_format(a.publicity_time,'%Y-%m-%d') as publicityDate,
+	date_format(a.licence_time,'%Y-%m-%d') as licenceDate,date_format(a.task_distribution_time,'%Y-%m-%d') as taskDate,
+	REPLACE(e.contact_mobile, SUBSTR(e.contact_mobile,4,4), '****') as contactMobile
+from t_order_task a left join business_project b on a.commodity_id=b.id
+  	left join business_category c on b.cid=c.id
+    left join admin d on a.task_receiver=d.id
+    left join t_order_new e on a.order_no=e.order_no
+    left join user f on e.buyer_id=f.id
+    left join admin g on e.salesman_id=g.id
+    where a.id= #{id,jdbcType=VARCHAR}
+  </select>
+  <select id="selectBySuperId"  resultType="com.goafanti.common.model.TOrderTask">
+     select super_id as superId,min(task_status) as taskStatus,min(project_status) as projectStatus  from t_order_task
+    where super_id = #{superId,jdbcType=VARCHAR} group by super_id
+  </select>
 </mapper>

+ 147 - 0
src/main/java/com/goafanti/order/bo/TOrderTaskDetailBo.java

@@ -0,0 +1,147 @@
+package com.goafanti.order.bo;
+
+public class TOrderTaskDetailBo {
+	private String id;
+	private String taskName;
+	private String orderNo;
+	private String userName;
+	private String cname;
+	private String receiverName;
+	private Integer projectStatus;
+	private Integer taskStatus;
+	private String taskDate;
+	private String taskComment;
+	private String contacts;
+	private String attachmentUrl;
+	private String salesmanName;
+	private String startDate;
+	private String endDate;
+	private String acceptDate;
+	private String reviewDate;
+	private String publicityDate;
+	private String licenceDate;
+	private String contactMobile;
+	
+	public String getTaskComment() {
+		return taskComment;
+	}
+	public void setTaskComment(String taskComment) {
+		this.taskComment = taskComment;
+	}
+	public String getContacts() {
+		return contacts;
+	}
+	public void setContacts(String contacts) {
+		this.contacts = contacts;
+	}
+	public String getSalesmanName() {
+		return salesmanName;
+	}
+	public void setSalesmanName(String salesmanName) {
+		this.salesmanName = salesmanName;
+	}
+	public String getStartDate() {
+		return startDate;
+	}
+	public void setStartDate(String startDate) {
+		this.startDate = startDate;
+	}
+	public String getEndDate() {
+		return endDate;
+	}
+	public void setEndDate(String endDate) {
+		this.endDate = endDate;
+	}
+	public String getAcceptDate() {
+		return acceptDate;
+	}
+	public void setAcceptDate(String acceptDate) {
+		this.acceptDate = acceptDate;
+	}
+	public String getReviewDate() {
+		return reviewDate;
+	}
+	public void setReviewDate(String reviewDate) {
+		this.reviewDate = reviewDate;
+	}
+	public String getPublicityDate() {
+		return publicityDate;
+	}
+	public void setPublicityDate(String publicityDate) {
+		this.publicityDate = publicityDate;
+	}
+	public String getLicenceDate() {
+		return licenceDate;
+	}
+	public void setLicenceDate(String licenceDate) {
+		this.licenceDate = licenceDate;
+	}
+	public String getContactMobile() {
+		return contactMobile;
+	}
+	public void setContactMobile(String contactMobile) {
+		this.contactMobile = contactMobile;
+	}
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getTaskName() {
+		return taskName;
+	}
+	public void setTaskName(String taskName) {
+		this.taskName = taskName;
+	}
+	public String getOrderNo() {
+		return orderNo;
+	}
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+	public String getCname() {
+		return cname;
+	}
+	public void setCname(String cname) {
+		this.cname = cname;
+	}
+	public String getReceiverName() {
+		return receiverName;
+	}
+	public void setReceiverName(String receiverName) {
+		this.receiverName = receiverName;
+	}
+	public Integer getProjectStatus() {
+		return projectStatus;
+	}
+	public void setProjectStatus(Integer projectStatus) {
+		this.projectStatus = projectStatus;
+	}
+	public Integer getTaskStatus() {
+		return taskStatus;
+	}
+	public void setTaskStatus(Integer taskStatus) {
+		this.taskStatus = taskStatus;
+	}
+	public String getTaskDate() {
+		return taskDate;
+	}
+	public void setTaskDate(String taskDate) {
+		this.taskDate = taskDate;
+	}
+	
+	public String getUserName() {
+		return userName;
+	}
+	public void setUserName(String userName) {
+		this.userName = userName;
+	}
+	public String getAttachmentUrl() {
+		return attachmentUrl;
+	}
+	public void setAttachmentUrl(String attachmentUrl) {
+		this.attachmentUrl = attachmentUrl;
+	}
+	
+}

+ 75 - 0
src/main/java/com/goafanti/order/bo/TOrderTaskListBo.java

@@ -0,0 +1,75 @@
+package com.goafanti.order.bo;
+
+public class TOrderTaskListBo {
+	private String id;
+	private String taskName;
+	private String orderNo;
+	private String userName;
+	private String cname;
+	private String receiverName;
+	private Integer projectStatus;
+	private Integer taskStatus;
+	private String taskDate;
+	private Integer commodityQuantity;
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getTaskName() {
+		return taskName;
+	}
+	public void setTaskName(String taskName) {
+		this.taskName = taskName;
+	}
+	public String getOrderNo() {
+		return orderNo;
+	}
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+	public String getCname() {
+		return cname;
+	}
+	public void setCname(String cname) {
+		this.cname = cname;
+	}
+	public String getReceiverName() {
+		return receiverName;
+	}
+	public void setReceiverName(String receiverName) {
+		this.receiverName = receiverName;
+	}
+	public Integer getProjectStatus() {
+		return projectStatus;
+	}
+	public void setProjectStatus(Integer projectStatus) {
+		this.projectStatus = projectStatus;
+	}
+	public Integer getTaskStatus() {
+		return taskStatus;
+	}
+	public void setTaskStatus(Integer taskStatus) {
+		this.taskStatus = taskStatus;
+	}
+	public String getTaskDate() {
+		return taskDate;
+	}
+	public void setTaskDate(String taskDate) {
+		this.taskDate = taskDate;
+	}
+	public Integer getCommodityQuantity() {
+		return commodityQuantity;
+	}
+	public void setCommodityQuantity(Integer commodityQuantity) {
+		this.commodityQuantity = commodityQuantity;
+	}
+	public String getUserName() {
+		return userName;
+	}
+	public void setUserName(String userName) {
+		this.userName = userName;
+	}
+	
+}

+ 30 - 3
src/main/java/com/goafanti/order/controller/OrderProjectApiController.java

@@ -1,6 +1,5 @@
 package com.goafanti.order.controller;
 
-import javax.servlet.http.HttpServletRequest;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -11,6 +10,7 @@ import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.utils.StringUtils;
+import com.goafanti.order.bo.TOrderTaskDetailBo;
 import com.goafanti.order.service.OrderProjectService;
 
 @RestController
@@ -25,14 +25,41 @@ public class OrderProjectApiController extends CertifyApiController {
 	 * 项目分配
 	 */
 	@RequestMapping(value = "/projectDistribution", method = RequestMethod.POST)
-	public Result projectDistribution(Integer taskId,String taskReceiverId){
+	public Result projectDistribution(Integer taskId,String taskReceiverId,Integer specially ){
 		Result res = new Result();
 		if(null==taskId || StringUtils.isBlank(taskReceiverId)){
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务编号和受理人"));
 			return res;
 		}
-		res.setData(orderProjectService.updateProjectDistribution( taskId, taskReceiverId));
+		res.setData(orderProjectService.updateProjectDistribution( taskId, taskReceiverId,specially));
 		return res;
 	}
 	
+	/**
+	 * 任务派单列表
+	 */
+	@RequestMapping(value="/orderTaskList" ,method = RequestMethod.GET)
+	public Result orderTaskList(String name,String orderNo,String taskId,Integer taskStatus,String adminName,Integer specially  ,Integer pageNo,Integer pageSize){
+		Result res=new Result();
+		res.setData(orderProjectService.orderTaskList( name, orderNo, taskId, taskStatus, adminName,specially , pageNo, pageSize));
+		return res;
+	}
+	/**
+	 * 任务详情
+	 */
+	@RequestMapping(value="/orderTaskDetail" ,method = RequestMethod.GET)
+	public Result orderTaskDetail(String id){
+		Result res=new Result();
+		res.setData(orderProjectService.orderTaskDetail(id));
+		return res;
+	}
+	/**
+	 * 任务修改
+	 */
+	@RequestMapping(value="/updateOrderTask" ,method = RequestMethod.POST)
+	public Result updateOrderTask(TOrderTaskDetailBo t){
+		Result res=new Result();
+		res.setData(orderProjectService.updateOrderTask(t));
+		return res;
+	}
 }

+ 11 - 2
src/main/java/com/goafanti/order/service/OrderProjectService.java

@@ -1,10 +1,19 @@
 package com.goafanti.order.service;
 
 import com.goafanti.core.mybatis.page.Pagination;
-import com.goafanti.order.bo.TOrderRefundBo;
+import com.goafanti.order.bo.TOrderTaskBo;
+import com.goafanti.order.bo.TOrderTaskDetailBo;
+import com.goafanti.order.bo.TOrderTaskListBo;
 
 public interface OrderProjectService {
 
-	int updateProjectDistribution(Integer taskId, String taskReceiverId);
+	int updateProjectDistribution(Integer taskId, String taskReceiverId,Integer specially);
+
+	Pagination<TOrderTaskListBo> orderTaskList(String name, String orderNo, String taskId, Integer taskStatus, String adminName,Integer specially,
+			Integer pageNo, Integer pageSize);
+
+	TOrderTaskDetailBo orderTaskDetail(String id);
+
+	int updateOrderTask(TOrderTaskDetailBo t);
 	
 }

+ 11 - 9
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -172,9 +172,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		organizationContactBookMapper.insertSelective(contactBook);
 		if (isSubmit==1) {
 			t.setOrderStatus(OrderNewState.QDDS.getCode());
-			if (t.getApproval()==ApprovalNewState.FTP.getCode()) {
-				t.setProcessStatus(ProcessStatus.YPYXGLY.getCode());
-			}
+			t.setProcessStatus(ProcessStatus.YPYXGLY.getCode());
+			
 		}
 		TOrderNew t2=tOrderNewMapper.selectByPrimaryKey(t.getOrderNo());
 		if (t2.getApproval()==ApprovalNewState.BH.getCode()||
@@ -371,16 +370,19 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	@Override
 	public boolean checkOrderMain(TOrderTask t) {
 		List<TOrderTaskBo> list=tOrderTaskMapper.selectOrderTask(t.getOrderNo());
-		boolean flag=false;
+		int flag=0;
+		if (t.getMain()==1) {
+			flag++;
+		}
 		for (TOrderTask t2 : list) {
 			if (t2.getMain()==1) {
-				flag=true;
-				if (t.getId()!=null&&t.getId().equals(t2.getId())) {
-					flag=false;
-				}
+				flag++;
 			}
 		}
-		return flag;
+		if (flag>1) {
+			return true;
+		}
+		return false;
 	}
 
 

+ 92 - 1
src/main/java/com/goafanti/order/service/impl/OrderProjectServiceImpl.java

@@ -1,9 +1,16 @@
 package com.goafanti.order.service.impl;
 
+import java.lang.reflect.InvocationTargetException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.converters.DateConverter;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -18,6 +25,8 @@ import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.order.bo.TOrderNewBo;
 import com.goafanti.order.bo.TOrderRefundBo;
 import com.goafanti.order.bo.TOrderTaskBo;
+import com.goafanti.order.bo.TOrderTaskDetailBo;
+import com.goafanti.order.bo.TOrderTaskListBo;
 import com.goafanti.order.enums.ProcessStatus;
 import com.goafanti.order.service.OrderProjectService;
 import com.goafanti.techproject.enums.TaskState;
@@ -29,11 +38,27 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 	private TOrderNewMapper	tOrderNewMapper;
 	
 	@Override
-	public int updateProjectDistribution(Integer taskId, String taskReceiverId) {
+	public int updateProjectDistribution(Integer taskId, String taskReceiverId,Integer specially) {
 		TOrderTask t=tOrderTaskMapper.selectByPrimaryKey(taskId);
 		t.setTaskStatus(TaskState.DISTRIBUTION.getCode());
 		t.setTaskReceiver(taskReceiverId);
+		t.setTaskDistributionTime(new Date());
 		tOrderTaskMapper.updateByPrimaryKeySelective(t);
+		if (specially==0&&t.getCommodityQuantity()>1) {
+			for (int i = 0; i < t.getCommodityQuantity(); i++) {
+				TOrderTask tOrderTask=new TOrderTask();
+				try {
+					ConvertUtils.register(new DateConverter(null), java.util.Date.class);
+					BeanUtils.copyProperties(tOrderTask, t);
+					tOrderTask.setId(null);
+					tOrderTask.setCommodityQuantity(1);
+					tOrderTask.setSuperId(t.getId().toString());
+					tOrderTaskMapper.insertSelective(tOrderTask);
+				} catch (IllegalAccessException | InvocationTargetException e) {
+					e.printStackTrace();
+				}
+			}
+		}
 		List<TOrderTaskBo> taskBos=tOrderTaskMapper.selectOrderTask(t.getOrderNo());
 		TOrderNew tNew=new TOrderNew();
 		tNew.setOrderNo(t.getOrderNo());
@@ -53,5 +78,71 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		return 1;
 	}
 
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<TOrderTaskListBo> orderTaskList(String name, String orderNo, String taskId, Integer taskStatus,
+			String adminName,Integer specially, Integer pageNo, Integer pageSize) {
+		Map<String, Object> params = new HashMap<String, Object>();
+		if(pageSize==null||pageSize<0)pageSize=10;
+		if(pageNo==null||pageNo<0)pageNo=1;
+		if (specially!=null&&specially==0) {
+			params.put("aid", TokenManager.getAdminId()==null?"e82a4405-2104-481d-ba5f-72a639589efd":TokenManager.getAdminId());
+		}
+		if (null!=specially) params.put("specially", specially);
+		if (StringUtils.isNotBlank(name)) params.put("name", name);
+		if (StringUtils.isNotBlank(orderNo)) params.put("orderNo", orderNo);
+		if (StringUtils.isNotBlank(taskId)) params.put("taskId", taskId);
+		if (StringUtils.isNotBlank(adminName)) params.put("adminName", adminName);
+		if (null != taskStatus) params.put("taskStatus", taskStatus);
+		Pagination<TOrderTaskListBo> p = (Pagination<TOrderTaskListBo>)findPage("selectOrderTaskListByPage", "selectOrderTaskListCount", params, pageNo, pageSize);
+		return p;
+	}
+
+	@Override
+	public TOrderTaskDetailBo orderTaskDetail(String id) {
+		return tOrderTaskMapper.getOrderTaskDetail(id);
+	}
+
+	@Override
+	public int updateOrderTask(TOrderTaskDetailBo t) {
+		TOrderTask task=new TOrderTask();
+		task.setAttachmentUrl(t.getAttachmentUrl());
+		task.setId(Integer.valueOf(t.getId()));
+		task.setTaskStatus(t.getTaskStatus());
+		task.setProjectStatus(t.getProjectStatus());
+		task.setTaskComment(t.getTaskComment());
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		try {
+			if(StringUtils.isNotBlank(t.getStartDate()))task.setTaskStartTime(sdf.parse(t.getStartDate()));
+			if(StringUtils.isNotBlank(t.getEndDate()))task.setTaskEndTime(sdf.parse(t.getEndDate()));
+			if(StringUtils.isNotBlank(t.getAcceptDate()))task.setAcceptTime(sdf.parse(t.getAcceptDate()));
+			if(StringUtils.isNotBlank(t.getReviewDate()))task.setReviewTime(sdf.parse(t.getReviewDate()));
+			if(StringUtils.isNotBlank(t.getPublicityDate()))task.setPublicityTime(sdf.parse(t.getPublicityDate()));
+			if(StringUtils.isNotBlank(t.getLicenceDate()))task.setLicenceTime(sdf.parse(t.getLicenceDate()));
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		tOrderTaskMapper.updateByPrimaryKeySelective(task);
+		TOrderTask task2=tOrderTaskMapper.selectByPrimaryKey(task.getId());//查询出项目信息
+		if (task2.getSuperId()!=null) {//是否有父项目
+			TOrderTask task3 =tOrderTaskMapper.selectBySuperId(task2.getSuperId());
+			task3.setId(Integer.valueOf(task2.getSuperId()));
+			tOrderTaskMapper.updateByPrimaryKeySelective(task3);
+			meanwhileUpdateOrder(task3);
+		}else {
+			meanwhileUpdateOrder(task2);
+		}
+		return 1;
+	}
+
+	private void meanwhileUpdateOrder(TOrderTask task) {
+		if (task.getMain()==1) {//是否是主要项目
+			TOrderNew tNew=new TOrderNew();
+			tNew.setProjectStatus(task.getProjectStatus());
+			tNew.setOrderNo(task.getOrderNo());
+			tOrderNewMapper.updateByPrimaryKeySelective(tNew);
+		}
+	}
+	
 	
 }