| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776 |
- package com.uas.service.Impl;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.uas.core.support.GetProperties;
- import com.uas.dao.*;
- import com.uas.entity.*;
- import com.uas.service.CustomerService;
- import com.uas.utils.HttpUtil;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Async;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.*;
- /**
- * @author koul
- * @email koul@usoftchina.com
- * @date 2020-10-27 9:03
- */
- @Service
- public class CustomerServiceImpl implements CustomerService {
- private static Map<String,String> httpConfig = GetProperties.getAllProperty();
- private static String url = httpConfig.get("URL");
- private static String apikey = httpConfig.get("APIKEY");
- private static String company = httpConfig.get("company");
- private final Logger logger = LoggerFactory.getLogger(getClass());
- private final static int size=50;
- private final static HashMap hender = new HashMap() {{
- put(httpConfig.get("henderKey"), httpConfig.get("henderValue"));
- }};
- private final static Map<String, String> params = new HashMap<String, String>(){{
- put("apikey",apikey);
- put("from",Integer.toString(0));
- put("size",Integer.toString(size));
- }};
- @Autowired
- private BaseDao baseDao;
- @Autowired
- private BusinessDao businessDao;
- @Autowired
- private BusinessDetailDao businessDetailDao;
- @Autowired
- private BusinessChangeDao businessChangeDao;
- @Autowired
- private InvestorDao investorDao;
- @Autowired
- private InvestorRJDetailDao investorRJDetailDao;
- @Autowired
- private InvestorSJDetailDao investorSJDetailDao;
- @Autowired
- private MemberDao memberDao;
- @Autowired
- private KtggDao ktggDao;
- @Autowired
- private KtggDetailDao ktggDetailDao;
- @Autowired
- private CpwsDao cpwsDao;
- @Autowired
- private CpwsDetailDao cpwsDetailDao;
- @Autowired
- private ExecutedPersonDao executedPersonDao;
- @Autowired
- private SxbzxrDao sxbzxrDao;
- @Autowired
- private JyycDao jyycDao;
- @Autowired
- private SswfDao sswfDao;
- @Autowired
- private QsjlDao qsjlDao;
- @Autowired
- private DcdyDao dcdyDao;
- @Autowired
- private DcdyDetailDao dcdyDetailDao;
- @Autowired
- private GqczDao gqczDao;
- @Autowired
- private SfxzDao sfxzDao;
- @Autowired
- private SsggDao ssggDao;
- @Autowired
- private DanBaoDao danBaoDao;
- /**
- * 获取所有分组
- * @return
- */
- private List<Group> getGroupAll() throws Exception{
- Map<String, String> param = new HashMap<>();
- param.put("apikey",apikey);
- String group = httpResponse(url + httpConfig.get("group"), hender, param);
- if (group != null && !"[]".equals(group)) {
- return JSON.parseArray(group, Group.class);
- }
- return null;
- }
- /**
- * 获取所有客户统一信用编码
- * @return
- */
- @Override
- public List<String> getFollowingByGroup() throws Exception {
- Map<String, String> param = new HashMap<>();
- param.put("apikey",apikey);
- param.put("from",Integer.toString(0));
- param.put("size",Integer.toString(1000));
- List<Group> groupAll = getGroupAll();
- if (groupAll!=null){
- List<String> list = new ArrayList<>();
- for (Group group:groupAll) {
- param.put("group_id",Long.toString(group.getId()));
- JSONArray following = httpResponseBySize(url + httpConfig.get("following"), apikey, 1000, hender, param);
- if (following!=null){
- List<String> strings = JSON.parseArray(following.toString(), String.class);
- list.addAll(strings);
- }
- }
- return list;
- }
- return null;
- }
- /**
- * 保存工商资料
- * @param company_id
- */
- @Async("taskExecutor")
- @Transactional(rollbackFor=Exception.class)
- @Override
- public void saveBusiness(String company_id) throws Exception{
- deleteByCompanyId(company_id);
- Map<String, String> param = new HashMap<>();
- param.put("apikey", apikey);
- String s = httpResponse(url + company + "/" + company_id, hender, param);
- if (s != null) {
- Business business = JSON.parseObject(s, Business.class);
- business.setFb_gzstatus("正在关注");
- business.setFb_gxdate(new Date());
- business.setFb_evaluation(stringArraytoString(business.getFb_evaluation()));
- business.setFb_oldname(stringArraytoString(business.getFb_oldname()));
- Business save = businessDao.save(business);
- Long fb_id = save.getFb_id();
- JSONObject jsonObject = JSONObject.parseObject(s);
- Object objzcd = jsonObject.get("注册地");
- if (objzcd != null) {
- BusinessDetail zcd = JSON.parseObject(objzcd.toString(), BusinessDetail.class);
- zcd.setFbd_fbid(fb_id);
- zcd.setFbd_type("注册地");
- zcd.setFbd_detno(1);
- businessDetailDao.save(zcd);
- }
- Object objjyd = jsonObject.get("经营地");
- if (objjyd != null) {
- BusinessDetail zcd = JSON.parseObject(objjyd.toString(), BusinessDetail.class);
- zcd.setFbd_fbid(fb_id);
- zcd.setFbd_type("经营地");
- zcd.setFbd_detno(1);
- businessDetailDao.save(zcd);
- }
- Object objgp = jsonObject.get("股票");
- if (objgp != null && !"[]".equals(objgp.toString())) {
- List<BusinessDetail> gps = JSON.parseArray(objgp.toString(),
- BusinessDetail.class);
- int detno = 1;
- for (BusinessDetail gp : gps) {
- gp.setFbd_fbid(fb_id);
- gp.setFbd_type("股票");
- gp.setFbd_detno(detno);
- detno = detno + 1;
- }
- businessDetailDao.save(gps);
- }
- saveBusinessChange(company_id,fb_id);
- saveInvestor(company_id,fb_id);
- saveMember(company_id,fb_id);
- saveKtgg(company_id,fb_id);
- saveCpws(company_id,fb_id);
- saveExecutedPerson(company_id,fb_id);
- saveSxbzxr(company_id,fb_id);
- saveJyyc(company_id,fb_id);
- saveSswf(company_id,fb_id);
- saveQsjl(company_id,fb_id);
- saveDcdy(company_id,fb_id);
- saveGqcz(company_id,fb_id);
- saveSfxz(company_id,fb_id);
- saveSsgg(company_id,fb_id);
- saveDanbao(company_id,fb_id);
- }
- }
- /**
- * 保存工商变更
- * @param company_id
- */
- /*@Async("taskExecutor")*/
- private void saveBusinessChange(String company_id,Long id) throws Exception{
- JSONArray gsbg = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("gsbg"),
- apikey, size, hender, params);
- if(gsbg!=null) {
- List<BusinessChange> businessChanges = JSON.parseArray(gsbg.toString(), BusinessChange.class);
- if (businessChanges != null && businessChanges.size() > 0) {
- int detno = 1;
- for (BusinessChange fbc : businessChanges) {
- fbc.setFbc_detno(detno);
- fbc.setFbc_tyshxycode(company_id);
- fbc.setFbc_fbid(id);
- detno = detno + 1;
- }
- businessChangeDao.save(businessChanges);
- }
- }
- }
- /**
- * 保存工商登记股东信息
- * @param company_id
- */
- private void saveInvestor(String company_id,Long id) throws Exception{
- JSONArray objects = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("investor")
- , apikey, size, hender, params);
- if (objects!=null) {
- int det=1;
- for (Object obj:objects) {
- JSONObject jsonObject = JSON.parseObject(obj.toString());
- Investor investor = JSON.parseObject(obj.toString(), Investor.class);
- investor.setFi_detno(det);
- investor.setFi_tyshxycode(company_id);
- investor.setFi_fbid(id);
- Investor save = investorDao.save(investor);
- det=det+1;
- Long fi_id = save.getFi_id();
- Object sjmx = jsonObject.get("实缴明细");
- if (sjmx!=null&&!"[]".equals(sjmx.toString())) {
- List<InvestorSJDetail> sjDetails = JSON.parseArray(sjmx.toString(),
- InvestorSJDetail.class);
- int detno=1;
- for (InvestorSJDetail investorSJDetail:sjDetails) {
- investorSJDetail.setFid_detno(detno);
- investorSJDetail.setFid_fiid(fi_id);
- investorSJDetail.setFid_type("实缴明细");
- detno=detno+1;
- }
- investorSJDetailDao.save(sjDetails);
- }
- Object rjmx = jsonObject.get("认缴明细");
- if (rjmx!=null&&!"[]".equals(rjmx.toString())) {
- List<InvestorRJDetail> rjDetails = JSON.parseArray(rjmx.toString(),InvestorRJDetail.class);
- int no=1;
- for (InvestorRJDetail investorRJDetail:rjDetails) {
- investorRJDetail.setFid_detno(no);
- investorRJDetail.setFid_fiid(fi_id);
- investorRJDetail.setFid_type("认缴明细");
- no=no+1;
- }
- investorRJDetailDao.save(rjDetails);
- }
- }
- }
- }
- /**
- * 保存主要成员
- * @param company_id
- */
- private void saveMember(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("member")
- , apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Member> members = JSON.parseArray(jsonArray.toString(), Member.class);
- for (Member member:members) {
- member.setFm_tyshxycode(company_id);
- member.setFm_fbid(id);
- }
- memberDao.save(members);
- }
- }
- /**
- * 保存开庭公告
- * @param company_id
- */
- private void saveKtgg(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("ktgg")
- , apikey, size, hender, params);
- if (jsonArray!=null) {
- int detno=1;
- for (Object obj:jsonArray) {
- JSONObject jsonObject = JSON.parseObject(obj.toString());
- Ktgg ktgg = JSON.parseObject(obj.toString(), Ktgg.class);
- ktgg.setFk_tyshxycode(company_id);
- ktgg.setFk_fbid(id);
- ktgg.setFk_entities(stringArraytoString(ktgg.getFk_entities()));
- ktgg.setFk_otherroles(stringArraytoString(ktgg.getFk_otherroles()));
- ktgg.setFk_plaintif(stringArraytoString(ktgg.getFk_plaintif()));
- ktgg.setFk_party(stringArraytoString(ktgg.getFk_party()));
- ktgg.setFk_defendant(stringArraytoString(ktgg.getFk_defendant()));
- ktgg.setFk_detno(detno);
- Ktgg save = ktggDao.save(ktgg);
- detno=detno+1;
- Long fk_id = save.getFk_id();
- Object dsrDetail = jsonObject.get("当事人详情");
- if (dsrDetail != null && !"[]".equals(dsrDetail.toString())) {
- List<KtggDetail> ktggDetails = JSON.parseArray(dsrDetail.toString(), KtggDetail.class);
- int det=1;
- for (KtggDetail ktggdetail:ktggDetails) {
- ktggdetail.setFkd_fkid(fk_id);
- ktggdetail.setFkd_detno(det);
- ktggdetail.setFkd_type("当事人详情");
- ktggdetail.setFkd_otherroles(stringArraytoString(ktggdetail.getFkd_otherroles()));
- det=det+1;
- }
- ktggDetailDao.save(ktggDetails);
- }
- Object ssdq = jsonObject.get("所属地区");
- if (ssdq!=null){
- KtggDetail ktggDetail = JSON.parseObject(ssdq.toString(), KtggDetail.class);
- ktggDetail.setFkd_fkid(fk_id);
- ktggDetail.setFkd_type("所属地区");
- ktggDetailDao.save(ktggDetail);
- }
- }
- }
- }
- /**
- * 保存裁判文书
- * @param company_id
- */
- private void saveCpws(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("cpws"), apikey, size, hender, params);
- if (jsonArray!=null) {
- int detno=1;
- for (Object obj:jsonArray) {
- JSONObject jsonObject = JSON.parseObject(obj.toString());
- Cpws cpws = JSON.parseObject(obj.toString(), Cpws.class);
- cpws.setFc_tyshxycode(company_id);
- cpws.setFc_detno(detno);
- cpws.setFc_fbid(id);
- Cpws save = cpwsDao.save(cpws);
- detno=detno+1;
- Long fc_id = save.getFc_id();
- Object ssdq = jsonObject.get("所属地区");
- if (ssdq!=null){
- CpwsDetail cpwsDetail = JSON.parseObject(ssdq.toString(), CpwsDetail.class);
- cpwsDetail.setFcd_fcid(fc_id);
- cpwsDetail.setFcd_type("所属地区");
- cpwsDetail.setFcd_detno(1);
- cpwsDetailDao.save(cpwsDetail);
- }
- Object dls = jsonObject.get("段落");
- if (dls != null && !"[]".equals(dls.toString())) {
- List<CpwsDetail> cpwsDetails = JSON.parseArray(dls.toString(), CpwsDetail.class);
- int det=1;
- for (CpwsDetail cpwsDetail:cpwsDetails) {
- cpwsDetail.setFcd_fcid(fc_id);
- cpwsDetail.setFcd_type("段落");
- cpwsDetail.setFcd_detno(det);
- det=det+1;
- }
- cpwsDetailDao.save(cpwsDetails);
- }
- Object dsrs = jsonObject.get("当事人");
- if (dsrs != null && !"[]".equals(dsrs.toString())) {
- List<CpwsDetail> cpwsDetails = JSON.parseArray(dsrs.toString(),CpwsDetail.class);
- int det=1;
- for (CpwsDetail cpwsDetail:cpwsDetails) {
- cpwsDetail.setFcd_fcid(fc_id);
- cpwsDetail.setFcd_type("当事人");
- cpwsDetail.setFcd_detno(det);
- cpwsDetail.setFcd_otherroles(stringArraytoString(cpwsDetail.getFcd_otherroles()));
- cpwsDetail.setFcd_oldname(stringArraytoString(cpwsDetail.getFcd_oldname()));
- cpwsDetail.setFcd_role(stringArraytoString(cpwsDetail.getFcd_role()));
- cpwsDetail.setFcd_legalrepresentative(stringArraytoString(cpwsDetail.getFcd_legalrepresentative()));
- det=det+1;
- }
- cpwsDetailDao.save(cpwsDetails);
- }
- Object cpjes = jsonObject.get("判决金额");
- if (cpjes != null && !"[]".equals(cpjes.toString())) {
- List<CpwsDetail> cpwsDetails = JSON.parseArray(cpjes.toString(),CpwsDetail.class);
- int det=1;
- for (CpwsDetail cpwsDetail:cpwsDetails) {
- cpwsDetail.setFcd_type("判决金额");
- cpwsDetail.setFcd_detno(det);
- cpwsDetail.setFcd_payer(stringArraytoString(cpwsDetail.getFcd_payer()));
- cpwsDetail.setFcd_fcid(fc_id);
- det=det+1;
- }
- cpwsDetailDao.save(cpwsDetails);
- }
- }
- }
- }
- /**
- * 保存被执行人
- * @param company_id
- */
- private void saveExecutedPerson(String company_id,Long id) throws Exception{
- JSONArray zhixing = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("zhixing"), apikey, size, hender, params);
- if (zhixing!=null) {
- List<ExecutedPerson> executedPersonList = JSON.parseArray(zhixing.toString(), ExecutedPerson.class);
- for (ExecutedPerson executedPerson:executedPersonList) {
- executedPerson.setFep_entities(stringArraytoString(executedPerson.getFep_entities()));
- executedPerson.setFep_tyshxycode(company_id);
- executedPerson.setFep_fbid(id);
- }
- executedPersonDao.save(executedPersonList);
- }
- }
- /**
- * 保存失信被执行人
- * @param company_id
- */
- private void saveSxbzxr(String company_id,Long id) throws Exception{
- JSONArray shixin = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("shixin"), apikey, size, hender, params);
- if (shixin!=null) {
- List<Sxbzxr> sxbzxrs = JSON.parseArray(shixin.toString(), Sxbzxr.class);
- for (Sxbzxr sxbzxr:sxbzxrs) {
- sxbzxr.setFsx_tyshxycode(company_id);
- sxbzxr.setFsx_fbid(id);
- }
- sxbzxrDao.save(sxbzxrs);
- }
- }
- /**
- * 保存经营异常
- * @param company_id
- */
- private void saveJyyc(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("jyyc"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Jyyc> jyycs = JSON.parseArray(jsonArray.toString(), Jyyc.class);
- for (Jyyc jyyc:jyycs) {
- jyyc.setFj_tyshxycode(company_id);
- jyyc.setFj_fbid(id);
- }
- jyycDao.save(jyycs);
- }
- }
- /**
- * 保存重大税收违法
- * @param company_id
- */
- private void saveSswf(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("sswf"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Sswf> sswfs = JSON.parseArray(jsonArray.toString(), Sswf.class);
- for (Sswf sswf:sswfs) {
- sswf.setFs_taxpayercode(company_id);
- sswf.setFs_fbid(id);
- }
- sswfDao.save(sswfs);
- }
- }
- /**
- * 保存催缴/欠税
- * @param company_id
- */
- private void saveQsjl(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("qsjl"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Qsjl> qsjls = JSON.parseArray(jsonArray.toString(), Qsjl.class);
- for (Qsjl qsjl:qsjls) {
- qsjl.setFq_tyshxycode(company_id);
- qsjl.setFq_fbid(id);
- }
- qsjlDao.save(qsjls);
- }
- }
- /**
- * 保存动产抵押
- * @param company_id
- */
- private void saveDcdy(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("dcdy"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- for (Object obj:jsonArray) {
- JSONObject jsonObject = JSON.parseObject(obj.toString());
- Dcdy dcdy = JSON.parseObject(obj.toString(), Dcdy.class);
- dcdy.setFd_tyshxycode(company_id);
- dcdy.setFd_fbid(id);
- Dcdy save = dcdyDao.save(dcdy);
- Long fd_id = save.getFd_id();
- Object dsrs = jsonObject.get("当事人");
- if (dsrs != null && !"[]".equals(dsrs.toString())) {
- List<DcdyDetail> dcdyDetails = JSON.parseArray(dsrs.toString(), DcdyDetail.class);
- for (DcdyDetail dsr:dcdyDetails) {
- dsr.setFdd_fdid(fd_id);
- dsr.setFdd_type("当事人");
- }
- dcdyDetailDao.save(dcdyDetails);
- }
- Object dywgks = jsonObject.get("抵押物概况");
- if (dywgks != null && !"[]".equals(dywgks.toString())) {
- List<DcdyDetail> dcdyDetails = JSON.parseArray(dywgks.toString(), DcdyDetail.class);
- for (DcdyDetail dywgk:dcdyDetails) {
- dywgk.setFdd_fdid(fd_id);
- dywgk.setFdd_type("抵押物概况");
- }
- dcdyDetailDao.save(dcdyDetails);
- }
- }
- }
- }
- /**
- * 保存股权出质
- * @param company_id
- */
- private void saveGqcz(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("gqcz"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Gqcz> gqczs = JSON.parseArray(jsonArray.toString(), Gqcz.class);
- for (Gqcz gqcz:gqczs) {
- gqcz.setFg_tyshxycode(company_id);
- gqcz.setFg_fbid(id);
- }
- gqczDao.save(gqczs);
- }
- }
- /**
- * 保存司法协助
- * @param company_id
- */
- private void saveSfxz(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("sfxz"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Sfxz> sfxzs = JSON.parseArray(jsonArray.toString(), Sfxz.class);
- for (Sfxz sfxz:sfxzs) {
- sfxz.setFf_tyshxycode(company_id);
- sfxz.setFf_fbid(id);
- }
- sfxzDao.save(sfxzs);
- }
- }
- /**
- * 保存涉诉公告
- * @param company_id
- */
- private void saveSsgg(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("ssgg"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<Ssgg> ssggs = JSON.parseArray(jsonArray.toString(), Ssgg.class);
- for (Ssgg ssgg:ssggs) {
- ssgg.setFss_party(stringArraytoString(ssgg.getFss_party()));
- ssgg.setFss_tyshxycode(company_id);
- ssgg.setFss_entities(stringArraytoString(ssgg.getFss_entities()));
- ssgg.setFss_fbid(id);
- }
- ssggDao.save(ssggs);
- }
- }
- /**
- * 保存担保
- * @param company_id
- */
- private void saveDanbao(String company_id,Long id) throws Exception{
- JSONArray jsonArray = httpResponseBySize(url + company + "/" + company_id + "/" + httpConfig.get("danbao"),
- apikey, size, hender, params);
- if (jsonArray!=null) {
- List<DanBao> danBaos = JSON.parseArray(jsonArray.toString(), DanBao.class);
- int detno=1;
- for (DanBao danBao:danBaos) {
- danBao.setFd_party(stringArraytoString(danBao.getFd_party()));
- danBao.setFd_guarantor(stringArraytoString(danBao.getFd_guarantor()));
- danBao.setFd_dbmethod(stringArraytoString(danBao.getFd_dbmethod()));
- danBao.setFd_bparty(stringArraytoString(danBao.getFd_bparty()));
- danBao.setFd_tyshxycode(company_id);
- danBao.setFd_detno(detno);
- danBao.setFd_detail(stringArraytoString(danBao.getFd_detail()));
- danBao.setFd_fbid(id);
- detno=detno+1;
- }
- danBaoDao.save(danBaos);
- }
- }
- /**
- * 更新客户关注状态为已取消关注
- */
- @Override
- public void updateGZStatus(List<String> list){
- if (list!=null&&list.size()>0) {
- baseDao.execute("update fbbusiness set fb_gzstatus='已取消关注' where fb_tyshxycode not in (" + list2String(list) + ")");
- baseDao.execute("update customer set cu_gzstatus='已取消关注' where cu_name in (select fb_name from fbbusiness where fb_tyshxycode not in (" + list2String(list) + "))");
- }
- }
- /**
- * 更新客户关注状态为正在关注
- */
- @Override
- public void updateCUGZStatus(List<String> list){
- if (list!=null&&list.size()>0) {
- baseDao.execute(
- "update customer set cu_gzstatus='正在关注' where cu_name in (select fb_name from fbbusiness where fb_tyshxycode in (" + list2String(list) + ")");
- }
- }
- /**
- * 清除所有相关表中数据
- */
- private void deleteByCompanyId(String company_id) {
- if (baseDao.checkIf("FBBUSINESS","fb_tyshxycode='"+company_id+"'")) {
- //清除工商资料明细
- baseDao.execute("delete from FBBUSINESSDETAIL where fbd_fbid in (select fb_id from FBBUSINESS where fb_tyshxycode='" + company_id + "')");
- //清除工商资料
- baseDao.execute("delete from FBBUSINESS where fb_tyshxycode='" + company_id + "'");
- //清除工商变更
- baseDao.execute("delete from FBBUSINESSCHANGE where fbc_tyshxycode='" + company_id + "'");
- //清除工商登记股东信息明细
- baseDao.execute("delete from FBINVESTORDETAIL where fid_fiid in (select fi_id from FBINVESTOR where fi_tyshxycode='" + company_id + "')");
- //清除工商登记股东信息
- baseDao.execute("delete from FBINVESTOR where fi_tyshxycode='" + company_id + "'");
- //清除主要成员
- baseDao.execute("delete from FBMEMBER where fm_tyshxycode='" + company_id + "'");
- //清除开庭公告明细
- baseDao.execute("delete from FBKTGGDETAIL where fkd_fkid in (select fk_id from FBKTGG where fk_tyshxycode='" + company_id + "')");
- //清除开庭公告
- baseDao.execute("delete from FBKTGG where fk_tyshxycode='" + company_id + "'");
- //清除裁判文书明细
- baseDao.execute("delete from FBCPWSDETAIL where fcd_fcid in (select fc_id from FBCPWS where fc_tyshxycode='" + company_id + "')");
- //清除裁判文书
- baseDao.execute("delete from FBCPWS where fc_tyshxycode='" + company_id + "'");
- //清除被执行人
- baseDao.execute("delete from FBEXECUTEDPERSON where fep_tyshxycode='" + company_id + "'");
- //清除失信被执行人
- baseDao.execute("delete from FBSXBZXR where fsx_tyshxycode='" + company_id + "'");
- //清除经营异常
- baseDao.execute("delete from FBJYYC where fj_tyshxycode='" + company_id + "'");
- //清除重大税收违法
- baseDao.execute("delete from FBSSWF where fs_tyshxycode='" + company_id + "'");
- //清除催缴/欠税
- baseDao.execute("delete from FBQSJL where fq_tyshxycode='" + company_id + "'");
- //清除动产抵押明细
- baseDao.execute("delete from FBDCDYDETAIL where fdd_fdid in (select fd_id from FBDCDY where fd_tyshxycode='" + company_id + "')");
- //清除动产抵押
- baseDao.execute("delete from FBDCDY where fd_tyshxycode='" + company_id + "'");
- //清除股权出质
- baseDao.execute("delete from FBGQCZ where fg_tyshxycode='" + company_id + "'");
- //清除司法协助
- baseDao.execute("delete from FBSFXZ where ff_tyshxycode='" + company_id + "'");
- //清除涉诉公告
- baseDao.execute("delete from FBSSGG where fss_tyshxycode='" + company_id + "'");
- //清除担保信息
- baseDao.execute("delete from FBDANBAO where fd_tyshxycode='" + company_id + "'");
- }
- }
- /**
- * 接口结果简单处理
- * @param url
- * @param hend
- * @param param
- * @return
- */
- private String httpResponse(String url,HashMap<String,String> hend,Map<String,String> param) throws Exception{
- logger.info(url +"?apikey="+apikey+" 参数:"+param.toString());
- HttpUtil.Response response = HttpUtil.sendGetRequest(url, hend, param);
- int statusCode = response.getStatusCode();
- logger.info(Integer.toString(statusCode));
- if (statusCode==200) {
- return response.getResponseText();
- }else{
- throw new Exception("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
- }
- }
- /**
- * 接口结果分页处理
- * @param url
- * @param hend
- * @param param
- * @return
- */
- private JSONArray httpResponseBySize(String url,String apikey,int size,HashMap<String,String> hend, Map<String, String> param) throws Exception{
- logger.info(url +"?apikey="+apikey+" 参数:"+param.toString());
- JSONArray jsonArray=null;
- HttpUtil.Response response = HttpUtil.sendGetRequest(url, hend, param);
- int statusCode = response.getStatusCode();
- logger.info(Integer.toString(statusCode));
- if (statusCode==200) {
- String responseText = response.getResponseText();
- if (responseText != null) {
- JSONObject jsonObject = JSON.parseObject(responseText);
- int total = Integer.parseInt(jsonObject.get("total").toString());
- if (total>0) {
- Object hits = jsonObject.get("hits");
- jsonArray = JSON.parseArray(hits.toString());
- if (total > size) {
- Map<String, String> map = new HashMap<>();
- map.put("apikey", apikey);
- for (int i = size; i < total; i += size) {
- map.put("from", Integer.toString(i));
- map.put("size", Integer.toString(size));
- HttpUtil.Response response1 = HttpUtil.sendGetRequest(url, hend, map);
- int status = response1.getStatusCode();
- if (status == 200) {
- String s = response1.getResponseText();
- if (s != null) {
- Object hits1 = JSON.parseObject(s).get("hits");
- JSONArray array = JSON.parseArray(hits1.toString());
- jsonArray.addAll(array);
- }
- }else {
- throw new Exception("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
- }
- }
- }
- }
- }
- return jsonArray;
- } else{
- logger.error("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
- throw new Exception("接口状态:"+statusCode+",返回内容:"+response.getResponseText());
- }
- }
- /**
- * 数组形式处理/分割
- * @param stringArray
- * @return
- */
- private String stringArraytoString(String stringArray){
- if ("[]".equals(stringArray)||stringArray==null){
- return null;
- }
- List<String> strings = JSON.parseArray(stringArray, String.class);
- String str="";
- for (String string:strings) {
- str=str+string+"/";
- }
- return str.substring(0,str.length()-1);
- }
- private String list2String(List<String> list){
- StringBuffer str = new StringBuffer();
- for (int i = 0; i < list.size(); i++) {
- if (i > 0) {
- str.append(",");
- }
- str.append("'").append(list.get(i)).append("'");
- }
- return str.toString();
- }
- }
|