This commit is contained in:
xiao-fajia 2024-09-18 15:05:09 +08:00
commit 20b79ec1ca
8 changed files with 122 additions and 74 deletions

View File

@ -1,8 +1,6 @@
package cn.iocoder.yudao.module.project.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import cn.iocoder.yudao.module.project.service.RepairWaresService;
import cn.iocoder.yudao.module.project.vo.RepairWaresPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairWaresRespVO;
@ -41,8 +39,9 @@ public class RepairWaresController {
@PostMapping("/create")
@Operation(summary = "创建配件库")
@PreAuthorize("@ss.hasPermission('repair:wares:create')")
public CommonResult<String> createWares(@Valid @RequestBody RepairWaresSaveReqVO createReqVO) {
return success(waresService.createWares(createReqVO));
public CommonResult<Boolean> createWares(@Valid @RequestBody RepairWaresSaveReqVO createReqVO) {
waresService.saveWares(createReqVO);
return success(true);
}
/**
@ -57,7 +56,7 @@ public class RepairWaresController {
@Operation(summary = "更新配件库")
@PreAuthorize("@ss.hasPermission('repair:wares:update')")
public CommonResult<Boolean> updateWares(@Valid @RequestBody RepairWaresSaveReqVO updateReqVO) {
waresService.updateWares(updateReqVO);
waresService.saveWares(updateReqVO);
return success(true);
}
@ -91,8 +90,7 @@ public class RepairWaresController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('repair:wares:query')")
public CommonResult<RepairWaresRespVO> getWares(@RequestParam("id") String id) {
RepairWares wares = waresService.getWares(id);
return success(BeanUtils.toBean(wares, RepairWaresRespVO.class));
return success(waresService.getWares(id));
}
/**

View File

@ -98,5 +98,9 @@ public class RepairWares extends TenantBaseDO {
* 备注
*/
private String remark;
/**状态*/
private String status;
/**数据来源*/
private String dataForm;
}

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.project.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import cn.iocoder.yudao.module.project.vo.RepairWaresPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairWaresRespVO;
@ -16,42 +15,42 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface RepairWaresService extends IService<RepairWares> {
/**
* 创建配件库
*
* @param createReqVO 创建信息
* @return 编号
*/
String createWares(RepairWaresSaveReqVO createReqVO);
/**
* 更新配件库
* 保存配件库
*
* @param updateReqVO 更新信息
*/
void updateWares(RepairWaresSaveReqVO updateReqVO);
* @param saveReqVO RepairWaresSaveReqVO实体
* @author PQZ
* @date 9:33 2024/9/18
**/
void saveWares(RepairWaresSaveReqVO saveReqVO);
/**
* 删除配件库
*
* @param id 编号
*/
* @param id 配件id
* @author PQZ
* @date 9:37 2024/9/18
**/
void deleteWares(String id);
/**
* 获得配件库
* 根据id获取配件信息
*
* @param id 编号
* @return 配件库
*/
RepairWares getWares(String id);
* @param id id
* @return cn.iocoder.yudao.module.project.vo.RepairWaresRespVO
* @author PQZ
* @date 10:52 2024/9/18
**/
RepairWaresRespVO getWares(String id);
/**
* 获得配件库分页
* 分页获取配件库
*
* @param pageReqVO 分页查询
* @return 配件库分页
*/
* @param pageReqVO RepairWaresPageReqVO实体
* @param page 分页信息
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.project.vo.RepairWaresRespVO>
* @author PQZ
* @date 10:53 2024/9/18
**/
IPage<RepairWaresRespVO> getWaresPage(RepairWaresPageReqVO pageReqVO, Page<RepairWaresRespVO> page);
}

View File

@ -10,10 +10,12 @@ import cn.iocoder.yudao.module.project.vo.RepairWaresSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Arrays;
/**
* 配件库 Service 实现类
@ -27,37 +29,63 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
@Resource
private RepairWaresMapper waresMapper;
/**
* 保存配件库
*
* @param saveReqVO RepairWaresSaveReqVO实体
* @author PQZ
* @date 9:33 2024/9/18
**/
@Override
public String createWares(RepairWaresSaveReqVO createReqVO) {
// 插入
RepairWares wares = BeanUtils.toBean(createReqVO, RepairWares.class);
waresMapper.insert(wares);
// 返回
return wares.getId();
}
@Override
public void updateWares(RepairWaresSaveReqVO updateReqVO) {
// 更新
RepairWares updateObj = BeanUtils.toBean(updateReqVO, RepairWares.class);
waresMapper.updateById(updateObj);
public void saveWares(RepairWaresSaveReqVO saveReqVO) {
RepairWares repairWares = BeanUtils.toBean(saveReqVO, RepairWares.class);
saveOrUpdate(repairWares);
}
/**
* @param id 配件id
* @author PQZ
* @date 9:37 2024/9/18
**/
@Override
public void deleteWares(String id) {
// 删除
waresMapper.deleteById(id);
}
/**
* 根据id获取配件信息
*
* @param id id
* @return cn.iocoder.yudao.module.project.vo.RepairWaresRespVO
* @author PQZ
* @date 10:52 2024/9/18
**/
@Override
public RepairWares getWares(String id) {
return waresMapper.selectById(id);
public RepairWaresRespVO getWares(String id) {
//基本信息
RepairWares repairWares = getById(id);
RepairWaresRespVO result = BeanUtils.toBean(repairWares, RepairWaresRespVO.class);
//关联子公司转换
if (StringUtils.isNotBlank(result.getCorpId())) {
result.setCorpIds(Arrays.asList(result.getCorpId().split(",")));
}
return result;
}
/**
* 分页获取配件库
*
* @param pageReqVO RepairWaresPageReqVO实体
* @param page 分页信息
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.project.vo.RepairWaresRespVO>
* @author PQZ
* @date 10:53 2024/9/18
**/
@Override
public IPage<RepairWaresRespVO> getWaresPage(RepairWaresPageReqVO pageReqVO, Page<RepairWaresRespVO> page) {
return waresMapper.queryListPage(pageReqVO,page);
return waresMapper.queryListPage(pageReqVO, page);
}
}

View File

@ -1,20 +1,15 @@
package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import lombok.*;
import java.util.*;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 配件库分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RepairWaresPageReqVO extends RepairProject {
public class RepairWaresPageReqVO extends RepairWares {
}

View File

@ -1,17 +1,24 @@
package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Schema(description = "管理后台 - 配件库 Response VO")
@Data
@ExcelIgnoreUnannotated
public class RepairWaresRespVO extends RepairProject {
public class RepairWaresRespVO extends RepairWares {
/**分公司*/
private String corpNames;
/**类型名称*/
private String typeName;
/**类型名称*/
private String warehouseName;
/**关联子公司*/
List<String> corpIds = new ArrayList<>();
}

View File

@ -1,15 +1,13 @@
package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.entity.RepairWares;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import lombok.Data;
@Schema(description = "管理后台 - 配件库新增/修改 Request VO")
@Data
public class RepairWaresSaveReqVO extends RepairProject {
public class RepairWaresSaveReqVO extends RepairWares {
}

View File

@ -9,6 +9,25 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="queryListPage" resultType="cn.iocoder.yudao.module.project.vo.RepairWaresRespVO">
SELECT
drw.*,
dbt.`name` AS typeName,
dbw.`name` AS warehouseName,
GROUP_CONCAT( bc.corp_name ) AS corpNames
FROM
dl_repair_wares drw
LEFT JOIN base_company bc ON FIND_IN_SET( bc.id, drw.corp_id ) > 0
LEFT JOIN dl_base_type dbt ON drw.type = dbt.id AND dbt.deleted = 0
LEFT JOIN dl_base_warehouse dbw ON drw.warehouse = dbw.id AND dbw.deleted = 0
<where>
drw.deleted = 0
<if test="entity.name != null and entity.name != ''">
and drw.name = #{entity.name}
</if>
</where>
GROUP BY
drw.id
ORDER BY
drw.create_time DESC
</select>
</mapper>