Commit 0c2ac97b authored by lizhichao's avatar lizhichao

新增外部采购功能

parent 8ffbd43c
package com.zehong.web.controller.transaction;
import java.util.List;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TPurchase;
import com.zehong.system.service.ITPurchaseService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 外部采购(报销)申请Controller
*
* @author zehong
* @date 2023-06-16
*/
@RestController
@RequestMapping("/system/purchase")
public class TPurchaseController extends BaseController
{
@Autowired
private ITPurchaseService tPurchaseService;
/**
* 查询外部采购(报销)申请列表
*/
@PreAuthorize("@ss.hasPermi('system:purchase:list')")
@GetMapping("/list")
public TableDataInfo list(TPurchase tPurchase)
{
startPage();
List<TPurchase> list = tPurchaseService.selectTPurchaseList(tPurchase);
return getDataTable(list);
}
/**
* 导出外部采购(报销)申请列表
*/
@PreAuthorize("@ss.hasPermi('system:purchase:export')")
@Log(title = "外部采购(报销)申请", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TPurchase tPurchase)
{
List<TPurchase> list = tPurchaseService.selectTPurchaseList(tPurchase);
ExcelUtil<TPurchase> util = new ExcelUtil<TPurchase>(TPurchase.class);
return util.exportExcel(list, "外部采购(报销)申请数据");
}
/**
* 获取外部采购(报销)申请详细信息
*/
@PreAuthorize("@ss.hasPermi('system:purchase:query')")
@GetMapping(value = "/{purchaseId}")
public AjaxResult getInfo(@PathVariable("purchaseId") Long purchaseId)
{
return AjaxResult.success(tPurchaseService.selectTPurchaseById(purchaseId));
}
/**
* 新增外部采购(报销)申请
*/
@PreAuthorize("@ss.hasPermi('system:purchase:add')")
@Log(title = "外部采购(报销)申请", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TPurchase tPurchase)
{
return toAjax(tPurchaseService.insertTPurchase(tPurchase));
}
/**
* 修改外部采购(报销)申请
*/
@PreAuthorize("@ss.hasPermi('system:purchase:edit')")
@Log(title = "外部采购(报销)申请", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TPurchase tPurchase)
{
return toAjax(tPurchaseService.updateTPurchase(tPurchase));
}
/**
* 删除外部采购(报销)申请
*/
@PreAuthorize("@ss.hasPermi('system:purchase:remove')")
@Log(title = "外部采购(报销)申请", businessType = BusinessType.DELETE)
@DeleteMapping("/{purchaseIds}")
public AjaxResult remove(@PathVariable Long[] purchaseIds)
{
return toAjax(tPurchaseService.deleteTPurchaseByIds(purchaseIds));
}
}
package com.zehong.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 外部采购(报销)申请对象 t_purchase
*
* @author zehong
* @date 2023-06-16
*/
public class TPurchase extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 采购主键 */
private Long purchaseId;
/** 采购申请部门 */
@Excel(name = "采购申请部门")
private Long purchaseDeptId;
public Long getHandled_by_user_id() {
return handled_by_user_id;
}
public void setHandled_by_user_id(Long handled_by_user_id) {
this.handled_by_user_id = handled_by_user_id;
}
private Long handled_by_user_id;
/** 采购名称 */
@Excel(name = "采购名称")
private String purchaseName;
/** 规格 */
@Excel(name = "规格")
private String specifications;
/** 型号 */
@Excel(name = "型号")
private String modelType;
/** 用途说明 */
@Excel(name = "用途说明")
private String applicationDescription;
/** 使用人 */
@Excel(name = "使用人")
private Long userId;
/** 单价 */
@Excel(name = "单价")
private BigDecimal price;
/** 数量 */
@Excel(name = "数量")
private Long count;
/** 总价 */
@Excel(name = "总价")
private BigDecimal total;
/** 采购申请部门长 */
@Excel(name = "采购申请部门长")
private Long purchaseDeptManagerId;
/** 审批人 */
@Excel(name = "审批人")
private Long approvedUserId;
/** 是否删除:0否,1是 */
@Excel(name = "是否删除:0否,1是")
private String isDel;
/** 采购状态:0.待部门长审核 1.核算部审批 2.完成 3.驳回 */
@Excel(name = "采购状态:0.待部门长审核 1.核算部审批 2.完成 3.驳回")
private String purchaseStatus;
/** 审核时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date approvedTime;
public void setPurchaseId(Long purchaseId)
{
this.purchaseId = purchaseId;
}
public Long getPurchaseId()
{
return purchaseId;
}
public void setPurchaseDeptId(Long purchaseDeptId)
{
this.purchaseDeptId = purchaseDeptId;
}
public Long getPurchaseDeptId()
{
return purchaseDeptId;
}
public void setPurchaseName(String purchaseName)
{
this.purchaseName = purchaseName;
}
public String getPurchaseName()
{
return purchaseName;
}
public void setSpecifications(String specifications)
{
this.specifications = specifications;
}
public String getSpecifications()
{
return specifications;
}
public void setModelType(String modelType)
{
this.modelType = modelType;
}
public String getModelType()
{
return modelType;
}
public void setApplicationDescription(String applicationDescription)
{
this.applicationDescription = applicationDescription;
}
public String getApplicationDescription()
{
return applicationDescription;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setCount(Long count)
{
this.count = count;
}
public Long getCount()
{
return count;
}
public void setTotal(BigDecimal total)
{
this.total = total;
}
public BigDecimal getTotal()
{
return total;
}
public void setPurchaseDeptManagerId(Long purchaseDeptManagerId)
{
this.purchaseDeptManagerId = purchaseDeptManagerId;
}
public Long getPurchaseDeptManagerId()
{
return purchaseDeptManagerId;
}
public void setApprovedUserId(Long approvedUserId)
{
this.approvedUserId = approvedUserId;
}
public Long getApprovedUserId()
{
return approvedUserId;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
public void setPurchaseStatus(String purchaseStatus)
{
this.purchaseStatus = purchaseStatus;
}
public String getPurchaseStatus()
{
return purchaseStatus;
}
public void setApprovedTime(Date approvedTime)
{
this.approvedTime = approvedTime;
}
public Date getApprovedTime()
{
return approvedTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("purchaseId", getPurchaseId())
.append("purchaseDeptId", getPurchaseDeptId())
.append("purchaseName", getPurchaseName())
.append("specifications", getSpecifications())
.append("modelType", getModelType())
.append("applicationDescription", getApplicationDescription())
.append("userId", getUserId())
.append("price", getPrice())
.append("count", getCount())
.append("total", getTotal())
.append("purchaseDeptManagerId", getPurchaseDeptManagerId())
.append("approvedUserId", getApprovedUserId())
.append("remark", getRemark())
.append("createTime", getCreateTime())
.append("isDel", getIsDel())
.append("updateTime", getUpdateTime())
.append("purchaseStatus", getPurchaseStatus())
.append("approvedTime", getApprovedTime())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TPurchase;
/**
* 外部采购(报销)申请Mapper接口
*
* @author zehong
* @date 2023-06-16
*/
public interface TPurchaseMapper
{
/**
* 查询外部采购(报销)申请
*
* @param purchaseId 外部采购(报销)申请ID
* @return 外部采购(报销)申请
*/
public TPurchase selectTPurchaseById(Long purchaseId);
/**
* 查询外部采购(报销)申请列表
*
* @param tPurchase 外部采购(报销)申请
* @return 外部采购(报销)申请集合
*/
public List<TPurchase> selectTPurchaseList(TPurchase tPurchase);
/**
* 新增外部采购(报销)申请
*
* @param tPurchase 外部采购(报销)申请
* @return 结果
*/
public int insertTPurchase(TPurchase tPurchase);
/**
* 修改外部采购(报销)申请
*
* @param tPurchase 外部采购(报销)申请
* @return 结果
*/
public int updateTPurchase(TPurchase tPurchase);
/**
* 删除外部采购(报销)申请
*
* @param purchaseId 外部采购(报销)申请ID
* @return 结果
*/
public int deleteTPurchaseById(Long purchaseId);
/**
* 批量删除外部采购(报销)申请
*
* @param purchaseIds 需要删除的数据ID
* @return 结果
*/
public int deleteTPurchaseByIds(Long[] purchaseIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TPurchase;
/**
* 外部采购(报销)申请Service接口
*
* @author zehong
* @date 2023-06-16
*/
public interface ITPurchaseService
{
/**
* 查询外部采购(报销)申请
*
* @param purchaseId 外部采购(报销)申请ID
* @return 外部采购(报销)申请
*/
public TPurchase selectTPurchaseById(Long purchaseId);
/**
* 查询外部采购(报销)申请列表
*
* @param tPurchase 外部采购(报销)申请
* @return 外部采购(报销)申请集合
*/
public List<TPurchase> selectTPurchaseList(TPurchase tPurchase);
/**
* 新增外部采购(报销)申请
*
* @param tPurchase 外部采购(报销)申请
* @return 结果
*/
public int insertTPurchase(TPurchase tPurchase);
/**
* 修改外部采购(报销)申请
*
* @param tPurchase 外部采购(报销)申请
* @return 结果
*/
public int updateTPurchase(TPurchase tPurchase);
/**
* 批量删除外部采购(报销)申请
*
* @param purchaseIds 需要删除的外部采购(报销)申请ID
* @return 结果
*/
public int deleteTPurchaseByIds(Long[] purchaseIds);
/**
* 删除外部采购(报销)申请信息
*
* @param purchaseId 外部采购(报销)申请ID
* @return 结果
*/
public int deleteTPurchaseById(Long purchaseId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TPurchaseMapper;
import com.zehong.system.domain.TPurchase;
import com.zehong.system.service.ITPurchaseService;
/**
* 外部采购(报销)申请Service业务层处理
*
* @author zehong
* @date 2023-06-16
*/
@Service
public class TPurchaseServiceImpl implements ITPurchaseService
{
@Autowired
private TPurchaseMapper tPurchaseMapper;
/**
* 查询外部采购(报销)申请
*
* @param purchaseId 外部采购(报销)申请ID
* @return 外部采购(报销)申请
*/
@Override
public TPurchase selectTPurchaseById(Long purchaseId)
{
return tPurchaseMapper.selectTPurchaseById(purchaseId);
}
/**
* 查询外部采购(报销)申请列表
*
* @param tPurchase 外部采购(报销)申请
* @return 外部采购(报销)申请
*/
@Override
public List<TPurchase> selectTPurchaseList(TPurchase tPurchase)
{
return tPurchaseMapper.selectTPurchaseList(tPurchase);
}
/**
* 新增外部采购(报销)申请
*
* @param tPurchase 外部采购(报销)申请
* @return 结果
*/
@Override
public int insertTPurchase(TPurchase tPurchase)
{
tPurchase.setCreateTime(DateUtils.getNowDate());
SysUser user = SecurityUtils.getLoginUser().getUser();
tPurchase.setPurchaseDeptId(user.getDeptId());
tPurchase.setHandled_by_user_id(user.getUserId());//经办人
return tPurchaseMapper.insertTPurchase(tPurchase);
}
/**
* 修改外部采购(报销)申请
*
* @param tPurchase 外部采购(报销)申请
* @return 结果
*/
@Override
public int updateTPurchase(TPurchase tPurchase)
{
tPurchase.setUpdateTime(DateUtils.getNowDate());
return tPurchaseMapper.updateTPurchase(tPurchase);
}
/**
* 批量删除外部采购(报销)申请
*
* @param purchaseIds 需要删除的外部采购(报销)申请ID
* @return 结果
*/
@Override
public int deleteTPurchaseByIds(Long[] purchaseIds)
{
return tPurchaseMapper.deleteTPurchaseByIds(purchaseIds);
}
/**
* 删除外部采购(报销)申请信息
*
* @param purchaseId 外部采购(报销)申请ID
* @return 结果
*/
@Override
public int deleteTPurchaseById(Long purchaseId)
{
return tPurchaseMapper.deleteTPurchaseById(purchaseId);
}
}
<?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.zehong.system.mapper.TPurchaseMapper">
<resultMap type="TPurchase" id="TPurchaseResult">
<result property="purchaseId" column="purchase_id" />
<result property="purchaseDeptId" column="purchase_dept_id" />
<result property="purchaseName" column="purchase_name" />
<result property="specifications" column="specifications" />
<result property="modelType" column="model_type" />
<result property="applicationDescription" column="application_description" />
<result property="userId" column="user_id" />
<result property="price" column="price" />
<result property="count" column="count" />
<result property="total" column="total" />
<result property="purchaseDeptManagerId" column="purchase_dept_manager_id" />
<result property="approvedUserId" column="approved_user_id" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="isDel" column="is_del" />
<result property="updateTime" column="update_time" />
<result property="purchaseStatus" column="purchase_status" />
<result property="approvedTime" column="approved_time" />
</resultMap>
<sql id="selectTPurchaseVo">
select purchase_id, purchase_dept_id, purchase_name, specifications, model_type, application_description, user_id, price, count, total, purchase_dept_manager_id, approved_user_id, remark, create_time, is_del, update_time, purchase_status, approved_time from t_purchase
</sql>
<select id="selectTPurchaseList" parameterType="TPurchase" resultMap="TPurchaseResult">
<include refid="selectTPurchaseVo"/>
<where>
<if test="purchaseDeptId != null "> and purchase_dept_id = #{purchaseDeptId}</if>
<if test="purchaseName != null and purchaseName != ''"> and purchase_name like concat('%', #{purchaseName}, '%')</if>
<if test="specifications != null and specifications != ''"> and specifications = #{specifications}</if>
<if test="modelType != null and modelType != ''"> and model_type = #{modelType}</if>
<if test="applicationDescription != null and applicationDescription != ''"> and application_description = #{applicationDescription}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="price != null "> and price = #{price}</if>
<if test="count != null "> and count = #{count}</if>
<if test="total != null "> and total = #{total}</if>
<if test="purchaseDeptManagerId != null "> and purchase_dept_manager_id = #{purchaseDeptManagerId}</if>
<if test="approvedUserId != null "> and approved_user_id = #{approvedUserId}</if>
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
<if test="purchaseStatus != null and purchaseStatus != ''"> and purchase_status = #{purchaseStatus}</if>
<if test="approvedTime != null "> and approved_time = #{approvedTime}</if>
</where>
</select>
<select id="selectTPurchaseById" parameterType="Long" resultMap="TPurchaseResult">
<include refid="selectTPurchaseVo"/>
where purchase_id = #{purchaseId}
</select>
<insert id="insertTPurchase" parameterType="TPurchase">
insert into t_purchase
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="purchaseId != null">purchase_id,</if>
<if test="purchaseDeptId != null">purchase_dept_id,</if>
<if test="purchaseName != null">purchase_name,</if>
<if test="specifications != null">specifications,</if>
<if test="modelType != null">model_type,</if>
<if test="applicationDescription != null">application_description,</if>
<if test="userId != null">user_id,</if>
<if test="price != null">price,</if>
<if test="count != null">count,</if>
<if test="total != null">total,</if>
<if test="purchaseDeptManagerId != null">purchase_dept_manager_id,</if>
<if test="approvedUserId != null">approved_user_id,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="isDel != null">is_del,</if>
<if test="updateTime != null">update_time,</if>
<if test="purchaseStatus != null">purchase_status,</if>
<if test="approvedTime != null">approved_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="purchaseId != null">#{purchaseId},</if>
<if test="purchaseDeptId != null">#{purchaseDeptId},</if>
<if test="purchaseName != null">#{purchaseName},</if>
<if test="specifications != null">#{specifications},</if>
<if test="modelType != null">#{modelType},</if>
<if test="applicationDescription != null">#{applicationDescription},</if>
<if test="userId != null">#{userId},</if>
<if test="price != null">#{price},</if>
<if test="count != null">#{count},</if>
<if test="total != null">#{total},</if>
<if test="purchaseDeptManagerId != null">#{purchaseDeptManagerId},</if>
<if test="approvedUserId != null">#{approvedUserId},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="purchaseStatus != null">#{purchaseStatus},</if>
<if test="approvedTime != null">#{approvedTime},</if>
</trim>
</insert>
<update id="updateTPurchase" parameterType="TPurchase">
update t_purchase
<trim prefix="SET" suffixOverrides=",">
<if test="purchaseDeptId != null">purchase_dept_id = #{purchaseDeptId},</if>
<if test="purchaseName != null">purchase_name = #{purchaseName},</if>
<if test="specifications != null">specifications = #{specifications},</if>
<if test="modelType != null">model_type = #{modelType},</if>
<if test="applicationDescription != null">application_description = #{applicationDescription},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="price != null">price = #{price},</if>
<if test="count != null">count = #{count},</if>
<if test="total != null">total = #{total},</if>
<if test="purchaseDeptManagerId != null">purchase_dept_manager_id = #{purchaseDeptManagerId},</if>
<if test="approvedUserId != null">approved_user_id = #{approvedUserId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="purchaseStatus != null">purchase_status = #{purchaseStatus},</if>
<if test="approvedTime != null">approved_time = #{approvedTime},</if>
</trim>
where purchase_id = #{purchaseId}
</update>
<delete id="deleteTPurchaseById" parameterType="Long">
delete from t_purchase where purchase_id = #{purchaseId}
</delete>
<delete id="deleteTPurchaseByIds" parameterType="String">
delete from t_purchase where purchase_id in
<foreach item="purchaseId" collection="array" open="(" separator="," close=")">
#{purchaseId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询外部采购(报销)申请列表
export function listPurchase(query) {
return request({
url: '/system/purchase/list',
method: 'get',
params: query
})
}
// 查询外部采购(报销)申请详细
export function getPurchase(purchaseId) {
return request({
url: '/system/purchase/' + purchaseId,
method: 'get'
})
}
// 新增外部采购(报销)申请
export function addPurchase(data) {
return request({
url: '/system/purchase',
method: 'post',
data: data
})
}
// 修改外部采购(报销)申请
export function updatePurchase(data) {
return request({
url: '/system/purchase',
method: 'put',
data: data
})
}
// 删除外部采购(报销)申请
export function delPurchase(purchaseId) {
return request({
url: '/system/purchase/' + purchaseId,
method: 'delete'
})
}
// 导出外部采购(报销)申请
export function exportPurchase(query) {
return request({
url: '/system/purchase/export',
method: 'get',
params: query
})
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment