DictionaryDataService.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package com.dk.mdm.service.mst;
  2. import com.dk.common.infrastructure.annotaiton.Pagination;
  3. import com.dk.common.infrastructure.constant.Constant;
  4. import com.dk.common.model.pojo.PageList;
  5. import com.dk.common.response.ResponseResultUtil;
  6. import com.dk.common.response.ResponseResultVO;
  7. import com.dk.mdm.infrastructure.convert.mst.DictionaryDataConvert;
  8. import com.dk.mdm.mapper.mst.MoneyAccountMapper;
  9. import com.dk.mdm.model.pojo.mst.DictionaryData;
  10. import com.dk.mdm.mapper.mst.DictionaryDataMapper;
  11. import com.dk.common.service.BaseService;
  12. import com.dk.common.mapper.BaseMapper;
  13. import com.dk.mdm.model.query.mst.DictionaryDataQuery;
  14. import com.dk.mdm.model.query.mst.MoneyAccountQuery;
  15. import com.dk.mdm.model.response.mst.DictionaryDataResponse;
  16. import com.dk.mdm.model.vo.mst.DictionaryDataVO;
  17. import com.dk.mdm.model.vo.mst.WarehouseVO;
  18. import com.dk.mdm.service.common.CommonService;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import java.util.HashMap;
  23. import java.util.List;
  24. import java.util.Map;
  25. @Service
  26. @Transactional
  27. public class DictionaryDataService extends BaseService<DictionaryData> {
  28. @Override
  29. public BaseMapper<DictionaryData> getRepository() {
  30. return dictionaryDataMapper;
  31. }
  32. @Autowired
  33. private DictionaryDataMapper dictionaryDataMapper;
  34. @Autowired
  35. private CommonService commonService;
  36. @Autowired
  37. private DictionaryDataConvert dictionaryDataConvert;
  38. @Autowired
  39. private MoneyAccountMapper moneyAccountMapper;
  40. /**
  41. * @desc : 重写主键
  42. * @author : 于继渤
  43. * @date : 2024/2/29 20:29
  44. */
  45. @Override
  46. public String getPrimaryKey() {
  47. return "data_id";
  48. }
  49. /**
  50. * @desc : 查询
  51. * @author : 于继渤
  52. * @date : 2023/1/5 9:39
  53. */
  54. @Pagination
  55. public ResponseResultVO<PageList<DictionaryDataResponse>> selectByCond(DictionaryDataQuery dictionaryDataQuery) {
  56. return super.mergeListWithCount(dictionaryDataQuery, dictionaryDataMapper.selectByCond(dictionaryDataQuery),
  57. dictionaryDataMapper.countByCond(dictionaryDataQuery));
  58. }
  59. public ResponseResultVO<Long> countByCondMoneyAccount(String id) {
  60. Long aLong = dictionaryDataMapper.countByCondMoneyAccount(id);
  61. return ResponseResultUtil.success(aLong);
  62. }
  63. /**
  64. * @desc : 新建
  65. * @author : 于继渤
  66. * @date : 2023/1/5 9:39
  67. */
  68. @Transactional(
  69. rollbackFor = {Exception.class}
  70. )
  71. public ResponseResultVO<?> insert(DictionaryDataVO dictionaryDataVO) {
  72. //实体转换
  73. DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
  74. Map<String, Object> map = new HashMap<>();
  75. map.put("dictCode",dictionaryDataVO.getDictCode());
  76. //设置序号
  77. dictionaryData.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.DICTIONARYDATA,map));
  78. //设置编码
  79. Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(dictionaryDataVO.getDictCode(), true);
  80. dictionaryData.setDataId(uniqueNoteCode.get("outId").toString());
  81. dictionaryData.setDataCode(uniqueNoteCode.get("outNote").toString());
  82. //新建
  83. dictionaryDataMapper.insert(dictionaryData);
  84. return ResponseResultUtil.success();
  85. }
  86. /**
  87. * @desc : 编辑
  88. * @author : 于继渤
  89. * @date : 2023/1/5 9:39
  90. */
  91. @Transactional(
  92. rollbackFor = {Exception.class}
  93. )
  94. public ResponseResultVO<?> update(DictionaryDataVO dictionaryDataVO) {
  95. DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
  96. super.updateByUuid(dictionaryData);
  97. return ResponseResultUtil.success();
  98. }
  99. /**
  100. * @desc : 批量编辑序号
  101. * @author : 于继渤
  102. * @date : 2023/1/4 9:39
  103. */
  104. @Transactional(
  105. rollbackFor = {Exception.class}
  106. )
  107. public ResponseResultVO<?> updateBatchDictionaryDataDisplayNo(DictionaryDataVO dictionaryDataVO) {
  108. dictionaryDataMapper.updateBatchDictionaryDataDisplayNo(dictionaryDataVO.getDataIds());
  109. return ResponseResultUtil.success();
  110. }
  111. }