设备管理-检查项维护(新增)

highway
wws 1 year ago
parent 6a14a48c97
commit e81e645667

@ -2,6 +2,8 @@ package com.op.device.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.device.domain.dto.EquCheckItemDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -23,75 +25,75 @@ import com.op.common.core.web.page.TableDataInfo;
/**
* Controller
*
*
* @author wws
* @date 2023-10-09
*/
@RestController
@RequestMapping("/item")
public class EquCheckItemController extends BaseController {
@Autowired
private IEquCheckItemService equCheckItemService;
@Autowired
private IEquCheckItemService equCheckItemService;
/**
*
*/
@RequiresPermissions("device:item:list")
@GetMapping("/list")
public TableDataInfo list(EquCheckItem equCheckItem) {
startPage();
List<EquCheckItem> list = equCheckItemService.selectEquCheckItemList(equCheckItem);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("device:item:list")
@GetMapping("/list")
public TableDataInfo list(EquCheckItem equCheckItem) {
startPage();
List<EquCheckItem> list = equCheckItemService.selectEquCheckItemList(equCheckItem);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("device:item:export")
@Log(title = "检查项维护", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EquCheckItem equCheckItem) {
List<EquCheckItem> list = equCheckItemService.selectEquCheckItemList(equCheckItem);
ExcelUtil<EquCheckItem> util = new ExcelUtil<EquCheckItem>(EquCheckItem.class);
util.exportExcel(response, list, "检查项维护数据");
}
/**
*
*/
@RequiresPermissions("device:item:export")
@Log(title = "检查项维护", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EquCheckItem equCheckItem) {
List<EquCheckItem> list = equCheckItemService.selectEquCheckItemList(equCheckItem);
ExcelUtil<EquCheckItem> util = new ExcelUtil<EquCheckItem>(EquCheckItem.class);
util.exportExcel(response, list, "检查项维护数据");
}
/**
*
*/
@RequiresPermissions("device:item:query")
@GetMapping(value = "/{itemId}")
public AjaxResult getInfo(@PathVariable("itemId") String itemId) {
return success(equCheckItemService.selectEquCheckItemByItemId(itemId));
}
/**
*
*/
@RequiresPermissions("device:item:query")
@GetMapping(value = "/{itemId}")
public AjaxResult getInfo(@PathVariable("itemId") String itemId) {
return success(equCheckItemService.selectEquCheckItemByItemId(itemId));
}
/**
*
*/
@RequiresPermissions("device:item:add")
@Log(title = "检查项维护", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquCheckItem equCheckItem) {
return toAjax(equCheckItemService.insertEquCheckItem(equCheckItem));
}
/**
*
*/
@RequiresPermissions("device:item:add")
@Log(title = "检查项维护", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquCheckItemDTO equCheckItemDTO) {
return equCheckItemService.insertEquCheckItem(equCheckItemDTO);
}
/**
*
*/
@RequiresPermissions("device:item:edit")
@Log(title = "检查项维护", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquCheckItem equCheckItem) {
return toAjax(equCheckItemService.updateEquCheckItem(equCheckItem));
}
/**
*
*/
@RequiresPermissions("device:item:edit")
@Log(title = "检查项维护", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquCheckItem equCheckItem) {
return toAjax(equCheckItemService.updateEquCheckItem(equCheckItem));
}
/**
*
*/
@RequiresPermissions("device:item:remove")
@Log(title = "检查项维护", businessType = BusinessType.DELETE)
@DeleteMapping("/{itemIds}")
public AjaxResult remove(@PathVariable String[] itemIds) {
return toAjax(equCheckItemService.deleteEquCheckItemByItemIds(itemIds));
}
/**
*
*/
@RequiresPermissions("device:item:remove")
@Log(title = "检查项维护", businessType = BusinessType.DELETE)
@DeleteMapping("/{itemIds}")
public AjaxResult remove(@PathVariable String[] itemIds) {
return toAjax(equCheckItemService.deleteEquCheckItemByItemIds(itemIds));
}
}

@ -198,11 +198,11 @@ public class EquCheckItem extends BaseEntity {
public String getItemRemark() {
return itemRemark;
}
public void setFactory(String factoryCode) {
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactory() {
public String getFactoryCode() {
return factoryCode;
}
public void setAttr1(String attr1) {
@ -272,7 +272,7 @@ public class EquCheckItem extends BaseEntity {
.append("itemType", getItemType())
.append("itemTypeName", getItemTypeName())
.append("itemRemark", getItemRemark())
.append("factoryCode", getFactory())
.append("factoryCode", getFactoryCode())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())

@ -0,0 +1,231 @@
package com.op.device.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.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
/**
* equ_check_item_detail
*
* @author wws
* @date 2023-10-10
*/
public class EquCheckItemDetail extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private String detailId;
/** 主检查项编码 */
@Excel(name = "主检查项编码")
private String parentCode;
/** 标准类型 */
@Excel(name = "标准类型")
private String standardType;
/** 标准名称;qualitative(定性)、quantify定量 */
@Excel(name = "标准名称;qualitative(定性)、quantify", readConverterExp = "定=量")
private String standardName;
/** 工厂 */
@Excel(name = "工厂")
private String factoryCode;
/** 上限 */
@Excel(name = "上限")
private BigDecimal detailUpLimit;
/** 下限 */
@Excel(name = "下限")
private BigDecimal detailDownLimit;
/** 单位 */
@Excel(name = "单位")
private String detailUnit;
/** 备用字段1 */
@Excel(name = "备用字段1")
private String attr1;
/** 备用字段2 */
@Excel(name = "备用字段2")
private String attr2;
/** 备用字段3 */
@Excel(name = "备用字段3")
private String attr3;
/** 删除标识 */
private String delFlag;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
/** 更新人 */
@Excel(name = "更新人")
private String updatedBy;
/** 详情编码 */
@Excel(name = "详情编码")
private String detailCode;
public String getDetailCode() {
return detailCode;
}
public void setDetailCode(String detailCode) {
this.detailCode = detailCode;
}
public void setDetailId(String detailId) {
this.detailId = detailId;
}
public String getDetailId() {
return detailId;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCode() {
return parentCode;
}
public void setStandardType(String standardType) {
this.standardType = standardType;
}
public String getStandardType() {
return standardType;
}
public void setStandardName(String standardName) {
this.standardName = standardName;
}
public String getStandardName() {
return standardName;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryCode() {
return factoryCode;
}
public void setDetailUpLimit(BigDecimal detailUpLimit) {
this.detailUpLimit = detailUpLimit;
}
public BigDecimal getDetailUpLimit() {
return detailUpLimit;
}
public void setDetailDownLimit(BigDecimal detailDownLimit) {
this.detailDownLimit = detailDownLimit;
}
public BigDecimal getDetailDownLimit() {
return detailDownLimit;
}
public void setDetailUnit(String detailUnit) {
this.detailUnit = detailUnit;
}
public String getDetailUnit() {
return detailUnit;
}
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(String attr3) {
this.attr3 = attr3;
}
public String getAttr3() {
return attr3;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getDelFlag() {
return delFlag;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getCreatedBy() {
return createdBy;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public Date getUpdatedTime() {
return updatedTime;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("detailId", getDetailId())
.append("parentCode", getParentCode())
.append("standardType", getStandardType())
.append("standardName", getStandardName())
.append("factoryCode", getFactoryCode())
.append("detailUpLimit", getDetailUpLimit())
.append("detailDownLimit", getDetailDownLimit())
.append("detailUnit", getDetailUnit())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("delFlag", getDelFlag())
.append("createdTime", getCreatedTime())
.append("createdBy", getCreatedBy())
.append("updatedTime", getUpdatedTime())
.append("updatedBy", getUpdatedBy())
.append("detailCode", getDetailCode())
.toString();
}
}

@ -0,0 +1,245 @@
package com.op.device.domain.dto;
import com.op.device.domain.EquCheckItemDetail;
import java.util.Date;
import java.util.List;
// 检查项维护页面DTO
public class EquCheckItemDTO {
/** 主键 */
private String itemId ;
/** 检查项编码 */
private String itemCode ;
/** 检查项名称 */
private String itemName ;
/** 检查项方法/工具 */
private String itemMethod ;
/** 维护类型编码 */
private String itemType ;
/** 维护类型名称 */
private String itemTypeName ;
/** 检查项备注 */
private String itemRemark ;
/** 工厂 */
private String factoryCode ;
/** 备用字段1 */
private String attr1 ;
/** 备用字段2 */
private String attr2 ;
/** 备用字段3 */
private String attr3 ;
/** 删除标识 */
private String delFlag ;
/** 创建时间 */
private Date createdTime ;
/** 创建人 */
private String createdBy ;
/** 更新时间 */
private Date updatedTime ;
/** 更新人 */
private String updatedBy ;
// 标准列表
private List<EquCheckItemDetail> formStandard;
// 创建日期范围list
private List<Date> createdTimeArray;
// 更新日期范围list
private List<Date> updateTimeArray;
// 更新日期开始
private String updateTimeStart;
// 更新日期结束
private String updateTimeEnd;
// 创建日期开始
private String createTimeStart;
// 创建日期结束
private String createTimeEnd;
public List<Date> getCreatedTimeArray() {
return createdTimeArray;
}
public void setCreatedTimeArray(List<Date> createdTimeArray) {
this.createdTimeArray = createdTimeArray;
}
public List<Date> getUpdateTimeArray() {
return updateTimeArray;
}
public void setUpdateTimeArray(List<Date> updateTimeArray) {
this.updateTimeArray = updateTimeArray;
}
public String getUpdateTimeStart() {
return updateTimeStart;
}
public void setUpdateTimeStart(String updateTimeStart) {
this.updateTimeStart = updateTimeStart;
}
public String getUpdateTimeEnd() {
return updateTimeEnd;
}
public void setUpdateTimeEnd(String updateTimeEnd) {
this.updateTimeEnd = updateTimeEnd;
}
public String getCreateTimeStart() {
return createTimeStart;
}
public void setCreateTimeStart(String createTimeStart) {
this.createTimeStart = createTimeStart;
}
public String getCreateTimeEnd() {
return createTimeEnd;
}
public void setCreateTimeEnd(String createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getItemMethod() {
return itemMethod;
}
public void setItemMethod(String itemMethod) {
this.itemMethod = itemMethod;
}
public String getItemType() {
return itemType;
}
public void setItemType(String itemType) {
this.itemType = itemType;
}
public String getItemTypeName() {
return itemTypeName;
}
public void setItemTypeName(String itemTypeName) {
this.itemTypeName = itemTypeName;
}
public String getItemRemark() {
return itemRemark;
}
public void setItemRemark(String itemRemark) {
this.itemRemark = itemRemark;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr3() {
return attr3;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getUpdatedTime() {
return updatedTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public List<EquCheckItemDetail> getFormStandard() {
return formStandard;
}
public void setFormStandard(List<EquCheckItemDetail> formStandard) {
this.formStandard = formStandard;
}
}

@ -0,0 +1,180 @@
package com.op.device.domain.vo;
import com.op.device.domain.EquCheckItemDetail;
import java.util.Date;
import java.util.List;
// 检查项维护页面VO
public class EquCheckItemVO {
/** 主键 */
private String itemId ;
/** 检查项编码 */
private String itemCode ;
/** 检查项名称 */
private String itemName ;
/** 检查项方法/工具 */
private String itemMethod ;
/** 维护类型编码 */
private String itemType ;
/** 维护类型名称 */
private String itemTypeName ;
/** 检查项备注 */
private String itemRemark ;
/** 工厂 */
private String factoryCode ;
/** 备用字段1 */
private String attr1 ;
/** 备用字段2 */
private String attr2 ;
/** 备用字段3 */
private String attr3 ;
/** 删除标识 */
private String delFlag ;
/** 创建时间 */
private Date createdTime ;
/** 创建人 */
private String createdBy ;
/** 更新时间 */
private Date updatedTime ;
/** 更新人 */
private String updatedBy ;
// 标准列表
private List<EquCheckItemDetail> formStandard;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getItemMethod() {
return itemMethod;
}
public void setItemMethod(String itemMethod) {
this.itemMethod = itemMethod;
}
public String getItemType() {
return itemType;
}
public void setItemType(String itemType) {
this.itemType = itemType;
}
public String getItemTypeName() {
return itemTypeName;
}
public void setItemTypeName(String itemTypeName) {
this.itemTypeName = itemTypeName;
}
public String getItemRemark() {
return itemRemark;
}
public void setItemRemark(String itemRemark) {
this.itemRemark = itemRemark;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr3() {
return attr3;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getUpdatedTime() {
return updatedTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public List<EquCheckItemDetail> getFormStandard() {
return formStandard;
}
public void setFormStandard(List<EquCheckItemDetail> formStandard) {
this.formStandard = formStandard;
}
}

@ -0,0 +1,75 @@
package com.op.device.mapper;
import java.util.List;
import com.op.device.domain.EquCheckItemDetail;
/**
* Mapper
*
* @author wws
* @date 2023-10-10
*/
public interface EquCheckItemDetailMapper {
/**
*
*
* @param detailId
* @return
*/
public EquCheckItemDetail selectEquCheckItemDetailByDetailId(String detailId);
/**
*
*
* @param equCheckItemDetail
* @return
*/
public List<EquCheckItemDetail> selectEquCheckItemDetailList(EquCheckItemDetail equCheckItemDetail);
/**
*
*
* @param equCheckItemDetail
* @return
*/
public int insertEquCheckItemDetail(EquCheckItemDetail equCheckItemDetail);
/**
*
*
* @param equCheckItemDetail
* @return
*/
public int updateEquCheckItemDetail(EquCheckItemDetail equCheckItemDetail);
/**
*
*
* @param detailId
* @return
*/
public int deleteEquCheckItemDetailByDetailId(String detailId);
/**
*
*
* @param detailIds
* @return
*/
public int deleteEquCheckItemDetailByDetailIds(String[] detailIds);
/**
* code
* @param itemCode
* @return
*/
int selectSerialNumber(String itemCode);
/**
* code
* @param itemCode
* @return
*/
List<EquCheckItemDetail> selectEquCheckItemDetailByParentCode(String itemCode);
}

@ -58,4 +58,17 @@ public interface EquCheckItemMapper {
* @return
*/
public int deleteEquCheckItemByItemIds(String[] itemIds);
/**
*
* @param itemName
* @return
*/
EquCheckItem selectEquCheckItemByItemName(String itemName);
/**
*
* @return
*/
int selectSerialNumber();
}

@ -1,7 +1,10 @@
package com.op.device.service;
import java.util.List;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquCheckItem;
import com.op.device.domain.dto.EquCheckItemDTO;
/**
* Service
@ -29,10 +32,10 @@ public interface IEquCheckItemService {
/**
*
*
* @param equCheckItem
* @param equCheckItemDTO
* @return
*/
public int insertEquCheckItem(EquCheckItem equCheckItem);
public AjaxResult insertEquCheckItem(EquCheckItemDTO equCheckItemDTO);
/**
*

@ -3,13 +3,29 @@ package com.op.device.service.impl;
import java.text.SimpleDateFormat;
import java.util.List;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.log.annotation.Log;
import com.op.device.domain.EquCheckItemDetail;
import com.op.device.domain.dto.EquCheckItemDTO;
import com.op.device.mapper.EquCheckItemDetailMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.device.mapper.EquCheckItemMapper;
import com.op.device.domain.EquCheckItem;
import com.op.device.service.IEquCheckItemService;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* Service
@ -21,6 +37,8 @@ import com.op.device.service.IEquCheckItemService;
public class EquCheckItemServiceImpl implements IEquCheckItemService {
@Autowired
private EquCheckItemMapper equCheckItemMapper;
@Autowired
private EquCheckItemDetailMapper equCheckItemDetailMapper;
/**
*
@ -65,13 +83,72 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
/**
*
*
* @param equCheckItem
* @param equCheckItemDTO
* @return
* TODO
*/
@Override
@DS("#header.poolName")
public int insertEquCheckItem(EquCheckItem equCheckItem) {
return equCheckItemMapper.insertEquCheckItem(equCheckItem);
public AjaxResult insertEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验重复
EquCheckItem checkItem = equCheckItemMapper.selectEquCheckItemByItemName(equCheckItemDTO.getItemName());
if (checkItem != null) {
return error("检查项已存在!新增失败!");
}
// 创建检查项对象
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO,equCheckItem);
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 获取检查项流水号
String serialNum = String.format("%02d", equCheckItemMapper.selectSerialNumber());
// 处理检查项信息
equCheckItem.setItemId(IdUtils.fastSimpleUUID());
equCheckItem.setFactoryCode(factory);
equCheckItem.setItemCode("CI"+serialNum);
equCheckItem.setCreatedBy(SecurityContextHolder.getUserName());
equCheckItem.setCreatedTime(DateUtils.getNowDate());
equCheckItem.setUpdatedBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdatedTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
// 插入数据库
equCheckItemMapper.insertEquCheckItem(equCheckItem);
// 处理标准信息
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(factory);
detail.setDetailCode(equCheckItem.getItemCode()+detailSerialNum);
detail.setCreatedBy(SecurityContextHolder.getUserName());
detail.setCreatedTime(DateUtils.getNowDate());
detail.setUpdatedBy(SecurityContextHolder.getUserName());
detail.setUpdatedTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
return success("新增成功");
}
/**

@ -0,0 +1,143 @@
<?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.op.device.mapper.EquCheckItemDetailMapper">
<resultMap type="EquCheckItemDetail" id="EquCheckItemDetailResult">
<result property="detailId" column="detail_id" />
<result property="parentCode" column="parent_code" />
<result property="standardType" column="standard_type" />
<result property="standardName" column="standard_name" />
<result property="factoryCode" column="factory_code" />
<result property="detailUpLimit" column="detail_up_limit" />
<result property="detailDownLimit" column="detail_down_limit" />
<result property="detailUnit" column="detail_unit" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="delFlag" column="del_flag" />
<result property="createdTime" column="created_time" />
<result property="createdBy" column="created_by" />
<result property="updatedTime" column="updated_time" />
<result property="updatedBy" column="updated_by" />
<result property="detailCode" column="detail_code" />
</resultMap>
<sql id="selectEquCheckItemDetailVo">
select detail_id, parent_code, standard_type, standard_name, factory_code, detail_up_limit, detail_down_limit, detail_unit, attr1, attr2, attr3, del_flag, created_time, created_by, updated_time, updated_by, detail_code from equ_check_item_detail
</sql>
<select id="selectEquCheckItemDetailList" parameterType="EquCheckItemDetail" resultMap="EquCheckItemDetailResult">
<include refid="selectEquCheckItemDetailVo"/>
<where>
<if test="parentCode != null and parentCode != ''"> and parent_code = #{parentCode}</if>
<if test="standardType != null and standardType != ''"> and standard_type = #{standardType}</if>
<if test="standardName != null and standardName != ''"> and standard_name like concat('%', #{standardName}, '%')</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="detailUpLimit != null "> and detail_up_limit = #{detailUpLimit}</if>
<if test="detailDownLimit != null "> and detail_down_limit = #{detailDownLimit}</if>
<if test="detailUnit != null and detailUnit != ''"> and detail_unit = #{detailUnit}</if>
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="detailCode != null and detailCode != ''"> and detail_code = #{detailCode}</if>
</where>
</select>
<select id="selectEquCheckItemDetailByDetailId" parameterType="String" resultMap="EquCheckItemDetailResult">
<include refid="selectEquCheckItemDetailVo"/>
where detail_id = #{detailId}
</select>
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(detail_id)+1 AS serialNum
FROM equ_check_item_detail
WHERE CONVERT(date, GETDATE()) = CONVERT(date,created_time) and parent_code = #{itemCode};
</select>
<select id="selectEquCheckItemDetailByParentCode" parameterType="String" resultMap="EquCheckItemDetailResult">
<include refid="selectEquCheckItemDetailVo"/>
where parent_code = #{parentCode}
</select>
<insert id="insertEquCheckItemDetail" parameterType="EquCheckItemDetail">
insert into equ_check_item_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="detailId != null">detail_id,</if>
<if test="parentCode != null and parentCode != ''">parent_code,</if>
<if test="standardType != null and standardType != ''">standard_type,</if>
<if test="standardName != null and standardName != ''">standard_name,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="detailUpLimit != null">detail_up_limit,</if>
<if test="detailDownLimit != null">detail_down_limit,</if>
<if test="detailUnit != null and detailUnit != ''">detail_unit,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createdTime != null">created_time,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="updatedBy != null and updatedBy != ''">updated_by,</if>
<if test="detailCode != null and detailCode != ''">detail_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="detailId != null">#{detailId},</if>
<if test="parentCode != null and parentCode != ''">#{parentCode},</if>
<if test="standardType != null and standardType != ''">#{standardType},</if>
<if test="standardName != null and standardName != ''">#{standardName},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="detailUpLimit != null">#{detailUpLimit},</if>
<if test="detailDownLimit != null">#{detailDownLimit},</if>
<if test="detailUnit != null and detailUnit != ''">#{detailUnit},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
<if test="detailCode != null and detailCode != ''">#{detailCode},</if>
</trim>
</insert>
<update id="updateEquCheckItemDetail" parameterType="EquCheckItemDetail">
update equ_check_item_detail
<trim prefix="SET" suffixOverrides=",">
<if test="parentCode != null and parentCode != ''">parent_code = #{parentCode},</if>
<if test="standardType != null and standardType != ''">standard_type = #{standardType},</if>
<if test="standardName != null and standardName != ''">standard_name = #{standardName},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="detailUpLimit != null">detail_up_limit = #{detailUpLimit},</if>
<if test="detailDownLimit != null">detail_down_limit = #{detailDownLimit},</if>
<if test="detailUnit != null and detailUnit != ''">detail_unit = #{detailUnit},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="updatedBy != null and updatedBy != ''">updated_by = #{updatedBy},</if>
<if test="detailCode != null and detailCode != ''">detail_code = #{detailCode},</if>
</trim>
where detail_id = #{detailId}
</update>
<delete id="deleteEquCheckItemDetailByDetailId" parameterType="String">
delete from equ_check_item_detail where detail_id = #{detailId}
</delete>
<delete id="deleteEquCheckItemDetailByDetailIds" parameterType="String">
delete from equ_check_item_detail where detail_id in
<foreach item="detailId" collection="array" open="(" separator="," close=")">
#{detailId}
</foreach>
</delete>
</mapper>

@ -54,7 +54,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectEquCheckItemVo"/>
where item_id = #{itemId}
</select>
<select id="selectEquCheckItemByItemName" parameterType="String" resultMap="EquCheckItemResult">
<include refid="selectEquCheckItemVo"/>
where item_name = #{itemName}
</select>
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(item_id)+1 AS serialNum
FROM equ_check_item
WHERE CONVERT(date, GETDATE()) = CONVERT(date,created_time);
</select>
<insert id="insertEquCheckItem" parameterType="EquCheckItem">
insert into equ_check_item
<trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save