feat: 智聪记账管理,物价管理-物价记录代码提交。

This commit is contained in:
tianyongbao
2025-03-20 18:33:17 +08:00
parent b7d12ce02b
commit 8a07585379
8 changed files with 723 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
package com.intc.invest.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
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.intc.common.log.annotation.Log;
import com.intc.common.log.enums.BusinessType;
import com.intc.common.security.annotation.RequiresPermissions;
import com.intc.invest.domain.ProductPriceRecord;
import com.intc.invest.domain.vo.ProductPriceRecordVo;
import com.intc.invest.domain.dto.ProductPriceRecordDto;
import com.intc.invest.service.IProductPriceRecordService;
import com.intc.common.core.web.controller.BaseController;
import com.intc.common.core.web.domain.AjaxResult;
import com.intc.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.intc.common.core.web.page.TableDataInfo;
/**
* 物价记录Controller
*
* @author tianyongbao
* @date 2025-03-19
*/
@Api(tags=" 物价记录")
@RestController
@RequestMapping("/productPriceRecord")
public class ProductPriceRecordController extends BaseController
{
@Resource
private IProductPriceRecordService productPriceRecordService;
/**
* 查询物价记录列表
*/
@ApiOperation(value="查询物价记录列表",response = ProductPriceRecordVo.class)
@RequiresPermissions("invest:productPriceRecord:list")
@GetMapping("/list")
public TableDataInfo list(ProductPriceRecordDto productPriceRecordDto)
{
startPage();
List<ProductPriceRecordVo> list = productPriceRecordService.selectProductPriceRecordList(productPriceRecordDto);
return getDataTable(list);
}
/**
* 导出物价记录列表
*/
@ApiOperation(value="导出物价记录列表")
@RequiresPermissions("invest:productPriceRecord:export")
@Log(title = "物价记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ProductPriceRecordDto productPriceRecordDto)
{
List<ProductPriceRecordVo> list = productPriceRecordService.selectProductPriceRecordList(productPriceRecordDto);
ExcelUtil<ProductPriceRecordVo> util = new ExcelUtil<ProductPriceRecordVo>(ProductPriceRecordVo.class);
util.exportExcel(response, list, "物价记录数据");
}
/**
* 获取物价记录详细信息
*/
@ApiOperation(value="获取物价记录详细信息")
@RequiresPermissions("invest:productPriceRecord:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(productPriceRecordService.selectProductPriceRecordById(id));
}
/**
* 新增物价记录
*/
@ApiOperation(value="新增物价记录")
@RequiresPermissions("invest:productPriceRecord:add")
@Log(title = "物价记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProductPriceRecord productPriceRecord)
{
return toAjax(productPriceRecordService.insertProductPriceRecord(productPriceRecord));
}
/**
* 修改物价记录
*/
@ApiOperation(value="修改物价记录")
@RequiresPermissions("invest:productPriceRecord:edit")
@Log(title = "物价记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ProductPriceRecord productPriceRecord)
{
return toAjax(productPriceRecordService.updateProductPriceRecord(productPriceRecord));
}
/**
* 删除物价记录
*/
@ApiOperation(value="删除物价记录")
@RequiresPermissions("invest:productPriceRecord:remove")
@Log(title = "物价记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(productPriceRecordService.deleteProductPriceRecordByIds(ids));
}
}

View File

@@ -0,0 +1,109 @@
package com.intc.invest.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.intc.common.core.annotation.Excel;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 物价记录对象 product_price_record
*
* @author tianyongbao
* @date 2025-03-19
*/
@ApiModel("物价记录对象")
@Data
public class ProductPriceRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 商品ID */
@ApiModelProperty(value="商品ID)")
@NotNull(message="商品ID不能为空")
@Excel(name = "商品ID")
private Long productId;
/** 价格 */
@ApiModelProperty(value="价格)")
@NotNull(message="价格不能为空")
@Excel(name = "价格")
private Double price;
/** 记录时间 */
@ApiModelProperty(value="记录时间)")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date recordTime;
/** 更新者 */
@ApiModelProperty(value="更新者")
@Excel(name = "更新者")
private String updatedBy;
/** 地点 */
@ApiModelProperty(value="地点)")
@NotNull(message="地点不能为空")
@Excel(name = "地点")
private String address;
/** 删除标志0代表存在 1代表删除 */
private String delFlag;
/** 商家 */
@ApiModelProperty(value="商家")
@Excel(name = "商家")
private String merchant;
/** 预留字段 */
@ApiModelProperty(value="预留字段")
@Excel(name = "预留字段")
private String fields;
/** 单位 */
@ApiModelProperty(value="单位")
@Excel(name = "单位")
private String unit;
/** 子类别 */
@ApiModelProperty(value="子类别)")
@NotNull(message="子类别不能为空")
@Excel(name = "子类别")
private String kind;
/** 类别 */
@ApiModelProperty(value="类别)")
@NotNull(message="类别不能为空")
@Excel(name = "类别")
private String category;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("productId", getProductId())
.append("price", getPrice())
.append("recordTime", getRecordTime())
.append("remark", getRemark())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updatedBy", getUpdatedBy())
.append("address", getAddress())
.append("delFlag", getDelFlag())
.append("merchant", getMerchant())
.append("fields", getFields())
.append("unit", getUnit())
.append("kind", getKind())
.append("category", getCategory())
.toString();
}
}

View File

@@ -0,0 +1,67 @@
package com.intc.invest.domain.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 物价记录Dto对象 product_price_record
*
* @author tianyongbao
* @date 2025-03-19
*/
@ApiModel("物价记录Dto对象")
@Data
public class ProductPriceRecordDto implements Serializable
{
private static final long serialVersionUID = 1L;
/** 商品ID */
@ApiModelProperty(value="商品ID")
private Long productId;
/** 价格 */
@ApiModelProperty(value="价格")
private Double price;
/** 记录时间 */
@ApiModelProperty(value="记录时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date recordTime;
/** 地点 */
@ApiModelProperty(value="地点")
private String address;
/** 商家 */
@ApiModelProperty(value="商家")
private String merchant;
/** 子类别 */
@ApiModelProperty(value="子类别")
private String kind;
/** 类别 */
@ApiModelProperty(value="类别")
private String category;
/** 开始日期 */
@ApiModelProperty(value="开始日期")
private String startTime;
/** 结束日期 */
@ApiModelProperty(value="结束日期")
private String endTime;
/** 开始时间*/
@ApiModelProperty(value="开始时间")
private Date startDateTime;
/** 结束时间*/
@ApiModelProperty(value="结束时间")
private Date endDateTime;
}

View File

@@ -0,0 +1,19 @@
package com.intc.invest.domain.vo;
import com.intc.invest.domain.ProductPriceRecord;
import lombok.Data;
import io.swagger.annotations.ApiModel;
/**
* 物价记录Vo对象 product_price_record
*
* @author tianyongbao
* @date 2025-03-19
*/
@ApiModel("物价记录Vo对象")
@Data
public class ProductPriceRecordVo extends ProductPriceRecord
{
/** 名称 */
private String productName;
}

View File

@@ -0,0 +1,79 @@
package com.intc.invest.mapper;
import java.util.List;
import com.intc.invest.domain.ProductPriceRecord;
import com.intc.invest.domain.dto.ProductPriceRecordDto;
import com.intc.invest.domain.vo.ProductPriceRecordVo;
/**
* 物价记录Mapper接口
*
* @author tianyongbao
* @date 2025-03-19
*/
public interface ProductPriceRecordMapper
{
/**
* 查询物价记录
*
* @param id 物价记录主键
* @return 物价记录
*/
public ProductPriceRecordVo selectProductPriceRecordById(Long id);
/**
* 查询物价记录列表
*
* @param productPriceRecordDto 物价记录
* @return 物价记录集合
*/
public List<ProductPriceRecordVo> selectProductPriceRecordList(ProductPriceRecordDto productPriceRecordDto);
/**
* 新增物价记录
*
* @param productPriceRecord 物价记录
* @return 结果
*/
public int insertProductPriceRecord(ProductPriceRecord productPriceRecord);
/**
* 修改物价记录
*
* @param productPriceRecord 物价记录
* @return 结果
*/
public int updateProductPriceRecord(ProductPriceRecord productPriceRecord);
/**
* 删除物价记录
*
* @param id 物价记录主键
* @return 结果
*/
public int deleteProductPriceRecordById(Long id);
/**
* 批量删除物价记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteProductPriceRecordByIds(Long[] ids);
/**
* 逻辑删除物价记录
*
* @param id 物价记录主键
* @return 结果
*/
public int removeProductPriceRecordById(Long id);
/**
* 批量逻辑删除物价记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int removeProductPriceRecordByIds(Long[] ids);
}

View File

@@ -0,0 +1,63 @@
package com.intc.invest.service;
import java.util.List;
import com.intc.invest.domain.ProductPriceRecord;
import com.intc.invest.domain.dto.ProductPriceRecordDto;
import com.intc.invest.domain.vo.ProductPriceRecordVo;
/**
* 物价记录Service接口
*
* @author tianyongbao
* @date 2025-03-19
*/
public interface IProductPriceRecordService
{
/**
* 查询物价记录
*
* @param id 物价记录主键
* @return 物价记录
*/
public ProductPriceRecordVo selectProductPriceRecordById(Long id);
/**
* 查询物价记录列表
*
* @param productPriceRecordDto 物价记录
* @return 物价记录集合
*/
public List<ProductPriceRecordVo> selectProductPriceRecordList(ProductPriceRecordDto productPriceRecordDto);
/**
* 新增物价记录
*
* @param productPriceRecord 物价记录
* @return 结果
*/
public int insertProductPriceRecord(ProductPriceRecord productPriceRecord);
/**
* 修改物价记录
*
* @param productPriceRecord 物价记录
* @return 结果
*/
public int updateProductPriceRecord(ProductPriceRecord productPriceRecord);
/**
* 批量删除物价记录
*
* @param ids 需要删除的物价记录主键集合
* @return 结果
*/
public int deleteProductPriceRecordByIds(Long[] ids);
/**
* 删除物价记录信息
*
* @param id 物价记录主键
* @return 结果
*/
public int deleteProductPriceRecordById(Long id);
}

View File

@@ -0,0 +1,103 @@
package com.intc.invest.service.impl;
import com.intc.common.core.utils.DateUtils;
import com.intc.common.core.utils.IdWorker;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.invest.domain.ProductPriceRecord;
import com.intc.invest.domain.dto.ProductPriceRecordDto;
import com.intc.invest.domain.vo.ProductPriceRecordVo;
import com.intc.invest.mapper.ProductPriceRecordMapper;
import com.intc.invest.service.IProductPriceRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 物价记录Service业务层处理
*
* @author tianyongbao
* @date 2025-03-19
*/
@Service
public class ProductPriceRecordServiceImpl implements IProductPriceRecordService
{
@Resource
private ProductPriceRecordMapper productPriceRecordMapper;
/**
* 查询物价记录
*
* @param id 物价记录主键
* @return 物价记录
*/
@Override
public ProductPriceRecordVo selectProductPriceRecordById(Long id)
{
return productPriceRecordMapper.selectProductPriceRecordById(id);
}
/**
* 查询物价记录列表
*
* @param productPriceRecordDto 物价记录
* @return 物价记录
*/
@Override
public List<ProductPriceRecordVo> selectProductPriceRecordList(ProductPriceRecordDto productPriceRecordDto)
{
return productPriceRecordMapper.selectProductPriceRecordList(productPriceRecordDto);
}
/**
* 新增物价记录
*
* @param productPriceRecord 物价记录
* @return 结果
*/
@Override
public int insertProductPriceRecord(ProductPriceRecord productPriceRecord)
{
productPriceRecord.setCreateTime(DateUtils.getNowDate());
productPriceRecord.setCreateBy(SecurityUtils.getUsername());
productPriceRecord.setId(IdWorker.getId());
return productPriceRecordMapper.insertProductPriceRecord(productPriceRecord);
}
/**
* 修改物价记录
*
* @param productPriceRecord 物价记录
* @return 结果
*/
@Override
public int updateProductPriceRecord(ProductPriceRecord productPriceRecord)
{
productPriceRecord.setUpdateTime(DateUtils.getNowDate());
return productPriceRecordMapper.updateProductPriceRecord(productPriceRecord);
}
/**
* 批量删除物价记录
*
* @param ids 需要删除的物价记录主键
* @return 结果
*/
@Override
public int deleteProductPriceRecordByIds(Long[] ids)
{
return productPriceRecordMapper.removeProductPriceRecordByIds(ids);
}
/**
* 删除物价记录信息
*
* @param id 物价记录主键
* @return 结果
*/
@Override
public int deleteProductPriceRecordById(Long id)
{
return productPriceRecordMapper.removeProductPriceRecordById(id);
}
}

View File

@@ -0,0 +1,167 @@
<?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.intc.invest.mapper.ProductPriceRecordMapper">
<resultMap type="ProductPriceRecordVo" id="ProductPriceRecordResult">
<result property="id" column="id" />
<result property="productId" column="product_id" />
<result property="price" column="price" />
<result property="recordTime" column="record_time" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updatedBy" column="updated_by" />
<result property="address" column="address" />
<result property="delFlag" column="del_flag" />
<result property="merchant" column="merchant" />
<result property="fields" column="fields" />
<result property="unit" column="unit" />
<result property="kind" column="kind" />
<result property="category" column="category" />
<result property="productName" column="product_name" />
</resultMap>
<sql id="selectProductPriceRecordVo">
select
a.id,
a.product_id,
pi2."name" as product_name,
a.price,
a.record_time,
a.remark,
a.create_time,
a.create_by,
a.update_time,
a.updated_by,
a.address,
a.del_flag,
a.merchant,
a.fields,
a.unit,
a.kind,
a.category
from
product_price_record a
left join product_infor pi2 on
pi2.id = a.product_id
</sql>
<select id="selectProductPriceRecordList" parameterType="ProductPriceRecordDto" resultMap="ProductPriceRecordResult">
<include refid="selectProductPriceRecordVo"/>
<where>
a.del_flag='0'
<if test="productId != null "> and a.product_id = #{productId}</if>
<if test="price != null "> and a.price = #{price}</if>
<if test="recordTime != null "> and a.record_time = #{recordTime}</if>
<if test="address != null and address != ''"> and a.address = #{address}</if>
<if test="merchant != null and merchant != ''"> and a.merchant = #{merchant}</if>
<if test="kind != null and kind != ''"> and a.kind = #{kind}</if>
<if test="category != null and category != ''"> and a.category = #{category}</if>
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(a.record_time, 'yyyy-MM-dd')
</if>
<if test="startTime!=null and startTime !=''">
and to_char(a.record_time, 'yyyy-MM-dd')>=#{startTime}
</if>
<if test="endDateTime!=null">
and #{endDateTime}>=a.record_time
</if>
<if test="startDateTime!=null">
and a.record_time>=#{startDateTime}
</if>
</where>
order by a.create_time desc
</select>
<select id="selectProductPriceRecordById" parameterType="Long" resultMap="ProductPriceRecordResult">
<include refid="selectProductPriceRecordVo"/>
where a.id = #{id}
</select>
<insert id="insertProductPriceRecord" parameterType="ProductPriceRecord" useGeneratedKeys="true" keyProperty="id">
insert into product_price_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="productId != null">product_id,</if>
<if test="price != null">price,</if>
<if test="recordTime != null">record_time,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="address != null and address != ''">address,</if>
<if test="delFlag != null">del_flag,</if>
<if test="merchant != null">merchant,</if>
<if test="fields != null">fields,</if>
<if test="unit != null">unit,</if>
<if test="kind != null and kind != ''">kind,</if>
<if test="category != null and category != ''">category,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="productId != null">#{productId},</if>
<if test="price != null">#{price},</if>
<if test="recordTime != null">#{recordTime},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="address != null and address != ''">#{address},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="merchant != null">#{merchant},</if>
<if test="fields != null">#{fields},</if>
<if test="unit != null">#{unit},</if>
<if test="kind != null and kind != ''">#{kind},</if>
<if test="category != null and category != ''">#{category},</if>
</trim>
</insert>
<update id="updateProductPriceRecord" parameterType="ProductPriceRecord">
update product_price_record
<trim prefix="SET" suffixOverrides=",">
<if test="productId != null">product_id = #{productId},</if>
<if test="price != null">price = #{price},</if>
<if test="recordTime != null">record_time = #{recordTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="address != null and address != ''">address = #{address},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="merchant != null">merchant = #{merchant},</if>
<if test="fields != null">fields = #{fields},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="kind != null and kind != ''">kind = #{kind},</if>
<if test="category != null and category != ''">category = #{category},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteProductPriceRecordById" parameterType="Long">
delete from product_price_record where id = #{id}
</delete>
<delete id="deleteProductPriceRecordByIds" parameterType="String">
delete from product_price_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="removeProductPriceRecordById" parameterType="Long">
update product_price_record set del_flag='1' where id = #{id}
</update>
<update id="removeProductPriceRecordByIds" parameterType="String">
update product_price_record set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>