Browse Source

订单管理

wanghui 8 years ago
parent
commit
e2e6cb49d7
20 changed files with 454 additions and 151 deletions
  1. 4 1
      src/main/java/com/goafanti/business/service/BusinessProjectService.java
  2. 13 4
      src/main/java/com/goafanti/business/service/impl/BusinessProjectServiceImpl.java
  3. 5 1
      src/main/java/com/goafanti/common/dao/BusinessProjectMapper.java
  4. 8 1
      src/main/java/com/goafanti/common/dao/ContractMapper.java
  5. 1 1
      src/main/java/com/goafanti/common/dao/TechProjectMapper.java
  6. 9 1
      src/main/java/com/goafanti/common/mapper/BusinessProjectMapper.xml
  7. 4 7
      src/main/java/com/goafanti/common/mapper/ContractMapper.xml
  8. 6 4
      src/main/java/com/goafanti/common/mapper/ContractTaskMapper.xml
  9. 12 5
      src/main/java/com/goafanti/common/mapper/TOrderMapper.xml
  10. 44 40
      src/main/java/com/goafanti/common/mapper/TechProjectMapper.xml
  11. 0 1
      src/main/java/com/goafanti/common/model/BusinessProject.java
  12. 36 7
      src/main/java/com/goafanti/order/controller/AdminOrderApiController.java
  13. 11 3
      src/main/java/com/goafanti/order/service/OrderService.java
  14. 83 13
      src/main/java/com/goafanti/order/service/impl/OrderServiceImpl.java
  15. 8 0
      src/main/java/com/goafanti/techproject/bo/ProjectListBo.java
  16. 13 5
      src/main/java/com/goafanti/techproject/bo/TaskDetailBo.java
  17. 107 5
      src/main/java/com/goafanti/techproject/bo/TaskListBo.java
  18. 62 16
      src/main/java/com/goafanti/techproject/controller/AdminTechProjectApiController.java
  19. 9 3
      src/main/java/com/goafanti/techproject/service/TechProjectService.java
  20. 19 33
      src/main/java/com/goafanti/techproject/service/impl/TechProjectServiceImpl.java

+ 4 - 1
src/main/java/com/goafanti/business/service/BusinessProjectService.java

@@ -9,6 +9,7 @@ import com.goafanti.app.bo.ProjectDetailBo;
 import com.goafanti.business.bo.BusinessProjectBo;
 import com.goafanti.business.bo.ProjectSizeBo;
 import com.goafanti.common.model.BusinessProject;
+import com.goafanti.common.model.BusinessVarieties;
 import com.goafanti.common.model.ProjectSize;
 import com.goafanti.core.mybatis.page.Pagination;
 
@@ -63,6 +64,8 @@ public interface BusinessProjectService {
 
 	ProjectDetailBo ProjectDetail(String id);
 	
-	List<BusinessProject> selectBusinessProjectByName(String businessName);
+	List<BusinessProject> selectBusinessProjectByName(String businessName,String cid);
+
+	 List<BusinessVarieties> selectBusinessProjectCatalog();
 	
 }

+ 13 - 4
src/main/java/com/goafanti/business/service/impl/BusinessProjectServiceImpl.java

@@ -412,10 +412,6 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		}
 		return false;
 	}
-	@Override
-	public List<BusinessProject> selectBusinessProjectByName(String businessName) {
-		return businessProjectMapper.selectBusinessProjectByName(businessName);
-	}
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<ProjectBo> portalRecommendList(Integer pNo, Integer pSize) {
@@ -435,6 +431,7 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		return data;
 	
 	}
+	
 	@Override
 	public ProjectDetailBo ProjectDetail(String id) {
 		ProjectDetailBo pd=businessProjectMapper.selectAppProjectDetail(id);
@@ -447,9 +444,21 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		return pd;
 	
 	}
+	
 	@Override
 	public List<ProjectBo> portalRecommend() {
 		return businessProjectMapper.selectServiceProjectDetail();
 	}
+	
+	@Override
+	public List<BusinessProject> selectBusinessProjectByName(String businessName,String cid) {
+		return businessProjectMapper.selectBusinessProjectByName(businessName,cid);
+	}
+	
+	@Override
+	public List<BusinessVarieties> selectBusinessProjectCatalog() {
+		
+		return businessProjectMapper.selectBusinessProjectCatalog();
+	}
 }
 

+ 5 - 1
src/main/java/com/goafanti/common/dao/BusinessProjectMapper.java

@@ -4,6 +4,8 @@ import com.goafanti.app.bo.ProjectBo;
 import com.goafanti.app.bo.ProjectDetailBo;
 import com.goafanti.common.model.BusinessProject;
 import com.goafanti.common.model.BusinessProjectExample;
+import com.goafanti.common.model.BusinessVarieties;
+
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
@@ -88,7 +90,9 @@ public interface BusinessProjectMapper {
 
 	int checkProject(String id);
 
-	List<BusinessProject> selectBusinessProjectByName(String businessName);
+	List<BusinessProject> selectBusinessProjectByName(@Param("businessName")String businessName,@Param("cid")String cid);
 	
 	List<ProjectBo> selectServiceProjectDetail();
+
+	 List<BusinessVarieties> selectBusinessProjectCatalog();
 }

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

@@ -90,5 +90,12 @@ public interface ContractMapper {
 	 * 批量插入和同明细
 	 * @param contractDetailList
 	 */
-	void batchInsertContractTask(List<ContractTask> list);
+	void batchInsert(@Param("list")List<ContractTask> list);
+
+	/**
+	 * 删除项目任务
+	 * @param taskId
+	 * @return
+	 */
+	int deleteProjectTask(String taskId);
 }

+ 1 - 1
src/main/java/com/goafanti/common/dao/TechProjectMapper.java

@@ -4,8 +4,8 @@ import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
 
-import com.goafanti.app.bo.ProjectDetailBo;
 import com.goafanti.common.model.TechProject;
+import com.goafanti.techproject.bo.ProjectDetailBo;
 import com.goafanti.techproject.bo.TaskListBo;
 import com.goafanti.techproject.bo.TechProjectContractListBo;
 import com.goafanti.techproject.bo.TechProjectDetailBo;

+ 9 - 1
src/main/java/com/goafanti/common/mapper/BusinessProjectMapper.xml

@@ -789,7 +789,11 @@ where id=#{id,jdbcType=VARCHAR}
  
  <select id="selectBusinessProjectByName" parameterType="java.lang.String" resultMap="BaseResultMap">
  	select  id,bname,ifnull(price,0) as price,ifnull(first_payment,0) as firstPayment from business_project 
- 	where bname like concat('%',#{businessName},'%') and delete_sign=0 and status=0
+ 	where 1=1
+ 	<if test="cid != null">
+ 		and cid = #{cid,jdbcType=VARCHAR}
+ 	</if>
+ 	and bname like concat('%',#{businessName},'%') and delete_sign=0 and status=0
  </select>
  
   
@@ -801,4 +805,8 @@ where id=#{id,jdbcType=VARCHAR}
 	and boutique=1	
 	LIMIT 0, 3	
   </select>
+  
+  <select id="selectBusinessProjectCatalog" resultType="com.goafanti.common.model.BusinessVarieties">
+  	select id,cname from business_varieties where delete_sign = 0
+  </select>
 </mapper>

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

@@ -720,10 +720,8 @@
 	   	)
 	and uid = #{uid,jdbcType=VARCHAR} and deleted_sign = 0
   </select>
-  <insert id="batchInsertContractTask" parameterType="com.goafanti.common.model.ContractTask">
-  insert
-	into
-		contract_task(
+  <insert id="batchInsert" parameterType="com.goafanti.common.model.ContractTask">
+ 	 insert into contract_task(
 			id,
 			contract_id,
 			commodity_id,
@@ -742,10 +740,9 @@
 		#{item.commodityName,jdbcType=VARCHAR}, 
 		#{item.commodityMode,jdbcType=VARCHAR}, 
 		#{item.commodityType,jdbcType=INTEGER},
-		#{item.printingFee,jdbcType=INTEGER}, 
 		#{item.commodityQuantity,jdbcType=INTEGER},
-		#{item.create_time,jdbcType=TIMESTAMP},
+		#{item.createTime,jdbcType=TIMESTAMP}
 	  )
     </foreach>
-    </insert>
+   </insert>
 </mapper>

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

@@ -550,23 +550,25 @@
 			a.id as taskId,
 			a.commodity_id as commodityId,
 			a.serial_number as taskNo,
-			a.task_distribution_time  as taskDistributionTime,
+			a.task_status as taskStatus,
+			date_format(a.task_distribution_time ,'%Y-%m-%d %H:%i:%S') as taskDistributionTime,
 			a.task_comment as taskComment,
 			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.name as taskAllocatorName,
-			f.name as taskReceiverName
+			f.name as taskReceiverName,
+			g.nickname as buyerName
 		from
 			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 admin e on 
 			a.task_allocator = e.id left join admin f on 
-			a.task_receiver = f.id
+			a.task_receiver = f.id left join user g on
+			d.uid = g.id
 		where 
 			a.id = #{taskId,jdbcType=VARCHAR}
   </select>

+ 12 - 5
src/main/java/com/goafanti/common/mapper/TOrderMapper.xml

@@ -997,6 +997,7 @@
 			a.order_channel as orderChannel,
 			a.buyer_id as buyerId,
 			a.seller_id as sellerId,
+			a.delete_sign as deleteSign,
 			b.nickname as buyerName,		
 			c.name as salesmanName,
 			d.name as financeName,
@@ -1148,6 +1149,7 @@
 			a.actually_total_amount as actuallyTotalAmount,
 			a.order_status as orderStatus,
 			a.order_stage as orderStage,
+			a.delete_sign as deleteSign,
 			a.liquidation_status as liquidationStatus,
 			a.approval,
 			a.order_remarks as orderRemarks,
@@ -1155,6 +1157,7 @@
 			a.contract_picture_url as contractPictureUrl,
 			a.buyer_id as buyerId,
 			a.seller_id as sellerId,
+			a.buyer_id as buyerId,
 			b.nickname as buyerName,
 			c.name as salesmanName,
 			a.finance_id as financeId,
@@ -1196,6 +1199,9 @@
 		<if test="buyerName != null and buyerName != ''">
 			and b.nickname = #{buyerName,jdbcType=VARCHAR}
 		</if>
+		<if test="orderType != null">
+			and a.order_type = #{orderType,jdbcType=INTEGER}
+		</if>
 		<if test="orderStatus != null">
 			and a.order_status = #{orderStatus,jdbcType=INTEGER}
 		</if>
@@ -1485,12 +1491,13 @@
 			a.bill_no = #{billNo,jdbcType=VARCHAR}
   </select>
   
-  <select id="selectSetUpProjectByPage" resultType="com.goafanti.order.bo.OrderListBo">
+  <select id="selectSetUpServiceOrderByPage" resultType="com.goafanti.order.bo.OrderListBo">
 		select
 			a.order_no as orderNo,
 			a.order_type as orderType,
 			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
 			a.order_status as orderStatus,
+			a.project_stage as projectStage,
 			a.liquidation_status as liquidationStatus,
 			a.approval,
 			a.order_channel as orderChannel,
@@ -1498,7 +1505,7 @@
 			c.name as salesmanName,
 			d.name as financeName,
 			e.name as technicianName,
-			f.departmentName
+			f.name as departmentName
 		from
 			t_order a left join user b on
 			a.buyer_id = b.id left join admin c on
@@ -1506,7 +1513,7 @@
 			a.finance_id = d.id left join admin e on
 			a.technician_id = e.id left join department_management f on 
 			d.department_id = f.id
-		where a.type = 0 and a.order_status = 3 
+		where a.order_type = 0 and a.order_status = 3 
 			and (a.liquidation_status = 1 or a.liquidation_status = 2 or a.approval = 2) <!-- 已首付 or 已付清 or 已特批 -->
 		<if test="salesmanId != null">
 			and a.salesman_id = #{a.salesmanId,jdbcType=VARCHAR}
@@ -1536,7 +1543,7 @@
 			${page_sql}
 		</if>
   </select>
-  <select id="selectSetUpProjectCount" resultType="java.lang.Integer">
+  <select id="selectSetUpServiceOrderCount" resultType="java.lang.Integer">
 		select
 			count(0)
 		from
@@ -1546,7 +1553,7 @@
 			a.finance_id = d.id left join admin e on
 			a.technician_id = e.id left join department_management f on 
 			d.department_id = f.id
-		where a.type = 0 and a.order_status = 3 
+		where a.order_type = 0 and a.order_status = 3 
 			and (a.liquidation_status = 1 or a.liquidation_status = 2 or a.approval = 2) <!-- 已首付 or 已付清 or 已特批 -->
 		<if test="salesmanId != null">
 			and a.salesman_id = #{a.salesmanId,jdbcType=VARCHAR}

+ 44 - 40
src/main/java/com/goafanti/common/mapper/TechProjectMapper.xml

@@ -587,24 +587,24 @@
 		c.salesman_id = d.id
 	where 1=1
 	<if test="deleteSign != null">
-		a.delete_sign = #{deleteSign,jdbcType=INTEGER}
+		and a.delete_sign = #{deleteSign,jdbcType=INTEGER}
 	</if>
 	<if test="orderNo != null and orderNo != ''">
-		a.order_no = #{orderNo,jdbcType=VARCHAR}
+		and a.order_no = #{orderNo,jdbcType=VARCHAR}
 	</if>
 	<if test="setUpStartDate != null and setUpStartDate != ''">
-		a.create_time &gt; #{setUpStartDate,jdbcType=TIMESTAMP}
+		and a.create_time &gt; #{setUpStartDate,jdbcType=TIMESTAMP}
 	</if>
 	<if test="setUpEndDate != null and setUpEndDate != ''">
-		a.create_time &lt; #{setUpEndDate,jdbcType=TIMESTAMP}
+		and a.create_time &lt; #{setUpEndDate,jdbcType=TIMESTAMP}
 	</if>
 	<if test="buyerName != null and buyerName != ''">
-		b.nickname = #{buyerName,jdbcType=VARCHAR}
+		and b.nickname = #{buyerName,jdbcType=VARCHAR}
 	</if>
 	<if test="salesmanName != null and salesmanName !=''">
 		and d.name = #{salesmanName,jdbcType=VARCHAR}
 	</if>
-	<if test="depId != null adn depId != ''">
+	<if test="depId != null and depId != ''">
 		and d.department_id = #{depId,jdbcType=VARCHAR}
 	</if>
 	<if test="orderStartDate != null and orderStartDate != ''">
@@ -617,7 +617,7 @@
 		${page_sql}
 	</if>
   </select>
-  <select id="listProjectCount" parameterType="java.lang.Integer">
+  <select id="listProjectCount" resultType="java.lang.Integer">
   	select
 		count(0)
 	from
@@ -627,19 +627,19 @@
 		c.salesman_id = d.id
 	where 1=1
 	<if test="deleteSign != null">
-		a.delete_sign = #{deleteSign,jdbcType=INTEGER}
+		and a.delete_sign = #{deleteSign,jdbcType=INTEGER}
 	</if>
 	<if test="orderNo != null and orderNo != ''">
-		a.order_no = #{orderNo,jdbcType=VARCHAR}
+		and a.order_no = #{orderNo,jdbcType=VARCHAR}
 	</if>
 	<if test="setUpStartDate != null and setUpStartDate != ''">
-		a.create_time &gt; #{setUpStartDate,jdbcType=TIMESTAMP}
+		and a.create_time &gt; #{setUpStartDate,jdbcType=TIMESTAMP}
 	</if>
 	<if test="setUpEndDate != null and setUpEndDate != ''">
-		a.create_time &lt; #{setUpEndDate,jdbcType=TIMESTAMP}
+		and a.create_time &lt; #{setUpEndDate,jdbcType=TIMESTAMP}
 	</if>
 	<if test="buyerName != null and buyerName != ''">
-		b.nickname = #{buyerName,jdbcType=VARCHAR}
+		and b.nickname = #{buyerName,jdbcType=VARCHAR}
 	</if>
 	<if test="salesmanName != null and salesmanName !=''">
 		and d.name = #{salesmanName,jdbcType=VARCHAR}
@@ -669,18 +669,19 @@
 		a.order_no as orderNo,
 		a.type as projectType,
 		b.nickname as buyerName,
-		d.name as salesmanName
+		c.name as technicianName,
+		d.name as principalName
 	from
 		contract a left join user b on
-		a.uid = b.id left join t_order c on
-		a.order_no = c.order_no left join admin d on
-		c.salesman_id = d.id
+		a.uid = b.id left join admin c on
+		a.uid = c.id left join admin d on
+		a.principal = d.id
 	where a.id = #{contractId,jdbcType=VARCHAR}
   </select>
   
   <select id="selectProjectTask" resultType="com.goafanti.techproject.bo.TaskListBo">
 	select
-		a.id,
+		a.id as taskId,
 		a.commodity_name as commodityName,
 		a.commodity_quantity as commodityQuantity,
 		a.task_status as taskStatus,
@@ -688,7 +689,7 @@
 		a.task_comment as taskComment,
 		b.name as technicianName
 	from
-		contract_task a left join admin on
+		contract_task a left join admin b on
 		a.task_receiver = b.id
 	where a.contract_id = #{contractId,jdbcType=VARCHAR}
   </select>
@@ -697,7 +698,9 @@
 			a.id as taskId,
 			a.commodity_id as commodityId,
 			a.serial_number as taskNo,
-			a.task_distribution_time  as taskDistributionTime,
+			a.task_status as taskStatus,
+			a.delete_sign as deleteSign,
+			date_format(a.task_distribution_time,'%Y-%m-%d %H:%i:%S') as taskDistributionTimes,
 			a.task_comment as taskComment,
 			b.bname as commodityName ,
 			c.cname as categoryName,
@@ -705,40 +708,42 @@
 			d.serial_number as projectNo,
 			d.status,
 			d.deleted_sign as deletedSign,
-			e.name as buyerName,
+			e.nickname as buyerName,
 			f.name as taskReceiverName
 		from
 			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
-			b.uid = e.id left join admin f on 
+			d.uid = e.id left join admin f on 
 			a.task_receiver = f.id
 		where 1=1
 		<if test="taskReceiverId != null and taskReceiverId != ''">
-			a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
+			and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
 		</if>
 		<if test="taskStatus != null">
-			a.task_status = #{taskStatus,jdbcType=VARCHAR}
+			and a.task_status = #{taskStatus,jdbcType=VARCHAR}
 		</if>
 		<if test="startDate != null">
-			a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
+			and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
 		</if>
 		<if test="endDate != null">
-			a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
+			and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
 		</if>
 		<if test="projectNo != null and projectNo != ''">
-			d.serial_number = #{projectNo,jdbcType=VARCHAR}
+			and d.serial_number = #{projectNo,jdbcType=VARCHAR}
 		</if>
 		<if test="buyerName != null and buyerName != ''">
-			e.name = #{buyerName,jdbcType=VARCHAR}
+			and e.name = #{buyerName,jdbcType=VARCHAR}
 		</if>
-		
 		<if test="taskReceiverName != null and taskReceiverName != ''">
-			f.name = #{taskReceiverName,jdbcType=VARCHAR}
+			and f.name = #{taskReceiverName,jdbcType=VARCHAR}
 		</if>
 		<if test="categoryId != null and categoryId != ''">
-			c.id = #{categoryId,jdbcType=VARCHAR}
+			and c.id = #{categoryId,jdbcType=VARCHAR}
+		</if>
+		<if test="page_sql != null">
+			${page_sql}
 		</if>
   </select>
   
@@ -750,33 +755,32 @@
 			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
-			b.uid = e.id left join admin f on 
+			d.uid = e.id left join admin f on 
 			a.task_receiver = f.id
 		where 1=1
 		<if test="taskReceiverId != null and taskReceiverId != ''">
-			a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
+			and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
 		</if>
 		<if test="taskStatus != null">
-			a.task_status = #{taskStatus,jdbcType=VARCHAR}
+			and a.task_status = #{taskStatus,jdbcType=VARCHAR}
 		</if>
 		<if test="startDate != null">
-			a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
+			and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
 		</if>
 		<if test="endDate != null">
-			a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
+			and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
 		</if>
 		<if test="projectNo != null and projectNo != ''">
-			d.serial_number = #{projectNo,jdbcType=VARCHAR}
+			and d.serial_number = #{projectNo,jdbcType=VARCHAR}
 		</if>
 		<if test="buyerName != null and buyerName != ''">
-			e.name = #{buyerName,jdbcType=VARCHAR}
+			and e.name = #{buyerName,jdbcType=VARCHAR}
 		</if>
-		
 		<if test="taskReceiverName != null and taskReceiverName != ''">
-			f.name = #{taskReceiverName,jdbcType=VARCHAR}
+			and f.name = #{taskReceiverName,jdbcType=VARCHAR}
 		</if>
 		<if test="categoryId != null and categoryId != ''">
-			c.id = #{categoryId,jdbcType=VARCHAR}
+			and c.id = #{categoryId,jdbcType=VARCHAR}
 		</if>
   </select>
 </mapper>

+ 0 - 1
src/main/java/com/goafanti/common/model/BusinessProject.java

@@ -3,7 +3,6 @@ package com.goafanti.common.model;
 import java.math.BigDecimal;
 import java.util.Date;
 
-import com.goafanti.common.utils.StringUtils;
 
 public class BusinessProject {
 

+ 36 - 7
src/main/java/com/goafanti/order/controller/AdminOrderApiController.java

@@ -164,9 +164,20 @@ public class AdminOrderApiController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/getBusinessProjectByName", method = RequestMethod.GET)
-	public Result getBusinessProjectByName(String businessName){
+	public Result getBusinessProjectByName(String businessName,String cid){
 		Result res = new Result();
-		res.setData(businessProjectServiceImpl.selectBusinessProjectByName(businessName));
+		res.setData(businessProjectServiceImpl.selectBusinessProjectByName(businessName,cid));
+		return res;
+	}
+	
+	/**
+	 * 查询业务项目分类
+	 * @return
+	 */
+	@RequestMapping(value="/getBusinessProjectCatalog",method = RequestMethod.GET)
+	public Result getBusinessProjectCatalog(){
+		Result res = new Result();
+		res.setData(businessProjectServiceImpl.selectBusinessProjectCatalog());
 		return res;
 	}
 	
@@ -307,9 +318,10 @@ public class AdminOrderApiController extends CertifyApiController {
 	 * @param orderNo
 	 * @return
 	 */
+	@RequestMapping(value = "/approvalServiceOrder",method = RequestMethod.GET)
 	public Result approvalServiceOrder(String orderNo,Integer confirm){
 		Result res = new Result();
-		orderServiceImpl.approvalServiceOrder(orderNo,confirm);
+		orderServiceImpl.updateApprovalServiceOrder(orderNo,confirm);
 		return res;
 	}
 	
@@ -345,14 +357,14 @@ public class AdminOrderApiController extends CertifyApiController {
 	
 	/** 查询公共订单 **/
 	@RequestMapping(value = "/listPublicOrder", method = RequestMethod.POST)
-	public Result listPublicOrder(Integer pageNo, Integer pageSize){
+	public Result listPublicOrder(OrderListBo bo,String startDate,String endDate,Integer pageNo, Integer pageSize){
 		Result res = new Result();
-		orderServiceImpl.listPublicOrder(pageNo,pageSize);
+		res.setData(orderServiceImpl.selectPublicOrder(bo,startDate,endDate,pageNo,pageSize));
 		return res;
 	}
 	
 	/** 分配订单到营销员 **/
-	@RequestMapping(value = "/appointSalesman", method = RequestMethod.POST)
+	@RequestMapping(value = "/appointSalesman", method = RequestMethod.GET)
 	public Result appointSalesman(String orderNo,String salesmanId){
 		Result res = new Result();
 		if(StringUtils.isBlank(orderNo)){
@@ -514,10 +526,27 @@ public class AdminOrderApiController extends CertifyApiController {
 	public Result distributionOrder(String orderNo,String financeId){
 		Result res = new Result();
 		if(StringUtils.isBlank(orderNo) || StringUtils.isBlank(financeId)){
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号和定负责人"));
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号和定负责人"));
 			return res;
 		}
 		orderServiceImpl.updateDistributionOrder(orderNo,financeId);
 		return res;
 	}
+
+	/**
+	 * 解锁、锁定、作废
+	 * @param operatorType
+	 * @param orderNo
+	 * @return
+	 */
+	@RequestMapping(value = "/lockOrRevokeOrder",method = RequestMethod.GET)
+	public Result lockOrRevokeOrder(String orderNo,Integer operatorType){
+		Result res = new Result();
+		if(StringUtils.isBlank(orderNo) || operatorType == null){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号和操作类型"));
+			return res;
+		}
+		orderServiceImpl.updateLockOrRevokeOrder(orderNo,operatorType);
+		return res;
+	}
 }

+ 11 - 3
src/main/java/com/goafanti/order/service/OrderService.java

@@ -244,7 +244,7 @@ public interface OrderService {
 	 * 查询公共订单
 	 * @return
 	 */
-	Pagination<OrderListBo> listPublicOrder(Integer pageNo, Integer pageSize);
+	Pagination<OrderListBo> selectPublicOrder(OrderListBo bo,String startDate,String endDate,Integer pageNo, Integer pageSize);
 	
 	/**
 	 * 指定的营销员
@@ -346,7 +346,7 @@ public interface OrderService {
 	 * @param confirm
 	 * @return
 	 */
-	int approvalServiceOrder(String orderNo, Integer confirm);
+	int updateApprovalServiceOrder(String orderNo, Integer confirm);
 	/**
 	 * 查询待立项订单
 	 * @param bo
@@ -367,7 +367,7 @@ public interface OrderService {
 	 * @param signComment
 	 * @return
 	 */
-	int setUpProject(String orderNo, String signDate, String signComment);
+	int updateSetUpProject(String orderNo, String signDate, String signComment);
 	
 	/**
 	 * 订单编号
@@ -391,4 +391,12 @@ public interface OrderService {
 	 * @return
 	 */
 	int updateDistributionOrder(String orderNo, String financeId);
+
+	/**
+	 * 锁定、解锁、废除
+	 * @param orderNo
+	 * @param operatorType
+	 * @return
+	 */
+	int updateLockOrRevokeOrder(String orderNo, Integer operatorType);
 }

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

@@ -541,7 +541,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 				&& tOrder.getOrderStatus() != OrderState.SELLER_CANCEL_AFTER_SIGN.getCode()){
 			flag = false;
 		}
-		if(flag && tOrder.getActuallyTotalAmount().doubleValue() == 0){
+		if(flag && tOrder.getActuallyTotalAmount().doubleValue() == 0 
+				&& tOrder.getDeleteSign() == DeleteStatus.UNDELETE.getCode()){
 			active.setApplyRevoke(true); //作废
 		}else{
 			active.setApplyRevoke(false); //作废
@@ -554,7 +555,17 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		flag = true;
 		if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode())
 			flag = false;
-		active.setApplySign(flag);
+		active.setApplySign(flag); //签单
+		if(tOrder.getDeleteSign() == DeleteStatus.UNDELETE.getCode()){
+			active.setApplyLock(true);
+		}else{
+			active.setApplyLock(false);
+		}
+		if(tOrder.getDeleteSign() == DeleteStatus.LOCKING.getCode()){
+			active.setApplyUnLock(true);
+		}else{
+			active.setApplyUnLock(false);
+		}
 		return active;
 	}
 
@@ -852,13 +863,15 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		if (tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()) {
 			throw new BusinessException(new Error(ErrorConstants.NOT_ACCORD_WITH_NEXT, orderNo, ""));
 		} else {
+			Date signTime = new Date();
 			tOrder.setSignFirstPayment(new BigDecimal(signFirstPayment));
 			tOrder.setSignTotalAmount(new BigDecimal(signTotalAmount));
 			tOrder.setOrderStage(OrderStage.SIGNED.getCode());
 			tOrder.setOrderStatus(OrderState.ALREADY_SIGN.getCode());
 			tOrder.setProjectStage(ProjectStage.WAIT_SET_UP.getCode());
 			tOrder.setApproval(Integer.valueOf(approval));
-			tOrder.setUpdateTime(new Date());
+			tOrder.setUpdateTime(signTime);
+			tOrder.setSignTime(signTime);
 			tOrderMapper.updateByPrimaryKeySelective(tOrder);
 		}
 		return 1;
@@ -1089,7 +1102,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 			String depIds,Integer approvalHistory, Integer pageNo, Integer pageSize) {
 		Map<String,Object> params = disposeParams(bo,startDate,endDate);
 		if(StringUtils.isNotBlank(depIds)) {
-			params.put("depIds", depIds);
+			params.put("depIds", "'" + depIds + "'");
 		}else{
 			if(!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION))
 				return new Pagination<OrderListBo>();
@@ -1097,6 +1110,12 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		if(approvalHistory != null){
 			params.put("approvalHistory", approvalHistory);
 		}
+		if(StringUtils.isNotBlank(bo.getBuyerName())) params.put("buyerName", bo.getBuyerName());
+		if(bo.getOrderType() != null) params.put("orderType", bo.getOrderType());
+		if(bo.getOrderChannel() != null) params.put("orderChannel", bo.getOrderChannel());
+		if(bo.getOrderStatus() != null) params.put("orderStatus", bo.getOrderStatus());
+		if(StringUtils.isNotBlank(startDate)) params.put("startDate", startDate);
+		if(StringUtils.isNotBlank(endDate)) params.put("endDate", endDate);
 		return  (Pagination<OrderListBo>)findPage("selectServiceOrderByPage","selectServiceOrderCount", 
 				params, pageNo, pageSize);
 	}
@@ -1125,9 +1144,16 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<OrderListBo> listPublicOrder(Integer pageNo, Integer pageSize) {
+	public Pagination<OrderListBo> selectPublicOrder(OrderListBo bo,String startDate,String endDate,Integer pageNo, Integer pageSize) {
+		Map<String, Object> params = new HashMap<String,Object>();
+		if(StringUtils.isNotBlank(bo.getBuyerName())) params.put("buyerName", bo.getBuyerName());
+		if(bo.getOrderType() != null) params.put("orderType", bo.getOrderType());
+		if(bo.getOrderChannel() != null) params.put("orderChannel", bo.getOrderChannel());
+		if(bo.getOrderStatus() != null) params.put("orderStatus", bo.getOrderStatus());
+		if(StringUtils.isNotBlank(startDate)) params.put("startDate", startDate);
+		if(StringUtils.isNotBlank(endDate)) params.put("endDate", endDate);
 		return (Pagination<OrderListBo>)findPage("selectPublicOrderByPage","selectPublicOrderCount", 
-				null, pageNo, pageSize);
+				params, pageNo, pageSize);
 	}
 
 	@Override
@@ -1259,7 +1285,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 				bill.setConfirmSign(AuditState.AUDIT_FAIL.getCode());
 				bill.setDeleteSign(Boolean.TRUE);
 			}
-			tOrderBillMapper.updateByPrimaryKey(bill);
+			tOrderBillMapper.updateByPrimaryKeySelective(bill);
 		}
 		return 1;
 	}
@@ -1276,12 +1302,11 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 			e.printStackTrace();
 		}
 		bill.setRemarks(remarks);
-		tOrderBillMapper.updateByPrimaryKey(bill);
-		return 1;
+		return tOrderBillMapper.updateByPrimaryKeySelective(bill);
 	}
 
 	@Override
-	public int approvalServiceOrder(String orderNo, Integer confirm) {
+	public int updateApprovalServiceOrder(String orderNo, Integer confirm) {
 		TOrder tOrder = tOrderMapper.selectByPrimaryKey(orderNo);
 		checkOrder(tOrder);
 		if(tOrder.getOrderStatus() != OrderState.ALREADY_SIGN.getCode()
@@ -1322,7 +1347,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 
 	@Override
 	@Transactional
-	public int setUpProject(String orderNo, String signDate, String signComment) {
+	public int updateSetUpProject(String orderNo, String signDate, String signComment) {
 		TOrder tOrder = tOrderMapper.selectByPrimaryKey(orderNo);
 		checkOrder(tOrder);
 		boolean flag = false;
@@ -1344,8 +1369,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		List<ContractTask> taskList = new ArrayList<>();
 		ContractTask task = null;
 		Date createTime = new Date();
-		String contractId = UUID.randomUUID().toString(); //合同ID
 		Contract contract = new Contract();
+		String contractId = UUID.randomUUID().toString().replace("-", "");
 		contract.setId(contractId);
 		contract.setCreateTime(createTime);
 		contract.setType(tOrder.getOrderType());
@@ -1353,6 +1378,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		contract.setOrderNo(orderNo);
 		contract.setStatus(ProjectStage.ALREADY_SET_UP.getCode());
 		contract.setUid(tOrder.getBuyerId());
+		contract.setCreater(TokenManager.getAdminId());
+		contract.setPrincipal(tOrder.getTechnicianId()); //暂不确定
 		contractMapper.insert(contract);
 		for(TOrderDetail orderDetail: detailList){
 			for(int i=0; i<orderDetail.getCommodityQuantity();i++){
@@ -1370,7 +1397,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 				taskList.add(task);
 			}
 		}
-		contractMapper.batchInsertContractTask(taskList);
+		contractMapper.batchInsert(taskList);
 		return 1;
 	}
 
@@ -1405,4 +1432,47 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
 		return tOrderMapper.updateByPrimaryKeySelective(tOrder);
 	}
 
+	@Override
+	public int updateLockOrRevokeOrder(String orderNo, Integer operatorType) {
+		TOrder tOrder = tOrderMapper.selectByPrimaryKey(orderNo);
+		if(tOrder != null){
+			if(operatorType == 0){ //锁定
+				if(tOrder.getDeleteSign() != DeleteStatus.UNDELETE.getCode())
+					throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
+				tOrder.setDeleteSign(DeleteStatus.LOCKING.getCode());
+			}else if(operatorType == 1){ //解锁
+				if(tOrder.getDeleteSign() != DeleteStatus.LOCKING.getCode())
+					throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
+				tOrder.setDeleteSign(DeleteStatus.UNDELETE.getCode());
+			}else if(operatorType == 2){ //作废
+				if(tOrder.getDeleteSign() != DeleteStatus.UNDELETE.getCode())
+					throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
+				if(tOrder.getActuallyTotalAmount().doubleValue() > 0){
+					throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
+				}
+				if(tOrder.getOrderStatus() != OrderState.BUYER_CANCEL_AFTER_SIGN.getCode()
+						&& tOrder.getOrderStatus() != OrderState.BUYER_CANCEL_BEFORE_SIGN.getCode()
+						&& tOrder.getOrderStatus() != OrderState.SELLER_CANCEL_AFTER_SIGN.getCode()
+						&& tOrder.getOrderStatus() != OrderState.SELLER_REFUSE_BEFORE_SIGNL.getCode())
+					throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
+				tOrder.setDeleteSign(DeleteStatus.DELETED.getCode());
+			}else if(operatorType == 3){ //签单前取消订单
+				boolean flag = true;
+				if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
+					flag = false;
+				}			
+				if(tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode()
+						&& tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_LAST_BALANCE.getCode()
+						&& tOrder.getLiquidationStatus() != LiquidationState.ALREADY_PAY.getCode()){
+					flag = false;
+				}
+				if(!flag)
+					throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
+				tOrder.setOrderStatus(OrderState.SELLER_REFUSE_BEFORE_SIGNL.getCode());
+			}
+			tOrderMapper.updateByPrimaryKey(tOrder);
+		}
+		return 1;
+	}
+	
 }

+ 8 - 0
src/main/java/com/goafanti/techproject/bo/ProjectListBo.java

@@ -28,6 +28,8 @@ public class ProjectListBo {
 	private String financeName;
 	/** 技术员 **/
 	private String technicianName;
+	/** 项目负责人 **/
+	private String principalName;
 	/** 立项时间 **/
 	private String signDate;
 	/** 结项时间 **/
@@ -116,6 +118,12 @@ public class ProjectListBo {
 	public void setTechnicianName(String technicianName) {
 		this.technicianName = technicianName;
 	}
+	public String getPrincipalName() {
+		return principalName;
+	}
+	public void setPrincipalName(String principalName) {
+		this.principalName = principalName;
+	}
 	public String getSignDate() {
 		return signDate;
 	}

+ 13 - 5
src/main/java/com/goafanti/techproject/bo/TaskDetailBo.java

@@ -24,9 +24,11 @@ public class TaskDetailBo{
 	/** 任务接收人 **/
 	private String taskReceiverName;
 	/** 任务状态 **/
-	private Integer status;
+	private Integer taskStatus;
 	/** 锁定状态 **/
 	private Integer deletedSign;
+	/** 客户名 **/
+	private String buyerName;
 	public String getTaskId() {
 		return taskId;
 	}
@@ -93,11 +95,11 @@ public class TaskDetailBo{
 	public void setTaskReceiverName(String taskReceiverName) {
 		this.taskReceiverName = taskReceiverName;
 	}
-	public Integer getStatus() {
-		return status;
+	public Integer getTaskStatus() {
+		return taskStatus;
 	}
-	public void setStatus(Integer status) {
-		this.status = status;
+	public void setTaskStatus(Integer taskStatus) {
+		this.taskStatus = taskStatus;
 	}
 	public Integer getDeletedSign() {
 		return deletedSign;
@@ -105,4 +107,10 @@ public class TaskDetailBo{
 	public void setDeletedSign(Integer deletedSign) {
 		this.deletedSign = deletedSign;
 	}
+	public String getBuyerName() {
+		return buyerName;
+	}
+	public void setBuyerName(String buyerName) {
+		this.buyerName = buyerName;
+	}
 }

+ 107 - 5
src/main/java/com/goafanti/techproject/bo/TaskListBo.java

@@ -1,15 +1,117 @@
 package com.goafanti.techproject.bo;
 
-import com.goafanti.common.model.ContractTask;
-
-public class TaskListBo extends ContractTask{
-	private String 	technicianName;
 
+public class TaskListBo{
+	private String taskId;
+	private String technicianName;
+	private String taskDistributionTimes;
+	private String taskNo;
+	private Integer taskStatus;
+	private String taskComment; 
+	private Integer deleteSign;
+	private String projectNo;
+	private String commodityName;
+	private Integer commodityQuantity;
+	private String categoryName;
+	private String categoryId;
+	private Integer status;
+	private Integer deletedSign;
+	private String buyerName;
+	private String taskReceiverName;
+	public String getTaskId() {
+		return taskId;
+	}
+	public void setTaskId(String taskId) {
+		this.taskId = taskId;
+	}
 	public String getTechnicianName() {
 		return technicianName;
 	}
-
 	public void setTechnicianName(String technicianName) {
 		this.technicianName = technicianName;
 	}
+	public String getTaskDistributionTimes() {
+		return taskDistributionTimes;
+	}
+	public void setTaskDistributionTimes(String taskDistributionTimes) {
+		this.taskDistributionTimes = taskDistributionTimes;
+	}
+	public String getTaskNo() {
+		return taskNo;
+	}
+	public void setTaskNo(String taskNo) {
+		this.taskNo = taskNo;
+	}
+	public Integer getTaskStatus() {
+		return taskStatus;
+	}
+	public void setTaskStatus(Integer taskStatus) {
+		this.taskStatus = taskStatus;
+	}
+	public String getTaskComment() {
+		return taskComment;
+	}
+	public void setTaskComment(String taskComment) {
+		this.taskComment = taskComment;
+	}
+	public Integer getDeleteSign() {
+		return deleteSign;
+	}
+	public void setDeleteSign(Integer deleteSign) {
+		this.deleteSign = deleteSign;
+	}
+	public String getProjectNo() {
+		return projectNo;
+	}
+	public void setProjectNo(String projectNo) {
+		this.projectNo = projectNo;
+	}
+	public String getCommodityName() {
+		return commodityName;
+	}
+	public void setCommodityName(String commodityName) {
+		this.commodityName = commodityName;
+	}
+	public Integer getCommodityQuantity() {
+		return commodityQuantity;
+	}
+	public void setCommodityQuantity(Integer commodityQuantity) {
+		this.commodityQuantity = commodityQuantity;
+	}
+	public String getCategoryName() {
+		return categoryName;
+	}
+	public void setCategoryName(String categoryName) {
+		this.categoryName = categoryName;
+	}
+	public String getCategoryId() {
+		return categoryId;
+	}
+	public void setCategoryId(String categoryId) {
+		this.categoryId = categoryId;
+	}
+	public Integer getStatus() {
+		return status;
+	}
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+	public Integer getDeletedSign() {
+		return deletedSign;
+	}
+	public void setDeletedSign(Integer deletedSign) {
+		this.deletedSign = deletedSign;
+	}
+	public String getBuyerName() {
+		return buyerName;
+	}
+	public void setBuyerName(String buyerName) {
+		this.buyerName = buyerName;
+	}
+	public String getTaskReceiverName() {
+		return taskReceiverName;
+	}
+	public void setTaskReceiverName(String taskReceiverName) {
+		this.taskReceiverName = taskReceiverName;
+	}
 }

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

@@ -6,13 +6,13 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
-import java.util.UUID;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -589,9 +589,9 @@ public class AdminTechProjectApiController extends CertifyApiController {
 	public Result toSetUpProject(String orderNo,String buyerName){
 		Result res = new Result();
 		ProjectListBo bo = new ProjectListBo();
-		bo.setId(UUID.randomUUID().toString().replace("-", ""));
 		bo.setOrderNo(orderNo);
 		bo.setBuyerName(buyerName);
+		bo.setSignDate(DateFormatUtils.format(new Date(), AFTConstants.YYYYMMDDHHMMSS));
 		res.setData(bo);
 		return res;
 	}
@@ -604,7 +604,7 @@ public class AdminTechProjectApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
 			return res;
 		}
-		orderServiceImpl.setUpProject(orderNo,signDate,signComment);
+		orderServiceImpl.updateSetUpProject(orderNo,signDate,signComment);
 		return res;
 	}
 	
@@ -636,15 +636,15 @@ public class AdminTechProjectApiController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/createProject",method = RequestMethod.POST)
-	public Result createProject(String orderNo,String uid,String aid,Integer projectType,String signComment){
+	public Result createProject(String uid,String aid,Integer projectType,String signComment){
 		Result res = new Result();
-		if(StringUtils.isBlank(orderNo)){
+		if(StringUtils.isBlank(aid)){
 			if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid) || projectType==null){
-				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "请填写项目信息"));
+				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "客户和项目负责人"));
 				return res;
 			} 
 		}
-		techProjectService.createProject(orderNo, uid, aid, projectType, signComment);
+		techProjectService.createProject(uid, aid, signComment);
 		return res;
 	}
 	
@@ -657,7 +657,7 @@ public class AdminTechProjectApiController extends CertifyApiController {
 	public Result getProjectDetail(String contractId){
 		Result res = new Result();
 		if(StringUtils.isBlank(contractId)){
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "合同ID"));
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目ID"));
 			return res;
 		}
 		res.setData(techProjectService.selectTechProjectDetail(contractId));
@@ -673,7 +673,7 @@ public class AdminTechProjectApiController extends CertifyApiController {
 	public Result getProjectTask(String contractId){
 		Result res = new Result();
 		if(StringUtils.isBlank(contractId)){
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "合同ID"));
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目ID"));
 			return res;
 		}
 		res.setData(techProjectService.selectProjectTask(contractId));
@@ -700,6 +700,22 @@ public class AdminTechProjectApiController extends CertifyApiController {
 	}
 	
 	/**
+	 * 删除任务
+	 * @param taskId
+	 * @return
+	 */
+	@RequestMapping(value = "/deleteProjectTask", method = RequestMethod.GET)
+	public Result deleteProjectTask(String taskId){
+		Result res = new Result();
+		if(StringUtils.isBlank(taskId)){
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目编号"));
+			return res;
+		}
+		techProjectService.deleteProjectTask(taskId);
+		return res;
+	}
+	
+	/**
 	 * 查询任务详情
 	 * @param taskId
 	 * @return
@@ -730,7 +746,11 @@ public class AdminTechProjectApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务编号"));
 			return res;
 		}
-		ContractTask task = new ContractTask();
+		ContractTask task = techProjectService.selectTaskById(taskId);
+		if(task != null){
+			if(task.getTaskStatus() != TaskState.UN_DISTRIBUTION.getCode())
+				res.getError().add(buildError(ErrorConstants.NOT_ACCORD_WITH_NEXT, ""));
+		}
 		task.setCommodityId(commodityId);
 		task.setTaskComment(taskComment);
 		task.setCommodityMode(commodityMode);
@@ -751,11 +771,17 @@ public class AdminTechProjectApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务编号和制定派单人"));
 			return res;
 		}
-		ContractTask task = new ContractTask();
-		task.setTaskReceiver(taskReceiverId);
-		task.setTaskAllocator(TokenManager.getAdminId());
-		task.setTaskDistributionTime(new Date());
-		techProjectService.updateProjectTask(task);
+		ContractTask task = techProjectService.selectTaskById(taskId);
+		if(task != null){
+			if(task.getTaskStatus() != TaskState.UN_DISTRIBUTION.getCode())
+				res.getError().add(buildError(ErrorConstants.NOT_ACCORD_WITH_NEXT, ""));
+			task.setId(taskId);
+			task.setTaskReceiver(taskReceiverId);
+			task.setTaskAllocator(TokenManager.getAdminId());
+			task.setTaskDistributionTime(new Date());
+			task.setTaskStatus(TaskState.DISTRIBUTION.getCode());
+			techProjectService.updateProjectTask(task);
+		}
 		return res;
 	}
 	
@@ -843,5 +869,25 @@ public class AdminTechProjectApiController extends CertifyApiController {
 		task.setTaskStatus(TaskState.COMPLETE.getCode());
 		techProjectService.updateProjectTask(task);
 		return res;
-	} 
+	}
+	
+	/**
+	 * 转交任务
+	 * @param taskId
+	 * @param receiverId
+	 * @return
+	 */
+	@RequestMapping(value = "/transferTask", method = RequestMethod.GET)
+	public Result transferTask(String taskId,String taskReceiverId){
+		Result res = new Result();
+		if(StringUtils.isBlank(taskId) || StringUtils.isBlank(taskReceiverId)){
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务和转交人"));
+			return res;
+		}
+		ContractTask task = new ContractTask();
+		task.setId(taskId);
+		task.setTaskReceiver(taskReceiverId);
+		techProjectService.updateProjectTask(task);
+		return res;
+	}
 }

+ 9 - 3
src/main/java/com/goafanti/techproject/service/TechProjectService.java

@@ -3,12 +3,12 @@ package com.goafanti.techproject.service;
 import java.util.Date;
 import java.util.List;
 
-import com.goafanti.app.bo.ProjectDetailBo;
 import com.goafanti.common.model.Contract;
 import com.goafanti.common.model.ContractTask;
 import com.goafanti.common.model.TechProject;
 import com.goafanti.common.model.TechProjectLog;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.techproject.bo.ProjectDetailBo;
 import com.goafanti.techproject.bo.ProjectListBo;
 import com.goafanti.techproject.bo.TaskDetailBo;
 import com.goafanti.techproject.bo.TaskListBo;
@@ -57,14 +57,13 @@ public interface TechProjectService {
 
 	/**
 	 * 创建项目
-	 * @param orderNo
 	 * @param uid
 	 * @param aid
 	 * @param projectType
 	 * @param signComment
 	 * @return
 	 */
-	int createProject(String orderNo,String uid,String aid,Integer projectType,String signComment) ;
+	int createProject(String uid,String aid,String signComment) ;
 
 	/**
 	 * 查询项目详情
@@ -129,4 +128,11 @@ public interface TechProjectService {
 	 * @return
 	 */
 	ContractTask selectTaskById(String taskId);
+
+	/**
+	 * 删除项目任务
+	 * @param taskId
+	 * @return
+	 */
+	int deleteProjectTask(String taskId);
 }

+ 19 - 33
src/main/java/com/goafanti/techproject/service/impl/TechProjectServiceImpl.java

@@ -12,14 +12,12 @@ import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.goafanti.app.bo.ProjectDetailBo;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.dao.ContractMapper;
 import com.goafanti.common.dao.ContractTaskMapper;
 import com.goafanti.common.dao.NoticeMapper;
-import com.goafanti.common.dao.TOrderMapper;
 import com.goafanti.common.dao.TechProjectLogMapper;
 import com.goafanti.common.dao.TechProjectMapper;
 import com.goafanti.common.dao.UserMapper;
@@ -32,7 +30,6 @@ import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.Contract;
 import com.goafanti.common.model.ContractTask;
 import com.goafanti.common.model.Notice;
-import com.goafanti.common.model.TOrder;
 import com.goafanti.common.model.TechProject;
 import com.goafanti.common.model.TechProjectLog;
 import com.goafanti.common.model.User;
@@ -40,10 +37,9 @@ import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
-import com.goafanti.order.bo.ServiceOrderDetailBo;
-import com.goafanti.order.enums.ActiveState;
 import com.goafanti.order.enums.CommodityType;
 import com.goafanti.order.enums.ProjectStage;
+import com.goafanti.techproject.bo.ProjectDetailBo;
 import com.goafanti.techproject.bo.ProjectListBo;
 import com.goafanti.techproject.bo.TaskDetailBo;
 import com.goafanti.techproject.bo.TaskListBo;
@@ -66,8 +62,6 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 	@Autowired
 	private UserMapper				userMapper;
 	@Autowired
-	private TOrderMapper 			tOrderMapper;
-	@Autowired
 	private ContractMapper 			contractMapper;
 	@Autowired
 	private ContractTaskMapper 		contractTaskMapper;
@@ -330,36 +324,17 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 	}
 
 	@Override
-	public int createProject(String orderNo, String uid, String aid, Integer projectType, String signComment) {
+	public int createProject(String uid, String aid, String signComment) {
 		Contract contract = new Contract();
 		contract.setId(UUID.randomUUID().toString());
-		contract.setStatus(ProjectStage.WAIT_SET_UP.getCode());
+		contract.setStatus(ProjectStage.ALREADY_SET_UP.getCode());
 		contract.setSignComment(signComment);
 		contract.setCreateTime(new Date());
-		if(StringUtils.isNotBlank(orderNo)){
-			ServiceOrderDetailBo detail = tOrderMapper.selectServiceOrderDetail(orderNo);
-			if(detail == null)
-				 throw new BusinessException(new Error(ErrorConstants.ORDER_NOT_EXIST, "",""));
-			if(detail.getDeleteSign() == ActiveState.ABOLISH.getCode())
-				 throw new BusinessException(new Error(ErrorConstants.ORDER_ALREADY_FREEZE, orderNo,""));
-			if(detail.getDeleteSign() == ActiveState.LOCKING.getCode())
-				 throw new BusinessException(new Error(ErrorConstants.ORDER_ALREADY_REVOKE, orderNo,""));
-			if(detail.getProjectStage() != ProjectStage.WAIT_SET_UP.getCode())
-				 throw new BusinessException(new Error(ErrorConstants.NOT_ACCORD_WITH_NEXT, orderNo,""));
-			contract.setType(detail.getOrderType());
-			contract.setOrderNo(orderNo);
-			contract.setUid(detail.getBuyerId());
-			TOrder tOrder = new TOrder();
-			tOrder.setOrderNo(orderNo);
-			tOrder.setProjectStage(ProjectStage.WAIT_SET_UP.getCode());
-			tOrder.setUpdateTime(new Date());
-			tOrderMapper.updateByPrimaryKeySelective(tOrder);
-		}else {
-			contract.setType(CommodityType.SERVICE.getTypeCode());
-			contract.setUid(uid);
-		}
-		contractMapper.insert(contract);
-		return 1;
+		contract.setType(CommodityType.SERVICE.getTypeCode());
+		contract.setUid(uid);
+		contract.setCreater(TokenManager.getAdminId());
+		contract.setPrincipal(aid);
+		return	contractMapper.insert(contract);
 	}
 
 	@Override
@@ -388,6 +363,7 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 		task.setContractId(contractId);
 		task.setTaskStatus(TaskState.UN_DISTRIBUTION.getCode());
 		task.setDeleteSign(DeleteStatus.LOCKING.getCode());
+		task.setTaskComment(taskComment);
 		return contractTaskMapper.insert(task);
 	}
 
@@ -429,4 +405,14 @@ public class TechProjectServiceImpl extends BaseMybatisDao<TechProjectMapper> im
 		return contractTaskMapper.selectByPrimaryKey(taskId);
 	}
 
+	@Override
+	public int deleteProjectTask(String taskId) {
+		ContractTask task = contractTaskMapper.selectByPrimaryKey(taskId);
+		if(task != null){
+			if(task.getTaskStatus() == TaskState.STARTED.getCode() || task.getTaskStatus() == TaskState.COMPLETE.getCode())
+				throw new BusinessException(new Error(ErrorConstants.NOT_ACCORD_WITH_NEXT, taskId, ""));
+		}
+		return contractTaskMapper.deleteByPrimaryKey(taskId);
+	}
+
 }