STKServiceImpl.java 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. package com.uas.eis.service.Impl;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.alibaba.fastjson.serializer.SerializerFeature;
  5. import com.uas.eis.core.config.SpObserver;
  6. import com.uas.eis.dao.BaseDao;
  7. import com.uas.eis.dao.SqlRowList;
  8. import com.uas.eis.sdk.dto.AssistBalanceDTO;
  9. import com.uas.eis.sdk.dto.BalanceCountDTO;
  10. import com.uas.eis.sdk.dto.BalanceDTO;
  11. import com.uas.eis.sdk.dto.CashFlowDTO;
  12. import com.uas.eis.sdk.entity.ApiResult;
  13. import com.uas.eis.sdk.resp.ApiResponse;
  14. import com.uas.eis.service.STKService;
  15. import com.uas.eis.utils.CollectionUtil;
  16. import com.uas.eis.utils.FlexJsonUtil;
  17. import com.uas.eis.utils.PSHttpUtils;
  18. import com.uas.eis.utils.StringUtil;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23. import org.springframework.util.StringUtils;
  24. import javax.servlet.http.HttpServletRequest;
  25. import java.io.IOException;
  26. import java.util.*;
  27. /**
  28. * @author zhuxl
  29. * @date 2024-10-12
  30. */
  31. @Service
  32. public class STKServiceImpl implements STKService {
  33. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  34. @Autowired
  35. private BaseDao baseDao;
  36. @Override
  37. public ApiResult<String> getAssistBalanceCount(HttpServletRequest request, AssistBalanceDTO dto) {
  38. String yearmonth = dto.getYearMonth();
  39. boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
  40. if (bool) {
  41. int batch_no = baseDao.getSeqId("STK_ASSISTBALANCE2_SEQ");
  42. String res = baseDao.callProcedure("SP_INSER_ASSISTBALANCE",
  43. new Object[] {batch_no,yearmonth});
  44. if (res != null && !res.trim().equals("")) {
  45. return ApiResponse.successRsp("1",res,request.getHeader("RequestId"),null);
  46. }else{
  47. int count = baseDao.getCount("select count(1) from STK_ASSISTBALANCE where FPERIODNAME='" + yearmonth + "'");
  48. BalanceCountDTO balanceCountDTO = new BalanceCountDTO();
  49. balanceCountDTO.setYearMonth(yearmonth);
  50. balanceCountDTO.setBatch_no(batch_no);
  51. balanceCountDTO.setCount(count);
  52. String s = JSON.toJSONString(balanceCountDTO, SerializerFeature.WriteMapNullValue);
  53. return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
  54. }
  55. }else{
  56. return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
  57. }
  58. }
  59. @Override
  60. public ApiResult<String> getAssistBalance(HttpServletRequest request, AssistBalanceDTO dto) {
  61. String yearmonth = dto.getYearMonth();
  62. String batch_no = dto.getBatch_no();
  63. int pageNum = Integer.valueOf(dto.getPageNum());
  64. int pageSize = Integer.valueOf(dto.getPageSize());
  65. int start = ((pageNum - 1) * pageSize + 1);
  66. int end = pageNum * pageSize;
  67. boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
  68. if (bool) {
  69. List<BalanceDTO> balanceDTO = baseDao.query("SELECT fid,fssno,fsoid,forgunitno,forgunitname,fperiodname,fcurrencyname,forginalcname,faccountno,faccountname," +
  70. " fassistgrptype,fassistgrpno1,fassistgrpname1," +
  71. " fassistgrpno2,fassistgrpname2," +
  72. " fbeginbalancefor,fbeginbalancelocal," +
  73. " fcreditfor,fcreditlocal,fdebitfor,fdebitlocal," +
  74. " fendbalancefor,fendbalancelocal," +
  75. " fyearpnlfor,fyearpnllocal," +
  76. " fyeardebitfor,fyeardebitlocal,fyearcreditfor,fyearcreditlocal," +
  77. " faccoccurfor,faccoccurlocal," +
  78. " to_char(fmodifytime,'yyyy-mm-dd hh24:mi:ss') fmodifytime,to_char(flockintime,'yyyy-mm-dd hh24:mi:ss') flockintime," +
  79. " fdisablelabel,fdatamode,fbilltype,batch_no from stk_assistbalance " +
  80. "WHERE batch_no ="+batch_no+" and FPERIODNAME = '"+yearmonth +"' and QUERYDETNO >= " +start+ " and QUERYDETNO <= " + end, BalanceDTO.class);
  81. //String s = JSON.toJSONString(rs.getResultList(), SerializerFeature.WriteMapNullValue);
  82. String s = JSON.toJSONString(balanceDTO, SerializerFeature.WriteMapNullValue);
  83. return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
  84. }else{
  85. return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
  86. }
  87. }
  88. @Override
  89. public ApiResult<String> getCashFlowCount(HttpServletRequest request, AssistBalanceDTO dto) {
  90. String yearmonth = dto.getYearMonth();
  91. boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
  92. if (bool) {
  93. int batch_no = baseDao.getSeqId("STK_CASHFLOW2_SEQ");
  94. String res = baseDao.callProcedure("SP_INSER_CASHFLOW",
  95. new Object[] {batch_no,yearmonth});
  96. if (res != null && !res.trim().equals("")) {
  97. return ApiResponse.successRsp("2001",res,request.getHeader("RequestId"),null);
  98. }else{
  99. int count = baseDao.getCount("select count(1) from STK_CASHFLOW where FPERIODNAME='" + yearmonth + "'");
  100. BalanceCountDTO balanceCountDTO = new BalanceCountDTO();
  101. balanceCountDTO.setYearMonth(yearmonth);
  102. balanceCountDTO.setBatch_no(batch_no);
  103. balanceCountDTO.setCount(count);
  104. String s = JSON.toJSONString(balanceCountDTO, SerializerFeature.WriteMapNullValue);
  105. return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
  106. }
  107. }else{
  108. return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
  109. }
  110. }
  111. @Override
  112. public ApiResult<String> getCashFlow(HttpServletRequest request, AssistBalanceDTO dto) {
  113. String yearmonth = dto.getYearMonth();
  114. String batch_no = dto.getBatch_no();
  115. int pageNum = Integer.valueOf(dto.getPageNum());
  116. int pageSize = Integer.valueOf(dto.getPageSize());
  117. int start = ((pageNum - 1) * pageSize + 1);
  118. int end = pageNum * pageSize;
  119. boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-A' and pd_status=99 and pd_detno='"+yearmonth+"'");
  120. if (bool) {
  121. List<CashFlowDTO> cashFlowDTO = baseDao.query("SELECT fid,fssno,fsoid,forgunitno,forgunitname,fperiodname,fcurrencyname,forginalcname,faccountno,faccountname," +
  122. " fassistgrptype,fassistgrpno1,fassistgrpname1," +
  123. " fassistgrpno2,fassistgrpname2," +
  124. " fytdamt,fytdlocalamt," +
  125. " fmodifytime,flockintime,fdisablelabel,fdatamode,batch_no from STK_CASHFLOW " +
  126. "WHERE batch_no ="+batch_no+" and FPERIODNAME = '"+yearmonth +"' and QUERYDETNO >= " +start+ " and QUERYDETNO <= " + end, CashFlowDTO.class);
  127. //String s = JSON.toJSONString(rs.getResultList(), SerializerFeature.WriteMapNullValue);
  128. String s = JSON.toJSONString(cashFlowDTO, SerializerFeature.WriteMapNullValue);
  129. return ApiResponse.successRsp("1",null,request.getHeader("RequestId"),s);
  130. }else{
  131. return ApiResponse.successRsp("2001","当前期间未结账!",request.getHeader("RequestId"),null);
  132. }
  133. }
  134. @Override
  135. public ApiResult<String> getAssistBalanceCountTest(HttpServletRequest request, AssistBalanceDTO dto) {
  136. //取yearMonth
  137. String yearMonth = dto.getYearMonth();
  138. System.out.println("body参数打印:"+dto.getYearMonth());
  139. //获取header参数
  140. Map<String,String> headerMap = getHeaderParams(request);
  141. System.out.println("header参数:【AccessKey:"+headerMap.get("AccessKey")+",Timestamp:"+headerMap.get("Timestamp")
  142. +",RequestId:"+headerMap.get("RequestId")+",Signature:"+headerMap.get("Signature")+"】");
  143. return null;
  144. }
  145. /**
  146. * 获取header参数
  147. * */
  148. public Map<String,String> getHeaderParams(HttpServletRequest request){
  149. String accessKey = request.getHeader("AccessKey");
  150. String timestamp = request.getHeader("Timestamp");
  151. String requestId = request.getHeader("RequestId");
  152. String signature = request.getHeader("Signature");
  153. Map<String,String> headerMap = new HashMap<>();
  154. if(!StringUtils.isEmpty(accessKey)){
  155. headerMap.put("AccessKey",accessKey);
  156. }
  157. if(!StringUtils.isEmpty(timestamp)){
  158. headerMap.put("Timestamp",timestamp);
  159. }
  160. if(!StringUtils.isEmpty(requestId)){
  161. headerMap.put("RequestId",requestId);
  162. }
  163. if(!StringUtils.isEmpty(signature)){
  164. headerMap.put("Signature",signature);
  165. }
  166. return headerMap;
  167. }
  168. private JSONObject getJsonData(HttpServletRequest request){
  169. JSONObject jsonObject=null;
  170. try {
  171. String data = PSHttpUtils.readRaw(request.getInputStream());
  172. jsonObject = JSON.parseObject(data);
  173. } catch (IOException e) {
  174. logger.info("参数解析异常信息:"+e.getMessage());
  175. e.printStackTrace();
  176. }
  177. return jsonObject;
  178. }
  179. }