diff --git a/ktg-mes/src/main/java/com/ktg/mes/dv/controller/DvCheckSubjectController.java b/ktg-mes/src/main/java/com/ktg/mes/dv/controller/DvCheckSubjectController.java new file mode 100644 index 0000000..3a8a10b --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/dv/controller/DvCheckSubjectController.java @@ -0,0 +1,113 @@ +package com.ktg.mes.dv.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.dv.domain.DvCheckSubject; +import com.ktg.mes.dv.service.IDvCheckSubjectService; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.common.core.page.TableDataInfo; + +/** + * 点检项目Controller + * + * @author yinjinlu + * @date 2022-06-18 + */ +@RestController +@RequestMapping("/mes/dv/checksubject") +public class DvCheckSubjectController extends BaseController +{ + @Autowired + private IDvCheckSubjectService dvCheckSubjectService; + + /** + * 查询点检项目列表 + */ + @PreAuthorize("@ss.hasPermi('mes:dv:checksubject:list')") + @GetMapping("/list") + public TableDataInfo list(DvCheckSubject dvCheckSubject) + { + startPage(); + List list = dvCheckSubjectService.selectDvCheckSubjectList(dvCheckSubject); + return getDataTable(list); + } + + /** + * 导出点检项目列表 + */ + @PreAuthorize("@ss.hasPermi('mes:dv:checksubject:export')") + @Log(title = "点检项目", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, DvCheckSubject dvCheckSubject) + { + List list = dvCheckSubjectService.selectDvCheckSubjectList(dvCheckSubject); + ExcelUtil util = new ExcelUtil(DvCheckSubject.class); + util.exportExcel(response, list, "点检项目数据"); + } + + /** + * 获取点检项目详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:dv:checksubject:query')") + @GetMapping(value = "/{recordId}") + public AjaxResult getInfo(@PathVariable("recordId") Long recordId) + { + return AjaxResult.success(dvCheckSubjectService.selectDvCheckSubjectByRecordId(recordId)); + } + + /** + * 新增点检项目 + */ + @PreAuthorize("@ss.hasPermi('mes:dv:checksubject:add')") + @Log(title = "点检项目", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DvCheckSubject dvCheckSubject) + { + if(UserConstants.NOT_UNIQUE.equals(dvCheckSubjectService.checkSubjectUnique(dvCheckSubject))){ + return AjaxResult.error("点检项目已经添加过!"); + } + + return toAjax(dvCheckSubjectService.insertDvCheckSubject(dvCheckSubject)); + } + + /** + * 修改点检项目 + */ + @PreAuthorize("@ss.hasPermi('mes:dv:checksubject:edit')") + @Log(title = "点检项目", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DvCheckSubject dvCheckSubject) + { + if(UserConstants.NOT_UNIQUE.equals(dvCheckSubjectService.checkSubjectUnique(dvCheckSubject))){ + return AjaxResult.error("点检项目已经添加过!"); + } + return toAjax(dvCheckSubjectService.updateDvCheckSubject(dvCheckSubject)); + } + + /** + * 删除点检项目 + */ + @PreAuthorize("@ss.hasPermi('mes:dv:checksubject:remove')") + @Log(title = "点检项目", businessType = BusinessType.DELETE) + @DeleteMapping("/{recordIds}") + public AjaxResult remove(@PathVariable Long[] recordIds) + { + return toAjax(dvCheckSubjectService.deleteDvCheckSubjectByRecordIds(recordIds)); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/dv/domain/DvCheckSubject.java b/ktg-mes/src/main/java/com/ktg/mes/dv/domain/DvCheckSubject.java new file mode 100644 index 0000000..0c82617 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/dv/domain/DvCheckSubject.java @@ -0,0 +1,192 @@ +package com.ktg.mes.dv.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; + +/** + * 点检项目对象 dv_check_subject + * + * @author yinjinlu + * @date 2022-06-18 + */ +public class DvCheckSubject extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 流水号 */ + private Long recordId; + + /** 计划ID */ + @Excel(name = "计划ID") + private Long planId; + + /** 设备ID */ + @Excel(name = "设备ID") + private Long subjectId; + + /** 项目编码 */ + @Excel(name = "项目编码") + private String subjectCode; + + /** 项目名称 */ + @Excel(name = "项目名称") + private String subjectName; + + /** 项目类型 */ + @Excel(name = "项目类型") + private String subjectType; + + /** 项目内容 */ + @Excel(name = "项目内容") + private String subjectContent; + + /** 标准 */ + @Excel(name = "标准") + private String subjectStandard; + + /** 预留字段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 setSubjectId(Long subjectId) + { + this.subjectId = subjectId; + } + + public Long getSubjectId() + { + return subjectId; + } + public void setSubjectCode(String subjectCode) + { + this.subjectCode = subjectCode; + } + + public String getSubjectCode() + { + return subjectCode; + } + public void setSubjectName(String subjectName) + { + this.subjectName = subjectName; + } + + public String getSubjectName() + { + return subjectName; + } + public void setSubjectType(String subjectType) + { + this.subjectType = subjectType; + } + + public String getSubjectType() + { + return subjectType; + } + public void setSubjectContent(String subjectContent) + { + this.subjectContent = subjectContent; + } + + public String getSubjectContent() + { + return subjectContent; + } + public void setSubjectStandard(String subjectStandard) + { + this.subjectStandard = subjectStandard; + } + + public String getSubjectStandard() + { + return subjectStandard; + } + 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("subjectId", getSubjectId()) + .append("subjectCode", getSubjectCode()) + .append("subjectName", getSubjectName()) + .append("subjectType", getSubjectType()) + .append("subjectContent", getSubjectContent()) + .append("subjectStandard", getSubjectStandard()) + .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(); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/dv/mapper/DvCheckSubjectMapper.java b/ktg-mes/src/main/java/com/ktg/mes/dv/mapper/DvCheckSubjectMapper.java new file mode 100644 index 0000000..f9e0225 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/dv/mapper/DvCheckSubjectMapper.java @@ -0,0 +1,64 @@ +package com.ktg.mes.dv.mapper; + +import java.util.List; +import com.ktg.mes.dv.domain.DvCheckSubject; + +/** + * 点检项目Mapper接口 + * + * @author yinjinlu + * @date 2022-06-18 + */ +public interface DvCheckSubjectMapper +{ + /** + * 查询点检项目 + * + * @param recordId 点检项目主键 + * @return 点检项目 + */ + public DvCheckSubject selectDvCheckSubjectByRecordId(Long recordId); + + /** + * 查询点检项目列表 + * + * @param dvCheckSubject 点检项目 + * @return 点检项目集合 + */ + public List selectDvCheckSubjectList(DvCheckSubject dvCheckSubject); + + + public DvCheckSubject checkSubjectUnique(DvCheckSubject dvCheckSubject); + + /** + * 新增点检项目 + * + * @param dvCheckSubject 点检项目 + * @return 结果 + */ + public int insertDvCheckSubject(DvCheckSubject dvCheckSubject); + + /** + * 修改点检项目 + * + * @param dvCheckSubject 点检项目 + * @return 结果 + */ + public int updateDvCheckSubject(DvCheckSubject dvCheckSubject); + + /** + * 删除点检项目 + * + * @param recordId 点检项目主键 + * @return 结果 + */ + public int deleteDvCheckSubjectByRecordId(Long recordId); + + /** + * 批量删除点检项目 + * + * @param recordIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDvCheckSubjectByRecordIds(Long[] recordIds); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/dv/service/IDvCheckSubjectService.java b/ktg-mes/src/main/java/com/ktg/mes/dv/service/IDvCheckSubjectService.java new file mode 100644 index 0000000..1216de1 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/dv/service/IDvCheckSubjectService.java @@ -0,0 +1,69 @@ +package com.ktg.mes.dv.service; + +import java.util.List; +import com.ktg.mes.dv.domain.DvCheckSubject; + +/** + * 点检项目Service接口 + * + * @author yinjinlu + * @date 2022-06-18 + */ +public interface IDvCheckSubjectService +{ + /** + * 查询点检项目 + * + * @param recordId 点检项目主键 + * @return 点检项目 + */ + public DvCheckSubject selectDvCheckSubjectByRecordId(Long recordId); + + /** + * 查询点检项目列表 + * + * @param dvCheckSubject 点检项目 + * @return 点检项目集合 + */ + public List selectDvCheckSubjectList(DvCheckSubject dvCheckSubject); + + + /** + * 检查当前计划下,点检项目是否唯一 + * @param dvCheckSubject + * @return + */ + public String checkSubjectUnique(DvCheckSubject dvCheckSubject); + + /** + * 新增点检项目 + * + * @param dvCheckSubject 点检项目 + * @return 结果 + */ + public int insertDvCheckSubject(DvCheckSubject dvCheckSubject); + + /** + * 修改点检项目 + * + * @param dvCheckSubject 点检项目 + * @return 结果 + */ + public int updateDvCheckSubject(DvCheckSubject dvCheckSubject); + + /** + * 批量删除点检项目 + * + * @param recordIds 需要删除的点检项目主键集合 + * @return 结果 + */ + public int deleteDvCheckSubjectByRecordIds(Long[] recordIds); + + /** + * 删除点检项目信息 + * + * @param recordId 点检项目主键 + * @return 结果 + */ + public int deleteDvCheckSubjectByRecordId(Long recordId); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/dv/service/impl/DvCheckSubjectServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/dv/service/impl/DvCheckSubjectServiceImpl.java new file mode 100644 index 0000000..31f728a --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/dv/service/impl/DvCheckSubjectServiceImpl.java @@ -0,0 +1,111 @@ +package com.ktg.mes.dv.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.apache.catalina.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ktg.mes.dv.mapper.DvCheckSubjectMapper; +import com.ktg.mes.dv.domain.DvCheckSubject; +import com.ktg.mes.dv.service.IDvCheckSubjectService; + +/** + * 点检项目Service业务层处理 + * + * @author yinjinlu + * @date 2022-06-18 + */ +@Service +public class DvCheckSubjectServiceImpl implements IDvCheckSubjectService +{ + @Autowired + private DvCheckSubjectMapper dvCheckSubjectMapper; + + /** + * 查询点检项目 + * + * @param recordId 点检项目主键 + * @return 点检项目 + */ + @Override + public DvCheckSubject selectDvCheckSubjectByRecordId(Long recordId) + { + return dvCheckSubjectMapper.selectDvCheckSubjectByRecordId(recordId); + } + + /** + * 查询点检项目列表 + * + * @param dvCheckSubject 点检项目 + * @return 点检项目 + */ + @Override + public List selectDvCheckSubjectList(DvCheckSubject dvCheckSubject) + { + return dvCheckSubjectMapper.selectDvCheckSubjectList(dvCheckSubject); + } + + @Override + public String checkSubjectUnique(DvCheckSubject dvCheckSubject) { + DvCheckSubject subject = dvCheckSubjectMapper.checkSubjectUnique(dvCheckSubject); + Long recordId = dvCheckSubject.getRecordId()==null?-1L:dvCheckSubject.getRecordId(); + if(StringUtils.isNotNull(subject) && subject.getRecordId().longValue() != recordId.longValue()){ + return UserConstants.NOT_UNIQUE; + } + + return UserConstants.UNIQUE; + } + + /** + * 新增点检项目 + * + * @param dvCheckSubject 点检项目 + * @return 结果 + */ + @Override + public int insertDvCheckSubject(DvCheckSubject dvCheckSubject) + { + dvCheckSubject.setCreateTime(DateUtils.getNowDate()); + return dvCheckSubjectMapper.insertDvCheckSubject(dvCheckSubject); + } + + /** + * 修改点检项目 + * + * @param dvCheckSubject 点检项目 + * @return 结果 + */ + @Override + public int updateDvCheckSubject(DvCheckSubject dvCheckSubject) + { + dvCheckSubject.setUpdateTime(DateUtils.getNowDate()); + return dvCheckSubjectMapper.updateDvCheckSubject(dvCheckSubject); + } + + /** + * 批量删除点检项目 + * + * @param recordIds 需要删除的点检项目主键 + * @return 结果 + */ + @Override + public int deleteDvCheckSubjectByRecordIds(Long[] recordIds) + { + return dvCheckSubjectMapper.deleteDvCheckSubjectByRecordIds(recordIds); + } + + /** + * 删除点检项目信息 + * + * @param recordId 点检项目主键 + * @return 结果 + */ + @Override + public int deleteDvCheckSubjectByRecordId(Long recordId) + { + return dvCheckSubjectMapper.deleteDvCheckSubjectByRecordId(recordId); + } +} diff --git a/ktg-mes/src/main/resources/mapper/dv/DvCheckSubjectMapper.xml b/ktg-mes/src/main/resources/mapper/dv/DvCheckSubjectMapper.xml new file mode 100644 index 0000000..c8aab8b --- /dev/null +++ b/ktg-mes/src/main/resources/mapper/dv/DvCheckSubjectMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select record_id, plan_id, subject_id, subject_code, subject_name, subject_type, subject_content, subject_standard, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from dv_check_subject + + + + + + + + + + insert into dv_check_subject + + plan_id, + subject_id, + subject_code, + subject_name, + subject_type, + subject_content, + subject_standard, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{planId}, + #{subjectId}, + #{subjectCode}, + #{subjectName}, + #{subjectType}, + #{subjectContent}, + #{subjectStandard}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update dv_check_subject + + plan_id = #{planId}, + subject_id = #{subjectId}, + subject_code = #{subjectCode}, + subject_name = #{subjectName}, + subject_type = #{subjectType}, + subject_content = #{subjectContent}, + subject_standard = #{subjectStandard}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where record_id = #{recordId} + + + + delete from dv_check_subject where record_id = #{recordId} + + + + delete from dv_check_subject where record_id in + + #{recordId} + + + \ No newline at end of file