|
|
@@ -13,11 +13,17 @@ 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.dao.NoticeMapper;
|
|
|
+import com.goafanti.common.dao.UserMapper;
|
|
|
import com.goafanti.common.enums.ContractBusinessStatus;
|
|
|
import com.goafanti.common.enums.ContractStatus;
|
|
|
import com.goafanti.common.enums.DeleteStatus;
|
|
|
+import com.goafanti.common.enums.NoticeReadStatus;
|
|
|
+import com.goafanti.common.enums.NoticeStatus;
|
|
|
import com.goafanti.common.model.Contract;
|
|
|
import com.goafanti.common.model.ContractLog;
|
|
|
+import com.goafanti.common.model.Notice;
|
|
|
+import com.goafanti.common.model.User;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.contract.bo.ContractManageListBo;
|
|
|
@@ -32,6 +38,10 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
|
|
|
private ContractMapper contractMapper;
|
|
|
@Autowired
|
|
|
private ContractLogMapper contractLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private UserMapper userMapper;
|
|
|
+ @Autowired
|
|
|
+ private NoticeMapper noticeMapper;
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
@@ -58,8 +68,8 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
|
|
|
if (null != status) {
|
|
|
params.put("status", status);
|
|
|
}
|
|
|
-
|
|
|
- if (!StringUtils.isBlank(uid)){
|
|
|
+
|
|
|
+ if (!StringUtils.isBlank(uid)) {
|
|
|
params.put("uid", uid);
|
|
|
}
|
|
|
|
|
|
@@ -106,34 +116,86 @@ public class ContractServiceImpl extends BaseMybatisDao<ContractMapper> implemen
|
|
|
|
|
|
@Override
|
|
|
public Contract saveManageContract(Contract c) {
|
|
|
+ c.setStatus(ContractStatus.CREATE.getCode());
|
|
|
+ c = disposeContract(c);
|
|
|
+ contractMapper.insert(c);
|
|
|
+ contractLogMapper.insert(disposeContractLog(c));
|
|
|
+ return c;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateContractByManage(Contract contract) {
|
|
|
+ return contractMapper.updateByPrimaryKeySelective(contract);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void insertManageSubmit(Contract c, String[] principals) {
|
|
|
+ c.setStatus(ContractStatus.CIRCULATION.getCode());
|
|
|
+ c = disposeContract(c);
|
|
|
+ contractMapper.insert(c);
|
|
|
+ ContractLog clog = disposeContractLog(c);
|
|
|
+ clog.setStatus(ContractStatus.SIGN.getCode());
|
|
|
+ contractLogMapper.insert(clog);
|
|
|
+
|
|
|
+ for (int i = 0; i < principals.length; i++) {
|
|
|
+ ContractLog log = disposeContractLog(c);
|
|
|
+ log.setPrincipal(principals[i]);
|
|
|
+ contractLogMapper.insert(log);
|
|
|
+ createNotice(c, log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Contract disposeContract(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);
|
|
|
+ return c;
|
|
|
+ }
|
|
|
|
|
|
+ private ContractLog disposeContractLog(Contract 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());
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ now.set(Calendar.MILLISECOND, 0);
|
|
|
+ cl.setRecordTime(now.getTime());
|
|
|
cl.setStatus(c.getStatus());
|
|
|
cl.setCid(c.getId());
|
|
|
- contractLogMapper.insert(cl);
|
|
|
- return c;
|
|
|
+ return cl;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public int updateContractByManage(Contract contract) {
|
|
|
- return contractMapper.updateByPrimaryKeySelective(contract);
|
|
|
+ private void createNotice(Contract c, ContractLog l) {
|
|
|
+ Contract info = contractMapper.selectByPrimaryKey(c.getId());
|
|
|
+
|
|
|
+ Notice n = new Notice();
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ now.set(Calendar.MILLISECOND, 0);
|
|
|
+ n.setId(UUID.randomUUID().toString());
|
|
|
+ n.setCreateTime(now.getTime());
|
|
|
+ n.setReaded(NoticeReadStatus.UNREAD.getCode());
|
|
|
+
|
|
|
+ User u = userMapper.selectByPrimaryKey(c.getUid());
|
|
|
+ if (null != u) {
|
|
|
+ n.setPid(u.getAid());
|
|
|
+ }
|
|
|
+
|
|
|
+ n.setUid(c.getUid());
|
|
|
+ n.setRid(c.getId());
|
|
|
+
|
|
|
+ n.setAid(l.getPrincipal());
|
|
|
+ n.setContent("编号" + info.getSerialNumber() + " " + ContractStatus.getStatus(c.getStatus()).getDesc());
|
|
|
+ n.setNoticeType(NoticeStatus.TECHPROJECT.getCode());
|
|
|
+ noticeMapper.insert(n);
|
|
|
}
|
|
|
|
|
|
}
|