Browse Source

合同管理--保存草稿接口

Antiloveg 8 years ago
parent
commit
a480b4b6e9

+ 2 - 0
schema/2017-05-09.sql

@@ -0,0 +1,2 @@
+alter table `contract` 
+add column `contacts` int(1) null comment '联系人' after `uid`;

+ 1 - 1
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -3031,8 +3031,8 @@ public class AdminApiController extends CertifyApiController {
 				}
 			} catch (ParseException e) {
 			}
-
 		}
+		
 		String salesman = cog.getSalesman();
 		OrgCognizance oc = new OrgCognizance();
 		BeanUtils.copyProperties(cog, oc);

+ 72 - 6
src/main/java/com/goafanti/admin/controller/AdminContractApiController.java

@@ -1,33 +1,49 @@
 package com.goafanti.admin.controller;
 
+import java.text.ParseException;
+
 import javax.annotation.Resource;
 import javax.validation.Valid;
 
+import org.springframework.beans.BeanUtils;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.goafanti.cognizance.bo.LatelyCogRecord;
+import com.goafanti.cognizance.service.OrgCognizanceService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.enums.ContractFields;
+import com.goafanti.common.enums.OrgCognizanceStatus;
+import com.goafanti.common.model.Contract;
+import com.goafanti.common.model.User;
 import com.goafanti.common.utils.StringUtils;
+import com.goafanti.common.utils.TimeUtils;
 import com.goafanti.contract.bo.InputContract;
+import com.goafanti.contract.bo.InputSaveContract;
 import com.goafanti.contract.service.ContractService;
+import com.goafanti.user.service.UserService;
 
 @RestController
 @RequestMapping(value = "/api/admin/contract")
 public class AdminContractApiController extends CertifyApiController {
 	@Resource
-	private ContractService contractService;
+	private ContractService			contractService;
+	@Resource
+	private UserService				userService;
+	@Resource
+	private OrgCognizanceService	orgCognizanceService;
 
 	/**
 	 * 合同列表
 	 */
 	@RequestMapping(value = "/list", method = RequestMethod.GET)
 	public Result listContract(Integer serialNumber, Integer type, Integer status, String startDateFormattedDate,
-			String endDateFormattedDate, String province, String unitName, String pageNo, String pageSize) {
+			String endDateFormattedDate, String province, String unitName, String uid, String pageNo, String pageSize) {
 		Result res = new Result();
 		Integer pNo = 1;
 		Integer pSize = 10;
@@ -38,26 +54,76 @@ public class AdminContractApiController extends CertifyApiController {
 			pNo = Integer.parseInt(pageNo);
 		}
 		res.setData(contractService.getManageList(serialNumber, type, status, startDateFormattedDate,
-				endDateFormattedDate, province, unitName, pNo, pSize));
+				endDateFormattedDate, province, unitName, uid, pNo, pSize));
 		return res;
 	}
 
 	/**
-	 * 新增合同
+	 * 新增合同(保存)
 	 */
 	@RequestMapping(value = "/apply", method = RequestMethod.POST)
-	public Result applyContract(@Valid InputContract ic, String[] principals, BindingResult bindingResult) {
+	public Result applyContract(@Valid InputSaveContract contract, BindingResult bindingResult) {
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
 			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
 					ContractFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		if (StringUtils.isBlank(ic.getUid())) {
+		if (StringUtils.isBlank(contract.getUid())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
 			return res;
 		}
 
+		User curUser = userService.selectByPrimaryKey(contract.getUid());
+		if (!checkCertify(res, curUser)) {
+			return res;
+		}
+
+		if (null != contract.getCognizanceYear()) {
+			LatelyCogRecord lcr = orgCognizanceService.selectLatelyRecord(contract.getUid());
+			if (null != lcr && null != lcr.getState() && OrgCognizanceStatus.FOSTER.getCode() == lcr.getState()) {
+				res.getError().add(buildError(ErrorConstants.STATUS_ERROR, "高企培育中!无法提交新申请!", "高企培育中!无法提交新申请!"));
+				return res;
+			}
+
+			if (null != lcr && null != lcr.getState() && OrgCognizanceStatus.SETTLEMENT.getCode() != lcr.getState()
+					&& OrgCognizanceStatus.CALLBACK.getCode() != lcr.getState()) {
+				res.getError().add(buildError(ErrorConstants.STATUS_ERROR, "高企申请中!无法提交新申请!", "高企申请中!无法提交新申请!"));
+				return res;
+			}
+
+			if (null != lcr && null != lcr.getState() && OrgCognizanceStatus.SETTLEMENT.getCode() == lcr.getState()) {
+				if (null == lcr.getIssuingDate()) {
+					res.getError().add(buildError(ErrorConstants.STATUS_ERROR, "高企认定未过期!无法提交新申请!", "高企认定未过期!无法提交新申请!"));
+					return res;
+				}
+				try {
+					if (Boolean.FALSE == TimeUtils.checkCogExpire(lcr.getIssuingDate())) {
+						res.getError()
+								.add(buildError(ErrorConstants.STATUS_ERROR, "高企认定未过期,无法提交新申请!", "高企认定未过期,无法提交新申请!"));
+						return res;
+					}
+				} catch (ParseException e) {
+				}
+			}
+		}
+		
+		Contract c = new Contract();
+		BeanUtils.copyProperties(contract, c);
+		if (StringUtils.isBlank(contract.getId())) {
+			res.setData(contractService.saveManageContract(c));
+		}
+		return res;
+	}
+
+	/**
+	 * 新增提交合同
+	 */
+	@RequestMapping(value = "/submit", method = RequestMethod.POST)
+	public Result submitContract(@Valid InputContract ic, BindingResult bindingResult,
+			@RequestParam(name = "principals[]", required = false) String[] principals) {
+		Result res = new Result();
 		return res;
 	}
+
 }

+ 55 - 0
src/main/java/com/goafanti/common/enums/ContractBusinessStatus.java

@@ -0,0 +1,55 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum ContractBusinessStatus {
+	UNCREATE(0, "未创建"),
+	CREATE(1,"已创建"),
+	OTHER(2, "其他");
+
+	private ContractBusinessStatus(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, ContractBusinessStatus> status = new HashMap<Integer, ContractBusinessStatus>();
+
+	static {
+		for (ContractBusinessStatus value : ContractBusinessStatus.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static ContractBusinessStatus getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+
+	public static ContractBusinessStatus getStatus(String code) {
+		if (StringUtils.isNumeric(code)) {
+			return getStatus(Integer.parseInt(code));
+		}
+		return OTHER;
+	}
+
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+
+	private Integer	code;
+	private String	desc;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 56 - 0
src/main/java/com/goafanti/common/enums/ContractStatus.java

@@ -0,0 +1,56 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum ContractStatus {
+	CREATE(0, "草稿"),
+	SIGN(1,"签订"),
+	CIRCULATION(2,"分发流转"),
+	COMPLETE(3, "完成(已结款)"),
+	OTHER(4, "其他");
+
+	private ContractStatus(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, ContractStatus> status = new HashMap<Integer, ContractStatus>();
+
+	static {
+		for (ContractStatus value : ContractStatus.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static ContractStatus getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+
+	public static ContractStatus getStatus(String code) {
+		if (StringUtils.isNumeric(code)) {
+			return getStatus(Integer.parseInt(code));
+		}
+		return OTHER;
+	}
+
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+
+	private Integer	code;
+	private String	desc;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+}

+ 25 - 6
src/main/java/com/goafanti/common/mapper/ContractMapper.xml

@@ -23,11 +23,13 @@
     <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
     <result column="complete_date" property="completeDate" jdbcType="TIMESTAMP" />
     <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
+    <result column="contacts" property="contacts" jdbcType="INTEGER" />
   </resultMap>
   <sql id="Base_Column_List" >
     id, uid, serial_number, name, type, sign_date, founder, describe, status, patent_num, 
     patent_status, copyright_num, copyright_status, cognizance_year, cognizance_status, 
-    tech_project_num, tech_project_status, comment, create_time, complete_date, deleted_sign
+    tech_project_num, tech_project_status, comment, create_time, complete_date, deleted_sign,
+    contacts
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
     select 
@@ -46,7 +48,7 @@
       patent_num, patent_status, copyright_num, 
       copyright_status, cognizance_year, cognizance_status, 
       tech_project_num, tech_project_status, comment, 
-      create_time, complete_date, deleted_sign
+      create_time, complete_date, deleted_sign, contacts
       )
     values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{serialNumber,jdbcType=INTEGER}, 
       #{name,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{signDate,jdbcType=TIMESTAMP}, 
@@ -54,7 +56,8 @@
       #{patentNum,jdbcType=INTEGER}, #{patentStatus,jdbcType=INTEGER}, #{copyrightNum,jdbcType=INTEGER}, 
       #{copyrightStatus,jdbcType=INTEGER}, #{cognizanceYear,jdbcType=INTEGER}, #{cognizanceStatus,jdbcType=INTEGER}, 
       #{techProjectNum,jdbcType=INTEGER}, #{techProjectStatus,jdbcType=INTEGER}, #{comment,jdbcType=VARCHAR}, 
-      #{createTime,jdbcType=TIMESTAMP}, #{completeDate,jdbcType=TIMESTAMP}, #{deletedSign,jdbcType=INTEGER}
+      #{createTime,jdbcType=TIMESTAMP}, #{completeDate,jdbcType=TIMESTAMP}, #{deletedSign,jdbcType=INTEGER},
+      #{contacts,jdbcType=INTEGER}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.Contract" >
@@ -123,6 +126,9 @@
       <if test="deletedSign != null" >
         deleted_sign,
       </if>
+      <if test="contacts != null" >
+        contacts,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="id != null" >
@@ -188,6 +194,9 @@
       <if test="deletedSign != null" >
         #{deletedSign,jdbcType=INTEGER},
       </if>
+      <if test="contacts != null" >
+        #{contacts,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Contract" >
@@ -253,6 +262,9 @@
       <if test="deletedSign != null" >
         deleted_sign = #{deletedSign,jdbcType=INTEGER},
       </if>
+      <if test="contacts != null" >
+        contacts = #{contacts,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -277,7 +289,8 @@
       comment = #{comment,jdbcType=VARCHAR},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       complete_date = #{completeDate,jdbcType=TIMESTAMP},
-      deleted_sign = #{deletedSign,jdbcType=INTEGER}
+      deleted_sign = #{deletedSign,jdbcType=INTEGER},
+      contacts = #{contacts,jdbcType=INTEGER}
     where id = #{id,jdbcType=VARCHAR}
   </update>
   
@@ -285,7 +298,7 @@
    select c.id, c.uid, oi.unit_name as unitName, 
    		  oi.licence_province as province, c.serial_number as serialNumber, c.type,
    		  c.sign_date as signDate, a.name as founder, 
-   		  c.describe, c.status, c.complete_date as completeDate
+   		  c.describe, c.status, c.complete_date as completeDate, c.contacts
    from contract c 
 		LEFT JOIN organization_identity oi on oi.uid = c.uid
 		LEFT JOIN admin a on a.id = c.founder
@@ -299,9 +312,12 @@
   <if test="serialNumber !=null">
     and c.serialNumber = #{serialNumber,jdbcType=VARCAHR}
   </if>
-   <if test="type !=null">
+  <if test="type !=null">
     and c.type = #{type,jdbcType=INTEGER}
   </if>
+   <if test="uid !=null">
+    and c.uid = #{uid,jdbcType=INTEGER}
+  </if>
    <if test="status !=null">
     and c.status= #{status ,jdbcType=INTEGER}
   </if>
@@ -345,6 +361,9 @@
    <if test="type !=null">
     and c.type = #{type,jdbcType=INTEGER}
   </if>
+   <if test="uid !=null">
+    and c.uid = #{uid,jdbcType=INTEGER}
+  </if>
    <if test="status !=null">
     and c.status= #{status ,jdbcType=INTEGER}
   </if>

+ 12 - 1
src/main/java/com/goafanti/common/model/Contract.java

@@ -13,6 +13,8 @@ public class Contract {
     private String id;
 
     private String uid;
+    
+    private Integer contacts;
 
     /**
     * 合同编号
@@ -121,8 +123,17 @@ public class Contract {
     public void setUid(String uid) {
         this.uid = uid;
     }
+    
+    @JsonFormat(shape = Shape.STRING)
+    public Integer getContacts() {
+		return contacts;
+	}
+
+	public void setContacts(Integer contacts) {
+		this.contacts = contacts;
+	}
 
-    public Integer getSerialNumber() {
+	public Integer getSerialNumber() {
         return serialNumber;
     }
 

+ 11 - 0
src/main/java/com/goafanti/contract/bo/ContractManageListBo.java

@@ -13,6 +13,8 @@ public class ContractManageListBo {
 
 	private String	uid;
 	
+	private Integer contacts;
+	
 	private String province;
 	
 	private String unitName;
@@ -69,6 +71,15 @@ public class ContractManageListBo {
 	public void setUid(String uid) {
 		this.uid = uid;
 	}
+	
+	@JsonFormat(shape = Shape.STRING)
+	public Integer getContacts() {
+		return contacts;
+	}
+
+	public void setContacts(Integer contacts) {
+		this.contacts = contacts;
+	}
 
 	public String getProvince() {
 		return province;

+ 25 - 3
src/main/java/com/goafanti/contract/bo/InputContract.java

@@ -8,6 +8,9 @@ import com.goafanti.common.constant.ErrorConstants;
 
 public class InputContract {
 	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String id;
+	
+	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	uid;
 	
 	@Max(value = 3, message = "{" + ErrorConstants.PARAM_ERROR + "}")
@@ -33,11 +36,12 @@ public class InputContract {
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	private Integer	techProjectNum;
 	
-	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
-	private String		principal;
-	
 	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	comment;
+	
+	@Max(value = 3, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer status;
 
 	public String getUid() {
 		return uid;
@@ -103,4 +107,22 @@ public class InputContract {
 		this.comment = comment;
 	}
 
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+	
+	
+
 }

+ 160 - 0
src/main/java/com/goafanti/contract/bo/InputSaveContract.java

@@ -0,0 +1,160 @@
+package com.goafanti.contract.bo;
+
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Size;
+
+import com.goafanti.common.constant.ErrorConstants;
+
+public class InputSaveContract {
+	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	id;
+	
+	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	uid;
+	
+	@Max(value = 3, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 1, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer contacts;
+
+	private Integer	serialNumber;
+
+
+	@Max(value = 3, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	type;
+
+
+	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	describe;
+
+	@Max(value = 3, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	status;
+
+	@Max(value = 99, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	patentNum;
+
+
+	@Max(value = 99, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	copyrightNum;
+
+
+	@Max(value = 9999, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	cognizanceYear;
+
+
+	@Max(value = 99, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	techProjectNum;
+
+
+	@Size(min = 0, max = 128, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	comment;
+
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+	
+
+	public Integer getContacts() {
+		return contacts;
+	}
+
+	public void setContacts(Integer contacts) {
+		this.contacts = contacts;
+	}
+
+	public Integer getSerialNumber() {
+		return serialNumber;
+	}
+
+	public void setSerialNumber(Integer serialNumber) {
+		this.serialNumber = serialNumber;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public String getDescribe() {
+		return describe;
+	}
+
+	public void setDescribe(String describe) {
+		this.describe = describe;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Integer getPatentNum() {
+		return patentNum;
+	}
+
+	public void setPatentNum(Integer patentNum) {
+		this.patentNum = patentNum;
+	}
+
+	public Integer getCopyrightNum() {
+		return copyrightNum;
+	}
+
+	public void setCopyrightNum(Integer copyrightNum) {
+		this.copyrightNum = copyrightNum;
+	}
+
+	public Integer getCognizanceYear() {
+		return cognizanceYear;
+	}
+
+	public void setCognizanceYear(Integer cognizanceYear) {
+		this.cognizanceYear = cognizanceYear;
+	}
+
+	public Integer getTechProjectNum() {
+		return techProjectNum;
+	}
+
+	public void setTechProjectNum(Integer techProjectNum) {
+		this.techProjectNum = techProjectNum;
+	}
+
+	public String getComment() {
+		return comment;
+	}
+
+	public void setComment(String comment) {
+		this.comment = comment;
+	}
+
+	
+	
+
+}

+ 6 - 1
src/main/java/com/goafanti/contract/service/ContractService.java

@@ -1,11 +1,16 @@
 package com.goafanti.contract.service;
 
+import com.goafanti.common.model.Contract;
 import com.goafanti.contract.bo.ContractManageListBo;
 import com.goafanti.core.mybatis.page.Pagination;
 
 public interface ContractService {
 
 	Pagination<ContractManageListBo> getManageList(Integer serialNumber, Integer type, Integer status, String startDateFormattedDate,
-			String endDateFormattedDate, String province, String unitName, Integer pNo, Integer pSize);
+			String endDateFormattedDate, String province, String unitName, String uid, Integer pNo, Integer pSize);
+
+	Contract saveManageContract(Contract c);
+
+	int updateContractByManage(Contract contract);
 
 }

+ 70 - 23
src/main/java/com/goafanti/contract/service/impl/ContractServiceImpl.java

@@ -1,15 +1,23 @@
 package com.goafanti.contract.service.impl;
 
 import java.text.ParseException;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.dao.ContractLogMapper;
 import com.goafanti.common.dao.ContractMapper;
+import com.goafanti.common.enums.ContractBusinessStatus;
+import com.goafanti.common.enums.ContractStatus;
+import com.goafanti.common.enums.DeleteStatus;
+import com.goafanti.common.model.Contract;
+import com.goafanti.common.model.ContractLog;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.contract.bo.ContractManageListBo;
@@ -17,63 +25,70 @@ import com.goafanti.contract.service.ContractService;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+
 @Service
 public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implements ContractService {
 	@Autowired
-	private ContractMapper contractMapper;
+	private ContractMapper		contractMapper;
+	@Autowired
+	private ContractLogMapper	contractLogMapper;
 
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<ContractManageListBo> getManageList(Integer serialNumber, Integer type, Integer status,
-			String startDateFormattedDate, String endDateFormattedDate, String province, String unitName, Integer pNo,
-			Integer pSize) {
+			String startDateFormattedDate, String endDateFormattedDate, String province, String unitName, String uid,
+			Integer pNo, Integer pSize) {
 		Date cStart = null;
 		Date cEnd = null;
-		
+
 		Map<String, Object> params = new HashMap<>();
-		
+
 		if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
 			params.put("principal", TokenManager.getAdminId());
 		}
-		
-		if (null != serialNumber){
+
+		if (null != serialNumber) {
 			params.put("serialNumber", serialNumber);
 		}
-		
-		if (null != type){
+
+		if (null != type) {
 			params.put("type", type);
 		}
-		
-		if (null != status){
+
+		if (null != status) {
 			params.put("status", status);
 		}
 		
-		if (!StringUtils.isBlank(startDateFormattedDate)){
+		if (!StringUtils.isBlank(uid)){
+			params.put("uid", uid);
+		}
+
+		if (!StringUtils.isBlank(startDateFormattedDate)) {
 			try {
 				cStart = DateUtils.parseDate(startDateFormattedDate, AFTConstants.YYYYMMDD);
 			} catch (ParseException e) {
 			}
 		}
-		
-		if (null != cStart){
+
+		if (null != cStart) {
 			params.put("cStart", cStart);
 		}
-		
-		if (!StringUtils.isBlank(endDateFormattedDate)){
+
+		if (!StringUtils.isBlank(endDateFormattedDate)) {
 			try {
 				cEnd = DateUtils.parseDate(endDateFormattedDate, AFTConstants.YYYYMMDD);
 			} catch (ParseException e) {
 			}
 		}
-		
-		if (null != cEnd){
+
+		if (null != cEnd) {
 			params.put("cEnd", cEnd);
 		}
-		
+
 		if (!StringUtils.isBlank(province)) {
 			params.put("province", province);
 		}
-		
+
 		if (!StringUtils.isBlank(unitName)) {
 			params.put("unitName", unitName);
 		}
@@ -84,9 +99,41 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
 		if (pSize == null || pSize < 0) {
 			pSize = 10;
 		}
-		
-		return (Pagination<ContractManageListBo>) findPage("findManageContractListByPage", "findManageContractCount", params,
-				pNo, pSize);
+
+		return (Pagination<ContractManageListBo>) findPage("findManageContractListByPage", "findManageContractCount",
+				params, pNo, pSize);
+	}
+
+	@Override
+	public Contract saveManageContract(Contract c) {
+		c.setId(UUID.randomUUID().toString());
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		c.setCreateTime(now.getTime());
+		c.setFounder(TokenManager.getAdminId());
+		c.setStatus(ContractStatus.CREATE.getCode());
+		c.setPatentStatus(ContractBusinessStatus.UNCREATE.getCode());
+		c.setCopyrightStatus(ContractBusinessStatus.UNCREATE.getCode());
+		c.setTechProjectStatus(ContractBusinessStatus.UNCREATE.getCode());
+		c.setCognizanceStatus(ContractBusinessStatus.UNCREATE.getCode());
+		c.setDeletedSign(DeleteStatus.UNDELETE.getCode());
+		contractMapper.insert(c);
+
+		ContractLog cl = new ContractLog();
+		cl.setId(UUID.randomUUID().toString());
+		cl.setComment(c.getComment());
+		cl.setOperator(c.getFounder());
+		cl.setPrincipal(c.getFounder());
+		cl.setRecordTime(c.getCreateTime());
+		cl.setStatus(c.getStatus());
+		cl.setCid(c.getId());
+		contractLogMapper.insert(cl);
+		return c;
+	}
+
+	@Override
+	public int updateContractByManage(Contract contract) {
+		return contractMapper.updateByPrimaryKeySelective(contract);
 	}
 
 }