WarehouseService.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.WarehouseConvert;
  8. import com.dk.mdm.model.pojo.mst.Warehouse;
  9. import com.dk.mdm.mapper.mst.WarehouseMapper;
  10. import com.dk.common.service.BaseService;
  11. import com.dk.common.mapper.BaseMapper;
  12. import com.dk.mdm.model.query.mst.WarehouseQuery;
  13. import com.dk.mdm.model.response.mst.WarehouseResponse;
  14. import com.dk.mdm.model.vo.mst.WarehouseVO;
  15. import com.dk.mdm.service.common.CommonService;
  16. import org.springframework.stereotype.Service;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.transaction.annotation.Transactional;
  19. import java.util.Map;
  20. @Service
  21. @Transactional
  22. public class WarehouseService extends BaseService<Warehouse> {
  23. @Override
  24. public BaseMapper<Warehouse> getRepository() {
  25. return warehouseMapper;
  26. }
  27. @Autowired
  28. private WarehouseMapper warehouseMapper;
  29. @Autowired
  30. private CommonService commonService;
  31. @Autowired
  32. private WarehouseConvert warehouseConvert;
  33. /**
  34. * @desc : 重写主键
  35. * @author : 于继渤
  36. * @date : 2024/2/29 20:29
  37. */
  38. @Override
  39. public String getPrimaryKey() {
  40. return "wh_id";
  41. }
  42. /**
  43. * @desc : 查询
  44. * @author : 于继渤
  45. * @date : 2023/1/5 9:39
  46. */
  47. @Pagination
  48. public ResponseResultVO<PageList<WarehouseResponse>> selectByCond(WarehouseQuery warehouseQuery) {
  49. return super.mergeListWithCount(warehouseQuery, warehouseMapper.selectByCond(warehouseQuery),
  50. warehouseMapper.countByCond(warehouseQuery));
  51. }
  52. /**
  53. * @desc : 新建
  54. * @author : 于继渤
  55. * @date : 2023/1/5 9:39
  56. */
  57. @Transactional(
  58. rollbackFor = {Exception.class}
  59. )
  60. public ResponseResultVO<?> insert(WarehouseVO warehouseVO) {
  61. //实体转换
  62. Warehouse warehouse = warehouseConvert.convertToPo(warehouseVO);
  63. Integer displayNo = warehouseMapper.selectDisplayNo(new WarehouseQuery());
  64. if (displayNo != null) {
  65. //插入序号
  66. warehouse.setDisplayNo(displayNo);
  67. } else {
  68. warehouse.setDisplayNo(0);
  69. }
  70. //设置编码
  71. Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.WAREHOUSE.getName(), true);
  72. warehouse.setWhId(uniqueNoteCode.get("outId").toString());
  73. warehouse.setWhCode(uniqueNoteCode.get("outNote").toString());
  74. //新建
  75. warehouseMapper.insert(warehouse);
  76. return ResponseResultUtil.success();
  77. }
  78. /**
  79. * @desc : 编辑
  80. * @author : 于继渤
  81. * @date : 2023/1/5 9:39
  82. */
  83. @Transactional(
  84. rollbackFor = {Exception.class}
  85. )
  86. public ResponseResultVO<?> update(WarehouseVO warehouseVO) {
  87. Warehouse warehouse = warehouseConvert.convertToPo(warehouseVO);
  88. super.updateByUuid(warehouse);
  89. return ResponseResultUtil.success();
  90. }
  91. }