PatentInfoServiceImpl.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. package com.goafanti.patent.service.impl;
  2. import java.text.ParseException;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import java.util.UUID;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import com.goafanti.common.dao.OrgIntellectualPropertyMapper;
  12. import com.goafanti.common.dao.PatentCostMapper;
  13. import com.goafanti.common.dao.PatentInfoMapper;
  14. import com.goafanti.common.dao.PatentLogMapper;
  15. import com.goafanti.common.dao.PatentRegistrationMapper;
  16. import com.goafanti.common.dao.UserMapper;
  17. import com.goafanti.common.enums.PatentInfoStatus;
  18. import com.goafanti.common.enums.TechProjectStatus;
  19. import com.goafanti.common.model.Admin;
  20. import com.goafanti.common.model.OrgIntellectualProperty;
  21. import com.goafanti.common.model.PatentCost;
  22. import com.goafanti.common.model.PatentInfo;
  23. import com.goafanti.common.model.PatentLog;
  24. import com.goafanti.common.model.PatentRegistration;
  25. import com.goafanti.common.utils.DateUtils;
  26. import com.goafanti.common.utils.StringUtils;
  27. import com.goafanti.core.mybatis.BaseMybatisDao;
  28. import com.goafanti.core.mybatis.page.Pagination;
  29. import com.goafanti.core.shiro.token.TokenManager;
  30. import com.goafanti.patent.bo.PatentInfoDetailBo;
  31. import com.goafanti.patent.bo.PatentManageListBo;
  32. import com.goafanti.patent.bo.PatentNoticeOfCorrectionBo;
  33. import com.goafanti.patent.bo.PatentPendingBo;
  34. import com.goafanti.patent.service.PatentInfoService;
  35. @Service
  36. public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> implements PatentInfoService {
  37. @Autowired
  38. PatentInfoMapper patentInfoMapper;
  39. @Autowired
  40. UserMapper userMapper;
  41. @Autowired
  42. PatentRegistrationMapper patentRegistrationMapper;
  43. @Autowired
  44. PatentCostMapper patentCostMapper;
  45. @Autowired
  46. PatentLogMapper patentLogMapper;
  47. @Autowired
  48. OrgIntellectualPropertyMapper orgIntellectualPropertyMapper;
  49. @Override
  50. public PatentInfo insert(PatentInfo patentInfo) {
  51. patentInfoMapper.insert(patentInfo);
  52. return patentInfo;
  53. }
  54. @Override
  55. public int updateByPrimaryKeySelective(PatentInfo patentInfo) {
  56. return patentInfoMapper.updateByPrimaryKeySelective(patentInfo);
  57. }
  58. @Override
  59. public PatentInfo selectByPrimaryKey(String id) {
  60. return patentInfoMapper.selectByPrimaryKey(id);
  61. }
  62. @SuppressWarnings("unchecked")
  63. @Override
  64. public Pagination<PatentInfo> getClientApplyList(String uid, String patentNumber, String patentName,
  65. Integer patentCatagory, Integer patentState, Integer pageNo, Integer pageSize) {
  66. Map<String, Object> params = new HashMap<>();
  67. if (uid == null) {
  68. return null;
  69. } else {
  70. params.put("uid", uid);
  71. }
  72. if (patentNumber != null && patentNumber != "") {
  73. params.put("patentNumber", patentNumber);
  74. }
  75. if (patentName != null && patentName != "") {
  76. params.put("patentName", patentName);
  77. }
  78. if (patentCatagory != null) {
  79. params.put("patentCatagory", patentCatagory);
  80. }
  81. if (patentState != null) {
  82. params.put("patentState", patentState);
  83. }
  84. if (pageNo == null || pageNo < 0) {
  85. pageNo = 1;
  86. }
  87. if (pageSize == null || pageSize < 0) {
  88. pageSize = 10;
  89. }
  90. return (Pagination<PatentInfo>) findPage("findClientApplyListByPage", "findClentApplyCount", params, pageNo,
  91. pageSize);
  92. }
  93. @SuppressWarnings("unchecked")
  94. @Override
  95. public Pagination<PatentManageListBo> getManagePatentList(Integer serialNumber, String patentNumber, String office,
  96. String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState,
  97. String[] cDate, String[] pDate, String author, Integer pageNo, Integer pageSize) {
  98. Map<String, Object> params = new HashMap<>();
  99. Date cStart = null;
  100. Date cEnd = null;
  101. Date pStart = null;
  102. Date pEnd = null;
  103. if (cDate != null && cDate.length > 0) {
  104. try {
  105. cStart = StringUtils.isBlank(cDate[0]) ? null : DateUtils.parseDate(cDate[0], "yyyy-MM-dd");
  106. cEnd = StringUtils.isBlank(cDate[1]) ? null
  107. : DateUtils.addDays(DateUtils.parseDate(cDate[1], "yyyy-MM-dd"), 1);
  108. } catch (ParseException e) {
  109. }
  110. }
  111. if (pDate != null && pDate.length > 0) {
  112. try {
  113. pStart = StringUtils.isBlank(pDate[0]) ? null : DateUtils.parseDate(pDate[0], "yyyy-MM-dd");
  114. pEnd = StringUtils.isBlank(pDate[1]) ? null
  115. : DateUtils.addDays(DateUtils.parseDate(pDate[1], "yyyy-MM-dd"), 1);
  116. } catch (ParseException e) {
  117. }
  118. }
  119. if (cStart != null) {
  120. params.put("cStart", cStart);
  121. }
  122. if (cEnd != null) {
  123. params.put("cEnd", cEnd);
  124. }
  125. if (pStart != null) {
  126. params.put("pStart", pStart);
  127. }
  128. if (pEnd != null) {
  129. params.put("pEnd", pEnd);
  130. }
  131. if (serialNumber != null) {
  132. params.put("serialNumber", serialNumber);
  133. }
  134. if (patentNumber != null && patentNumber != "") {
  135. params.put("patentNumber", patentNumber);
  136. }
  137. if (office != null && office != "") {
  138. params.put("office", office);
  139. }
  140. if (locationProvince != null && locationProvince != "") {
  141. params.put("locationProvince", locationProvince);
  142. }
  143. if (unitName != null && unitName != "") {
  144. params.put("unitName", unitName);
  145. }
  146. if (patentCatagory != null) {
  147. params.put("patentCatagory", patentCatagory);
  148. }
  149. if (patentName != null && patentName != "") {
  150. params.put("patentName", patentName);
  151. }
  152. if (patentState != null) {
  153. params.put("patentState", patentState);
  154. }
  155. if (author != null && author != "") {
  156. params.put("author", author);
  157. }
  158. if (pageNo == null || pageNo < 0) {
  159. pageNo = 1;
  160. }
  161. if (pageSize == null || pageSize < 0) {
  162. pageSize = 10;
  163. }
  164. return (Pagination<PatentManageListBo>) findPage("findManagePatentListByPage", "findManagePatentCount", params,
  165. pageNo, pageSize);
  166. }
  167. @SuppressWarnings("unchecked")
  168. @Override
  169. public Pagination<PatentPendingBo> getManagePendingPaymentList(String locationProvince, Integer pageNo,
  170. Integer pageSize) {
  171. Map<String, Object> params = new HashMap<>();
  172. if (locationProvince != null && locationProvince != "") {
  173. params.put("locationProvince", locationProvince);
  174. }
  175. if (pageNo == null || pageNo < 0) {
  176. pageNo = 1;
  177. }
  178. if (pageSize == null || pageSize < 0) {
  179. pageSize = 10;
  180. }
  181. return (Pagination<PatentPendingBo>) findPage("findManagePendingPaymentListByPage",
  182. "findManagePendingPaymentCount", params, pageNo, pageSize);
  183. }
  184. @SuppressWarnings("unchecked")
  185. @Override
  186. public Pagination<PatentNoticeOfCorrectionBo> getNoticeOfCorrectionList(Date authorizedDate, Integer serialNumber,
  187. String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory,
  188. String patentName, Integer patentState, String author, Integer pageNo, Integer pageSize) {
  189. Map<String, Object> params = new HashMap<>();
  190. if (authorizedDate != null) {
  191. params.put("authorizedDate", authorizedDate);
  192. }
  193. if (serialNumber != null) {
  194. params.put("serialNumber", serialNumber);
  195. }
  196. if (patentNumber != null && patentNumber != "") {
  197. params.put(patentNumber, patentNumber);
  198. }
  199. if (office != null && office != "") {
  200. params.put("office", office);
  201. }
  202. if (locationProvince != null && locationProvince != "") {
  203. params.put("locationProvince", locationProvince);
  204. }
  205. if (unitName != null && unitName != "") {
  206. params.put("unitName", unitName);
  207. }
  208. if (patentCatagory != null) {
  209. params.put("patentCatagory", patentCatagory);
  210. }
  211. if (patentName != null && patentName != "") {
  212. params.put("patentName", patentName);
  213. }
  214. if (patentState != null) {
  215. params.put("patentState", patentState);
  216. }
  217. if (author != null && author != "") {
  218. params.put("author", patentState);
  219. }
  220. if (pageNo == null || pageNo < 0) {
  221. pageNo = 1;
  222. }
  223. if (pageSize == null || pageSize < 0) {
  224. pageSize = 10;
  225. }
  226. return (Pagination<PatentNoticeOfCorrectionBo>) findPage("findNoticeOfCorrectionListByPage",
  227. "findNoticeOfCorrectionCount", params, pageNo, pageSize);
  228. }
  229. @Override
  230. public int batchDeleteByPrimaryKey(List<String> id) {
  231. return patentInfoMapper.batchDeleteByPrimaryKey(id);
  232. }
  233. @Override
  234. public PatentInfo savePatentInfo(PatentInfo patentInfo, String aid) {
  235. patentInfo.setId(UUID.randomUUID().toString());
  236. Calendar now = Calendar.getInstance();
  237. now.set(Calendar.MILLISECOND, 0);
  238. patentInfo.setRecordTime(now.getTime());
  239. patentInfo.setDeletedSign(0);
  240. patentInfo.setConfirmState(0);
  241. patentInfo.setPatentState(PatentInfoStatus.CREATE.getCode());
  242. patentInfo.setPrincipal(aid);
  243. patentInfoMapper.insert(patentInfo);
  244. PatentRegistration patentRegistration = new PatentRegistration();
  245. patentRegistration.setId(UUID.randomUUID().toString());
  246. patentRegistration.setPid(patentInfo.getId());
  247. patentRegistrationMapper.insert(patentRegistration);
  248. PatentCost patentCost = new PatentCost();
  249. patentCost.setId(UUID.randomUUID().toString());
  250. patentCost.setPid(patentInfo.getId());
  251. patentCost.setAnnualFeeState(0);
  252. patentCost.setPaymentState(0);
  253. patentCostMapper.insert(patentCost);
  254. PatentLog log = new PatentLog();
  255. log.setId(UUID.randomUUID().toString());
  256. log.setPid(patentInfo.getId());
  257. log.setRecordTime(patentInfo.getCreateTime());
  258. log.setState(PatentInfoStatus.CREATE.getCode());
  259. log.setPrincipal(aid);
  260. if (TokenManager.getToken() instanceof Admin) {
  261. log.setOperator(TokenManager.getAdminId());
  262. }
  263. patentLogMapper.insert(log);
  264. return patentInfo;
  265. }
  266. @Override
  267. public void updatePatentInfo(PatentInfo p, PatentLog log, Date recordTime) {
  268. if (null != log.getState() && recordTime != null && null != log.getPrincipal()) {
  269. log.setId(UUID.randomUUID().toString());
  270. log.setPid(p.getId());
  271. log.setRecordTime(recordTime);
  272. if (TokenManager.getToken() instanceof Admin) {
  273. log.setOperator(TokenManager.getAdminId());
  274. }
  275. if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.DELIVERD) {
  276. p.setCreateTime(recordTime);
  277. } else if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.ACCEPT) {
  278. p.setPatentApplicationDate(recordTime);
  279. } else if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.AUTHORIZE) {
  280. p.setAuthorizedDate(recordTime);
  281. }
  282. if (TechProjectStatus.getStatus(log.getState()) != TechProjectStatus.CIRCULATION) {
  283. p.setPatentState(log.getState());
  284. }
  285. p.setPrincipal(log.getPrincipal());
  286. patentLogMapper.insert(log);
  287. }
  288. patentInfoMapper.updateByPrimaryKeySelective(p);
  289. if (PatentInfoStatus.getStatus(p.getPatentState()) == PatentInfoStatus.AUTHORIZE) {
  290. OrgIntellectualProperty o = new OrgIntellectualProperty();
  291. o.setId(UUID.randomUUID().toString());
  292. o.setUid(p.getUid());
  293. o.setPid(p.getId());
  294. o.setDeletedSign(0);
  295. o.setIntellectualPropertyNumber(p.getPatentNumber());
  296. o.setIntellectualPropertyName(p.getPatentName());
  297. o.setCatagory(1);
  298. o.setObtainWay(1);
  299. o.setAuthorizationNumber(p.getPatentNumber());
  300. o.setAuthorizationDate(p.getAuthorizedDate());
  301. o.setEvaluationCategory((3 == p.getPatentCatagory()) ? 0 : 1);
  302. orgIntellectualPropertyMapper.insert(o);
  303. }
  304. if (PatentInfoStatus.getStatus(p.getPatentState()) == PatentInfoStatus.LICENSE) {
  305. OrgIntellectualProperty o = orgIntellectualPropertyMapper.selectOrgIntellectualPropertyByPid(p.getId());
  306. if (null != o) {
  307. Integer i = 0;
  308. switch (p.getPatentCatagory()) {
  309. case 0:
  310. i = 0;
  311. break;
  312. case 1:
  313. i = 2;
  314. break;
  315. case 2:
  316. i = 3;
  317. break;
  318. case 3:
  319. i = 11;
  320. break;
  321. }
  322. o.setCatagory(i);
  323. orgIntellectualPropertyMapper.updateByPrimaryKeySelective(o);
  324. }
  325. }
  326. }
  327. @Override
  328. public void updateNoticeOfCorrection(String pid, Integer patentState) {
  329. PatentInfo patentInfo = new PatentInfo();
  330. patentInfo.setId(pid);
  331. if (patentState == PatentInfoStatus.REVIEWNOTICE.getCode()) {
  332. patentInfo.setPatentState(PatentInfoStatus.REVIEWREPLY.getCode());
  333. } else if (patentState == PatentInfoStatus.CORRECTIONNOTICE.getCode()) {
  334. patentInfo.setPatentState(PatentInfoStatus.CORRECTIONREPLY.getCode());
  335. }
  336. patentInfoMapper.updateByPrimaryKeySelective(patentInfo);
  337. PatentLog patentLog = new PatentLog();
  338. PatentInfo p = patentInfoMapper.selectByPrimaryKey(pid);
  339. patentLog.setId(UUID.randomUUID().toString());
  340. patentLog.setPid(pid);
  341. patentLog.setState(p.getPatentState());
  342. patentLog.setOperator(TokenManager.getAdminId());
  343. patentLog.setPrincipal(p.getPrincipal());
  344. Calendar now = Calendar.getInstance();
  345. now.set(Calendar.MILLISECOND, 0);
  346. patentLog.setRecordTime(now.getTime());
  347. patentLogMapper.insert(patentLog);
  348. }
  349. @Override
  350. public PatentInfoDetailBo selectPatentInfoDetail(String id) {
  351. return patentInfoMapper.selectPatentInfoDetail(id);
  352. }
  353. }