PatentInfoServiceImpl.java 21 KB

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