update 添加示方书维护、文件上传下载
parent
7d6528e4d9
commit
3e2eca569a
@ -0,0 +1,117 @@
|
|||||||
|
package org.dromara.mes.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
|
import org.dromara.mes.domain.vo.ProdSamplePrescriptionVo;
|
||||||
|
import org.dromara.mes.domain.bo.ProdSamplePrescriptionBo;
|
||||||
|
import org.dromara.mes.service.IProdSamplePrescriptionService;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 示方书维护
|
||||||
|
* 前端访问路由地址为:/mes/samplePrescription
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
* @date 2025-02-27
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/samplePrescription")
|
||||||
|
public class ProdSamplePrescriptionController extends BaseController {
|
||||||
|
|
||||||
|
private final IProdSamplePrescriptionService prodSamplePrescriptionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询示方书维护列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("mes:samplePrescription:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<ProdSamplePrescriptionVo> list(ProdSamplePrescriptionBo bo, PageQuery pageQuery) {
|
||||||
|
return prodSamplePrescriptionService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出示方书维护列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("mes:samplePrescription:export")
|
||||||
|
@Log(title = "示方书维护", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(ProdSamplePrescriptionBo bo, HttpServletResponse response) {
|
||||||
|
List<ProdSamplePrescriptionVo> list = prodSamplePrescriptionService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "示方书维护", ProdSamplePrescriptionVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取示方书维护详细信息
|
||||||
|
*
|
||||||
|
* @param sampleId 主键
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("mes:samplePrescription:query")
|
||||||
|
@GetMapping("/{sampleId}")
|
||||||
|
public R<ProdSamplePrescriptionVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long sampleId) {
|
||||||
|
return R.ok(prodSamplePrescriptionService.queryById(sampleId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增示方书维护
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("mes:samplePrescription:add")
|
||||||
|
@Log(title = "示方书维护", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody ProdSamplePrescriptionBo bo) {
|
||||||
|
return toAjax(prodSamplePrescriptionService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改示方书维护
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("mes:samplePrescription:edit")
|
||||||
|
@Log(title = "示方书维护", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ProdSamplePrescriptionBo bo) {
|
||||||
|
return toAjax(prodSamplePrescriptionService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除示方书维护
|
||||||
|
*
|
||||||
|
* @param sampleIds 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("mes:samplePrescription:remove")
|
||||||
|
@Log(title = "示方书维护", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{sampleIds}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] sampleIds) {
|
||||||
|
return toAjax(prodSamplePrescriptionService.deleteWithValidByIds(List.of(sampleIds), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下拉框查询示方书维护列表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@GetMapping("/getProdSamplePrescriptionList")
|
||||||
|
public R<List<ProdSamplePrescriptionVo>> getProdSamplePrescriptionList(ProdSamplePrescriptionBo bo) {
|
||||||
|
List<ProdSamplePrescriptionVo> list = prodSamplePrescriptionService.queryList(bo);
|
||||||
|
return R.ok(list);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.dromara.mes.mapper;
|
||||||
|
|
||||||
|
import org.dromara.mes.domain.ProdSamplePrescription;
|
||||||
|
import org.dromara.mes.domain.vo.ProdSamplePrescriptionVo;
|
||||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 示方书维护Mapper接口
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
* @date 2025-02-27
|
||||||
|
*/
|
||||||
|
public interface ProdSamplePrescriptionMapper extends BaseMapperPlus<ProdSamplePrescription, ProdSamplePrescriptionVo> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package org.dromara.mes.service;
|
||||||
|
|
||||||
|
import org.dromara.mes.domain.vo.ProdSamplePrescriptionVo;
|
||||||
|
import org.dromara.mes.domain.bo.ProdSamplePrescriptionBo;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 示方书维护Service接口
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
* @date 2025-02-27
|
||||||
|
*/
|
||||||
|
public interface IProdSamplePrescriptionService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询示方书维护
|
||||||
|
*
|
||||||
|
* @param sampleId 主键
|
||||||
|
* @return 示方书维护
|
||||||
|
*/
|
||||||
|
ProdSamplePrescriptionVo queryById(Long sampleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询示方书维护列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 示方书维护分页列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<ProdSamplePrescriptionVo> queryPageList(ProdSamplePrescriptionBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的示方书维护列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 示方书维护列表
|
||||||
|
*/
|
||||||
|
List<ProdSamplePrescriptionVo> queryList(ProdSamplePrescriptionBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增示方书维护
|
||||||
|
*
|
||||||
|
* @param bo 示方书维护
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(ProdSamplePrescriptionBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改示方书维护
|
||||||
|
*
|
||||||
|
* @param bo 示方书维护
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(ProdSamplePrescriptionBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除示方书维护信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
package org.dromara.mes.service.impl;
|
||||||
|
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.yulichang.toolkit.JoinWrappers;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.mes.domain.*;
|
||||||
|
import org.dromara.mes.domain.bo.ProdTechnologyInfoBo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.dromara.mes.domain.bo.ProdSamplePrescriptionBo;
|
||||||
|
import org.dromara.mes.domain.vo.ProdSamplePrescriptionVo;
|
||||||
|
import org.dromara.mes.mapper.ProdSamplePrescriptionMapper;
|
||||||
|
import org.dromara.mes.service.IProdSamplePrescriptionService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 示方书维护Service业务层处理
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
* @date 2025-02-27
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class ProdSamplePrescriptionServiceImpl implements IProdSamplePrescriptionService {
|
||||||
|
|
||||||
|
private final ProdSamplePrescriptionMapper baseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询示方书维护
|
||||||
|
*
|
||||||
|
* @param sampleId 主键
|
||||||
|
* @return 示方书维护
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ProdSamplePrescriptionVo queryById(Long sampleId) {
|
||||||
|
ProdSamplePrescriptionBo bo = new ProdSamplePrescriptionBo();
|
||||||
|
bo.setSampleId(sampleId);
|
||||||
|
MPJLambdaWrapper<ProdSamplePrescription> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoOne(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询示方书维护列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 示方书维护分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<ProdSamplePrescriptionVo> queryPageList(ProdSamplePrescriptionBo bo, PageQuery pageQuery) {
|
||||||
|
MPJLambdaWrapper<ProdSamplePrescription> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<ProdSamplePrescriptionVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的示方书维护列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 示方书维护列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProdSamplePrescriptionVo> queryList(ProdSamplePrescriptionBo bo) {
|
||||||
|
MPJLambdaWrapper<ProdSamplePrescription> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MPJLambdaWrapper<ProdSamplePrescription> buildQueryWrapper(ProdSamplePrescriptionBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
MPJLambdaWrapper<ProdSamplePrescription> lqw = JoinWrappers.lambda(ProdSamplePrescription.class)
|
||||||
|
.selectAll(ProdSamplePrescription.class)
|
||||||
|
.select(ProdBaseProcessInfo::getProcessName)
|
||||||
|
.select(BaseMaterialInfo::getMaterialName)
|
||||||
|
.leftJoin(ProdBaseProcessInfo.class, ProdBaseProcessInfo::getProcessId, ProdSamplePrescription::getProcessId)
|
||||||
|
.leftJoin(BaseMaterialInfo.class, BaseMaterialInfo::getMaterialId, ProdSamplePrescription::getMaterialId)
|
||||||
|
.eq(bo.getSampleId() != null, ProdSamplePrescription::getSampleId, bo.getSampleId())
|
||||||
|
.eq(bo.getProcessId() != null, ProdSamplePrescription::getProcessId, bo.getProcessId())
|
||||||
|
.eq(bo.getMaterialId() != null, ProdSamplePrescription::getMaterialId, bo.getMaterialId())
|
||||||
|
.eq(bo.getMaterialBomId() != null, ProdSamplePrescription::getMaterialBomId, bo.getMaterialBomId())
|
||||||
|
.eq(bo.getTechnologyId() != null, ProdSamplePrescription::getTechnologyId, bo.getTechnologyId())
|
||||||
|
.eq(bo.getOosId() != null, ProdSamplePrescription::getOosId, bo.getOosId())
|
||||||
|
.like(StringUtils.isNotBlank(bo.getOriginalName()), ProdSamplePrescription::getOriginalName, bo.getOriginalName())
|
||||||
|
.eq(StringUtils.isNotBlank(bo.getFileUrl()), ProdSamplePrescription::getFileUrl, bo.getFileUrl())
|
||||||
|
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ProdSamplePrescription::getActiveFlag, bo.getActiveFlag())
|
||||||
|
.eq(bo.getCreateBy() != null, ProdSamplePrescription::getCreateBy, bo.getCreateBy())
|
||||||
|
.eq(bo.getCreateTime() != null, ProdSamplePrescription::getCreateTime, bo.getCreateTime())
|
||||||
|
.orderByAsc(ProdSamplePrescription::getCreateTime);
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增示方书维护
|
||||||
|
*
|
||||||
|
* @param bo 示方书维护
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(ProdSamplePrescriptionBo bo) {
|
||||||
|
ProdSamplePrescription add = MapstructUtils.convert(bo, ProdSamplePrescription.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setSampleId(add.getSampleId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改示方书维护
|
||||||
|
*
|
||||||
|
* @param bo 示方书维护
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(ProdSamplePrescriptionBo bo) {
|
||||||
|
ProdSamplePrescription update = MapstructUtils.convert(bo, ProdSamplePrescription.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(ProdSamplePrescription entity) {
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除示方书维护信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if (isValid) {
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.dromara.mes.mapper.ProdSamplePrescriptionMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue