CustomerServiceImpl.java 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. package com.uas.service.Impl;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.uas.core.support.GetProperties;
  6. import com.uas.dao.*;
  7. import com.uas.entity.*;
  8. import com.uas.service.CustomerService;
  9. import com.uas.utils.HttpUtil;
  10. import org.slf4j.Logger;
  11. import org.slf4j.LoggerFactory;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.scheduling.annotation.Async;
  14. import org.springframework.stereotype.Service;
  15. import org.springframework.transaction.annotation.Transactional;
  16. import java.util.*;
  17. /**
  18. * @author koul
  19. * @email koul@usoftchina.com
  20. * @date 2020-10-27 9:03
  21. */
  22. @Service
  23. public class CustomerServiceImpl implements CustomerService {
  24. private static Map<String,String> httpConfig = GetProperties.getAllProperty();
  25. private static String url = httpConfig.get("URL");
  26. private static String apikey = httpConfig.get("APIKEY");
  27. private static String company = httpConfig.get("company");
  28. private final Logger logger = LoggerFactory.getLogger(getClass());
  29. private final static int size=50;
  30. private final static HashMap hender = new HashMap() {{
  31. put(httpConfig.get("henderKey"), httpConfig.get("henderValue"));
  32. }};
  33. private final static Map<String, String> params = new HashMap<String, String>(){{
  34. put("apikey",apikey);
  35. put("from",Integer.toString(0));
  36. put("size",Integer.toString(size));
  37. }};
  38. @Autowired
  39. private BaseDao baseDao;
  40. @Autowired
  41. private BusinessDao businessDao;
  42. @Autowired
  43. private BusinessDetailDao businessDetailDao;
  44. @Autowired
  45. private BusinessChangeDao businessChangeDao;
  46. @Autowired
  47. private InvestorDao investorDao;
  48. @Autowired
  49. private InvestorRJDetailDao investorRJDetailDao;
  50. @Autowired
  51. private InvestorSJDetailDao investorSJDetailDao;
  52. @Autowired
  53. private MemberDao memberDao;
  54. @Autowired
  55. private KtggDao ktggDao;
  56. @Autowired
  57. private KtggDetailDao ktggDetailDao;
  58. @Autowired
  59. private CpwsDao cpwsDao;
  60. @Autowired
  61. private CpwsDetailDao cpwsDetailDao;
  62. @Autowired
  63. private ExecutedPersonDao executedPersonDao;
  64. @Autowired
  65. private SxbzxrDao sxbzxrDao;
  66. @Autowired
  67. private JyycDao jyycDao;
  68. @Autowired
  69. private SswfDao sswfDao;
  70. @Autowired
  71. private QsjlDao qsjlDao;
  72. @Autowired
  73. private DcdyDao dcdyDao;
  74. @Autowired
  75. private DcdyDetailDao dcdyDetailDao;
  76. @Autowired
  77. private GqczDao gqczDao;
  78. @Autowired
  79. private SfxzDao sfxzDao;
  80. @Autowired
  81. private SsggDao ssggDao;
  82. @Autowired
  83. private DanBaoDao danBaoDao;
  84. /**
  85. * 获取所有分组
  86. * @return
  87. */
  88. private List<Group> getGroupAll() throws Exception{
  89. Map<String, String> param = new HashMap<>();
  90. param.put("apikey",apikey);
  91. String group = httpResponse(url + httpConfig.get("group"), hender, param);
  92. if (group != null && !"[]".equals(group)) {
  93. return JSON.parseArray(group, Group.class);
  94. }
  95. return null;
  96. }
  97. /**
  98. * 获取所有客户统一信用编码
  99. * @return
  100. */
  101. @Override
  102. public List<String> getFollowingByGroup() throws Exception {
  103. Map<String, String> param = new HashMap<>();
  104. param.put("apikey",apikey);
  105. param.put("from",Integer.toString(0));
  106. param.put("size",Integer.toString(1000));
  107. List<Group> groupAll = getGroupAll();
  108. if (groupAll!=null){
  109. List<String> list = new ArrayList<>();
  110. for (Group group:groupAll) {
  111. param.put("group_id",Long.toString(group.getId()));
  112. JSONArray following = httpResponseBySize(url + httpConfig.get("following"), apikey, 1000, hender, param);
  113. if (following!=null){
  114. List<String> strings = JSON.parseArray(following.toString(), String.class);
  115. list.addAll(strings);
  116. }
  117. }
  118. return list;
  119. }
  120. return null;
  121. }
  122. /**
  123. * 保存工商资料
  124. * @param company_id
  125. */
  126. @Async("taskExecutor")
  127. @Transactional(rollbackFor=Exception.class)
  128. @Override
  129. public void saveBusiness(String company_id) throws Exception{
  130. deleteByCompanyId(company_id);
  131. Map<String, String> param = new HashMap<>();
  132. param.put("apikey", apikey);
  133. String s = httpResponse(url + company + "/" + company_id, hender, param);
  134. if (s != null) {
  135. Business business = JSON.parseObject(s, Business.class);
  136. business.setFb_gzstatus("正在关注");
  137. business.setFb_gxdate(new Date());
  138. business.setFb_evaluation(stringArraytoString(business.getFb_evaluation()));
  139. business.setFb_oldname(stringArraytoString(business.getFb_oldname()));
  140. Business save = businessDao.save(business);
  141. Long fb_id = save.getFb_id();
  142. JSONObject jsonObject = JSONObject.parseObject(s);
  143. Object objzcd = jsonObject.get("注册地");
  144. if (objzcd != null) {
  145. BusinessDetail zcd = JSON.parseObject(objzcd.toString(), BusinessDetail.class);
  146. zcd.setFbd_fbid(fb_id);
  147. zcd.setFbd_type("注册地");
  148. zcd.setFbd_detno(1);
  149. businessDetailDao.save(zcd);
  150. }
  151. Object objjyd = jsonObject.get("经营地");
  152. if (objjyd != null) {
  153. BusinessDetail zcd = JSON.parseObject(objjyd.toString(), BusinessDetail.class);
  154. zcd.setFbd_fbid(fb_id);
  155. zcd.setFbd_type("经营地");
  156. zcd.setFbd_detno(1);
  157. businessDetailDao.save(zcd);
  158. }
  159. Object objgp = jsonObject.get("股票");
  160. if (objgp != null && !"[]".equals(objgp.toString())) {
  161. List<BusinessDetail> gps = JSON.parseArray(objgp.toString(),
  162. BusinessDetail.class);
  163. int detno = 1;
  164. for (BusinessDetail gp : gps) {
  165. gp.setFbd_fbid(fb_id);
  166. gp.setFbd_type("股票");
  167. gp.setFbd_detno(detno);
  168. detno = detno + 1;
  169. }
  170. businessDetailDao.save(gps);
  171. }
  172. saveBusinessChange(company_id,fb_id);
  173. saveInvestor(company_id,fb_id);
  174. saveMember(company_id,fb_id);
  175. saveKtgg(company_id,fb_id);
  176. saveCpws(company_id,fb_id);
  177. saveExecutedPerson(company_id,fb_id);
  178. saveSxbzxr(company_id,fb_id);
  179. saveJyyc(company_id,fb_id);
  180. saveSswf(company_id,fb_id);
  181. saveQsjl(company_id,fb_id);
  182. saveDcdy(company_id,fb_id);
  183. saveGqcz(company_id,fb_id);
  184. saveSfxz(company_id,fb_id);
  185. saveSsgg(company_id,fb_id);
  186. saveDanbao(company_id,fb_id);
  187. }
  188. }
  189. /**
  190. * 保存工商变更
  191. * @param company_id
  192. */
  193. /*@Async("taskExecutor")*/
  194. private void saveBusinessChange(String company_id,Long id) throws Exception{
  195. JSONArray gsbg = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("gsbg"),
  196. apikey, size, hender, params);
  197. if(gsbg!=null) {
  198. List<BusinessChange> businessChanges = JSON.parseArray(gsbg.toString(), BusinessChange.class);
  199. if (businessChanges != null && businessChanges.size() > 0) {
  200. int detno = 1;
  201. for (BusinessChange fbc : businessChanges) {
  202. fbc.setFbc_detno(detno);
  203. fbc.setFbc_tyshxycode(company_id);
  204. fbc.setFbc_fbid(id);
  205. detno = detno + 1;
  206. }
  207. businessChangeDao.save(businessChanges);
  208. }
  209. }
  210. }
  211. /**
  212. * 保存工商登记股东信息
  213. * @param company_id
  214. */
  215. private void saveInvestor(String company_id,Long id) throws Exception{
  216. JSONArray objects = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("investor")
  217. , apikey, size, hender, params);
  218. if (objects!=null) {
  219. int det=1;
  220. for (Object obj:objects) {
  221. JSONObject jsonObject = JSON.parseObject(obj.toString());
  222. Investor investor = JSON.parseObject(obj.toString(), Investor.class);
  223. investor.setFi_detno(det);
  224. investor.setFi_tyshxycode(company_id);
  225. investor.setFi_fbid(id);
  226. Investor save = investorDao.save(investor);
  227. det=det+1;
  228. Long fi_id = save.getFi_id();
  229. Object sjmx = jsonObject.get("实缴明细");
  230. if (sjmx!=null&&!"[]".equals(sjmx.toString())) {
  231. List<InvestorSJDetail> sjDetails = JSON.parseArray(sjmx.toString(),
  232. InvestorSJDetail.class);
  233. int detno=1;
  234. for (InvestorSJDetail investorSJDetail:sjDetails) {
  235. investorSJDetail.setFid_detno(detno);
  236. investorSJDetail.setFid_fiid(fi_id);
  237. investorSJDetail.setFid_type("实缴明细");
  238. detno=detno+1;
  239. }
  240. investorSJDetailDao.save(sjDetails);
  241. }
  242. Object rjmx = jsonObject.get("认缴明细");
  243. if (rjmx!=null&&!"[]".equals(rjmx.toString())) {
  244. List<InvestorRJDetail> rjDetails = JSON.parseArray(rjmx.toString(),InvestorRJDetail.class);
  245. int no=1;
  246. for (InvestorRJDetail investorRJDetail:rjDetails) {
  247. investorRJDetail.setFid_detno(no);
  248. investorRJDetail.setFid_fiid(fi_id);
  249. investorRJDetail.setFid_type("认缴明细");
  250. no=no+1;
  251. }
  252. investorRJDetailDao.save(rjDetails);
  253. }
  254. }
  255. }
  256. }
  257. /**
  258. * 保存主要成员
  259. * @param company_id
  260. */
  261. private void saveMember(String company_id,Long id) throws Exception{
  262. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("member")
  263. , apikey, size, hender, params);
  264. if (jsonArray!=null) {
  265. List<Member> members = JSON.parseArray(jsonArray.toString(), Member.class);
  266. for (Member member:members) {
  267. member.setFm_tyshxycode(company_id);
  268. member.setFm_fbid(id);
  269. }
  270. memberDao.save(members);
  271. }
  272. }
  273. /**
  274. * 保存开庭公告
  275. * @param company_id
  276. */
  277. private void saveKtgg(String company_id,Long id) throws Exception{
  278. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("ktgg")
  279. , apikey, size, hender, params);
  280. if (jsonArray!=null) {
  281. int detno=1;
  282. for (Object obj:jsonArray) {
  283. JSONObject jsonObject = JSON.parseObject(obj.toString());
  284. Ktgg ktgg = JSON.parseObject(obj.toString(), Ktgg.class);
  285. ktgg.setFk_tyshxycode(company_id);
  286. ktgg.setFk_fbid(id);
  287. ktgg.setFk_entities(stringArraytoString(ktgg.getFk_entities()));
  288. ktgg.setFk_otherroles(stringArraytoString(ktgg.getFk_otherroles()));
  289. ktgg.setFk_plaintif(stringArraytoString(ktgg.getFk_plaintif()));
  290. ktgg.setFk_party(stringArraytoString(ktgg.getFk_party()));
  291. ktgg.setFk_defendant(stringArraytoString(ktgg.getFk_defendant()));
  292. ktgg.setFk_detno(detno);
  293. Ktgg save = ktggDao.save(ktgg);
  294. detno=detno+1;
  295. Long fk_id = save.getFk_id();
  296. Object dsrDetail = jsonObject.get("当事人详情");
  297. if (dsrDetail != null && !"[]".equals(dsrDetail.toString())) {
  298. List<KtggDetail> ktggDetails = JSON.parseArray(dsrDetail.toString(), KtggDetail.class);
  299. int det=1;
  300. for (KtggDetail ktggdetail:ktggDetails) {
  301. ktggdetail.setFkd_fkid(fk_id);
  302. ktggdetail.setFkd_detno(det);
  303. ktggdetail.setFkd_type("当事人详情");
  304. ktggdetail.setFkd_otherroles(stringArraytoString(ktggdetail.getFkd_otherroles()));
  305. det=det+1;
  306. }
  307. ktggDetailDao.save(ktggDetails);
  308. }
  309. Object ssdq = jsonObject.get("所属地区");
  310. if (ssdq!=null){
  311. KtggDetail ktggDetail = JSON.parseObject(ssdq.toString(), KtggDetail.class);
  312. ktggDetail.setFkd_fkid(fk_id);
  313. ktggDetail.setFkd_type("所属地区");
  314. ktggDetailDao.save(ktggDetail);
  315. }
  316. }
  317. }
  318. }
  319. /**
  320. * 保存裁判文书
  321. * @param company_id
  322. */
  323. private void saveCpws(String company_id,Long id) throws Exception{
  324. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("cpws"), apikey, size, hender, params);
  325. if (jsonArray!=null) {
  326. int detno=1;
  327. for (Object obj:jsonArray) {
  328. JSONObject jsonObject = JSON.parseObject(obj.toString());
  329. Cpws cpws = JSON.parseObject(obj.toString(), Cpws.class);
  330. cpws.setFc_tyshxycode(company_id);
  331. cpws.setFc_detno(detno);
  332. cpws.setFc_fbid(id);
  333. Cpws save = cpwsDao.save(cpws);
  334. detno=detno+1;
  335. Long fc_id = save.getFc_id();
  336. Object ssdq = jsonObject.get("所属地区");
  337. if (ssdq!=null){
  338. CpwsDetail cpwsDetail = JSON.parseObject(ssdq.toString(), CpwsDetail.class);
  339. cpwsDetail.setFcd_fcid(fc_id);
  340. cpwsDetail.setFcd_type("所属地区");
  341. cpwsDetail.setFcd_detno(1);
  342. cpwsDetailDao.save(cpwsDetail);
  343. }
  344. Object dls = jsonObject.get("段落");
  345. if (dls != null && !"[]".equals(dls.toString())) {
  346. List<CpwsDetail> cpwsDetails = JSON.parseArray(dls.toString(), CpwsDetail.class);
  347. int det=1;
  348. for (CpwsDetail cpwsDetail:cpwsDetails) {
  349. cpwsDetail.setFcd_fcid(fc_id);
  350. cpwsDetail.setFcd_type("段落");
  351. cpwsDetail.setFcd_detno(det);
  352. det=det+1;
  353. }
  354. cpwsDetailDao.save(cpwsDetails);
  355. }
  356. Object dsrs = jsonObject.get("当事人");
  357. if (dsrs != null && !"[]".equals(dsrs.toString())) {
  358. List<CpwsDetail> cpwsDetails = JSON.parseArray(dsrs.toString(),CpwsDetail.class);
  359. int det=1;
  360. for (CpwsDetail cpwsDetail:cpwsDetails) {
  361. cpwsDetail.setFcd_fcid(fc_id);
  362. cpwsDetail.setFcd_type("当事人");
  363. cpwsDetail.setFcd_detno(det);
  364. cpwsDetail.setFcd_otherroles(stringArraytoString(cpwsDetail.getFcd_otherroles()));
  365. cpwsDetail.setFcd_oldname(stringArraytoString(cpwsDetail.getFcd_oldname()));
  366. cpwsDetail.setFcd_role(stringArraytoString(cpwsDetail.getFcd_role()));
  367. cpwsDetail.setFcd_legalrepresentative(stringArraytoString(cpwsDetail.getFcd_legalrepresentative()));
  368. det=det+1;
  369. }
  370. cpwsDetailDao.save(cpwsDetails);
  371. }
  372. Object cpjes = jsonObject.get("判决金额");
  373. if (cpjes != null && !"[]".equals(cpjes.toString())) {
  374. List<CpwsDetail> cpwsDetails = JSON.parseArray(cpjes.toString(),CpwsDetail.class);
  375. int det=1;
  376. for (CpwsDetail cpwsDetail:cpwsDetails) {
  377. cpwsDetail.setFcd_type("判决金额");
  378. cpwsDetail.setFcd_detno(det);
  379. cpwsDetail.setFcd_payer(stringArraytoString(cpwsDetail.getFcd_payer()));
  380. cpwsDetail.setFcd_fcid(fc_id);
  381. det=det+1;
  382. }
  383. cpwsDetailDao.save(cpwsDetails);
  384. }
  385. }
  386. }
  387. }
  388. /**
  389. * 保存被执行人
  390. * @param company_id
  391. */
  392. private void saveExecutedPerson(String company_id,Long id) throws Exception{
  393. JSONArray zhixing = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("zhixing"), apikey, size, hender, params);
  394. if (zhixing!=null) {
  395. List<ExecutedPerson> executedPersonList = JSON.parseArray(zhixing.toString(), ExecutedPerson.class);
  396. for (ExecutedPerson executedPerson:executedPersonList) {
  397. executedPerson.setFep_entities(stringArraytoString(executedPerson.getFep_entities()));
  398. executedPerson.setFep_tyshxycode(company_id);
  399. executedPerson.setFep_fbid(id);
  400. }
  401. executedPersonDao.save(executedPersonList);
  402. }
  403. }
  404. /**
  405. * 保存失信被执行人
  406. * @param company_id
  407. */
  408. private void saveSxbzxr(String company_id,Long id) throws Exception{
  409. JSONArray shixin = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("shixin"), apikey, size, hender, params);
  410. if (shixin!=null) {
  411. List<Sxbzxr> sxbzxrs = JSON.parseArray(shixin.toString(), Sxbzxr.class);
  412. for (Sxbzxr sxbzxr:sxbzxrs) {
  413. sxbzxr.setFsx_tyshxycode(company_id);
  414. sxbzxr.setFsx_fbid(id);
  415. }
  416. sxbzxrDao.save(sxbzxrs);
  417. }
  418. }
  419. /**
  420. * 保存经营异常
  421. * @param company_id
  422. */
  423. private void saveJyyc(String company_id,Long id) throws Exception{
  424. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("jyyc"),
  425. apikey, size, hender, params);
  426. if (jsonArray!=null) {
  427. List<Jyyc> jyycs = JSON.parseArray(jsonArray.toString(), Jyyc.class);
  428. for (Jyyc jyyc:jyycs) {
  429. jyyc.setFj_tyshxycode(company_id);
  430. jyyc.setFj_fbid(id);
  431. }
  432. jyycDao.save(jyycs);
  433. }
  434. }
  435. /**
  436. * 保存重大税收违法
  437. * @param company_id
  438. */
  439. private void saveSswf(String company_id,Long id) throws Exception{
  440. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("sswf"),
  441. apikey, size, hender, params);
  442. if (jsonArray!=null) {
  443. List<Sswf> sswfs = JSON.parseArray(jsonArray.toString(), Sswf.class);
  444. for (Sswf sswf:sswfs) {
  445. sswf.setFs_taxpayercode(company_id);
  446. sswf.setFs_fbid(id);
  447. }
  448. sswfDao.save(sswfs);
  449. }
  450. }
  451. /**
  452. * 保存催缴/欠税
  453. * @param company_id
  454. */
  455. private void saveQsjl(String company_id,Long id) throws Exception{
  456. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("qsjl"),
  457. apikey, size, hender, params);
  458. if (jsonArray!=null) {
  459. List<Qsjl> qsjls = JSON.parseArray(jsonArray.toString(), Qsjl.class);
  460. for (Qsjl qsjl:qsjls) {
  461. qsjl.setFq_tyshxycode(company_id);
  462. qsjl.setFq_fbid(id);
  463. }
  464. qsjlDao.save(qsjls);
  465. }
  466. }
  467. /**
  468. * 保存动产抵押
  469. * @param company_id
  470. */
  471. private void saveDcdy(String company_id,Long id) throws Exception{
  472. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("dcdy"),
  473. apikey, size, hender, params);
  474. if (jsonArray!=null) {
  475. for (Object obj:jsonArray) {
  476. JSONObject jsonObject = JSON.parseObject(obj.toString());
  477. Dcdy dcdy = JSON.parseObject(obj.toString(), Dcdy.class);
  478. dcdy.setFd_tyshxycode(company_id);
  479. dcdy.setFd_fbid(id);
  480. Dcdy save = dcdyDao.save(dcdy);
  481. Long fd_id = save.getFd_id();
  482. Object dsrs = jsonObject.get("当事人");
  483. if (dsrs != null && !"[]".equals(dsrs.toString())) {
  484. List<DcdyDetail> dcdyDetails = JSON.parseArray(dsrs.toString(), DcdyDetail.class);
  485. for (DcdyDetail dsr:dcdyDetails) {
  486. dsr.setFdd_fdid(fd_id);
  487. dsr.setFdd_type("当事人");
  488. }
  489. dcdyDetailDao.save(dcdyDetails);
  490. }
  491. Object dywgks = jsonObject.get("抵押物概况");
  492. if (dywgks != null && !"[]".equals(dywgks.toString())) {
  493. List<DcdyDetail> dcdyDetails = JSON.parseArray(dywgks.toString(), DcdyDetail.class);
  494. for (DcdyDetail dywgk:dcdyDetails) {
  495. dywgk.setFdd_fdid(fd_id);
  496. dywgk.setFdd_type("抵押物概况");
  497. }
  498. dcdyDetailDao.save(dcdyDetails);
  499. }
  500. }
  501. }
  502. }
  503. /**
  504. * 保存股权出质
  505. * @param company_id
  506. */
  507. private void saveGqcz(String company_id,Long id) throws Exception{
  508. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("gqcz"),
  509. apikey, size, hender, params);
  510. if (jsonArray!=null) {
  511. List<Gqcz> gqczs = JSON.parseArray(jsonArray.toString(), Gqcz.class);
  512. for (Gqcz gqcz:gqczs) {
  513. gqcz.setFg_tyshxycode(company_id);
  514. gqcz.setFg_fbid(id);
  515. }
  516. gqczDao.save(gqczs);
  517. }
  518. }
  519. /**
  520. * 保存司法协助
  521. * @param company_id
  522. */
  523. private void saveSfxz(String company_id,Long id) throws Exception{
  524. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("sfxz"),
  525. apikey, size, hender, params);
  526. if (jsonArray!=null) {
  527. List<Sfxz> sfxzs = JSON.parseArray(jsonArray.toString(), Sfxz.class);
  528. for (Sfxz sfxz:sfxzs) {
  529. sfxz.setFf_tyshxycode(company_id);
  530. sfxz.setFf_fbid(id);
  531. }
  532. sfxzDao.save(sfxzs);
  533. }
  534. }
  535. /**
  536. * 保存涉诉公告
  537. * @param company_id
  538. */
  539. private void saveSsgg(String company_id,Long id) throws Exception{
  540. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("ssgg"),
  541. apikey, size, hender, params);
  542. if (jsonArray!=null) {
  543. List<Ssgg> ssggs = JSON.parseArray(jsonArray.toString(), Ssgg.class);
  544. for (Ssgg ssgg:ssggs) {
  545. ssgg.setFss_party(stringArraytoString(ssgg.getFss_party()));
  546. ssgg.setFss_tyshxycode(company_id);
  547. ssgg.setFss_entities(stringArraytoString(ssgg.getFss_entities()));
  548. ssgg.setFss_fbid(id);
  549. }
  550. ssggDao.save(ssggs);
  551. }
  552. }
  553. /**
  554. * 保存担保
  555. * @param company_id
  556. */
  557. private void saveDanbao(String company_id,Long id) throws Exception{
  558. JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("danbao"),
  559. apikey, size, hender, params);
  560. if (jsonArray!=null) {
  561. List<DanBao> danBaos = JSON.parseArray(jsonArray.toString(), DanBao.class);
  562. int detno=1;
  563. for (DanBao danBao:danBaos) {
  564. danBao.setFd_party(stringArraytoString(danBao.getFd_party()));
  565. danBao.setFd_guarantor(stringArraytoString(danBao.getFd_guarantor()));
  566. danBao.setFd_dbmethod(stringArraytoString(danBao.getFd_dbmethod()));
  567. danBao.setFd_bparty(stringArraytoString(danBao.getFd_bparty()));
  568. danBao.setFd_tyshxycode(company_id);
  569. danBao.setFd_detno(detno);
  570. danBao.setFd_detail(stringArraytoString(danBao.getFd_detail()));
  571. danBao.setFd_fbid(id);
  572. detno=detno+1;
  573. }
  574. danBaoDao.save(danBaos);
  575. }
  576. }
  577. /**
  578. * 更新客户关注状态为已取消关注
  579. */
  580. @Override
  581. public void updateGZStatus(List<String> list){
  582. if (list!=null&&list.size()>0) {
  583. baseDao.execute("update fbbusiness set fb_gzstatus='已取消关注' where fb_tyshxycode not in (" + list2String(list) + ")");
  584. baseDao.execute("update customer set cu_gzstatus='已取消关注' where cu_name in (select fb_name from fbbusiness where fb_tyshxycode not in (" + list2String(list) + "))");
  585. }
  586. }
  587. /**
  588. * 更新客户关注状态为正在关注
  589. */
  590. @Override
  591. public void updateCUGZStatus(List<String> list){
  592. if (list!=null&&list.size()>0) {
  593. baseDao.execute(
  594. "update customer set cu_gzstatus='正在关注' where cu_name in (select fb_name from fbbusiness where fb_tyshxycode in (" + list2String(list) + ")");
  595. }
  596. }
  597. /**
  598. * 清除所有相关表中数据
  599. */
  600. private void deleteByCompanyId(String company_id) {
  601. if (baseDao.checkIf("FBBUSINESS","fb_tyshxycode='"+company_id+"'")) {
  602. //清除工商资料明细
  603. baseDao.execute("delete from FBBUSINESSDETAIL where fbd_fbid in (select fb_id from FBBUSINESS where fb_tyshxycode='" + company_id + "')");
  604. //清除工商资料
  605. baseDao.execute("delete from FBBUSINESS where fb_tyshxycode='" + company_id + "'");
  606. //清除工商变更
  607. baseDao.execute("delete from FBBUSINESSCHANGE where fbc_tyshxycode='" + company_id + "'");
  608. //清除工商登记股东信息明细
  609. baseDao.execute("delete from FBINVESTORDETAIL where fid_fiid in (select fi_id from FBINVESTOR where fi_tyshxycode='" + company_id + "')");
  610. //清除工商登记股东信息
  611. baseDao.execute("delete from FBINVESTOR where fi_tyshxycode='" + company_id + "'");
  612. //清除主要成员
  613. baseDao.execute("delete from FBMEMBER where fm_tyshxycode='" + company_id + "'");
  614. //清除开庭公告明细
  615. baseDao.execute("delete from FBKTGGDETAIL where fkd_fkid in (select fk_id from FBKTGG where fk_tyshxycode='" + company_id + "')");
  616. //清除开庭公告
  617. baseDao.execute("delete from FBKTGG where fk_tyshxycode='" + company_id + "'");
  618. //清除裁判文书明细
  619. baseDao.execute("delete from FBCPWSDETAIL where fcd_fcid in (select fc_id from FBCPWS where fc_tyshxycode='" + company_id + "')");
  620. //清除裁判文书
  621. baseDao.execute("delete from FBCPWS where fc_tyshxycode='" + company_id + "'");
  622. //清除被执行人
  623. baseDao.execute("delete from FBEXECUTEDPERSON where fep_tyshxycode='" + company_id + "'");
  624. //清除失信被执行人
  625. baseDao.execute("delete from FBSXBZXR where fsx_tyshxycode='" + company_id + "'");
  626. //清除经营异常
  627. baseDao.execute("delete from FBJYYC where fj_tyshxycode='" + company_id + "'");
  628. //清除重大税收违法
  629. baseDao.execute("delete from FBSSWF where fs_tyshxycode='" + company_id + "'");
  630. //清除催缴/欠税
  631. baseDao.execute("delete from FBQSJL where fq_tyshxycode='" + company_id + "'");
  632. //清除动产抵押明细
  633. baseDao.execute("delete from FBDCDYDETAIL where fdd_fdid in (select fd_id from FBDCDY where fd_tyshxycode='" + company_id + "')");
  634. //清除动产抵押
  635. baseDao.execute("delete from FBDCDY where fd_tyshxycode='" + company_id + "'");
  636. //清除股权出质
  637. baseDao.execute("delete from FBGQCZ where fg_tyshxycode='" + company_id + "'");
  638. //清除司法协助
  639. baseDao.execute("delete from FBSFXZ where ff_tyshxycode='" + company_id + "'");
  640. //清除涉诉公告
  641. baseDao.execute("delete from FBSSGG where fss_tyshxycode='" + company_id + "'");
  642. //清除担保信息
  643. baseDao.execute("delete from FBDANBAO where fd_tyshxycode='" + company_id + "'");
  644. }
  645. }
  646. /**
  647. * 接口结果简单处理
  648. * @param url
  649. * @param hend
  650. * @param param
  651. * @return
  652. */
  653. private String httpResponse(String url,HashMap<String,String> hend,Map<String,String> param) throws Exception{
  654. logger.info(url +"?apikey="+apikey+" 参数:"+param.toString());
  655. HttpUtil.Response response = HttpUtil.sendGetRequest(url, hend, param);
  656. int statusCode = response.getStatusCode();
  657. logger.info(Integer.toString(statusCode));
  658. if (statusCode==200) {
  659. return response.getResponseText();
  660. }else{
  661. throw new Exception("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
  662. }
  663. }
  664. /**
  665. * 接口结果分页处理
  666. * @param url
  667. * @param hend
  668. * @param param
  669. * @return
  670. */
  671. private JSONArray httpResponseBySize(String url,String apikey,int size,HashMap<String,String> hend, Map<String, String> param) throws Exception{
  672. logger.info(url +"?apikey="+apikey+" 参数:"+param.toString());
  673. JSONArray jsonArray=null;
  674. HttpUtil.Response response = HttpUtil.sendGetRequest(url, hend, param);
  675. int statusCode = response.getStatusCode();
  676. logger.info(Integer.toString(statusCode));
  677. if (statusCode==200) {
  678. String responseText = response.getResponseText();
  679. if (responseText != null) {
  680. JSONObject jsonObject = JSON.parseObject(responseText);
  681. int total = Integer.parseInt(jsonObject.get("total").toString());
  682. if (total>0) {
  683. Object hits = jsonObject.get("hits");
  684. jsonArray = JSON.parseArray(hits.toString());
  685. if (total > size) {
  686. Map<String, String> map = new HashMap<>();
  687. map.put("apikey", apikey);
  688. for (int i = size; i < total; i += size) {
  689. map.put("from", Integer.toString(i));
  690. map.put("size", Integer.toString(size));
  691. HttpUtil.Response response1 = HttpUtil.sendGetRequest(url, hend, map);
  692. int status = response1.getStatusCode();
  693. if (status == 200) {
  694. String s = response1.getResponseText();
  695. if (s != null) {
  696. Object hits1 = JSON.parseObject(s).get("hits");
  697. JSONArray array = JSON.parseArray(hits1.toString());
  698. jsonArray.addAll(array);
  699. }
  700. }else {
  701. throw new Exception("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
  702. }
  703. }
  704. }
  705. }
  706. }
  707. return jsonArray;
  708. } else{
  709. logger.error("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
  710. throw new Exception("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
  711. }
  712. }
  713. /**
  714. * 数组形式处理/分割
  715. * @param stringArray
  716. * @return
  717. */
  718. private String stringArraytoString(String stringArray){
  719. if ("[]".equals(stringArray)||stringArray==null){
  720. return null;
  721. }
  722. List<String> strings = JSON.parseArray(stringArray, String.class);
  723. String str="";
  724. for (String string:strings) {
  725. str=str+string+"/";
  726. }
  727. return str.substring(0,str.length()-1);
  728. }
  729. private String list2String(List<String> list){
  730. StringBuffer str = new StringBuffer();
  731. for (int i = 0; i < list.size(); i++) {
  732. if (i > 0) {
  733. str.append(",");
  734. }
  735. str.append("'").append(list.get(i)).append("'");
  736. }
  737. return str.toString();
  738. }
  739. }