ApplyPaymentSettleService.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package com.idea.oa.apply.service;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import com.idea.oa.apply.mapper.ApplyPaymentSettleExtendMapper;
  5. import com.idea.oa.apply.mapper.ApplyPaymentSettleMapper;
  6. import com.idea.oa.apply.model.ApplyPaymentSettle;
  7. import com.idea.oa.apply.model.ApplyPaymentSettleExample;
  8. import com.idea.oa.apply.model.inout.ApplyPaymentSettleIn;
  9. import com.idea.oa.apply.util.constant.RedisToUse;
  10. import com.rockstar.common.base.BaseService;
  11. import com.rockstar.common.support.Convert;
  12. import com.rockstar.frame.model.extend.DateTrans;
  13. import com.rockstar.frame.model.extend.Tablepar;
  14. import com.rockstar.util.UUIDUtils;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Service;
  17. import org.springframework.util.StringUtils;
  18. import java.text.SimpleDateFormat;
  19. import java.util.Date;
  20. import java.util.List;
  21. import java.util.Map;
  22. @Service
  23. public class ApplyPaymentSettleService implements BaseService<ApplyPaymentSettle, ApplyPaymentSettleExample> {
  24. //文件mapper
  25. @Autowired
  26. private ApplyPaymentSettleMapper modelMapper;
  27. @Autowired
  28. private ApplyPaymentSettleExtendMapper ApplyPaymentSettleExtendMapper;
  29. /**
  30. * 分页查询
  31. *
  32. * @return
  33. */
  34. public PageInfo<ApplyPaymentSettle> list(Tablepar tablepar, ApplyPaymentSettle model, DateTrans dt) {
  35. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  36. List<ApplyPaymentSettle> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  37. PageInfo<ApplyPaymentSettle> pageInfo = new PageInfo<>(list);
  38. return pageInfo;
  39. }
  40. public Object listAll(ApplyPaymentSettle model, DateTrans dt) {
  41. List<ApplyPaymentSettle> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  42. return list;
  43. }
  44. @Override
  45. public int deleteByPrimaryKey(String ids) {
  46. List<String> lista = Convert.toListStrArray(ids);
  47. ApplyPaymentSettleExample example = new ApplyPaymentSettleExample();
  48. example.createCriteria().andIdIn(lista);
  49. return modelMapper.deleteByExample(example);
  50. }
  51. @Override
  52. public ApplyPaymentSettle selectByPrimaryKey(String id) {
  53. return modelMapper.selectByPrimaryKey(id);
  54. }
  55. @Override
  56. public int updateByPrimaryKeySelective(ApplyPaymentSettle record) {
  57. return modelMapper.updateByPrimaryKeySelective(record);
  58. }
  59. @Override
  60. public int updateByExampleSelective(ApplyPaymentSettle record, ApplyPaymentSettleExample example) {
  61. return modelMapper.updateByExampleSelective(record, example);
  62. }
  63. @Override
  64. public int updateByExample(ApplyPaymentSettle record, ApplyPaymentSettleExample example) {
  65. return modelMapper.updateByExample(record, example);
  66. }
  67. @Override
  68. public List<ApplyPaymentSettle> selectByExample(ApplyPaymentSettleExample example) {
  69. return modelMapper.selectByExample(example);
  70. }
  71. @Override
  72. public long countByExample(ApplyPaymentSettleExample example) {
  73. return modelMapper.countByExample(example);
  74. }
  75. @Override
  76. public int deleteByExample(ApplyPaymentSettleExample example) {
  77. return modelMapper.deleteByExample(example);
  78. }
  79. public int insert(ApplyPaymentSettle record) {
  80. record.setId(UUIDUtils.middleUUID());
  81. return insertWithoutId(record);
  82. }
  83. public int insertWithoutId(ApplyPaymentSettle record) {
  84. record.setCreatedAt(new Date());
  85. return modelMapper.insert(record);
  86. }
  87. @Override
  88. public int insertSelective(ApplyPaymentSettle record) {
  89. record.setId(UUIDUtils.middleUUID());
  90. record.setCreatedAt(new Date());
  91. return modelMapper.insertSelective(record);
  92. }
  93. public ApplyPaymentSettleIn getInfoByFlowMainId(String flowMainId) {
  94. return ApplyPaymentSettleExtendMapper.getInfoByFlowMainId(flowMainId);
  95. }
  96. public ApplyPaymentSettleIn getInfoByFlowMainPushId(String flowMainPushId) {
  97. return ApplyPaymentSettleExtendMapper.getInfoByFlowMainPushId(flowMainPushId);
  98. }
  99. public Map<String, Object> getUserInfoByUserId(String userId) {
  100. Map<String, Object> userInfoByUserId = ApplyPaymentSettleExtendMapper.getUserInfoByUserId(userId);
  101. return userInfoByUserId;
  102. }
  103. // public static void main(String[] args) {
  104. // System.out.println(new ApplyPaymentSettleService().getMaxNum());
  105. // }
  106. /**
  107. * 付款记录编号 : 付款领用单20240401-002
  108. * @return
  109. */
  110. public String getMaxNum(){
  111. String maxnum = null;
  112. try {
  113. int c=0;
  114. while ("#".equals(RedisToUse.pmnumber)){
  115. try {
  116. c++;
  117. Thread.sleep(100);//等待毫秒
  118. } catch (InterruptedException e) {
  119. throw new RuntimeException(e);
  120. }
  121. if (c>=1000){
  122. break;
  123. }
  124. }
  125. maxnum = RedisToUse.pmnumber;
  126. RedisToUse.pmnumber="#";
  127. if (maxnum==null){
  128. maxnum = ApplyPaymentSettleExtendMapper.selectMaxNum();
  129. }
  130. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
  131. String topName = "付款领用单"+sdf.format(new Date())+"-";
  132. // 20221111-04
  133. if (StringUtils.isEmpty(maxnum)) {
  134. maxnum = topName+"001";
  135. }else {
  136. String substring = maxnum.substring(0, topName.length());
  137. if (topName.equals(substring)){
  138. maxnum= RedisToUse.addNumber(topName, maxnum);
  139. }else{
  140. maxnum = topName+"001";
  141. }
  142. }
  143. } finally {
  144. RedisToUse.pmnumber=maxnum;
  145. }
  146. return maxnum;
  147. }
  148. }