临时提交(报表,在做选择单价)

This commit is contained in:
磷叶 2024-10-18 18:08:14 +08:00
parent 7d833113b0
commit dd3cdb75d0
15 changed files with 838 additions and 96 deletions

View File

@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
/**
* Entity基类
*
*
* @author ruoyi
*/
public class BaseEntity implements Serializable
@ -38,10 +38,21 @@ public class BaseEntity implements Serializable
/** 备注 */
private String remark;
/** 是否需要数据隔离 */
private Boolean needScope;
/** 请求参数 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> params;
public Boolean getNeedScope() {
return needScope;
}
public void setNeedScope(Boolean needScope) {
this.needScope = needScope;
}
public String getSearchValue()
{
return searchValue;

View File

@ -2,6 +2,8 @@ package com.ruoyi.framework.aspectj;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.framework.util.DataScopeUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
@ -26,30 +28,6 @@ import com.ruoyi.framework.security.context.PermissionContextHolder;
@Component
public class DataScopeAspect
{
/**
* 全部数据权限
*/
public static final String DATA_SCOPE_ALL = "1";
/**
* 自定数据权限
*/
public static final String DATA_SCOPE_CUSTOM = "2";
/**
* 部门数据权限
*/
public static final String DATA_SCOPE_DEPT = "3";
/**
* 部门及以下数据权限
*/
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
/**
* 仅本人数据权限
*/
public static final String DATA_SCOPE_SELF = "5";
/**
* 数据权限过滤关键字
@ -90,81 +68,22 @@ public class DataScopeAspect
*/
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission)
{
StringBuilder sqlString = new StringBuilder();
List<String> conditions = new ArrayList<String>();
List<String> scopeCustomIds = new ArrayList<String>();
user.getRoles().forEach(role -> {
if (DATA_SCOPE_CUSTOM.equals(role.getDataScope()) && StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL) && StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
{
scopeCustomIds.add(Convert.toStr(role.getRoleId()));
}
});
for (SysRole role : user.getRoles())
{
String dataScope = role.getDataScope();
if (conditions.contains(dataScope) || StringUtils.equals(role.getStatus(), UserConstants.ROLE_DISABLE))
{
continue;
}
if (!StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
{
continue;
}
if (DATA_SCOPE_ALL.equals(dataScope))
{
sqlString = new StringBuilder();
conditions.add(dataScope);
break;
}
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
{
if (scopeCustomIds.size() > 1)
{
// 多个自定数据权限使用in查询避免多次拼接
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptAlias, String.join(",", scopeCustomIds)));
}
else
{
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId()));
}
}
else if (DATA_SCOPE_DEPT.equals(dataScope))
{
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
}
else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
{
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId()));
}
else if (DATA_SCOPE_SELF.equals(dataScope))
{
if (StringUtils.isNotBlank(userAlias))
{
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
}
else
{
// 数据权限为仅本人且没有userAlias别名不查询任何数据
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
}
}
conditions.add(dataScope);
}
// 角色都不包含传递过来的权限字符这个时候sqlString也会为空所以要限制一下,不查询任何数据
if (StringUtils.isEmpty(conditions))
{
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
}
StringBuilder sqlString = DataScopeUtil.getSqlString(user, deptAlias, userAlias, permission);
JoinSqlString(joinPoint, sqlString);
}
/**
* 将sql拼接
* @param joinPoint 切点
* @param sqlString sql字符串
*/
private static void JoinSqlString(JoinPoint joinPoint, StringBuilder sqlString) {
if (StringUtils.isNotBlank(sqlString.toString()))
{
Object params = joinPoint.getArgs()[0];
if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
{
BaseEntity baseEntity = (BaseEntity) params;
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
DataScopeUtil.joinSqlString((BaseEntity) params, sqlString);
}
}
}

View File

@ -0,0 +1,153 @@
package com.ruoyi.framework.util;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.security.context.PermissionContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* @author wjh
* 2024/6/13
* 更新时间 2024-10-18
*/
public class DataScopeUtil {
/**
* 数据权限过滤关键字
*/
public static final String DATA_SCOPE = "dataScope";
/**
* 全部数据权限
*/
public static final String DATA_SCOPE_ALL = "1";
/**
* 自定数据权限
*/
public static final String DATA_SCOPE_CUSTOM = "2";
/**
* 部门数据权限
*/
public static final String DATA_SCOPE_DEPT = "3";
/**
* 部门及以下数据权限
*/
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
/**
* 仅本人数据权限
*/
public static final String DATA_SCOPE_SELF = "5";
public static String dataScope(String deptAlias, String userAlias, boolean needScope) {
if (needScope) {
// 获取当前的用户
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNotNull(loginUser))
{
SysUser currentUser = loginUser.getUser();
// 如果是超级管理员则不过滤数据
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
{
StringBuilder sqlString = getSqlString(currentUser, deptAlias, userAlias, PermissionContextHolder.getContext());
return getJoinSqlString(sqlString, "");
}
}
}
return "";
}
public static StringBuilder getSqlString(SysUser user, String deptAlias, String userAlias, String permission) {
StringBuilder sqlString = new StringBuilder();
List<String> conditions = new ArrayList<String>();
List<String> scopeCustomIds = new ArrayList<String>();
user.getRoles().forEach(role -> {
if (DATA_SCOPE_CUSTOM.equals(role.getDataScope()) && StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL) && StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
{
scopeCustomIds.add(Convert.toStr(role.getRoleId()));
}
});
for (SysRole role : user.getRoles())
{
String dataScope = role.getDataScope();
if (conditions.contains(dataScope) || StringUtils.equals(role.getStatus(), UserConstants.ROLE_DISABLE))
{
continue;
}
if (!StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
{
continue;
}
if (DATA_SCOPE_ALL.equals(dataScope))
{
sqlString = new StringBuilder();
conditions.add(dataScope);
break;
}
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
{
if (scopeCustomIds.size() > 1)
{
// 多个自定数据权限使用in查询避免多次拼接
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptAlias, String.join(",", scopeCustomIds)));
}
else
{
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId()));
}
}
else if (DATA_SCOPE_DEPT.equals(dataScope))
{
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
}
else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
{
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId()));
}
else if (DATA_SCOPE_SELF.equals(dataScope))
{
if (StringUtils.isNotBlank(userAlias))
{
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
}
else
{
// 数据权限为仅本人且没有userAlias别名不查询任何数据
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
}
}
conditions.add(dataScope);
}
// 角色都不包含传递过来的权限字符这个时候sqlString也会为空所以要限制一下,不查询任何数据
if (StringUtils.isEmpty(conditions))
{
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
}
return sqlString;
}
public static void joinSqlString(BaseEntity baseEntity, StringBuilder sqlString) {
String scope = (String) baseEntity.getParams().get(DATA_SCOPE);
baseEntity.getParams().put(DATA_SCOPE, getJoinSqlString(sqlString, scope));
}
private static String getJoinSqlString(StringBuilder sqlString, String scope) {
return " AND (" + scope + sqlString.substring(4) + ")";
}
}

View File

@ -50,6 +50,17 @@ public class PriceController extends BaseController
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('yh:price:list')")
@PostMapping("/listByIds")
public AjaxResult listByIds(@RequestBody List<Long> priceIds)
{
PriceQuery query = new PriceQuery();
query.setPriceIds(priceIds);
query.setNeedScope(true);
List<PriceVO> list = priceService.selectPriceList(query);
return success(list);
}
@PreAuthorize("@ss.hasPermi('yh:price:export')")
@Log(title = "单价", businessType = BusinessType.EXPORT)
@PostMapping("/export")

View File

@ -17,4 +17,7 @@ public class PriceQuery extends PriceVO {
@ApiModelProperty("状态列表")
private List<String> statusList;
@ApiModelProperty("单价ID列表")
private List<Long> priceIds;
}

View File

@ -65,6 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="query.priceIds != null and query.priceIds.size() > 0">
and bp.price_id in
<foreach item="item" collection="query.priceIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope("sd", null, query.needScope)}
${query.params.dataScope}
</sql>

View File

@ -26,7 +26,7 @@ public class PriceConverterImpl implements PriceConverter {
LoginUser loginUser = SecurityUtils.getLoginUser();
Price po = new Price();
po.setStatus(PriceStatus.WAIT_SUBMIT.getStatus());
po.setStatus(PriceStatus.WAIT_VERIFY.getStatus());
po.setDisabled(false);
po.setDeptId(data.getDeptId());
po.setCategory(data.getCategory());
@ -53,7 +53,7 @@ public class PriceConverterImpl implements PriceConverter {
LoginUser loginUser = SecurityUtils.getLoginUser();
Price po = new Price();
po.setStatus(PriceStatus.WAIT_SUBMIT.getStatus());
po.setStatus(PriceStatus.WAIT_VERIFY.getStatus());
po.setPriceId(data.getPriceId());
po.setDeptId(data.getDeptId());
po.setCategory(data.getCategory());

View File

@ -0,0 +1,107 @@
package com.ruoyi.web.yh.report.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.yh.report.domain.Report;
import com.ruoyi.web.yh.report.domain.ReportVO;
import com.ruoyi.web.yh.report.domain.ReportQuery;
import com.ruoyi.web.yh.report.service.IReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 报表Controller
*
* @author ruoyi
* @date 2024-10-18
*/
@RestController
@RequestMapping("/yh/report")
public class ReportController extends BaseController
{
@Autowired
private IReportService reportService;
/**
* 查询报表列表
*/
@PreAuthorize("@ss.hasPermi('yh:report:list')")
@GetMapping("/list")
public TableDataInfo list(ReportQuery query)
{
startPage();
startOrderBy();
List<ReportVO> list = reportService.selectReportList(query);
return getDataTable(list);
}
/**
* 导出报表列表
*/
@PreAuthorize("@ss.hasPermi('yh:report:export')")
@Log(title = "报表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ReportQuery query)
{
List<ReportVO> list = reportService.selectReportList(query);
ExcelUtil<ReportVO> util = new ExcelUtil<ReportVO>(ReportVO.class);
util.exportExcel(response, list, "报表数据");
}
/**
* 获取报表详细信息
*/
@PreAuthorize("@ss.hasPermi('yh:report:query')")
@GetMapping(value = "/{reportId}")
public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
{
return success(reportService.selectReportByReportId(reportId));
}
/**
* 新增报表
*/
@PreAuthorize("@ss.hasPermi('yh:report:add')")
@Log(title = "报表", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Report report)
{
return toAjax(reportService.insertReport(report));
}
/**
* 修改报表
*/
@PreAuthorize("@ss.hasPermi('yh:report:edit')")
@Log(title = "报表", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Report report)
{
return toAjax(reportService.updateReport(report));
}
/**
* 删除报表
*/
@PreAuthorize("@ss.hasPermi('yh:report:remove')")
@Log(title = "报表", businessType = BusinessType.DELETE)
@DeleteMapping("/{reportIds}")
public AjaxResult remove(@PathVariable Long[] reportIds)
{
return toAjax(reportService.deleteReportByReportIds(reportIds));
}
}

View File

@ -0,0 +1,103 @@
package com.ruoyi.web.yh.report.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 报表对象 bst_report
*
* @author ruoyi
* @date 2024-10-18
*/
@Data
public class Report extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long reportId;
@Excel(name = "部门ID")
@ApiModelProperty("部门ID")
private Long deptId;
@Excel(name = "工序完成数量")
@ApiModelProperty("工序完成数量")
private BigDecimal num;
@Excel(name = "状态", readConverterExp = "1=未提交,2=待审核,3=已通过,4=已驳回")
@ApiModelProperty("状态")
private String status;
@Excel(name = "单价ID")
@ApiModelProperty("单价ID")
private Long priceId;
@Excel(name = "单价类别")
@ApiModelProperty("单价类别")
private String priceCategory;
@Excel(name = "单价大小")
@ApiModelProperty("单价大小")
private String priceSize;
@Excel(name = "单价工序名称")
@ApiModelProperty("单价工序名称")
private String priceName;
@Excel(name = "单价子工序名称")
@ApiModelProperty("单价子工序名称")
private String priceSubName;
@Excel(name = "单价图案")
@ApiModelProperty("单价图案")
private String pricePattern;
@Excel(name = "单价规格")
@ApiModelProperty("单价规格")
private String priceSpec;
@Excel(name = "单价单价(元)")
@ApiModelProperty("单价单价(元)")
private BigDecimal pricePrice;
@Excel(name = "单价单位")
@ApiModelProperty("单价单位")
private String priceUnit;
@Excel(name = "单价分类")
@ApiModelProperty("单价分类")
private String priceClassify;
@Excel(name = "单价生产数量倍数(个)")
@ApiModelProperty("单价生产数量倍数(个)")
private BigDecimal priceQuantity;
@Excel(name = "创建人ID")
@ApiModelProperty("创建人ID")
private Long createId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("审核时间")
private Date verifyTime;
@Excel(name = "审核人ID")
@ApiModelProperty("审核人ID")
private Long verifyId;
@Excel(name = "审核人名称")
@ApiModelProperty("审核人名称")
private String verifyBy;
@Excel(name = "更新人ID")
@ApiModelProperty("更新人ID")
private Long updateId;
}

View File

@ -0,0 +1,13 @@
package com.ruoyi.web.yh.report.domain;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author wjh
* 2024/10/18
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ReportQuery extends ReportVO {
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.web.yh.report.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author wjh
* 2024/10/18
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ReportVO extends Report {
@ApiModelProperty("部门名称")
private String deptName;
}

View File

@ -0,0 +1,64 @@
package com.ruoyi.web.yh.report.mapper;
import java.util.List;
import com.ruoyi.web.yh.report.domain.Report;
import com.ruoyi.web.yh.report.domain.ReportVO;
import com.ruoyi.web.yh.report.domain.ReportQuery;
import org.apache.ibatis.annotations.Param;
/**
* 报表Mapper接口
*
* @author ruoyi
* @date 2024-10-18
*/
public interface ReportMapper
{
/**
* 查询报表
*
* @param reportId 报表主键
* @return 报表
*/
public ReportVO selectReportByReportId(Long reportId);
/**
* 查询报表列表
*
* @param query 报表
* @return 报表集合
*/
public List<ReportVO> selectReportList(@Param("query")ReportQuery query);
/**
* 新增报表
*
* @param report 报表
* @return 结果
*/
public int insertReport(Report report);
/**
* 修改报表
*
* @param report 报表
* @return 结果
*/
public int updateReport(@Param("data") Report report);
/**
* 删除报表
*
* @param reportId 报表主键
* @return 结果
*/
public int deleteReportByReportId(Long reportId);
/**
* 批量删除报表
*
* @param reportIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteReportByReportIds(Long[] reportIds);
}

View File

@ -0,0 +1,172 @@
<?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="com.ruoyi.web.yh.report.mapper.ReportMapper">
<resultMap type="ReportVO" id="ReportResult" autoMapping="true"/>
<sql id="selectReportVo">
select
br.report_id,
br.dept_id,
br.num,
br.status,
br.price_id,
br.price_category,
br.price_size,
br.price_name,
br.price_sub_name,
br.price_pattern,
br.price_spec,
br.price_price,
br.price_unit,
br.price_classify,
br.price_quantity,
br.create_time,
br.create_id,
br.create_by,
br.verify_time,
br.verify_id,
br.verify_by,
br.update_time,
br.update_id,
br.update_by,
sd.dept_name as dept_name
from bst_report br
left join sys_dept sd on sd.dept_id = br.dept_id
</sql>
<sql id="searchCondition">
<if test="query.reportId != null "> and br.report_id = #{query.reportId}</if>
<if test="query.deptId != null "> and br.dept_id = #{query.deptId}</if>
<if test="query.status != null and query.status != ''"> and br.status = #{query.status}</if>
<if test="query.priceId != null "> and br.price_id = #{query.priceId}</if>
<if test="query.priceCategory != null and query.priceCategory != ''"> and br.price_category like concat('%', #{query.priceCategory}, '%')</if>
<if test="query.priceSize != null and query.priceSize != ''"> and br.price_size like concat('%', #{query.priceSize}, '%')</if>
<if test="query.priceName != null and query.priceName != ''"> and br.price_name like concat('%', #{query.priceName}, '%')</if>
<if test="query.priceSubName != null and query.priceSubName != ''"> and br.price_sub_name like concat('%', #{query.priceSubName}, '%')</if>
<if test="query.pricePattern != null and query.pricePattern != ''"> and br.price_pattern like concat('%', #{query.pricePattern}, '%')</if>
<if test="query.priceSpec != null and query.priceSpec != ''"> and br.price_spec like concat('%', #{query.priceSpec}, '%')</if>
<if test="query.priceUnit != null and query.priceUnit != ''"> and br.price_unit like concat('%', #{query.priceUnit}, '%')</if>
<if test="query.priceClassify != null and query.priceClassify != ''"> and br.price_classify like concat('%', #{query.priceClassify}, '%')</if>
<if test="query.createId != null "> and br.create_id = #{query.createId}</if>
<if test="query.createBy != null and query.createBy != ''"> and br.create_by like concat('%', #{query.createBy}, '%')</if>
<if test="query.verifyId != null "> and br.verify_id = #{query.verifyId}</if>
<if test="query.verifyBy != null and query.verifyBy != ''"> and br.verify_by like concat('%', #{query.verifyBy}, '%')</if>
<if test="query.updateId != null "> and br.update_id = #{query.updateId}</if>
<if test="query.updateBy != null and query.updateBy != ''"> and br.update_by like concat('%', #{query.updateBy}, '%')</if>
${query.params.dataScope}
</sql>
<select id="selectReportList" parameterType="ReportQuery" resultMap="ReportResult">
<include refid="selectReportVo"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<select id="selectReportByReportId" parameterType="Long" resultMap="ReportResult">
<include refid="selectReportVo"/>
where br.report_id = #{reportId}
</select>
<insert id="insertReport" parameterType="Report" useGeneratedKeys="true" keyProperty="reportId">
insert into bst_report
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="num != null">num,</if>
<if test="status != null and status != ''">status,</if>
<if test="priceId != null">price_id,</if>
<if test="priceCategory != null">price_category,</if>
<if test="priceSize != null">price_size,</if>
<if test="priceName != null and priceName != ''">price_name,</if>
<if test="priceSubName != null">price_sub_name,</if>
<if test="pricePattern != null">price_pattern,</if>
<if test="priceSpec != null">price_spec,</if>
<if test="pricePrice != null">price_price,</if>
<if test="priceUnit != null">price_unit,</if>
<if test="priceClassify != null">price_classify,</if>
<if test="priceQuantity != null">price_quantity,</if>
<if test="createTime != null">create_time,</if>
<if test="createId != null">create_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="verifyTime != null">verify_time,</if>
<if test="verifyId != null">verify_id,</if>
<if test="verifyBy != null">verify_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateId != null">update_id,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="num != null">#{num},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="priceId != null">#{priceId},</if>
<if test="priceCategory != null">#{priceCategory},</if>
<if test="priceSize != null">#{priceSize},</if>
<if test="priceName != null and priceName != ''">#{priceName},</if>
<if test="priceSubName != null">#{priceSubName},</if>
<if test="pricePattern != null">#{pricePattern},</if>
<if test="priceSpec != null">#{priceSpec},</if>
<if test="pricePrice != null">#{pricePrice},</if>
<if test="priceUnit != null">#{priceUnit},</if>
<if test="priceClassify != null">#{priceClassify},</if>
<if test="priceQuantity != null">#{priceQuantity},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createId != null">#{createId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="verifyTime != null">#{verifyTime},</if>
<if test="verifyId != null">#{verifyId},</if>
<if test="verifyBy != null">#{verifyBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateId != null">#{updateId},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateReport" parameterType="Report">
update bst_report
<trim prefix="SET" suffixOverrides=",">
<include refid="updateColumns"/>
</trim>
where report_id = #{data.reportId}
</update>
<sql id="updateColumns">
<if test="data.deptId != null">dept_id = #{data.deptId},</if>
<if test="data.num != null">num = #{data.num},</if>
<if test="data.status != null and data.status != ''">status = #{data.status},</if>
<if test="data.priceId != null">price_id = #{data.priceId},</if>
<if test="data.priceCategory != null">price_category = #{data.priceCategory},</if>
<if test="data.priceSize != null">price_size = #{data.priceSize},</if>
<if test="data.priceName != null and data.priceName != ''">price_name = #{data.priceName},</if>
<if test="data.priceSubName != null">price_sub_name = #{data.priceSubName},</if>
<if test="data.pricePattern != null">price_pattern = #{data.pricePattern},</if>
<if test="data.priceSpec != null">price_spec = #{data.priceSpec},</if>
<if test="data.pricePrice != null">price_price = #{data.pricePrice},</if>
<if test="data.priceUnit != null">price_unit = #{data.priceUnit},</if>
<if test="data.priceClassify != null">price_classify = #{data.priceClassify},</if>
<if test="data.priceQuantity != null">price_quantity = #{data.priceQuantity},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.createId != null">create_id = #{data.createId},</if>
<if test="data.createBy != null and data.createBy != ''">create_by = #{data.createBy},</if>
<if test="data.verifyTime != null">verify_time = #{data.verifyTime},</if>
<if test="data.verifyId != null">verify_id = #{data.verifyId},</if>
<if test="data.verifyBy != null">verify_by = #{data.verifyBy},</if>
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>
<if test="data.updateId != null">update_id = #{data.updateId},</if>
<if test="data.updateBy != null">update_by = #{data.updateBy},</if>
</sql>
<delete id="deleteReportByReportId" parameterType="Long">
delete from bst_report where report_id = #{reportId}
</delete>
<delete id="deleteReportByReportIds" parameterType="String">
delete from bst_report where report_id in
<foreach item="reportId" collection="array" open="(" separator="," close=")">
#{reportId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,63 @@
package com.ruoyi.web.yh.report.service;
import java.util.List;
import com.ruoyi.web.yh.report.domain.Report;
import com.ruoyi.web.yh.report.domain.ReportVO;
import com.ruoyi.web.yh.report.domain.ReportQuery;
/**
* 报表Service接口
*
* @author ruoyi
* @date 2024-10-18
*/
public interface IReportService
{
/**
* 查询报表
*
* @param reportId 报表主键
* @return 报表
*/
public ReportVO selectReportByReportId(Long reportId);
/**
* 查询报表列表
*
* @param report 报表
* @return 报表集合
*/
public List<ReportVO> selectReportList(ReportQuery report);
/**
* 新增报表
*
* @param report 报表
* @return 结果
*/
public int insertReport(Report report);
/**
* 修改报表
*
* @param report 报表
* @return 结果
*/
public int updateReport(Report report);
/**
* 批量删除报表
*
* @param reportIds 需要删除的报表主键集合
* @return 结果
*/
public int deleteReportByReportIds(Long[] reportIds);
/**
* 删除报表信息
*
* @param reportId 报表主键
* @return 结果
*/
public int deleteReportByReportId(Long reportId);
}

View File

@ -0,0 +1,98 @@
package com.ruoyi.web.yh.report.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.yh.report.mapper.ReportMapper;
import com.ruoyi.web.yh.report.domain.Report;
import com.ruoyi.web.yh.report.domain.ReportVO;
import com.ruoyi.web.yh.report.domain.ReportQuery;
import com.ruoyi.web.yh.report.service.IReportService;
/**
* 报表Service业务层处理
*
* @author ruoyi
* @date 2024-10-18
*/
@Service
public class ReportServiceImpl implements IReportService
{
@Autowired
private ReportMapper reportMapper;
/**
* 查询报表
*
* @param reportId 报表主键
* @return 报表
*/
@Override
public ReportVO selectReportByReportId(Long reportId)
{
return reportMapper.selectReportByReportId(reportId);
}
/**
* 查询报表列表
*
* @param report 报表
* @return 报表
*/
@Override
public List<ReportVO> selectReportList(ReportQuery report)
{
return reportMapper.selectReportList(report);
}
/**
* 新增报表
*
* @param report 报表
* @return 结果
*/
@Override
public int insertReport(Report report)
{
report.setCreateTime(DateUtils.getNowDate());
return reportMapper.insertReport(report);
}
/**
* 修改报表
*
* @param report 报表
* @return 结果
*/
@Override
public int updateReport(Report report)
{
report.setUpdateTime(DateUtils.getNowDate());
return reportMapper.updateReport(report);
}
/**
* 批量删除报表
*
* @param reportIds 需要删除的报表主键
* @return 结果
*/
@Override
public int deleteReportByReportIds(Long[] reportIds)
{
return reportMapper.deleteReportByReportIds(reportIds);
}
/**
* 删除报表信息
*
* @param reportId 报表主键
* @return 结果
*/
@Override
public int deleteReportByReportId(Long reportId)
{
return reportMapper.deleteReportByReportId(reportId);
}
}