PatentInfoServiceImpl.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. package com.goafanti.patent.service.impl;
  2. import java.text.ParseException;
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Calendar;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.UUID;
  11. import org.springframework.beans.BeanUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import com.goafanti.common.constant.AFTConstants;
  15. import com.goafanti.common.dao.ContractMapper;
  16. import com.goafanti.common.dao.NoticeMapper;
  17. import com.goafanti.common.dao.OrgIntellectualPropertyMapper;
  18. import com.goafanti.common.dao.OrganizationIdentityMapper;
  19. import com.goafanti.common.dao.PatentCostMapper;
  20. import com.goafanti.common.dao.PatentInfoMapper;
  21. import com.goafanti.common.dao.PatentLogMapper;
  22. import com.goafanti.common.dao.PatentRegistrationMapper;
  23. import com.goafanti.common.dao.UserMapper;
  24. import com.goafanti.common.enums.ContractBusinessStatus;
  25. import com.goafanti.common.enums.DeleteStatus;
  26. import com.goafanti.common.enums.IntellectualPropertyType;
  27. import com.goafanti.common.enums.NoticeReadStatus;
  28. import com.goafanti.common.enums.NoticeStatus;
  29. import com.goafanti.common.enums.PatentAnnualFeeStatus;
  30. import com.goafanti.common.enums.PatentInfoStatus;
  31. import com.goafanti.common.enums.PatentPaymentStatus;
  32. import com.goafanti.common.model.Admin;
  33. import com.goafanti.common.model.Contract;
  34. import com.goafanti.common.model.Notice;
  35. import com.goafanti.common.model.OrgIntellectualProperty;
  36. import com.goafanti.common.model.OrganizationIdentity;
  37. import com.goafanti.common.model.PatentCost;
  38. import com.goafanti.common.model.PatentInfo;
  39. import com.goafanti.common.model.PatentLog;
  40. import com.goafanti.common.model.PatentRegistration;
  41. import com.goafanti.common.model.User;
  42. import com.goafanti.common.utils.DateUtils;
  43. import com.goafanti.common.utils.StringUtils;
  44. import com.goafanti.core.mybatis.BaseMybatisDao;
  45. import com.goafanti.core.mybatis.page.Pagination;
  46. import com.goafanti.core.shiro.token.TokenManager;
  47. import com.goafanti.patent.bo.PatentContractListBo;
  48. import com.goafanti.patent.bo.PatentExpireBO;
  49. import com.goafanti.patent.bo.PatentInfoDetailBo;
  50. import com.goafanti.patent.bo.PatentManageListBo;
  51. import com.goafanti.patent.bo.PatentNoticeOfCorrectionBo;
  52. import com.goafanti.patent.bo.PatentPendingBo;
  53. import com.goafanti.patent.service.PatentInfoService;
  54. @Service
  55. public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> implements PatentInfoService {
  56. @Autowired
  57. private PatentInfoMapper patentInfoMapper;
  58. @Autowired
  59. private UserMapper userMapper;
  60. @Autowired
  61. private PatentRegistrationMapper patentRegistrationMapper;
  62. @Autowired
  63. private PatentCostMapper patentCostMapper;
  64. @Autowired
  65. private PatentLogMapper patentLogMapper;
  66. @Autowired
  67. private OrgIntellectualPropertyMapper orgIntellectualPropertyMapper;
  68. @Autowired
  69. private NoticeMapper noticeMapper;
  70. @Autowired
  71. private OrganizationIdentityMapper organizationIdentityMapper;
  72. @Autowired
  73. private ContractMapper contractMapper;
  74. @Override
  75. public PatentInfo insert(PatentInfo patentInfo) {
  76. patentInfoMapper.insert(patentInfo);
  77. return patentInfo;
  78. }
  79. @Override
  80. public int updateByPrimaryKeySelective(PatentInfo patentInfo) {
  81. return patentInfoMapper.updateByPrimaryKeySelective(patentInfo);
  82. }
  83. @Override
  84. public PatentInfo selectByPrimaryKey(String id) {
  85. return patentInfoMapper.selectByPrimaryKey(id);
  86. }
  87. @SuppressWarnings("unchecked")
  88. @Override
  89. public Pagination<PatentInfo> getClientApplyList(String uid, String patentNumber, String patentName,
  90. Integer patentCatagory, Integer patentState, Integer pageNo, Integer pageSize) {
  91. Map<String, Object> params = new HashMap<>();
  92. if (uid == null) {
  93. return null;
  94. } else {
  95. params.put("uid", uid);
  96. }
  97. if (patentNumber != null && patentNumber != "") {
  98. params.put("patentNumber", patentNumber);
  99. }
  100. if (patentName != null && patentName != "") {
  101. params.put("patentName", patentName);
  102. }
  103. if (patentCatagory != null) {
  104. params.put("patentCatagory", patentCatagory);
  105. }
  106. if (patentState != null) {
  107. params.put("patentState", patentState);
  108. }
  109. if (pageNo == null || pageNo < 0) {
  110. pageNo = 1;
  111. }
  112. if (pageSize == null || pageSize < 0) {
  113. pageSize = 10;
  114. }
  115. return (Pagination<PatentInfo>) findPage("findClientApplyListByPage", "findClentApplyCount", params, pageNo,
  116. pageSize);
  117. }
  118. @SuppressWarnings("unchecked")
  119. @Override
  120. public Pagination<PatentManageListBo> getManagePatentList(String contractId, Integer serialNumber, String patentNumber, String office,
  121. String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState,
  122. String[] cDate, String[] pDate, String author, String uid, Integer pageNo, Integer pageSize) {
  123. Map<String, Object> params = new HashMap<>();
  124. Date cStart = null;
  125. Date cEnd = null;
  126. Date pStart = null;
  127. Date pEnd = null;
  128. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  129. params.put("principal", TokenManager.getAdminId());
  130. }
  131. if (cDate != null && cDate.length > 0) {
  132. try {
  133. cStart = StringUtils.isBlank(cDate[0]) ? null : DateUtils.parseDate(cDate[0], AFTConstants.YYYYMMDD);
  134. cEnd = StringUtils.isBlank(cDate[1]) ? null
  135. : DateUtils.addDays(DateUtils.parseDate(cDate[1], AFTConstants.YYYYMMDD), 1);
  136. } catch (ParseException e) {
  137. }
  138. }
  139. if (pDate != null && pDate.length > 0) {
  140. try {
  141. pStart = StringUtils.isBlank(pDate[0]) ? null : DateUtils.parseDate(pDate[0], AFTConstants.YYYYMMDD);
  142. pEnd = StringUtils.isBlank(pDate[1]) ? null
  143. : DateUtils.addDays(DateUtils.parseDate(pDate[1], AFTConstants.YYYYMMDD), 1);
  144. } catch (ParseException e) {
  145. }
  146. }
  147. if (cStart != null) {
  148. params.put("cStart", cStart);
  149. }
  150. if (cEnd != null) {
  151. params.put("cEnd", cEnd);
  152. }
  153. if (pStart != null) {
  154. params.put("pStart", pStart);
  155. }
  156. if (pEnd != null) {
  157. params.put("pEnd", pEnd);
  158. }
  159. if (!StringUtils.isBlank(contractId)){
  160. params.put("contractId", contractId);
  161. }
  162. if (serialNumber != null) {
  163. params.put("serialNumber", serialNumber);
  164. }
  165. if (patentNumber != null && patentNumber != "") {
  166. params.put("patentNumber", patentNumber);
  167. }
  168. if (office != null && office != "") {
  169. params.put("office", office);
  170. }
  171. if (locationProvince != null && locationProvince != "") {
  172. params.put("locationProvince", locationProvince);
  173. }
  174. if (unitName != null && unitName != "") {
  175. params.put("unitName", unitName);
  176. }
  177. if (patentCatagory != null) {
  178. params.put("patentCatagory", patentCatagory);
  179. }
  180. if (patentName != null && patentName != "") {
  181. params.put("patentName", patentName);
  182. }
  183. if (patentState != null) {
  184. params.put("patentState", patentState);
  185. }
  186. if (author != null && author != "") {
  187. params.put("author", author);
  188. }
  189. if (uid != null && uid != "") {
  190. params.put("uid", uid);
  191. }
  192. if (pageNo == null || pageNo < 0) {
  193. pageNo = 1;
  194. }
  195. if (pageSize == null || pageSize < 0) {
  196. pageSize = 10;
  197. }
  198. return (Pagination<PatentManageListBo>) findPage("findManagePatentListByPage", "findManagePatentCount", params,
  199. pageNo, pageSize);
  200. }
  201. @SuppressWarnings("unchecked")
  202. @Override
  203. public Pagination<PatentPendingBo> getManagePendingPaymentList(String locationProvince, Integer pageNo,
  204. Integer pageSize) {
  205. Map<String, Object> params = new HashMap<>();
  206. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  207. params.put("principal", TokenManager.getAdminId());
  208. }
  209. if (locationProvince != null && locationProvince != "") {
  210. params.put("locationProvince", locationProvince);
  211. }
  212. if (pageNo == null || pageNo < 0) {
  213. pageNo = 1;
  214. }
  215. if (pageSize == null || pageSize < 0) {
  216. pageSize = 10;
  217. }
  218. return (Pagination<PatentPendingBo>) findPage("findManagePendingPaymentListByPage",
  219. "findManagePendingPaymentCount", params, pageNo, pageSize);
  220. }
  221. @SuppressWarnings("unchecked")
  222. @Override
  223. public Pagination<PatentNoticeOfCorrectionBo> getNoticeOfCorrectionList(Date authorizedDate, Integer serialNumber,
  224. String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory,
  225. String patentName, Integer patentState, String author, Integer pageNo, Integer pageSize) {
  226. Map<String, Object> params = new HashMap<>();
  227. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  228. params.put("principal", TokenManager.getAdminId());
  229. }
  230. if (authorizedDate != null) {
  231. params.put("authorizedDate", authorizedDate);
  232. }
  233. if (serialNumber != null) {
  234. params.put("serialNumber", serialNumber);
  235. }
  236. if (patentNumber != null && patentNumber != "") {
  237. params.put(patentNumber, patentNumber);
  238. }
  239. if (office != null && office != "") {
  240. params.put("office", office);
  241. }
  242. if (locationProvince != null && locationProvince != "") {
  243. params.put("locationProvince", locationProvince);
  244. }
  245. if (unitName != null && unitName != "") {
  246. params.put("unitName", unitName);
  247. }
  248. if (patentCatagory != null) {
  249. params.put("patentCatagory", patentCatagory);
  250. }
  251. if (patentName != null && patentName != "") {
  252. params.put("patentName", patentName);
  253. }
  254. if (patentState != null) {
  255. params.put("patentState", patentState);
  256. }
  257. if (author != null && author != "") {
  258. params.put("author", patentState);
  259. }
  260. if (pageNo == null || pageNo < 0) {
  261. pageNo = 1;
  262. }
  263. if (pageSize == null || pageSize < 0) {
  264. pageSize = 10;
  265. }
  266. return (Pagination<PatentNoticeOfCorrectionBo>) findPage("findNoticeOfCorrectionListByPage",
  267. "findNoticeOfCorrectionCount", params, pageNo, pageSize);
  268. }
  269. @Override
  270. public int batchDeleteByPrimaryKey(List<String> id) {
  271. return patentInfoMapper.batchDeleteByPrimaryKey(id);
  272. }
  273. @Override
  274. public PatentInfo savePatentInfo(PatentInfo patentInfo, String salesman) {
  275. patentInfo.setFounder(salesman);
  276. patentInfo.setPatentState(PatentInfoStatus.DELIVERD.getCode());
  277. patentInfo.setPrincipal(TokenManager.getAdminId());
  278. patentInfo = disposePatentInfoSave(patentInfo);
  279. PatentLog log = new PatentLog();
  280. log.setId(UUID.randomUUID().toString());
  281. log.setPid(patentInfo.getId());
  282. log.setRecordTime(patentInfo.getRecordTime());
  283. log.setState(PatentInfoStatus.CREATE.getCode());
  284. log.setPrincipal(salesman);
  285. log.setOperator(salesman);
  286. log.setComment(patentInfo.getPatentDes());
  287. patentLogMapper.insert(log);
  288. if (!StringUtils.isBlank(patentInfo.getPatentProryStatementUrl())) {
  289. OrganizationIdentity oi = organizationIdentityMapper.selectOrgIdentityByUserId(patentInfo.getUid());
  290. oi.setPatentProryStatementUrl(patentInfo.getPatentProryStatementUrl());
  291. organizationIdentityMapper.updateByPrimaryKeySelective(oi);
  292. }
  293. createNotice(patentInfo, log);
  294. PatentLog l = new PatentLog();
  295. l.setId(UUID.randomUUID().toString());
  296. l.setPid(patentInfo.getId());
  297. Calendar now = Calendar.getInstance();
  298. now.set(Calendar.MILLISECOND, 0);
  299. l.setRecordTime(now.getTime());
  300. l.setState(PatentInfoStatus.DELIVERD.getCode());
  301. l.setPrincipal(TokenManager.getAdminId());
  302. l.setOperator(salesman);
  303. patentLogMapper.insert(l);
  304. createNotice(patentInfo, l);
  305. return patentInfo;
  306. }
  307. @Override
  308. public void updatePatentInfo(PatentInfo p, PatentLog log, Date recordTime) {
  309. if (!StringUtils.isBlank(p.getPatentProryStatementUrl())) {
  310. OrganizationIdentity oi = organizationIdentityMapper.selectOrgIdentityByUserId(p.getUid());
  311. oi.setPatentProryStatementUrl(p.getPatentProryStatementUrl());
  312. organizationIdentityMapper.updateByPrimaryKeySelective(oi);
  313. }
  314. if (null != log.getState() && recordTime != null && null != log.getPrincipal()) {
  315. log.setId(UUID.randomUUID().toString());
  316. log.setPid(p.getId());
  317. log.setRecordTime(recordTime);
  318. if (TokenManager.getToken() instanceof Admin) {
  319. log.setOperator(TokenManager.getAdminId());
  320. }
  321. if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.ACCEPT) {
  322. p.setPatentApplicationDate(recordTime);
  323. } else if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.AUTHORIZE) {
  324. p.setAuthorizedDate(recordTime);
  325. } else if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.REVIEWNOTICE) {
  326. p.setRecordTime(recordTime);
  327. } else if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.CORRECTIONNOTICE) {
  328. p.setRecordTime(recordTime);
  329. }
  330. if (PatentInfoStatus.getStatus(log.getState()) != PatentInfoStatus.CIRCULATION) {
  331. p.setPatentState(log.getState());
  332. }
  333. p.setPrincipal(log.getPrincipal());
  334. patentLogMapper.insert(log);
  335. if (PatentInfoStatus.getStatus(p.getPatentState()) == PatentInfoStatus.AUTHORIZE) {
  336. OrgIntellectualProperty o = new OrgIntellectualProperty();
  337. o.setId(UUID.randomUUID().toString());
  338. o.setUid(p.getUid());
  339. o.setPid(p.getId());
  340. o.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  341. o.setIntellectualPropertyNumber(p.getPatentNumber());
  342. o.setIntellectualPropertyName(p.getPatentName());
  343. o.setCatagory(1);
  344. o.setObtainWay(1);
  345. o.setAuthorizationNumber(p.getPatentNumber());
  346. o.setAuthorizationDate(p.getAuthorizedDate());
  347. o.setEvaluationCategory((3 == p.getPatentCatagory()) ? 0 : 1);
  348. o.setType(IntellectualPropertyType.PATENT.getCode());
  349. o.setPropertyRightUrl(p.getPatentCertificateUrl());
  350. orgIntellectualPropertyMapper.insert(o);
  351. }
  352. if (PatentInfoStatus.getStatus(p.getPatentState()) == PatentInfoStatus.LICENSE) {
  353. OrgIntellectualProperty o = orgIntellectualPropertyMapper.selectOrgIntellectualPropertyByPid(p.getId());
  354. if (null != o) {
  355. Integer i = 0;
  356. switch (p.getPatentCatagory()) {
  357. case 0:
  358. i = 0;
  359. break;
  360. case 1:
  361. i = 2;
  362. break;
  363. case 2:
  364. i = 3;
  365. break;
  366. case 3:
  367. i = 11;
  368. break;
  369. }
  370. o.setCatagory(i);
  371. orgIntellectualPropertyMapper.updateByPrimaryKeySelective(o);
  372. }
  373. }
  374. createNotice(p, log);
  375. }
  376. patentInfoMapper.updateByPrimaryKeySelective(p);
  377. }
  378. @Override
  379. public void updateNoticeOfCorrection(String pid, Integer patentState) {
  380. PatentInfo patentInfo = new PatentInfo();
  381. patentInfo.setId(pid);
  382. if (patentState == PatentInfoStatus.REVIEWNOTICE.getCode()) {
  383. patentInfo.setPatentState(PatentInfoStatus.REVIEWREPLY.getCode());
  384. } else if (patentState == PatentInfoStatus.CORRECTIONNOTICE.getCode()) {
  385. patentInfo.setPatentState(PatentInfoStatus.CORRECTIONREPLY.getCode());
  386. }
  387. patentInfoMapper.updateByPrimaryKeySelective(patentInfo);
  388. PatentLog patentLog = new PatentLog();
  389. PatentInfo p = patentInfoMapper.selectByPrimaryKey(pid);
  390. patentLog.setId(UUID.randomUUID().toString());
  391. patentLog.setPid(pid);
  392. patentLog.setState(p.getPatentState());
  393. patentLog.setOperator(TokenManager.getAdminId());
  394. patentLog.setPrincipal(p.getPrincipal());
  395. Calendar now = Calendar.getInstance();
  396. now.set(Calendar.MILLISECOND, 0);
  397. patentLog.setRecordTime(now.getTime());
  398. patentLogMapper.insert(patentLog);
  399. }
  400. @Override
  401. public PatentInfoDetailBo selectPatentInfoDetail(String id) {
  402. return patentInfoMapper.selectPatentInfoDetail(id);
  403. }
  404. @Override
  405. public int batchCirculation(String[] ids, String recordTimeFormattedDate, PatentLog pl) {
  406. Date recordTime = null;
  407. try {
  408. recordTime = DateUtils.parseDate(recordTimeFormattedDate, AFTConstants.YYYYMMDDHHMMSS);
  409. } catch (ParseException e) {
  410. }
  411. pl.setRecordTime(recordTime);
  412. List<PatentLog> p = new ArrayList<PatentLog>();
  413. List<PatentInfo> list = patentInfoMapper.selectByPrimaryKeys(Arrays.asList(ids));
  414. if (null != list && list.size() > 0) {
  415. for (PatentInfo patentInfo : list) {
  416. PatentLog patentLog = new PatentLog();
  417. BeanUtils.copyProperties(pl, patentLog);
  418. patentLog.setId(UUID.randomUUID().toString());
  419. patentLog.setPid(patentInfo.getId());
  420. patentLog.setOperator(TokenManager.getAdminId());
  421. p.add(patentLog);
  422. if (PatentInfoStatus.CIRCULATION.getCode() != patentLog.getState()) {
  423. patentInfo.setPatentState(patentLog.getState());
  424. patentInfoMapper.updateByPrimaryKeySelective(patentInfo);
  425. }
  426. createNotice(patentInfo, patentLog);
  427. }
  428. return patentLogMapper.batchInsert(p);
  429. }
  430. return 0;
  431. }
  432. // 专利年费到期
  433. @Override
  434. public List<PatentExpireBO> selectExpireRecord() {
  435. return patentInfoMapper.selectExpireRecord();
  436. }
  437. @Override
  438. public PatentInfo insertPatentInfo(PatentInfo patentInfo, String aid) {
  439. patentInfo.setPatentState(PatentInfoStatus.CREATE.getCode());
  440. patentInfo.setPrincipal(aid);
  441. PatentInfo p = disposePatentInfoSave(patentInfo);
  442. PatentLog log = new PatentLog();
  443. log.setId(UUID.randomUUID().toString());
  444. log.setPid(patentInfo.getId());
  445. log.setRecordTime(patentInfo.getRecordTime());
  446. log.setState(PatentInfoStatus.CREATE.getCode());
  447. log.setPrincipal(aid);
  448. log.setComment(patentInfo.getPatentDes());
  449. patentLogMapper.insert(log);
  450. createNotice(patentInfo, log);
  451. return p;
  452. }
  453. private PatentInfo disposePatentInfoSave(PatentInfo patentInfo) {
  454. patentInfo.setId(UUID.randomUUID().toString());
  455. patentInfo.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  456. patentInfo.setConfirmState(0);
  457. Calendar now = Calendar.getInstance();
  458. now.set(Calendar.MILLISECOND, 0);
  459. patentInfo.setCreateTime(now.getTime());
  460. patentInfoMapper.insert(patentInfo);
  461. PatentRegistration patentRegistration = new PatentRegistration();
  462. patentRegistration.setId(UUID.randomUUID().toString());
  463. patentRegistration.setPid(patentInfo.getId());
  464. patentRegistrationMapper.insert(patentRegistration);
  465. PatentCost patentCost = new PatentCost();
  466. patentCost.setId(UUID.randomUUID().toString());
  467. patentCost.setPid(patentInfo.getId());
  468. patentCost.setAnnualFeeState(0);
  469. patentCost.setPaymentState(0);
  470. patentCostMapper.insert(patentCost);
  471. return patentInfo;
  472. }
  473. @Override
  474. public List<PatentContractListBo> listContractPatentByContractId(String contractId) {
  475. return patentInfoMapper.listContractPatentByContractId(contractId);
  476. }
  477. @Override
  478. public void batchInsertContractRecord(Contract contract) {
  479. List<PatentInfo> pi = new ArrayList<>();
  480. List<PatentRegistration> pr = new ArrayList<>();
  481. List<PatentCost> pc = new ArrayList<>();
  482. List<PatentLog> pl = new ArrayList<>();
  483. contract.setPatentStatus(ContractBusinessStatus.CREATE.getCode());
  484. contractMapper.updateByPrimaryKeySelective(contract);
  485. for (int i = 0; i < contract.getPatentNum(); i++) {
  486. PatentInfo p = new PatentInfo();
  487. PatentLog l = new PatentLog();
  488. PatentRegistration r = new PatentRegistration();
  489. PatentCost c = new PatentCost();
  490. p.setId(UUID.randomUUID().toString());
  491. p.setUid(contract.getUid());
  492. p.setContractId(contract.getId());
  493. p.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  494. p.setFounder(TokenManager.getAdminId());
  495. p.setPrincipal(TokenManager.getAdminId());
  496. p.setPatentState(PatentInfoStatus.CREATE.getCode());
  497. Calendar now = Calendar.getInstance();
  498. now.set(Calendar.MILLISECOND, 0);
  499. p.setCreateTime(now.getTime());
  500. l.setId(UUID.randomUUID().toString());
  501. l.setPid(p.getId());
  502. l.setPrincipal(TokenManager.getAdminId());
  503. l.setOperator(TokenManager.getAdminId());
  504. l.setRecordTime(now.getTime());
  505. l.setState(PatentInfoStatus.CREATE.getCode());
  506. r.setId(UUID.randomUUID().toString());
  507. r.setPid(p.getId());
  508. c.setId(UUID.randomUUID().toString());
  509. c.setPid(p.getId());
  510. c.setAnnualFeeState(PatentAnnualFeeStatus.UNPAID.getCode());
  511. c.setPaymentState(PatentPaymentStatus.UNPAID.getCode());
  512. pi.add(p);
  513. pr.add(r);
  514. pc.add(c);
  515. pl.add(l);
  516. }
  517. patentInfoMapper.batchInsert(pi);
  518. patentRegistrationMapper.batchInsert(pr);
  519. patentCostMapper.batchInsert(pc);
  520. patentLogMapper.batchInsert(pl);
  521. }
  522. private void createNotice(PatentInfo p, PatentLog l) {
  523. PatentInfo info = patentInfoMapper.selectByPrimaryKey(p.getId());
  524. Notice n = new Notice();
  525. Calendar now = Calendar.getInstance();
  526. now.set(Calendar.MILLISECOND, 0);
  527. n.setId(UUID.randomUUID().toString());
  528. n.setCreateTime(now.getTime());
  529. n.setReaded(NoticeReadStatus.UNREAD.getCode());
  530. User u = userMapper.selectByPrimaryKey(p.getUid());
  531. if (null != u) {
  532. n.setPid(u.getAid());
  533. }
  534. n.setUid(p.getUid());
  535. n.setRid(p.getId());
  536. n.setAid(l.getPrincipal());
  537. n.setContent("编号" + info.getSerialNumber() + " " + PatentInfoStatus.getStatus(l.getState()).getDesc());
  538. n.setNoticeType(NoticeStatus.PATENTINFO.getCode());
  539. noticeMapper.insert(n);
  540. }
  541. }