TFeeServiceImpl.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package com.ruoyi.finance.service.impl;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.ruoyi.common.core.domain.AjaxResult;
  5. import com.ruoyi.common.core.domain.model.LoginUser;
  6. import com.ruoyi.common.utils.DateUtils;
  7. import com.ruoyi.common.utils.StringUtils;
  8. import com.ruoyi.finance.domain.TFee;
  9. import com.ruoyi.finance.domain.TFeeDo;
  10. import com.ruoyi.finance.domain.TWareHouseFees;
  11. import com.ruoyi.finance.mapper.TFeeDoMapper;
  12. import com.ruoyi.finance.mapper.TFeeMapper;
  13. import com.ruoyi.finance.service.ITFeeService;
  14. import com.ruoyi.warehouseBusiness.domain.*;
  15. import com.ruoyi.warehouseBusiness.mapper.BillnoDelMapper;
  16. import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Service;
  19. import java.util.*;
  20. /**
  21. * 财务数据主Service业务层处理
  22. *
  23. * @author ruoyi
  24. * @date 2021-01-18
  25. */
  26. @Service
  27. public class TFeeServiceImpl implements ITFeeService {
  28. @Autowired
  29. private TFeeMapper tFeeMapper;
  30. @Autowired
  31. private TFeeDoMapper tFeeDoMapper;
  32. @Autowired
  33. private BillnoSerialServiceImpl billnoSerialServiceImpl;
  34. @Autowired
  35. private BillnoDelMapper billnoDelMapper;
  36. /**
  37. * 查询财务数据主
  38. *
  39. * @param fId 财务数据主ID
  40. * @return 财务数据主
  41. */
  42. @Override
  43. public TFee selectTFeeById(Long fId) {
  44. return tFeeMapper.selectTFeeById(fId);
  45. }
  46. /**
  47. * 查询财务数据主列表
  48. *
  49. * @param tFee 财务数据主
  50. * @return 财务数据主
  51. */
  52. @Override
  53. public List<TFee> selectTFeeList(TFee tFee) {
  54. return tFeeMapper.selectTFeeList(tFee);
  55. }
  56. /**
  57. * 新增财务数据主
  58. *
  59. * @param tFee 财务数据主
  60. * @return 结果
  61. */
  62. @Override
  63. public int insertTFee(TFee tFee) {
  64. tFee.setCreateTime(DateUtils.getNowDate());
  65. return tFeeMapper.insertTFee(tFee);
  66. }
  67. /**
  68. * 新增对账 、收费、
  69. * @param tfee
  70. * @param tfeeDo
  71. * @param loginUser
  72. * @param fBilltype
  73. * @return
  74. */
  75. @Override
  76. public AjaxResult insertTFeeTFeeDo(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
  77. Long fPid = null;
  78. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  79. if (StringUtils.isNull(tFee.getfId())) {
  80. // 如果是新数据
  81. tFee.setCreateBy(loginUser.getUser().getUserName());
  82. tFee.setfBilltype(fBilltype);
  83. // 业务编码
  84. Date time = new Date();
  85. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  86. tFee.setfBillno(billNo);
  87. tFeeMapper.insertTFee(tFee);
  88. fPid = tFee.getfId();
  89. } else {
  90. fPid = tFee.getfId();
  91. tFee.setUpdateBy(loginUser.getUser().getUserName());
  92. tFee.setUpdateTime(new Date());
  93. tFeeMapper.updateTFee(tFee);
  94. // 删除从表
  95. tFeeDoMapper.deleteByFPid(fPid);
  96. }
  97. // 财务从表
  98. if (StringUtils.isNotNull(tfeeDo)) {
  99. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  100. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  101. for (TFeeDo tFeeDo : tFeeDoList) {
  102. tFeeDo.setfPid(fPid);
  103. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  104. tFeeDo.setCreateTime(new Date());
  105. tFeeDoMapper.insertTFeeDo(tFeeDo);
  106. }
  107. }
  108. return AjaxResult.success();
  109. }
  110. /**
  111. * 修改财务数据主
  112. *
  113. * @param tFee 财务数据主
  114. * @return 结果
  115. */
  116. @Override
  117. public int updateTFee(TFee tFee) {
  118. tFee.setUpdateTime(DateUtils.getNowDate());
  119. return tFeeMapper.updateTFee(tFee);
  120. }
  121. /**
  122. * 批量删除财务数据主
  123. *
  124. * @param fIds 需要删除的财务数据主ID
  125. * @return 结果
  126. */
  127. @Override
  128. public int deleteTFeeByIds(Long[] fIds) {
  129. // 取出业务编号、 放入 billno_del
  130. for (Long id : fIds) {
  131. // 1、查询主表信息
  132. TFee tFee = tFeeMapper.selectTFeeById(id);
  133. // 2、业务编号、客存编号 放入 billno_del
  134. BillnoDel billnoDel = new BillnoDel();
  135. billnoDel.setBillType(tFee.getfBilltype());
  136. billnoDel.setBillNo(tFee.getfBillno());
  137. billnoDelMapper.insertBillnoDel(billnoDel);
  138. }
  139. return tFeeMapper.deleteTFeeByIds(fIds);
  140. }
  141. /**
  142. * 删除财务数据主信息
  143. *
  144. * @param fId 财务数据主ID
  145. * @return 结果
  146. */
  147. @Override
  148. public int deleteTFeeById(Long fId) {
  149. return tFeeMapper.deleteTFeeById(fId);
  150. }
  151. @Override
  152. public List<Map<String, Object>> warehouseBillsFeesList(TWareHouseFees tWareHouseFees) {
  153. Map<String, Object> map = new HashMap<>();
  154. map.put("tWareHouseFees", tWareHouseFees);
  155. return tFeeMapper.warehouseBillsFeesList(map);
  156. }
  157. }