| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- package com.uas.eis.service.Impl;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.alibaba.fastjson.serializer.SerializerFeature;
- import com.uas.eis.core.config.SpObserver;
- import com.uas.eis.dao.BaseDao;
- import com.uas.eis.dao.SqlRowList;
- import com.uas.eis.sdk.dto.AssistBalanceDTO;
- import com.uas.eis.sdk.dto.BalanceCountDTO;
- import com.uas.eis.sdk.dto.BalanceDTO;
- import com.uas.eis.sdk.dto.CashFlowDTO;
- import com.uas.eis.sdk.entity.ApiResult;
- import com.uas.eis.sdk.resp.ApiResponse;
- import com.uas.eis.service.STKService;
- import com.uas.eis.utils.CollectionUtil;
- import com.uas.eis.utils.FlexJsonUtil;
- import com.uas.eis.utils.PSHttpUtils;
- import com.uas.eis.utils.StringUtil;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.util.StringUtils;
- import javax.servlet.http.HttpServletRequest;
- import java.io.IOException;
- import java.util.*;
- /**
- * @author zhuxl
- * @date 2024-10-12
- */
- @Service
- public class STKServiceImpl implements STKService {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private BaseDao baseDao;
- @Override
- public ApiResult<String> getAssistBalanceCount(HttpServletRequest request, AssistBalanceDTO dto) {
- String yearmonth = dto.getYearMonth();
- boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
- if (bool) {
- int batch_no = baseDao.getSeqId("STK_ASSISTBALANCE2_SEQ");
- String res = baseDao.callProcedure("SP_INSER_ASSISTBALANCE",
- new Object[] {batch_no,yearmonth});
- if (res != null && !res.trim().equals("")) {
- return ApiResponse.successRsp("1",res,request.getHeader("RequestId"),null);
- }else{
- int count = baseDao.getCount("select count(1) from STK_ASSISTBALANCE where FPERIODNAME='" + yearmonth + "'");
- BalanceCountDTO balanceCountDTO = new BalanceCountDTO();
- balanceCountDTO.setYearMonth(yearmonth);
- balanceCountDTO.setBatch_no(batch_no);
- balanceCountDTO.setCount(count);
- String s = JSON.toJSONString(balanceCountDTO, SerializerFeature.WriteMapNullValue);
- return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
- }
- }else{
- return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
- }
- }
- @Override
- public ApiResult<String> getAssistBalance(HttpServletRequest request, AssistBalanceDTO dto) {
- String yearmonth = dto.getYearMonth();
- String batch_no = dto.getBatch_no();
- int pageNum = Integer.valueOf(dto.getPageNum());
- int pageSize = Integer.valueOf(dto.getPageSize());
- int start = ((pageNum - 1) * pageSize + 1);
- int end = pageNum * pageSize;
- boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
- if (bool) {
- List<BalanceDTO> balanceDTO = baseDao.query("SELECT fid,fssno,fsoid,forgunitno,forgunitname,fperiodname,fcurrencyname,forginalcname,faccountno,faccountname," +
- " fassistgrptype,fassistgrpno1,fassistgrpname1," +
- " fassistgrpno2,fassistgrpname2," +
- " fbeginbalancefor,fbeginbalancelocal," +
- " fcreditfor,fcreditlocal,fdebitfor,fdebitlocal," +
- " fendbalancefor,fendbalancelocal," +
- " fyearpnlfor,fyearpnllocal," +
- " fyeardebitfor,fyeardebitlocal,fyearcreditfor,fyearcreditlocal," +
- " faccoccurfor,faccoccurlocal," +
- " to_char(fmodifytime,'yyyy-mm-dd hh24:mi:ss') fmodifytime,to_char(flockintime,'yyyy-mm-dd hh24:mi:ss') flockintime," +
- " fdisablelabel,fdatamode,fbilltype,batch_no from stk_assistbalance " +
- "WHERE batch_no ="+batch_no+" and FPERIODNAME = '"+yearmonth +"' and QUERYDETNO >= " +start+ " and QUERYDETNO <= " + end, BalanceDTO.class);
- //String s = JSON.toJSONString(rs.getResultList(), SerializerFeature.WriteMapNullValue);
- String s = JSON.toJSONString(balanceDTO, SerializerFeature.WriteMapNullValue);
- return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
- }else{
- return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
- }
- }
- @Override
- public ApiResult<String> getCashFlowCount(HttpServletRequest request, AssistBalanceDTO dto) {
- String yearmonth = dto.getYearMonth();
- boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
- if (bool) {
- int batch_no = baseDao.getSeqId("STK_CASHFLOW2_SEQ");
- String res = baseDao.callProcedure("SP_INSER_CASHFLOW",
- new Object[] {batch_no,yearmonth});
- if (res != null && !res.trim().equals("")) {
- return ApiResponse.successRsp("2001",res,request.getHeader("RequestId"),null);
- }else{
- int count = baseDao.getCount("select count(1) from STK_CASHFLOW where FPERIODNAME='" + yearmonth + "'");
- BalanceCountDTO balanceCountDTO = new BalanceCountDTO();
- balanceCountDTO.setYearMonth(yearmonth);
- balanceCountDTO.setBatch_no(batch_no);
- balanceCountDTO.setCount(count);
- String s = JSON.toJSONString(balanceCountDTO, SerializerFeature.WriteMapNullValue);
- return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
- }
- }else{
- return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
- }
- }
- @Override
- public ApiResult<String> getCashFlow(HttpServletRequest request, AssistBalanceDTO dto) {
- String yearmonth = dto.getYearMonth();
- String batch_no = dto.getBatch_no();
- int pageNum = Integer.valueOf(dto.getPageNum());
- int pageSize = Integer.valueOf(dto.getPageSize());
- int start = ((pageNum - 1) * pageSize + 1);
- int end = pageNum * pageSize;
- boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
- if (bool) {
- List<CashFlowDTO> cashFlowDTO = baseDao.query("SELECT fid,fssno,fsoid,forgunitno,forgunitname,fperiodname,fcurrencyname,forginalcname,faccountno,faccountname," +
- " fassistgrptype,fassistgrpno1,fassistgrpname1," +
- " fassistgrpno2,fassistgrpname2," +
- " fytdamt,fytdlocalamt," +
- " fmodifytime,flockintime,fdisablelabel,fdatamode,batch_no from STK_CASHFLOW " +
- "WHERE batch_no ="+batch_no+" and FPERIODNAME = '"+yearmonth +"' and QUERYDETNO >= " +start+ " and QUERYDETNO <= " + end, CashFlowDTO.class);
- //String s = JSON.toJSONString(rs.getResultList(), SerializerFeature.WriteMapNullValue);
- String s = JSON.toJSONString(cashFlowDTO, SerializerFeature.WriteMapNullValue);
- return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
- }else{
- return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
- }
- }
- @Override
- public ApiResult<String> getAssistBalanceCountTest(HttpServletRequest request, AssistBalanceDTO dto) {
- //取yearMonth
- String yearMonth = dto.getYearMonth();
- System.out.println("body参数打印:"+dto.getYearMonth());
- //获取header参数
- Map<String,String> headerMap = getHeaderParams(request);
- System.out.println("header参数:【AccessKey:"+headerMap.get("AccessKey")+",Timestamp:"+headerMap.get("Timestamp")
- +",RequestId:"+headerMap.get("RequestId")+",Signature:"+headerMap.get("Signature")+"】");
- return null;
- }
- /**
- * 获取header参数
- * */
- public Map<String,String> getHeaderParams(HttpServletRequest request){
- String accessKey = request.getHeader("AccessKey");
- String timestamp = request.getHeader("Timestamp");
- String requestId = request.getHeader("RequestId");
- String signature = request.getHeader("Signature");
- Map<String,String> headerMap = new HashMap<>();
- if(!StringUtils.isEmpty(accessKey)){
- headerMap.put("AccessKey",accessKey);
- }
- if(!StringUtils.isEmpty(timestamp)){
- headerMap.put("Timestamp",timestamp);
- }
- if(!StringUtils.isEmpty(requestId)){
- headerMap.put("RequestId",requestId);
- }
- if(!StringUtils.isEmpty(signature)){
- headerMap.put("Signature",signature);
- }
- return headerMap;
- }
- private JSONObject getJsonData(HttpServletRequest request){
- JSONObject jsonObject=null;
- try {
- String data = PSHttpUtils.readRaw(request.getInputStream());
- jsonObject = JSON.parseObject(data);
- } catch (IOException e) {
- logger.info("参数解析异常信息:"+e.getMessage());
- e.printStackTrace();
- }
- return jsonObject;
- }
- }
|