package com.dk.mdm.service.mst; import com.dk.common.infrastructure.annotaiton.Pagination; import com.dk.common.infrastructure.constant.Constant; import com.dk.common.model.pojo.PageList; import com.dk.common.response.ResponseResultUtil; import com.dk.common.response.ResponseResultVO; import com.dk.mdm.infrastructure.convert.mst.WarehouseConvert; import com.dk.mdm.model.pojo.mst.Warehouse; import com.dk.mdm.mapper.mst.WarehouseMapper; import com.dk.common.service.BaseService; import com.dk.common.mapper.BaseMapper; import com.dk.mdm.model.query.mst.WarehouseQuery; import com.dk.mdm.model.response.mst.WarehouseResponse; import com.dk.mdm.model.vo.mst.WarehouseVO; import com.dk.mdm.service.common.CommonService; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import java.util.Map; @Service @Transactional public class WarehouseService extends BaseService { @Override public BaseMapper getRepository() { return warehouseMapper; } @Autowired private WarehouseMapper warehouseMapper; @Autowired private CommonService commonService; @Autowired private WarehouseConvert warehouseConvert; /** * @desc : 重写主键 * @author : 于继渤 * @date : 2024/2/29 20:29 */ @Override public String getPrimaryKey() { return "wh_id"; } /** * @desc : 查询 * @author : 于继渤 * @date : 2023/1/5 9:39 */ @Pagination public ResponseResultVO> selectByCond(WarehouseQuery warehouseQuery) { return super.mergeListWithCount(warehouseQuery, warehouseMapper.selectByCond(warehouseQuery), warehouseMapper.countByCond(warehouseQuery)); } /** * @desc : 新建 * @author : 于继渤 * @date : 2023/1/5 9:39 */ @Transactional( rollbackFor = {Exception.class} ) public ResponseResultVO insert(WarehouseVO warehouseVO) { //实体转换 Warehouse warehouse = warehouseConvert.convertToPo(warehouseVO); Integer displayNo = warehouseMapper.selectDisplayNo(new WarehouseQuery()); if (displayNo != null) { //插入序号 warehouse.setDisplayNo(displayNo); } else { warehouse.setDisplayNo(0); } //设置编码 Map uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.WAREHOUSE.getName(), true); warehouse.setWhId(uniqueNoteCode.get("outId").toString()); warehouse.setWhCode(uniqueNoteCode.get("outNote").toString()); //新建 warehouseMapper.insert(warehouse); return ResponseResultUtil.success(); } /** * @desc : 编辑 * @author : 于继渤 * @date : 2023/1/5 9:39 */ @Transactional( rollbackFor = {Exception.class} ) public ResponseResultVO update(WarehouseVO warehouseVO) { Warehouse warehouse = warehouseConvert.convertToPo(warehouseVO); super.updateByUuid(warehouse); return ResponseResultUtil.success(); } }