排班计划-班组

This commit is contained in:
JinLu.Yin 2022-06-07 22:39:21 +08:00
parent 3ec4fb7505
commit bae7d944b6
6 changed files with 606 additions and 0 deletions

View File

@ -0,0 +1,109 @@
package com.ktg.mes.cal.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ktg.common.constant.UserConstants;
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.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.enums.BusinessType;
import com.ktg.mes.cal.domain.CalPlanTeam;
import com.ktg.mes.cal.service.ICalPlanTeamService;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
/**
* 计划班组Controller
*
* @author yinjinlu
* @date 2022-06-07
*/
@RestController
@RequestMapping("/mes/cal/planteam")
public class CalPlanTeamController extends BaseController
{
@Autowired
private ICalPlanTeamService calPlanTeamService;
/**
* 查询计划班组列表
*/
@PreAuthorize("@ss.hasPermi('mes:cal:planteam:list')")
@GetMapping("/list")
public TableDataInfo list(CalPlanTeam calPlanTeam)
{
startPage();
List<CalPlanTeam> list = calPlanTeamService.selectCalPlanTeamList(calPlanTeam);
return getDataTable(list);
}
/**
* 导出计划班组列表
*/
@PreAuthorize("@ss.hasPermi('mes:cal:planteam:export')")
@Log(title = "计划班组", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CalPlanTeam calPlanTeam)
{
List<CalPlanTeam> list = calPlanTeamService.selectCalPlanTeamList(calPlanTeam);
ExcelUtil<CalPlanTeam> util = new ExcelUtil<CalPlanTeam>(CalPlanTeam.class);
util.exportExcel(response, list, "计划班组数据");
}
/**
* 获取计划班组详细信息
*/
@PreAuthorize("@ss.hasPermi('mes:cal:planteam:query')")
@GetMapping(value = "/{recordId}")
public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
{
return AjaxResult.success(calPlanTeamService.selectCalPlanTeamByRecordId(recordId));
}
/**
* 新增计划班组
*/
@PreAuthorize("@ss.hasPermi('mes:cal:planteam:add')")
@Log(title = "计划班组", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CalPlanTeam calPlanTeam)
{
if (UserConstants.NOT_UNIQUE.equals(calPlanTeamService.checkPlanTeamUnique(calPlanTeam))) {
return AjaxResult.error("班组已添加,不能重复添加!");
}
return toAjax(calPlanTeamService.insertCalPlanTeam(calPlanTeam));
}
/**
* 修改计划班组
*/
@PreAuthorize("@ss.hasPermi('mes:cal:planteam:edit')")
@Log(title = "计划班组", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CalPlanTeam calPlanTeam)
{
return toAjax(calPlanTeamService.updateCalPlanTeam(calPlanTeam));
}
/**
* 删除计划班组
*/
@PreAuthorize("@ss.hasPermi('mes:cal:planteam:remove')")
@Log(title = "计划班组", businessType = BusinessType.DELETE)
@DeleteMapping("/{recordIds}")
public AjaxResult remove(@PathVariable Long[] recordIds)
{
return toAjax(calPlanTeamService.deleteCalPlanTeamByRecordIds(recordIds));
}
}

View File

@ -0,0 +1,150 @@
package com.ktg.mes.cal.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;
/**
* 计划班组对象 cal_plan_team
*
* @author yinjinlu
* @date 2022-06-07
*/
public class CalPlanTeam extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 流水号 */
private Long recordId;
/** 计划ID */
@Excel(name = "计划ID")
private Long planId;
/** 班组ID */
@Excel(name = "班组ID")
private Long teamId;
/** 班组编号 */
@Excel(name = "班组编号")
private String teamCode;
/** 班组名称 */
@Excel(name = "班组名称")
private String teamName;
/** 预留字段1 */
private String attr1;
/** 预留字段2 */
private String attr2;
/** 预留字段3 */
private Long attr3;
/** 预留字段4 */
private Long attr4;
public void setRecordId(Long recordId)
{
this.recordId = recordId;
}
public Long getRecordId()
{
return recordId;
}
public void setPlanId(Long planId)
{
this.planId = planId;
}
public Long getPlanId()
{
return planId;
}
public void setTeamId(Long teamId)
{
this.teamId = teamId;
}
public Long getTeamId()
{
return teamId;
}
public void setTeamCode(String teamCode)
{
this.teamCode = teamCode;
}
public String getTeamCode()
{
return teamCode;
}
public void setTeamName(String teamName)
{
this.teamName = teamName;
}
public String getTeamName()
{
return teamName;
}
public void setAttr1(String attr1)
{
this.attr1 = attr1;
}
public String getAttr1()
{
return attr1;
}
public void setAttr2(String attr2)
{
this.attr2 = attr2;
}
public String getAttr2()
{
return attr2;
}
public void setAttr3(Long attr3)
{
this.attr3 = attr3;
}
public Long getAttr3()
{
return attr3;
}
public void setAttr4(Long attr4)
{
this.attr4 = attr4;
}
public Long getAttr4()
{
return attr4;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("recordId", getRecordId())
.append("planId", getPlanId())
.append("teamId", getTeamId())
.append("teamCode", getTeamCode())
.append("teamName", getTeamName())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,63 @@
package com.ktg.mes.cal.mapper;
import java.util.List;
import com.ktg.mes.cal.domain.CalPlanTeam;
/**
* 计划班组Mapper接口
*
* @author yinjinlu
* @date 2022-06-07
*/
public interface CalPlanTeamMapper
{
/**
* 查询计划班组
*
* @param recordId 计划班组主键
* @return 计划班组
*/
public CalPlanTeam selectCalPlanTeamByRecordId(Long recordId);
/**
* 查询计划班组列表
*
* @param calPlanTeam 计划班组
* @return 计划班组集合
*/
public List<CalPlanTeam> selectCalPlanTeamList(CalPlanTeam calPlanTeam);
public CalPlanTeam checkPlanTeamUnique(CalPlanTeam calPlanTeam);
/**
* 新增计划班组
*
* @param calPlanTeam 计划班组
* @return 结果
*/
public int insertCalPlanTeam(CalPlanTeam calPlanTeam);
/**
* 修改计划班组
*
* @param calPlanTeam 计划班组
* @return 结果
*/
public int updateCalPlanTeam(CalPlanTeam calPlanTeam);
/**
* 删除计划班组
*
* @param recordId 计划班组主键
* @return 结果
*/
public int deleteCalPlanTeamByRecordId(Long recordId);
/**
* 批量删除计划班组
*
* @param recordIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteCalPlanTeamByRecordIds(Long[] recordIds);
}

View File

@ -0,0 +1,63 @@
package com.ktg.mes.cal.service;
import java.util.List;
import com.ktg.mes.cal.domain.CalPlanTeam;
/**
* 计划班组Service接口
*
* @author yinjinlu
* @date 2022-06-07
*/
public interface ICalPlanTeamService
{
/**
* 查询计划班组
*
* @param recordId 计划班组主键
* @return 计划班组
*/
public CalPlanTeam selectCalPlanTeamByRecordId(Long recordId);
/**
* 查询计划班组列表
*
* @param calPlanTeam 计划班组
* @return 计划班组集合
*/
public List<CalPlanTeam> selectCalPlanTeamList(CalPlanTeam calPlanTeam);
public String checkPlanTeamUnique(CalPlanTeam calPlanTeam);
/**
* 新增计划班组
*
* @param calPlanTeam 计划班组
* @return 结果
*/
public int insertCalPlanTeam(CalPlanTeam calPlanTeam);
/**
* 修改计划班组
*
* @param calPlanTeam 计划班组
* @return 结果
*/
public int updateCalPlanTeam(CalPlanTeam calPlanTeam);
/**
* 批量删除计划班组
*
* @param recordIds 需要删除的计划班组主键集合
* @return 结果
*/
public int deleteCalPlanTeamByRecordIds(Long[] recordIds);
/**
* 删除计划班组信息
*
* @param recordId 计划班组主键
* @return 结果
*/
public int deleteCalPlanTeamByRecordId(Long recordId);
}

View File

@ -0,0 +1,109 @@
package com.ktg.mes.cal.service.impl;
import java.util.List;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.cal.mapper.CalPlanTeamMapper;
import com.ktg.mes.cal.domain.CalPlanTeam;
import com.ktg.mes.cal.service.ICalPlanTeamService;
/**
* 计划班组Service业务层处理
*
* @author yinjinlu
* @date 2022-06-07
*/
@Service
public class CalPlanTeamServiceImpl implements ICalPlanTeamService
{
@Autowired
private CalPlanTeamMapper calPlanTeamMapper;
/**
* 查询计划班组
*
* @param recordId 计划班组主键
* @return 计划班组
*/
@Override
public CalPlanTeam selectCalPlanTeamByRecordId(Long recordId)
{
return calPlanTeamMapper.selectCalPlanTeamByRecordId(recordId);
}
/**
* 查询计划班组列表
*
* @param calPlanTeam 计划班组
* @return 计划班组
*/
@Override
public List<CalPlanTeam> selectCalPlanTeamList(CalPlanTeam calPlanTeam)
{
return calPlanTeamMapper.selectCalPlanTeamList(calPlanTeam);
}
@Override
public String checkPlanTeamUnique(CalPlanTeam calPlanTeam) {
CalPlanTeam team = calPlanTeamMapper.checkPlanTeamUnique(calPlanTeam);
Long recodeId = calPlanTeam.getRecordId()==null?-1L:calPlanTeam.getRecordId();
if(StringUtils.isNotNull(team) && team.getRecordId().longValue() != recodeId.longValue()){
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* 新增计划班组
*
* @param calPlanTeam 计划班组
* @return 结果
*/
@Override
public int insertCalPlanTeam(CalPlanTeam calPlanTeam)
{
calPlanTeam.setCreateTime(DateUtils.getNowDate());
return calPlanTeamMapper.insertCalPlanTeam(calPlanTeam);
}
/**
* 修改计划班组
*
* @param calPlanTeam 计划班组
* @return 结果
*/
@Override
public int updateCalPlanTeam(CalPlanTeam calPlanTeam)
{
calPlanTeam.setUpdateTime(DateUtils.getNowDate());
return calPlanTeamMapper.updateCalPlanTeam(calPlanTeam);
}
/**
* 批量删除计划班组
*
* @param recordIds 需要删除的计划班组主键
* @return 结果
*/
@Override
public int deleteCalPlanTeamByRecordIds(Long[] recordIds)
{
return calPlanTeamMapper.deleteCalPlanTeamByRecordIds(recordIds);
}
/**
* 删除计划班组信息
*
* @param recordId 计划班组主键
* @return 结果
*/
@Override
public int deleteCalPlanTeamByRecordId(Long recordId)
{
return calPlanTeamMapper.deleteCalPlanTeamByRecordId(recordId);
}
}

View File

@ -0,0 +1,112 @@
<?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.ktg.mes.cal.mapper.CalPlanTeamMapper">
<resultMap type="CalPlanTeam" id="CalPlanTeamResult">
<result property="recordId" column="record_id" />
<result property="planId" column="plan_id" />
<result property="teamId" column="team_id" />
<result property="teamCode" column="team_code" />
<result property="teamName" column="team_name" />
<result property="remark" column="remark" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="attr4" column="attr4" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectCalPlanTeamVo">
select record_id, plan_id, team_id, team_code, team_name, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_plan_team
</sql>
<select id="selectCalPlanTeamList" parameterType="CalPlanTeam" resultMap="CalPlanTeamResult">
<include refid="selectCalPlanTeamVo"/>
<where>
<if test="planId != null "> and plan_id = #{planId}</if>
<if test="teamId != null "> and team_id = #{teamId}</if>
<if test="teamCode != null and teamCode != ''"> and team_code = #{teamCode}</if>
<if test="teamName != null and teamName != ''"> and team_name like concat('%', #{teamName}, '%')</if>
</where>
</select>
<select id="selectCalPlanTeamByRecordId" parameterType="Long" resultMap="CalPlanTeamResult">
<include refid="selectCalPlanTeamVo"/>
where record_id = #{recordId}
</select>
<select id="checkPlanTeamUnique" parameterType="CalPlanTeam" resultMap="CalPlanTeamResult">
<include refid="selectCalPlanTeamVo"/>
where plan_id = #{planId} and team_id = #{teamId} limit 1
</select>
<insert id="insertCalPlanTeam" parameterType="CalPlanTeam" useGeneratedKeys="true" keyProperty="recordId">
insert into cal_plan_team
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null">plan_id,</if>
<if test="teamId != null">team_id,</if>
<if test="teamCode != null">team_code,</if>
<if test="teamName != null">team_name,</if>
<if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null">#{planId},</if>
<if test="teamId != null">#{teamId},</if>
<if test="teamCode != null">#{teamCode},</if>
<if test="teamName != null">#{teamName},</if>
<if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateCalPlanTeam" parameterType="CalPlanTeam">
update cal_plan_team
<trim prefix="SET" suffixOverrides=",">
<if test="planId != null">plan_id = #{planId},</if>
<if test="teamId != null">team_id = #{teamId},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="teamName != null">team_name = #{teamName},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where record_id = #{recordId}
</update>
<delete id="deleteCalPlanTeamByRecordId" parameterType="Long">
delete from cal_plan_team where record_id = #{recordId}
</delete>
<delete id="deleteCalPlanTeamByRecordIds" parameterType="String">
delete from cal_plan_team where record_id in
<foreach item="recordId" collection="array" open="(" separator="," close=")">
#{recordId}
</foreach>
</delete>
</mapper>