Search in sources :

Example 41 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class BaiWangServiceImpl method verifyInvoice.

/**
 * 发票校验接口
 * @param FP_DM:发票代码
 * @param FP_HM:发票号码
 * @param JYM:发票校验码
 */
public Map<String, String> verifyInvoice(String FP_DM, String FP_HM, String JYM) {
    if (!baiWangTask.isConnection() || !baiWangTask.isBaiWangDanJiConnection()) {
        baiWangTask.initBaiWang();
    }
    Map<String, String> resultMap = new HashMap<>();
    try {
        String param = "<REQUEST><HEAD>" + "<client_id>" + BaiWangTask.client_id + "</client_id>" + "<access_token>" + BaiWangTask.access_token + "</access_token>" + "<openID>" + BaiWangTask.openID + "</openID>" + "</HEAD>" + "<BODY>" + "<SQM>" + BaiWangTask.SQM + "</SQM>" + "<FP_DM>" + FP_DM + "</FP_DM>" + "<FP_HM>" + FP_HM + "</FP_HM>" + "<JYM>" + JYM + "</JYM>" + "</BODY>" + "</REQUEST>";
        param = URLEncoder.encode(new String(Base64.encode(param.getBytes())), "UTF-8");
        LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
        String urlAccessToken = BaiWangTask.baseUrl + "thirdInvoiceService";
        URI uri;
        uri = new URI(urlAccessToken);
        map.add("sign", "invoiceCheck");
        map.add("xml", param);
        String xml = restTemplate.postForObject(uri, map, String.class);
        resultMap = BaiWangTask.parseXml(xml);
        String KPRQ = resultMap.get("KPRQ");
        if (StringUtils.isNotBlank(KPRQ)) {
            String year = KPRQ.substring(0, 4) + "年";
            String mouth = KPRQ.substring(4, 6) + "月";
            String day = KPRQ.substring(6, 8) + "日";
            resultMap.put("KPRQ", year + mouth + day);
        }
        return resultMap;
    /**
     *3.2.1、 返回参数:
     *<ROOT>
     *<HEAD>
     *<SERVICE>
     *<REPLYCODE>0000</REPLYCODE>
     *<REPLYMSG>success</REPLYMSG>
     *</SERVICE>
     *</HEAD>
     *<BODY>
     *<FP_DM>发票代码</FP_DM>
     *<FP_HM>发票号码</FP_HM>
     *<XSF_MC>销售方名称</XSF_MC>
     *<XSF_NSRSBH>销售方纳税人识别号</XSF_NSRSBH>
     *<GMF_MC>付款方名称/发票抬头</GMF_MC>
     *<GMF_NSRSBH>付款方纳税人识别号</GMF_NSRSBH>
     *<GMF_SJH>付款方手机号</GMF_SJH>
     *<KPRQ>开票日期</KPRQ>
     *<KPLX>开票类型</KPLX>
     *<JSHJ>价税合计</JSHJ>
     *<HJJE>合计金额</HJJE>
     *<HJSE>合计税额</HJSE>
     *<KPR>开票人</KPR>
     *<SKR>收款人</SKR>
     *<FHR>复核人</FHR>
     *<JYM>校验码</JYM>
     *<YFP_DM>原发票代码</YFP_DM>
     *<YFP_HM>原发票号码</YFP_HM>
     *</BODY>
     *</ROOT>
     */
    } catch (Exception e) {
    // TODO: handle exception
    }
    return resultMap;
}
Also used : HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) URI(java.net.URI)

Example 42 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class IxinUkeyRegrecordServiceImpl method insertOrUpdate.

/**
 * @param ixinUkeyRegrecord
 * @throws
 */
public void insertOrUpdate(String keySn, String certSn) {
    if (StringUtils.isBlank(certSn)) {
        return;
    }
    IxinUkeyRegrecord ixinUkeyRegrecord = selectByCertSn(certSn);
    Date date = new Date();
    if (null != ixinUkeyRegrecord) {
        ixinUkeyRegrecord.setModifyTime(date);
        ixinUkeyRegrecord.setRegTime(date);
        updateByPrimaryKeySelective(ixinUkeyRegrecord);
    // 
    } else {
        // 新增
        ixinUkeyRegrecord = new IxinUkeyRegrecord();
        ixinUkeyRegrecord.setCertSn(certSn);
        ixinUkeyRegrecord.setCreateTime(date);
        ixinUkeyRegrecord.setItemStatus(1);
        ixinUkeyRegrecord.setKeySn(keySn);
        ixinUkeyRegrecord.setModifyTime(date);
        ixinUkeyRegrecord.setRegTime(date);
        insert(ixinUkeyRegrecord);
    }
    // 通知ukey平台.该证书已经注册成功
    String url = systemConfigService.getUkeyAddress();
    if (StringUtils.isBlank(url)) {
        LogUtil.syslog(sqlSession, "系统配置异常", "未配置:终端支撑管理系统(ukey平台)地址");
        return;
    }
    url = url + extUrl;
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("keySn", keySn);
    map.add("certSn", certSn);
    try {
        String result = restTemplate.postForObject(url, map, String.class);
    } catch (Exception e) {
        // TODO: handle exception
        LogUtil.syslog(sqlSession, "发送ukey注册信息", "出现错误,错误信息:" + e.getMessage());
        log.error(e.getMessage());
    }
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Date(java.util.Date) IxinUkeyRegrecord(com.itrus.portal.db.IxinUkeyRegrecord)

Example 43 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project incubator-servicecomb-java-chassis by apache.

the class SpringMvcIntegrationTestBase method blowsUpWhenFileNameDoesNotMatch.

@Test
public void blowsUpWhenFileNameDoesNotMatch() throws IOException {
    String file1Content = "hello world";
    String file2Content = "bonjour";
    MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
    map.add("file1", new FileSystemResource(newFile(file1Content).getAbsolutePath()));
    map.add("unmatched name", new FileSystemResource(newFile(file2Content).getAbsolutePath()));
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
    try {
        restTemplate.postForObject(codeFirstUrl + "uploadWithoutAnnotation", new HttpEntity<>(map, headers), String.class);
        expectFailing(UnknownHttpStatusCodeException.class);
    } catch (RestClientException ignored) {
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) RestClientException(org.springframework.web.client.RestClientException) FileSystemResource(org.springframework.core.io.FileSystemResource) Test(org.junit.Test)

Example 44 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project incubator-servicecomb-java-chassis by apache.

the class SpringMvcIntegrationTestBase method ableToPostForm.

@Test
public void ableToPostForm() {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("a", "5");
    params.add("b", "3");
    HttpHeaders headers = new HttpHeaders();
    headers.add(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE);
    int result = restTemplate.postForObject(codeFirstUrl + "add", new HttpEntity<>(params, headers), Integer.class);
    assertThat(result, is(8));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.Test)

Example 45 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project incubator-servicecomb-java-chassis by apache.

the class SpringMvcIntegrationTestBase method ableToPostDate.

@Test
public void ableToPostDate() throws Exception {
    ZonedDateTime date = ZonedDateTime.now().truncatedTo(SECONDS);
    MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
    body.add("date", RestObjectMapper.INSTANCE.convertToString(Date.from(date.toInstant())));
    HttpHeaders headers = new HttpHeaders();
    headers.add(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE);
    int seconds = 1;
    Date result = restTemplate.postForObject(codeFirstUrl + "addDate?seconds={seconds}", new HttpEntity<>(body, headers), Date.class, seconds);
    assertThat(result, is(Date.from(date.plusSeconds(seconds).toInstant())));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ZonedDateTime(java.time.ZonedDateTime) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Date(java.util.Date) Test(org.junit.Test)

Aggregations

LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)413 Test (org.junit.Test)153 HttpHeaders (org.springframework.http.HttpHeaders)126 MultiValueMap (org.springframework.util.MultiValueMap)94 Test (org.junit.jupiter.api.Test)88 HttpEntity (org.springframework.http.HttpEntity)60 List (java.util.List)42 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)40 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)37 HashMap (java.util.HashMap)36 MediaType (org.springframework.http.MediaType)34 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 URI (java.net.URI)33 Map (java.util.Map)31 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)30 ArrayList (java.util.ArrayList)27 UUID (java.util.UUID)27 lombok.val (lombok.val)27 IOException (java.io.IOException)26 Assert (org.junit.Assert)25