Commit 89fbe881 authored by 耿迪迪's avatar 耿迪迪

生产计划

parent ba924539
package com.zehong.web.controller.track;
import java.util.List;
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.track.TProductPlan;
import com.zehong.system.service.track.ITProductPlanService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 生产计划Controller
*
* @author zehong
* @date 2024-08-24
*/
@RestController
@RequestMapping("/track/plan")
public class TProductPlanController extends BaseController
{
@Autowired
private ITProductPlanService tProductPlanService;
/**
* 查询生产计划列表
*/
// @PreAuthorize("@ss.hasPermi('system:plan:list')")
@GetMapping("/list")
public TableDataInfo list(TProductPlan tProductPlan)
{
startPage();
List<TProductPlan> list = tProductPlanService.selectTProductPlanList(tProductPlan);
return getDataTable(list);
}
/**
* 导出生产计划列表
*/
//@PreAuthorize("@ss.hasPermi('system:plan:export')")
@Log(title = "生产计划", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TProductPlan tProductPlan)
{
List<TProductPlan> list = tProductPlanService.selectTProductPlanList(tProductPlan);
ExcelUtil<TProductPlan> util = new ExcelUtil<TProductPlan>(TProductPlan.class);
return util.exportExcel(list, "生产计划数据");
}
/**
* 获取生产计划详细信息
*/
//@PreAuthorize("@ss.hasPermi('system:plan:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(tProductPlanService.selectTProductPlanById(id));
}
/**
* 新增生产计划
*/
//@PreAuthorize("@ss.hasPermi('system:plan:add')")
@Log(title = "生产计划", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TProductPlan tProductPlan)
{
return toAjax(tProductPlanService.insertTProductPlan(tProductPlan));
}
/**
* 修改生产计划
*/
//@PreAuthorize("@ss.hasPermi('system:plan:edit')")
@Log(title = "生产计划", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TProductPlan tProductPlan)
{
return toAjax(tProductPlanService.updateTProductPlan(tProductPlan));
}
/**
* 删除生产计划
*/
//@PreAuthorize("@ss.hasPermi('system:plan:remove')")
@Log(title = "生产计划", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(tProductPlanService.deleteTProductPlanByIds(ids));
}
}
package com.zehong.system.domain.track;
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_product_plan
*
* @author zehong
* @date 2024-08-24
*/
public class TProductPlan extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 计划名称 */
@Excel(name = "计划名称")
private String title;
/** 计划编号 */
@Excel(name = "计划编号")
private String planNo;
/** 计划描述 */
@Excel(name = "计划描述")
private String content;
/** 生产总数 */
@Excel(name = "生产总数")
private Long total;
/** 计划状态(数据字典) */
@Excel(name = "计划状态", dictType = "product_plan_status")
private String status;
/** 创建人 */
private Long createId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setPlanNo(String planNo)
{
this.planNo = planNo;
}
public String getPlanNo()
{
return planNo;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setTotal(Long total)
{
this.total = total;
}
public Long getTotal()
{
return total;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setCreateId(Long createId)
{
this.createId = createId;
}
public Long getCreateId()
{
return createId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("title", getTitle())
.append("planNo", getPlanNo())
.append("content", getContent())
.append("total", getTotal())
.append("status", getStatus())
.append("createTime", getCreateTime())
.append("createId", getCreateId())
.toString();
}
}
package com.zehong.system.mapper.track;
import java.util.List;
import com.zehong.system.domain.track.TProductPlan;
/**
* 生产计划Mapper接口
*
* @author zehong
* @date 2024-08-24
*/
public interface TProductPlanMapper
{
/**
* 查询生产计划
*
* @param id 生产计划ID
* @return 生产计划
*/
public TProductPlan selectTProductPlanById(Long id);
/**
* 查询生产计划列表
*
* @param tProductPlan 生产计划
* @return 生产计划集合
*/
public List<TProductPlan> selectTProductPlanList(TProductPlan tProductPlan);
/**
* 新增生产计划
*
* @param tProductPlan 生产计划
* @return 结果
*/
public int insertTProductPlan(TProductPlan tProductPlan);
/**
* 修改生产计划
*
* @param tProductPlan 生产计划
* @return 结果
*/
public int updateTProductPlan(TProductPlan tProductPlan);
/**
* 删除生产计划
*
* @param id 生产计划ID
* @return 结果
*/
public int deleteTProductPlanById(Long id);
/**
* 批量删除生产计划
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteTProductPlanByIds(Long[] ids);
}
package com.zehong.system.service.impl.track;
import java.util.List;
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.track.TProductPlanMapper;
import com.zehong.system.domain.track.TProductPlan;
import com.zehong.system.service.track.ITProductPlanService;
/**
* 生产计划Service业务层处理
*
* @author zehong
* @date 2024-08-24
*/
@Service
public class TProductPlanServiceImpl implements ITProductPlanService
{
@Autowired
private TProductPlanMapper tProductPlanMapper;
/**
* 查询生产计划
*
* @param id 生产计划ID
* @return 生产计划
*/
@Override
public TProductPlan selectTProductPlanById(Long id)
{
return tProductPlanMapper.selectTProductPlanById(id);
}
/**
* 查询生产计划列表
*
* @param tProductPlan 生产计划
* @return 生产计划
*/
@Override
public List<TProductPlan> selectTProductPlanList(TProductPlan tProductPlan)
{
return tProductPlanMapper.selectTProductPlanList(tProductPlan);
}
/**
* 新增生产计划
*
* @param tProductPlan 生产计划
* @return 结果
*/
@Override
public int insertTProductPlan(TProductPlan tProductPlan)
{
tProductPlan.setCreateTime(DateUtils.getNowDate());
tProductPlan.setCreateId(SecurityUtils.getLoginUser().getUser().getUserId());
return tProductPlanMapper.insertTProductPlan(tProductPlan);
}
/**
* 修改生产计划
*
* @param tProductPlan 生产计划
* @return 结果
*/
@Override
public int updateTProductPlan(TProductPlan tProductPlan)
{
return tProductPlanMapper.updateTProductPlan(tProductPlan);
}
/**
* 批量删除生产计划
*
* @param ids 需要删除的生产计划ID
* @return 结果
*/
@Override
public int deleteTProductPlanByIds(Long[] ids)
{
return tProductPlanMapper.deleteTProductPlanByIds(ids);
}
/**
* 删除生产计划信息
*
* @param id 生产计划ID
* @return 结果
*/
@Override
public int deleteTProductPlanById(Long id)
{
return tProductPlanMapper.deleteTProductPlanById(id);
}
}
package com.zehong.system.service.track;
import java.util.List;
import com.zehong.system.domain.track.TProductPlan;
/**
* 生产计划Service接口
*
* @author zehong
* @date 2024-08-24
*/
public interface ITProductPlanService
{
/**
* 查询生产计划
*
* @param id 生产计划ID
* @return 生产计划
*/
public TProductPlan selectTProductPlanById(Long id);
/**
* 查询生产计划列表
*
* @param tProductPlan 生产计划
* @return 生产计划集合
*/
public List<TProductPlan> selectTProductPlanList(TProductPlan tProductPlan);
/**
* 新增生产计划
*
* @param tProductPlan 生产计划
* @return 结果
*/
public int insertTProductPlan(TProductPlan tProductPlan);
/**
* 修改生产计划
*
* @param tProductPlan 生产计划
* @return 结果
*/
public int updateTProductPlan(TProductPlan tProductPlan);
/**
* 批量删除生产计划
*
* @param ids 需要删除的生产计划ID
* @return 结果
*/
public int deleteTProductPlanByIds(Long[] ids);
/**
* 删除生产计划信息
*
* @param id 生产计划ID
* @return 结果
*/
public int deleteTProductPlanById(Long id);
}
<?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.track.TProductPlanMapper">
<resultMap type="TProductPlan" id="TProductPlanResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="planNo" column="plan_no" />
<result property="content" column="content" />
<result property="total" column="total" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="createId" column="create_id" />
</resultMap>
<sql id="selectTProductPlanVo">
select id, title, plan_no, content, total, status, create_time, create_id, <include refid="Common.createBy"/> from t_product_plan
</sql>
<select id="selectTProductPlanList" parameterType="TProductPlan" resultMap="TProductPlanResult">
<include refid="selectTProductPlanVo"/>
<where>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="planNo != null and planNo != ''"> and plan_no like concat('%', #{planNo}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
order by create_time desc
</select>
<select id="selectTProductPlanById" parameterType="Long" resultMap="TProductPlanResult">
<include refid="selectTProductPlanVo"/>
where id = #{id}
</select>
<insert id="insertTProductPlan" parameterType="TProductPlan" useGeneratedKeys="true" keyProperty="id">
insert into t_product_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="planNo != null">plan_no,</if>
<if test="content != null">content,</if>
<if test="total != null">total,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
<if test="createId != null">create_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">#{title},</if>
<if test="planNo != null">#{planNo},</if>
<if test="content != null">#{content},</if>
<if test="total != null">#{total},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createId != null">#{createId},</if>
</trim>
</insert>
<update id="updateTProductPlan" parameterType="TProductPlan">
update t_product_plan
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="planNo != null">plan_no = #{planNo},</if>
<if test="content != null">content = #{content},</if>
<if test="total != null">total = #{total},</if>
<if test="status != null">status = #{status},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createId != null">create_id = #{createId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTProductPlanById" parameterType="Long">
delete from t_product_plan where id = #{id}
</delete>
<delete id="deleteTProductPlanByIds" parameterType="String">
delete from t_product_plan where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询生产计划列表
export function listPlan(query) {
return request({
url: '/track/plan/list',
method: 'get',
params: query
})
}
// 查询生产计划详细
export function getPlan(id) {
return request({
url: '/track/plan/' + id,
method: 'get'
})
}
// 新增生产计划
export function addPlan(data) {
return request({
url: '/track/plan',
method: 'post',
data: data
})
}
// 修改生产计划
export function updatePlan(data) {
return request({
url: '/track/plan',
method: 'put',
data: data
})
}
// 删除生产计划
export function delPlan(id) {
return request({
url: '/track/plan/' + id,
method: 'delete'
})
}
// 导出生产计划
export function exportPlan(query) {
return request({
url: '/track/plan/export',
method: 'get',
params: query
})
}
<template>
<el-dialog title="详情" :visible.sync="detailOpen" width="800px" append-to-body destroy-on-close :close-on-click-modal="false">
<el-form label-width="90px">
<el-row class="el-row-table">
<el-col :span="12">
<el-form-item label="计划名称">
<span v-if="detailInfo.title">{{ detailInfo.title }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="计划编号">
<span v-if="detailInfo.planNo">{{ detailInfo.planNo }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生产总数">
<span v-if="detailInfo.total">{{ detailInfo.total }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="创建时间">
<span v-if="detailInfo.createTime">{{ detailInfo.createTime }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="创建人">
<span v-if="detailInfo.createBy">{{ detailInfo.createBy }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="计划描述">
<span v-if="detailInfo.content">{{ detailInfo.content }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-dialog>
</template>
<script>
import { getPlan } from "@/api/track/plan";
export default {
name: "detail-info",
data(){
return{
detailOpen: false,
detailInfo: {}
}
},
methods:{
getDetailInfo(id){
getPlan(id).then(res =>{
if(res.code == 200){
this.detailInfo = res.data;
this.detailOpen = true;
}
})
}
}
}
</script>
<style scoped>
</style>
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="计划名称" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入计划名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="计划编号" prop="planNo">
<el-input
v-model="queryParams.planNo"
placeholder="请输入计划编号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="计划状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择计划状态" clearable size="small">
<el-option
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="计划名称" align="center" prop="title" />
<el-table-column label="计划编号" align="center" prop="planNo" />
<el-table-column label="生产总数" align="center" prop="total" />
<el-table-column label="计划状态" align="center" prop="status" :formatter="statusFormat" />
<el-table-column label="创建时间" align="center" prop="createTime"/>
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-document"
@click="handleDetail(scope.row)"
>详情</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改生产计划对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body destroy-on-close :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row class="el-row-table">
<el-col :span="12">
<el-form-item label="计划名称" prop="title">
<el-input v-model="form.title" placeholder="请输入计划名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="计划编号" prop="planNo">
<el-input v-model="form.planNo" placeholder="请输入计划编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生产总数" prop="total">
<el-input type="Number" v-model="form.total" placeholder="请输入生产总数" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="计划描述" prop="content">
<el-input v-model="form.content" :autosize="{ minRows: 3 }" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!-- 详情 -->
<DetailInfo ref="detail"/>
</div>
</template>
<script>
import { listPlan, getPlan, delPlan, addPlan, updatePlan, exportPlan } from "@/api/track/plan";
import DetailInfo from "./components/DetailInfo";
export default {
name: "Plan",
components: {
DetailInfo
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
titles: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 生产计划表格数据
planList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 计划状态字典
statusOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
title: null,
planNo: null,
status: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
title: [
{ required: true, message: "计划名称不能为空", trigger: "blur" }
],
planNo: [
{ required: true, message: "计划编号不能为空", trigger: "blur" }
],
total: [
{ required: true, message: "生产总数不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
this.getDicts("product_plan_status").then(response => {
this.statusOptions = response.data;
});
},
methods: {
/** 查询生产计划列表 */
getList() {
this.loading = true;
listPlan(this.queryParams).then(response => {
this.planList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 计划状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
title: null,
planNo: null,
content: null,
total: null,
status: "0",
createTime: null,
createId: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id);
this.titles = selection.map(item => item.title);
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加生产计划";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getPlan(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改生产计划";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updatePlan(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addPlan(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
const titles = row.title || this.titles;
this.$confirm('是否确认删除生产计划名称为"' + titles + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delPlan(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有生产计划数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return exportPlan(queryParams);
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
},
//详情
handleDetail(row){
this.$refs.detail.getDetailInfo(row.id);
}
}
};
</script>
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