Antiloveg 8 years ago
parent
commit
5374face32

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

@@ -337,7 +337,7 @@ public class AdminContractApiController extends CertifyApiController {
 		if (StringUtils.isBlank(ic.getId())) {
 			contractService.insertManageSubmit(c, principals, signDateFormattedDate);
 		} else {
-			contractService.updateByPrimaryKeySelective(c);
+			contractService.updateSubmit(c, principals, signDateFormattedDate);
 		}
 		return res;
 	}

+ 2 - 0
src/main/java/com/goafanti/contract/service/ContractService.java

@@ -22,4 +22,6 @@ public interface ContractService {
 
 	int updateByPrimaryKeySelective(Contract contract);
 
+	void updateSubmit(Contract c, String[] principals, String signDateFormattedDate);
+
 }

+ 60 - 20
src/main/java/com/goafanti/contract/service/impl/ContractServiceImpl.java

@@ -1,9 +1,11 @@
 package com.goafanti.contract.service.impl;
 
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -145,14 +147,20 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
 		ContractLog clog = disposeContractLog(c);
 		clog.setStatus(ContractStatus.SIGN.getCode());
 		clog.setRecordTime(signDate);
-		contractLogMapper.insert(clog);
+
+		List<ContractLog> logs = new ArrayList<>();
+		List<Notice> notice = new ArrayList<>();
+		logs.add(clog);
 
 		for (int i = 0; i < principals.length; i++) {
 			ContractLog log = disposeContractLog(c);
 			log.setPrincipal(principals[i]);
-			contractLogMapper.insert(log);
-			createNotice(c, log);
+			logs.add(log);
+			notice.add(createNotice(c, log));
 		}
+		contractLogMapper.insertBatch(logs);
+		noticeMapper.insertBatch(notice);
+
 	}
 
 	private Contract disposeContract(Contract c) {
@@ -184,7 +192,54 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
 		return cl;
 	}
 
-	private void createNotice(Contract c, ContractLog l) {
+	@Override
+	public ContractDetail selectContractDetail(String id) {
+		return contractMapper.selectContractDetail(id);
+	}
+
+	@Override
+	public Contract selectByPrimaryKey(String id) {
+		return contractMapper.selectByPrimaryKey(id);
+	}
+
+	@Override
+	public int updateByPrimaryKeySelective(Contract contract) {
+		return contractMapper.updateByPrimaryKeySelective(contract);
+	}
+
+	@Override
+	public void updateSubmit(Contract c, String[] principals, String signDateFormattedDate) {
+		Date signDate = null;
+		if (!StringUtils.isBlank(signDateFormattedDate)) {
+			try {
+				signDate = DateUtils.parseDate(signDateFormattedDate, AFTConstants.YYYYMMDDHHMMSS);
+			} catch (ParseException e) {
+			}
+		}
+		c.setStatus(ContractStatus.CIRCULATION.getCode());
+		c.setSignDate(signDate);
+		contractMapper.updateByPrimaryKeySelective(c);
+		
+		ContractLog clog = disposeContractLog(c);
+		clog.setStatus(ContractStatus.SIGN.getCode());
+		clog.setRecordTime(signDate);
+
+		List<ContractLog> logs = new ArrayList<>();
+		List<Notice> notice = new ArrayList<>();
+		logs.add(clog);
+
+		for (int i = 0; i < principals.length; i++) {
+			ContractLog log = disposeContractLog(c);
+			log.setPrincipal(principals[i]);
+			log.setOperator(TokenManager.getAdminId());
+			logs.add(log);
+			notice.add(createNotice(c, log));
+		}
+		contractLogMapper.insertBatch(logs);
+		noticeMapper.insertBatch(notice);
+	}
+
+	private Notice createNotice(Contract c, ContractLog l) {
 		Contract info = contractMapper.selectByPrimaryKey(c.getId());
 
 		Notice n = new Notice();
@@ -206,22 +261,7 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
 		n.setContent("编号" + info.getSerialNumber() + "  " + ContractStatus.getStatus(c.getStatus()).getDesc());
 		n.setNoticeType(NoticeStatus.CONTRACT.getCode());
 		n.setYear(info.getCognizanceYear());
-		noticeMapper.insert(n);
-	}
-
-	@Override
-	public ContractDetail selectContractDetail(String id) {
-		return contractMapper.selectContractDetail(id);
-	}
-
-	@Override
-	public Contract selectByPrimaryKey(String id) {
-		return contractMapper.selectByPrimaryKey(id);
-	}
-
-	@Override
-	public int updateByPrimaryKeySelective(Contract contract) {
-		return contractMapper.updateByPrimaryKeySelective(contract);
+		return n;
 	}
 
 }