物料管理相关代码2.0

This commit is contained in:
2026-03-12 14:25:11 +08:00
parent 454128ae64
commit 65773de7bf
14 changed files with 841 additions and 273 deletions

View File

@@ -261,6 +261,13 @@
<version>${paho.mqtt.version}</version> <version>${paho.mqtt.version}</version>
</dependency> </dependency>
<!-- 拼音 -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -22,7 +22,7 @@ import com.shzg.common.utils.poi.ExcelUtil;
import com.shzg.framework.web.page.TableDataInfo; import com.shzg.framework.web.page.TableDataInfo;
/** /**
* 废旧系统物料类型(支持父子级树结构)Controller * 物料类型Controller
* *
* @author shzg * @author shzg
* @date 2026-03-11 * @date 2026-03-11
@@ -35,7 +35,7 @@ public class WornMaterialTypeController extends BaseController
private IWornMaterialTypeService wornMaterialTypeService; private IWornMaterialTypeService wornMaterialTypeService;
/** /**
* 查询废旧系统物料类型(支持父子级树结构)列表 * 查询物料类型列表
*/ */
@PreAuthorize("@ss.hasPermi('worn:type:list')") @PreAuthorize("@ss.hasPermi('worn:type:list')")
@GetMapping("/list") @GetMapping("/list")
@@ -46,21 +46,22 @@ public class WornMaterialTypeController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 导出废旧系统物料类型(支持父子级树结构)列表 * 导出物料类型列表
*/ */
@PreAuthorize("@ss.hasPermi('worn:type:export')") @PreAuthorize("@ss.hasPermi('worn:type:export')")
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.EXPORT) @Log(title = "物料类型", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, WornMaterialType wornMaterialType) public void export(HttpServletResponse response, WornMaterialType wornMaterialType)
{ {
List<WornMaterialType> list = wornMaterialTypeService.selectWornMaterialTypeList(wornMaterialType); List<WornMaterialType> list = wornMaterialTypeService.selectWornMaterialTypeList(wornMaterialType);
ExcelUtil<WornMaterialType> util = new ExcelUtil<WornMaterialType>(WornMaterialType.class); ExcelUtil<WornMaterialType> util = new ExcelUtil<WornMaterialType>(WornMaterialType.class);
util.exportExcel(response, list, "废旧系统物料类型(支持父子级树结构)数据"); util.exportExcel(response, list, "物料类型数据");
} }
/** /**
* 获取废旧系统物料类型(支持父子级树结构)详细信息 * 获取物料类型详细信息
*/ */
@PreAuthorize("@ss.hasPermi('worn:type:query')") @PreAuthorize("@ss.hasPermi('worn:type:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@@ -70,10 +71,10 @@ public class WornMaterialTypeController extends BaseController
} }
/** /**
* 新增废旧系统物料类型(支持父子级树结构) * 新增物料类型
*/ */
@PreAuthorize("@ss.hasPermi('worn:type:add')") @PreAuthorize("@ss.hasPermi('worn:type:add')")
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.INSERT) @Log(title = "物料类型", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody WornMaterialType wornMaterialType) public AjaxResult add(@RequestBody WornMaterialType wornMaterialType)
{ {
@@ -81,10 +82,10 @@ public class WornMaterialTypeController extends BaseController
} }
/** /**
* 修改废旧系统物料类型(支持父子级树结构) * 修改物料类型
*/ */
@PreAuthorize("@ss.hasPermi('worn:type:edit')") @PreAuthorize("@ss.hasPermi('worn:type:edit')")
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.UPDATE) @Log(title = "物料类型", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody WornMaterialType wornMaterialType) public AjaxResult edit(@RequestBody WornMaterialType wornMaterialType)
{ {
@@ -92,13 +93,25 @@ public class WornMaterialTypeController extends BaseController
} }
/** /**
* 删除废旧系统物料类型(支持父子级树结构) * 删除物料类型
*/ */
@PreAuthorize("@ss.hasPermi('worn:type:remove')") @PreAuthorize("@ss.hasPermi('worn:type:remove')")
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.DELETE) @Log(title = "物料类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)
{ {
return toAjax(wornMaterialTypeService.deleteWornMaterialTypeByIds(ids)); return toAjax(wornMaterialTypeService.deleteWornMaterialTypeByIds(ids));
} }
/**
* 查询物料类型树结构
*/
@PreAuthorize("@ss.hasPermi('worn:type:list')")
@GetMapping("/tree")
public AjaxResult tree()
{
List<WornMaterialType> tree = wornMaterialTypeService.selectWornMaterialTypeTree();
return AjaxResult.success(tree);
}
} }

View File

@@ -80,19 +80,30 @@ public class WornMaterial extends BaseEntity
@Excel(name = "逻辑删除", readConverterExp = "0=正常,1=删除") @Excel(name = "逻辑删除", readConverterExp = "0=正常,1=删除")
private String isDelete; private String isDelete;
public void setId(Long id)
{ // ================== 查询展示字段(不落库) ==================
this.id = id;
} /** 单位名称 */
private String unitName;
/** 当前类型名称 */
private String typeName;
/** 类型祖级ID */
private String typeAncestors;
/** 父级类型名称 */
private String typeParentNames;
public Long getId() public Long getId()
{ {
return id; return id;
} }
public void setMaterialName(String materialName) public void setId(Long id)
{ {
this.materialName = materialName; this.id = id;
} }
public String getMaterialName() public String getMaterialName()
@@ -100,9 +111,9 @@ public class WornMaterial extends BaseEntity
return materialName; return materialName;
} }
public void setMaterialShortName(String materialShortName) public void setMaterialName(String materialName)
{ {
this.materialShortName = materialShortName; this.materialName = materialName;
} }
public String getMaterialShortName() public String getMaterialShortName()
@@ -110,9 +121,9 @@ public class WornMaterial extends BaseEntity
return materialShortName; return materialShortName;
} }
public void setMaterialCode(String materialCode) public void setMaterialShortName(String materialShortName)
{ {
this.materialCode = materialCode; this.materialShortName = materialShortName;
} }
public String getMaterialCode() public String getMaterialCode()
@@ -120,9 +131,9 @@ public class WornMaterial extends BaseEntity
return materialCode; return materialCode;
} }
public void setTypeId(Long typeId) public void setMaterialCode(String materialCode)
{ {
this.typeId = typeId; this.materialCode = materialCode;
} }
public Long getTypeId() public Long getTypeId()
@@ -130,9 +141,9 @@ public class WornMaterial extends BaseEntity
return typeId; return typeId;
} }
public void setUnitId(Long unitId) public void setTypeId(Long typeId)
{ {
this.unitId = unitId; this.typeId = typeId;
} }
public Long getUnitId() public Long getUnitId()
@@ -140,9 +151,9 @@ public class WornMaterial extends BaseEntity
return unitId; return unitId;
} }
public void setMaterialCategory(String materialCategory) public void setUnitId(Long unitId)
{ {
this.materialCategory = materialCategory; this.unitId = unitId;
} }
public String getMaterialCategory() public String getMaterialCategory()
@@ -150,9 +161,9 @@ public class WornMaterial extends BaseEntity
return materialCategory; return materialCategory;
} }
public void setKgFactor(BigDecimal kgFactor) public void setMaterialCategory(String materialCategory)
{ {
this.kgFactor = kgFactor; this.materialCategory = materialCategory;
} }
public BigDecimal getKgFactor() public BigDecimal getKgFactor()
@@ -160,9 +171,9 @@ public class WornMaterial extends BaseEntity
return kgFactor; return kgFactor;
} }
public void setSpecification(String specification) public void setKgFactor(BigDecimal kgFactor)
{ {
this.specification = specification; this.kgFactor = kgFactor;
} }
public String getSpecification() public String getSpecification()
@@ -170,9 +181,9 @@ public class WornMaterial extends BaseEntity
return specification; return specification;
} }
public void setModel(String model) public void setSpecification(String specification)
{ {
this.model = model; this.specification = specification;
} }
public String getModel() public String getModel()
@@ -180,9 +191,9 @@ public class WornMaterial extends BaseEntity
return model; return model;
} }
public void setBarcode(String barcode) public void setModel(String model)
{ {
this.barcode = barcode; this.model = model;
} }
public String getBarcode() public String getBarcode()
@@ -190,9 +201,9 @@ public class WornMaterial extends BaseEntity
return barcode; return barcode;
} }
public void setWeight(BigDecimal weight) public void setBarcode(String barcode)
{ {
this.weight = weight; this.barcode = barcode;
} }
public BigDecimal getWeight() public BigDecimal getWeight()
@@ -200,9 +211,9 @@ public class WornMaterial extends BaseEntity
return weight; return weight;
} }
public void setDescription(String description) public void setWeight(BigDecimal weight)
{ {
this.description = description; this.weight = weight;
} }
public String getDescription() public String getDescription()
@@ -210,9 +221,9 @@ public class WornMaterial extends BaseEntity
return description; return description;
} }
public void setOrderNum(Long orderNum) public void setDescription(String description)
{ {
this.orderNum = orderNum; this.description = description;
} }
public Long getOrderNum() public Long getOrderNum()
@@ -220,9 +231,9 @@ public class WornMaterial extends BaseEntity
return orderNum; return orderNum;
} }
public void setStatus(String status) public void setOrderNum(Long orderNum)
{ {
this.status = status; this.orderNum = orderNum;
} }
public String getStatus() public String getStatus()
@@ -230,9 +241,9 @@ public class WornMaterial extends BaseEntity
return status; return status;
} }
public void setIsDelete(String isDelete) public void setStatus(String status)
{ {
this.isDelete = isDelete; this.status = status;
} }
public String getIsDelete() public String getIsDelete()
@@ -240,6 +251,51 @@ public class WornMaterial extends BaseEntity
return isDelete; return isDelete;
} }
public void setIsDelete(String isDelete)
{
this.isDelete = isDelete;
}
public String getUnitName()
{
return unitName;
}
public void setUnitName(String unitName)
{
this.unitName = unitName;
}
public String getTypeName()
{
return typeName;
}
public void setTypeName(String typeName)
{
this.typeName = typeName;
}
public String getTypeAncestors()
{
return typeAncestors;
}
public void setTypeAncestors(String typeAncestors)
{
this.typeAncestors = typeAncestors;
}
public String getTypeParentNames()
{
return typeParentNames;
}
public void setTypeParentNames(String typeParentNames)
{
this.typeParentNames = typeParentNames;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -259,6 +315,10 @@ public class WornMaterial extends BaseEntity
.append("orderNum", getOrderNum()) .append("orderNum", getOrderNum())
.append("status", getStatus()) .append("status", getStatus())
.append("isDelete", getIsDelete()) .append("isDelete", getIsDelete())
.append("unitName", getUnitName())
.append("typeName", getTypeName())
.append("typeAncestors", getTypeAncestors())
.append("typeParentNames", getTypeParentNames())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

View File

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.shzg.framework.aspectj.lang.annotation.Excel; import com.shzg.framework.aspectj.lang.annotation.Excel;
import java.util.List;
/** /**
* 废旧系统物料类型(支持父子级树结构)对象 worn_material_type * 废旧系统物料类型(支持父子级树结构)对象 worn_material_type
* *
@@ -58,6 +60,9 @@ public class WornMaterialType extends BaseEntity
@Excel(name = "逻辑删除") @Excel(name = "逻辑删除")
private String isDelete; private String isDelete;
/** 子节点 */
private List<WornMaterialType> children;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@@ -168,6 +173,16 @@ public class WornMaterialType extends BaseEntity
return isDelete; return isDelete;
} }
public List<WornMaterialType> getChildren()
{
return children;
}
public void setChildren(List<WornMaterialType> children)
{
this.children = children;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@@ -58,4 +58,9 @@ public interface WornMaterialMapper
* @return 结果 * @return 结果
*/ */
public int deleteWornMaterialByIds(Long[] ids); public int deleteWornMaterialByIds(Long[] ids);
/**
* 查询当前最大物料编码
*/
String selectMaxMaterialCode();
} }

View File

@@ -4,7 +4,7 @@ import java.util.List;
import com.shzg.project.worn.domain.WornMaterialType; import com.shzg.project.worn.domain.WornMaterialType;
/** /**
* 废旧系统物料类型(支持父子级树结构)Mapper接口 * 物料类型Mapper接口
* *
* @author shzg * @author shzg
* @date 2026-03-11 * @date 2026-03-11
@@ -12,50 +12,71 @@ import com.shzg.project.worn.domain.WornMaterialType;
public interface WornMaterialTypeMapper public interface WornMaterialTypeMapper
{ {
/** /**
* 查询废旧系统物料类型(支持父子级树结构) * 查询物料类型
* *
* @param id 废旧系统物料类型(支持父子级树结构)主键 * @param id 物料类型主键
* @return 废旧系统物料类型(支持父子级树结构) * @return 物料类型
*/ */
public WornMaterialType selectWornMaterialTypeById(Long id); public WornMaterialType selectWornMaterialTypeById(Long id);
/** /**
* 查询废旧系统物料类型(支持父子级树结构)列表 * 查询物料类型列表
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 废旧系统物料类型(支持父子级树结构)集合 * @return 物料类型集合
*/ */
public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType); public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType);
/** /**
* 新增废旧系统物料类型(支持父子级树结构) * 新增物料类型
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 结果 * @return 结果
*/ */
public int insertWornMaterialType(WornMaterialType wornMaterialType); public int insertWornMaterialType(WornMaterialType wornMaterialType);
/** /**
* 修改废旧系统物料类型(支持父子级树结构) * 修改物料类型
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 结果 * @return 结果
*/ */
public int updateWornMaterialType(WornMaterialType wornMaterialType); public int updateWornMaterialType(WornMaterialType wornMaterialType);
/** /**
* 删除废旧系统物料类型(支持父子级树结构) * 删除物料类型
* *
* @param id 废旧系统物料类型(支持父子级树结构)主键 * @param id 物料类型主键
* @return 结果 * @return 结果
*/ */
public int deleteWornMaterialTypeById(Long id); public int deleteWornMaterialTypeById(Long id);
/** /**
* 批量删除废旧系统物料类型(支持父子级树结构) * 批量删除物料类型
* *
* @param ids 需要删除的数据主键集合 * @param ids 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteWornMaterialTypeByIds(Long[] ids); public int deleteWornMaterialTypeByIds(Long[] ids);
/**
* 查询最大类型编码
* @return
*/
String selectMaxTypeCode();
/**
* 查询子节点数量
*/
int selectChildCountByParentId(Long parentId);
/**
* 查询所有子节点
*/
List<WornMaterialType> selectChildrenById(Long id);
/**
* 更新子节点祖级信息
*/
int updateChildrenAncestors(WornMaterialType wornMaterialType);
} }

View File

@@ -4,7 +4,7 @@ import java.util.List;
import com.shzg.project.worn.domain.WornMaterialType; import com.shzg.project.worn.domain.WornMaterialType;
/** /**
* 废旧系统物料类型(支持父子级树结构)Service接口 * 物料类型Service接口
* *
* @author shzg * @author shzg
* @date 2026-03-11 * @date 2026-03-11
@@ -12,50 +12,49 @@ import com.shzg.project.worn.domain.WornMaterialType;
public interface IWornMaterialTypeService public interface IWornMaterialTypeService
{ {
/** /**
* 查询废旧系统物料类型(支持父子级树结构) * 查询物料类型
* *
* @param id 废旧系统物料类型(支持父子级树结构)主键 * @param id 物料类型主键
* @return 废旧系统物料类型(支持父子级树结构) * @return 物料类型
*/ */
public WornMaterialType selectWornMaterialTypeById(Long id); public WornMaterialType selectWornMaterialTypeById(Long id);
/** /**
* 查询废旧系统物料类型(支持父子级树结构)列表 * 查询物料类型列表
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 废旧系统物料类型(支持父子级树结构)集合 * @return 物料类型集合
*/ */
public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType); public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType);
/** /**
* 新增废旧系统物料类型(支持父子级树结构) * 物料类型
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 结果 * @return 结果
*/ */
public int insertWornMaterialType(WornMaterialType wornMaterialType); public int insertWornMaterialType(WornMaterialType wornMaterialType);
/** /**
* 修改废旧系统物料类型(支持父子级树结构) * 修改物料类型
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 结果 * @return 结果
*/ */
public int updateWornMaterialType(WornMaterialType wornMaterialType); public int updateWornMaterialType(WornMaterialType wornMaterialType);
/** /**
* 批量删除废旧系统物料类型(支持父子级树结构) * 批量删除物料类型
* *
* @param ids 需要删除的废旧系统物料类型(支持父子级树结构)主键集合 * @param ids 需要删除的物料类型主键集合
* @return 结果 * @return 结果
*/ */
public int deleteWornMaterialTypeByIds(Long[] ids); public int deleteWornMaterialTypeByIds(Long[] ids);
/** /**
* 删除废旧系统物料类型(支持父子级树结构)信息 * 查询物料类型树结构
*
* @param id 废旧系统物料类型(支持父子级树结构)主键
* @return 结果
*/ */
public int deleteWornMaterialTypeById(Long id); List<WornMaterialType> selectWornMaterialTypeTree();
} }

View File

@@ -54,6 +54,26 @@ public class WornMaterialServiceImpl implements IWornMaterialService
public int insertWornMaterial(WornMaterial wornMaterial) public int insertWornMaterial(WornMaterial wornMaterial)
{ {
wornMaterial.setCreateTime(DateUtils.getNowDate()); wornMaterial.setCreateTime(DateUtils.getNowDate());
// 生成物料编码
String maxCode = wornMaterialMapper.selectMaxMaterialCode();
String newCode;
if (maxCode == null)
{
newCode = "F0001";
}
else
{
int num = Integer.parseInt(maxCode.substring(1));
num++;
newCode = "F" + String.format("%04d", num);
}
wornMaterial.setMaterialCode(newCode);
return wornMaterialMapper.insertWornMaterial(wornMaterial); return wornMaterialMapper.insertWornMaterial(wornMaterial);
} }

View File

@@ -1,15 +1,20 @@
package com.shzg.project.worn.service.impl; package com.shzg.project.worn.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.shzg.common.exception.ServiceException;
import com.shzg.common.utils.DateUtils; import com.shzg.common.utils.DateUtils;
import com.shzg.project.worn.unit.PinyinUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.shzg.project.worn.mapper.WornMaterialTypeMapper; import com.shzg.project.worn.mapper.WornMaterialTypeMapper;
import com.shzg.project.worn.domain.WornMaterialType; import com.shzg.project.worn.domain.WornMaterialType;
import com.shzg.project.worn.service.IWornMaterialTypeService; import com.shzg.project.worn.service.IWornMaterialTypeService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 废旧系统物料类型(支持父子级树结构)Service业务层处理 * 物料类型Service业务层处理
* *
* @author shzg * @author shzg
* @date 2026-03-11 * @date 2026-03-11
@@ -21,10 +26,10 @@ public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
private WornMaterialTypeMapper wornMaterialTypeMapper; private WornMaterialTypeMapper wornMaterialTypeMapper;
/** /**
* 查询废旧系统物料类型(支持父子级树结构) * 查询物料类型
* *
* @param id 废旧系统物料类型(支持父子级树结构)主键 * @param id 物料类型主键
* @return 废旧系统物料类型(支持父子级树结构) * @return 物料类型
*/ */
@Override @Override
public WornMaterialType selectWornMaterialTypeById(Long id) public WornMaterialType selectWornMaterialTypeById(Long id)
@@ -33,10 +38,10 @@ public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
} }
/** /**
* 查询废旧系统物料类型(支持父子级树结构)列表 * 查询物料类型列表
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构) * @param wornMaterialType 物料类型
* @return 废旧系统物料类型(支持父子级树结构) * @return 物料类型
*/ */
@Override @Override
public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType) public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType)
@@ -44,53 +49,214 @@ public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
return wornMaterialTypeMapper.selectWornMaterialTypeList(wornMaterialType); return wornMaterialTypeMapper.selectWornMaterialTypeList(wornMaterialType);
} }
/**
* 新增废旧系统物料类型(支持父子级树结构)
*
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
* @return 结果
*/
@Override
public int insertWornMaterialType(WornMaterialType wornMaterialType)
{
wornMaterialType.setCreateTime(DateUtils.getNowDate());
return wornMaterialTypeMapper.insertWornMaterialType(wornMaterialType);
}
/** /**
* 修改废旧系统物料类型(支持父子级树结构) * 新增物料类型
* *
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertWornMaterialType(WornMaterialType type)
{
Long parentId = type.getParentId();
/** ==============================
* 1 处理 parent_id / ancestors / level
* ============================== */
// 一级类型
if (parentId == null || parentId == 0)
{
type.setParentId(0L);
type.setAncestors("0");
type.setLevel(1L);
}
// 子级类型
else
{
WornMaterialType parent = wornMaterialTypeMapper.selectWornMaterialTypeById(parentId);
if (parent == null)
{
throw new RuntimeException("父级类型不存在");
}
type.setParentId(parentId);
// ancestors = 父级 ancestors + 父级id
type.setAncestors(parent.getAncestors() + "," + parentId);
// level = 父级level + 1
type.setLevel(parent.getLevel() + 1);
}
/** ==============================
* 2 自动生成类型编码 type_code
* ============================== */
String maxCode = wornMaterialTypeMapper.selectMaxTypeCode();
int nextNum = 1;
if (maxCode != null)
{
nextNum = Integer.parseInt(maxCode.substring(2)) + 1;
}
String newCode = "MT" + String.format("%04d", nextNum);
type.setTypeCode(newCode);
/** ==============================
* 3 自动生成首字母
* ============================== */
String firstLetter = PinyinUtils.getFirstLetter(type.getTypeName());
type.setFirstLetter(firstLetter);
/** ==============================
* 4 默认字段
* ============================== */
type.setIsDelete("0");
type.setStatus("0");
type.setCreateTime(DateUtils.getNowDate());
/** ==============================
* 5 插入数据库
* ============================== */
return wornMaterialTypeMapper.insertWornMaterialType(type);
}
/**
* 修改物料类型
*
* @param wornMaterialType 物料类型
* @return 结果
*/
@Override
@Transactional
public int updateWornMaterialType(WornMaterialType wornMaterialType) public int updateWornMaterialType(WornMaterialType wornMaterialType)
{ {
wornMaterialType.setUpdateTime(DateUtils.getNowDate()); Long id = wornMaterialType.getId();
return wornMaterialTypeMapper.updateWornMaterialType(wornMaterialType); Long newParentId = wornMaterialType.getParentId();
// 查询当前节点原始数据
WornMaterialType old = wornMaterialTypeMapper.selectWornMaterialTypeById(id);
// 查询新的父节点
WornMaterialType parent = null;
if (newParentId != null && newParentId != 0)
{
parent = wornMaterialTypeMapper.selectWornMaterialTypeById(newParentId);
}
String newAncestors;
Long newLevel;
if (parent != null)
{
newAncestors = parent.getAncestors() + "," + parent.getId();
newLevel = parent.getLevel() + 1;
}
else
{
newAncestors = "0";
newLevel = 1L;
}
wornMaterialType.setAncestors(newAncestors);
wornMaterialType.setLevel(newLevel);
// 更新当前节点
int rows = wornMaterialTypeMapper.updateWornMaterialType(wornMaterialType);
// 如果父节点发生变化,需要更新所有子节点 ancestors
if (!old.getParentId().equals(newParentId))
{
List<WornMaterialType> children = wornMaterialTypeMapper.selectChildrenById(id);
for (WornMaterialType child : children)
{
String childAncestors = child.getAncestors().replace(old.getAncestors(), newAncestors);
child.setAncestors(childAncestors);
wornMaterialTypeMapper.updateChildrenAncestors(child);
}
}
return rows;
} }
/** /**
* 批量删除废旧系统物料类型(支持父子级树结构) * 批量删除物料类型
* *
* @param ids 需要删除的废旧系统物料类型(支持父子级树结构)主键 * @param ids 需要删除的物料类型主键
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteWornMaterialTypeByIds(Long[] ids) public int deleteWornMaterialTypeByIds(Long[] ids)
{ {
for (Long id : ids)
{
// 查询是否存在子节点
int count = wornMaterialTypeMapper.selectChildCountByParentId(id);
if (count > 0)
{
throw new ServiceException("该物料类型存在子类型,不能删除");
}
}
return wornMaterialTypeMapper.deleteWornMaterialTypeByIds(ids); return wornMaterialTypeMapper.deleteWornMaterialTypeByIds(ids);
} }
/**
* 删除废旧系统物料类型(支持父子级树结构)信息
*
* @param id 废旧系统物料类型(支持父子级树结构)主键
* @return 结果
*/
@Override @Override
public int deleteWornMaterialTypeById(Long id) public List<WornMaterialType> selectWornMaterialTypeTree()
{ {
return wornMaterialTypeMapper.deleteWornMaterialTypeById(id); List<WornMaterialType> list = wornMaterialTypeMapper.selectWornMaterialTypeList(new WornMaterialType());
return buildTree(list);
}
/**
* 构建树结构
*/
private List<WornMaterialType> buildTree(List<WornMaterialType> list)
{
List<WornMaterialType> roots = new ArrayList<>();
for (WornMaterialType node : list)
{
if (node.getParentId() != null && node.getParentId() == 0)
{
recursionFn(list, node);
roots.add(node);
}
}
return roots;
}
/**
* 递归子节点
*/
private void recursionFn(List<WornMaterialType> list, WornMaterialType node)
{
List<WornMaterialType> children = new ArrayList<>();
for (WornMaterialType t : list)
{
if (node.getId().equals(t.getParentId()))
{
recursionFn(list, t);
children.add(t);
}
}
node.setChildren(children);
} }
} }

View File

@@ -0,0 +1,34 @@
package com.shzg.project.worn.unit;
import net.sourceforge.pinyin4j.PinyinHelper;
public class PinyinUtils
{
/**
* 获取中文首字母
*/
public static String getFirstLetter(String chinese)
{
StringBuilder sb = new StringBuilder();
for (char c : chinese.toCharArray())
{
if (String.valueOf(c).matches("[\\u4E00-\\u9FA5]+"))
{
String[] pinyin = PinyinHelper.toHanyuPinyinStringArray(c);
if (pinyin != null)
{
sb.append(Character.toUpperCase(pinyin[0].charAt(0)));
}
}
else
{
sb.append(c);
}
}
return sb.toString();
}
}

View File

@@ -34,7 +34,8 @@ server:
# 日志配置 # 日志配置
logging: logging:
level: level:
com.ruoyi: debug root: info
com.shzg: debug
org.springframework: warn org.springframework: warn
# 用户配置 # 用户配置
@@ -64,7 +65,7 @@ spring:
devtools: devtools:
restart: restart:
# 热部署开关 # 热部署开关
enabled: true enabled: false
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址

View File

@@ -2,10 +2,13 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shzg.project.worn.mapper.WornMaterialMapper"> <mapper namespace="com.shzg.project.worn.mapper.WornMaterialMapper">
<resultMap type="WornMaterial" id="WornMaterialResult"> <resultMap id="WornMaterialResult" type="com.shzg.project.worn.domain.WornMaterial">
<result property="id" column="id" />
<id property="id" column="id"/>
<result property="materialName" column="material_name"/> <result property="materialName" column="material_name"/>
<result property="materialShortName" column="material_short_name"/> <result property="materialShortName" column="material_short_name"/>
<result property="materialCode" column="material_code"/> <result property="materialCode" column="material_code"/>
@@ -25,87 +28,205 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="unitName" column="unit_name"/>
<result property="typeName" column="type_name"/>
<result property="typeAncestors" column="ancestors"/>
<result property="typeParentNames" column="type_parent_names"/>
</resultMap> </resultMap>
<sql id="selectWornMaterialVo"> <sql id="selectWornMaterialVo">
select id, material_name, material_short_name, material_code, type_id, unit_id, material_category, kg_factor, specification, model, barcode, weight, description, order_num, status, is_delete, create_by, create_time, update_by, update_time from worn_material
SELECT
wm.id,
wm.material_name,
wm.material_short_name,
wm.material_code,
wm.type_id,
wm.unit_id,
wm.material_category,
wm.kg_factor,
wm.specification,
wm.model,
wm.barcode,
wm.weight,
wm.description,
wm.order_num,
wm.status,
wm.is_delete,
wm.create_by,
wm.create_time,
wm.update_by,
wm.update_time,
u.unit_name,
t.type_name,
t.ancestors,
(
SELECT GROUP_CONCAT(tp.type_name ORDER BY tp.id)
FROM worn_material_type tp
WHERE FIND_IN_SET(tp.id, t.ancestors)
) AS type_parent_names
FROM worn_material wm
LEFT JOIN worn_material_unit u
ON wm.unit_id = u.id
LEFT JOIN worn_material_type t
ON wm.type_id = t.id
</sql> </sql>
<select id="selectWornMaterialList" parameterType="WornMaterial" resultMap="WornMaterialResult">
<select id="selectWornMaterialList"
parameterType="com.shzg.project.worn.domain.WornMaterial"
resultMap="WornMaterialResult">
<include refid="selectWornMaterialVo"/> <include refid="selectWornMaterialVo"/>
<where> <where>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="materialShortName != null and materialShortName != ''"> and material_short_name like concat('%', #{materialShortName}, '%')</if> <if test="materialName != null and materialName != ''">
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if> AND wm.material_name LIKE CONCAT('%',#{materialName},'%')
<if test="typeId != null "> and type_id = #{typeId}</if> </if>
<if test="unitId != null "> and unit_id = #{unitId}</if>
<if test="materialCategory != null and materialCategory != ''"> and material_category = #{materialCategory}</if> <if test="materialShortName != null and materialShortName != ''">
<if test="kgFactor != null "> and kg_factor = #{kgFactor}</if> AND wm.material_short_name LIKE CONCAT('%',#{materialShortName},'%')
<if test="specification != null and specification != ''"> and specification = #{specification}</if> </if>
<if test="model != null and model != ''"> and model = #{model}</if>
<if test="barcode != null and barcode != ''"> and barcode = #{barcode}</if> <if test="materialCode != null and materialCode != ''">
<if test="weight != null "> and weight = #{weight}</if> AND wm.material_code = #{materialCode}
<if test="description != null and description != ''"> and description = #{description}</if> </if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="typeId != null">
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if> AND wm.type_id = #{typeId}
</if>
<if test="unitId != null">
AND wm.unit_id = #{unitId}
</if>
<if test="materialCategory != null and materialCategory != ''">
AND wm.material_category = #{materialCategory}
</if>
<if test="kgFactor != null">
AND wm.kg_factor = #{kgFactor}
</if>
<if test="specification != null and specification != ''">
AND wm.specification = #{specification}
</if>
<if test="model != null and model != ''">
AND wm.model = #{model}
</if>
<if test="barcode != null and barcode != ''">
AND wm.barcode = #{barcode}
</if>
<if test="weight != null">
AND wm.weight = #{weight}
</if>
<if test="description != null and description != ''">
AND wm.description = #{description}
</if>
<if test="orderNum != null">
AND wm.order_num = #{orderNum}
</if>
<if test="status != null and status != ''">
AND wm.status = #{status}
</if>
<if test="isDelete != null and isDelete != ''">
AND wm.is_delete = #{isDelete}
</if>
</where> </where>
</select> </select>
<select id="selectWornMaterialById" parameterType="Long" resultMap="WornMaterialResult">
<select id="selectWornMaterialById"
parameterType="Long"
resultMap="WornMaterialResult">
<include refid="selectWornMaterialVo"/> <include refid="selectWornMaterialVo"/>
where id = #{id}
WHERE wm.id = #{id}
</select> </select>
<insert id="insertWornMaterial" parameterType="WornMaterial" useGeneratedKeys="true" keyProperty="id">
insert into worn_material <insert id="insertWornMaterial"
parameterType="com.shzg.project.worn.domain.WornMaterial"
useGeneratedKeys="true"
keyProperty="id">
INSERT INTO worn_material
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="materialName != null and materialName != ''">material_name,</if> <if test="materialName != null and materialName != ''">material_name,</if>
<if test="materialShortName != null">material_short_name,</if> <if test="materialShortName != null and materialShortName != ''">material_short_name,</if>
<if test="materialCode != null and materialCode != ''">material_code,</if> <if test="materialCode != null and materialCode != ''">material_code,</if>
<if test="typeId != null">type_id,</if> <if test="typeId != null">type_id,</if>
<if test="unitId != null">unit_id,</if> <if test="unitId != null">unit_id,</if>
<if test="materialCategory != null">material_category,</if> <if test="materialCategory != null and materialCategory != ''">material_category,</if>
<if test="kgFactor != null">kg_factor,</if> <if test="kgFactor != null">kg_factor,</if>
<if test="specification != null">specification,</if> <if test="specification != null and specification != ''">specification,</if>
<if test="model != null">model,</if> <if test="model != null and model != ''">model,</if>
<if test="barcode != null">barcode,</if> <if test="barcode != null and barcode != ''">barcode,</if>
<if test="weight != null">weight,</if> <if test="weight != null">weight,</if>
<if test="description != null">description,</if> <if test="description != null and description != ''">description,</if>
<if test="orderNum != null">order_num,</if> <if test="orderNum != null">order_num,</if>
<if test="status != null">status,</if> <if test="status != null and status != ''">status,</if>
<if test="isDelete != null">is_delete,</if> <if test="isDelete != null and isDelete != ''">is_delete,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="materialName != null and materialName != ''">#{materialName},</if> <if test="materialName != null and materialName != ''">#{materialName},</if>
<if test="materialShortName != null">#{materialShortName},</if> <if test="materialShortName != null and materialShortName != ''">#{materialShortName},</if>
<if test="materialCode != null and materialCode != ''">#{materialCode},</if> <if test="materialCode != null and materialCode != ''">#{materialCode},</if>
<if test="typeId != null">#{typeId},</if> <if test="typeId != null">#{typeId},</if>
<if test="unitId != null">#{unitId},</if> <if test="unitId != null">#{unitId},</if>
<if test="materialCategory != null">#{materialCategory},</if> <if test="materialCategory != null and materialCategory != ''">#{materialCategory},</if>
<if test="kgFactor != null">#{kgFactor},</if> <if test="kgFactor != null">#{kgFactor},</if>
<if test="specification != null">#{specification},</if> <if test="specification != null and specification != ''">#{specification},</if>
<if test="model != null">#{model},</if> <if test="model != null and model != ''">#{model},</if>
<if test="barcode != null">#{barcode},</if> <if test="barcode != null and barcode != ''">#{barcode},</if>
<if test="weight != null">#{weight},</if> <if test="weight != null">#{weight},</if>
<if test="description != null">#{description},</if> <if test="description != null and description != ''">#{description},</if>
<if test="orderNum != null">#{orderNum},</if> <if test="orderNum != null">#{orderNum},</if>
<if test="status != null">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="isDelete != null">#{isDelete},</if> <if test="isDelete != null and isDelete != ''">#{isDelete},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
</trim> </trim>
</insert> </insert>
<update id="updateWornMaterial" parameterType="WornMaterial"> <update id="updateWornMaterial"
update worn_material parameterType="com.shzg.project.worn.domain.WornMaterial">
UPDATE worn_material
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="materialName != null and materialName != ''">material_name = #{materialName},</if> <if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
<if test="materialShortName != null">material_short_name = #{materialShortName},</if> <if test="materialShortName != null">material_short_name = #{materialShortName},</if>
<if test="materialCode != null and materialCode != ''">material_code = #{materialCode},</if> <if test="materialCode != null and materialCode != ''">material_code = #{materialCode},</if>
@@ -121,22 +242,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderNum != null">order_num = #{orderNum},</if> <if test="orderNum != null">order_num = #{orderNum},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</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="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
</trim> </trim>
where id = #{id}
WHERE id = #{id}
</update> </update>
<delete id="deleteWornMaterialById" parameterType="Long"> <delete id="deleteWornMaterialById" parameterType="Long">
delete from worn_material where id = #{id} DELETE FROM worn_material
WHERE id = #{id}
</delete> </delete>
<delete id="deleteWornMaterialByIds" parameterType="String">
delete from worn_material where id in <delete id="deleteWornMaterialByIds" parameterType="Long">
DELETE FROM worn_material
WHERE id IN
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="selectMaxMaterialCode" resultType="java.lang.String">
SELECT MAX(material_code)
FROM worn_material
</select>
</mapper> </mapper>

View File

@@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWornMaterialTypeList" parameterType="WornMaterialType" resultMap="WornMaterialTypeResult"> <select id="selectWornMaterialTypeList" parameterType="WornMaterialType" resultMap="WornMaterialTypeResult">
<include refid="selectWornMaterialTypeVo"/> <include refid="selectWornMaterialTypeVo"/>
<where> <where>
is_delete = '0'
<if test="parentId != null "> and parent_id = #{parentId}</if> <if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if> <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if> <if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if>
@@ -39,7 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderNum != null "> and order_num = #{orderNum}</if> <if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and status = #{status}</if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if> <if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
</where>
order by order_num</where>
</select> </select>
<select id="selectWornMaterialTypeById" parameterType="Long" resultMap="WornMaterialTypeResult"> <select id="selectWornMaterialTypeById" parameterType="Long" resultMap="WornMaterialTypeResult">
@@ -114,4 +116,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="selectMaxTypeCode" resultType="java.lang.String">
SELECT type_code
FROM worn_material_type
WHERE type_code LIKE 'MT%'
ORDER BY type_code DESC
LIMIT 1
</select>
<select id="selectChildCountByParentId" parameterType="Long" resultType="int">
SELECT COUNT(1)
FROM worn_material_type
WHERE parent_id = #{parentId}
AND is_delete = '0'
</select>
<!-- 查询所有子节点 -->
<select id="selectChildrenById" parameterType="Long" resultMap="WornMaterialTypeResult">
SELECT *
FROM worn_material_type
WHERE ancestors LIKE CONCAT('%,', #{id}, ',%')
AND is_delete = '0'
</select>
<!-- 更新子节点 ancestors -->
<update id="updateChildrenAncestors" parameterType="WornMaterialType">
UPDATE worn_material_type
SET ancestors = #{ancestors}
WHERE id = #{id}
</update>
</mapper> </mapper>

View File

@@ -2,10 +2,12 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shzg.project.worn.mapper.WornMaterialUnitMapper"> <mapper namespace="com.shzg.project.worn.mapper.WornMaterialUnitMapper">
<resultMap type="WornMaterialUnit" id="WornMaterialUnitResult"> <resultMap id="WornMaterialUnitResult" type="com.shzg.project.worn.domain.WornMaterialUnit">
<result property="id" column="id" /> <id property="id" column="id"/>
<result property="unitName" column="unit_name"/> <result property="unitName" column="unit_name"/>
<result property="description" column="description"/> <result property="description" column="description"/>
<result property="orderNum" column="order_num"/> <result property="orderNum" column="order_num"/>
@@ -17,28 +19,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<sql id="selectWornMaterialUnitVo"> <sql id="selectWornMaterialUnitVo">
select id, unit_name, description, order_num, status, is_delete, create_by, create_time, update_by, update_time from worn_material_unit SELECT
id,
unit_name,
description,
order_num,
status,
is_delete,
create_by,
create_time,
update_by,
update_time
FROM worn_material_unit
</sql> </sql>
<select id="selectWornMaterialUnitList" parameterType="WornMaterialUnit" resultMap="WornMaterialUnitResult">
<select id="selectWornMaterialUnitList"
parameterType="com.shzg.project.worn.domain.WornMaterialUnit"
resultMap="WornMaterialUnitResult">
<include refid="selectWornMaterialUnitVo"/> <include refid="selectWornMaterialUnitVo"/>
<where> <where>
<if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
<if test="description != null and description != ''"> and description = #{description}</if> <if test="unitName != null and unitName != ''">
<if test="orderNum != null "> and order_num = #{orderNum}</if> AND unit_name LIKE CONCAT('%',#{unitName},'%')
<if test="status != null and status != ''"> and status = #{status}</if> </if>
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
<if test="description != null and description != ''">
AND description = #{description}
</if>
<if test="orderNum != null">
AND order_num = #{orderNum}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="isDelete != null and isDelete != ''">
AND is_delete = #{isDelete}
</if>
</where> </where>
</select> </select>
<select id="selectWornMaterialUnitById" parameterType="Long" resultMap="WornMaterialUnitResult">
<select id="selectWornMaterialUnitById"
parameterType="Long"
resultMap="WornMaterialUnitResult">
<include refid="selectWornMaterialUnitVo"/> <include refid="selectWornMaterialUnitVo"/>
where id = #{id}
WHERE id = #{id}
</select> </select>
<insert id="insertWornMaterialUnit" parameterType="WornMaterialUnit" useGeneratedKeys="true" keyProperty="id">
insert into worn_material_unit <insert id="insertWornMaterialUnit"
parameterType="com.shzg.project.worn.domain.WornMaterialUnit"
useGeneratedKeys="true"
keyProperty="id">
INSERT INTO worn_material_unit
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitName != null and unitName != ''">unit_name,</if> <if test="unitName != null and unitName != ''">unit_name,</if>
<if test="description != null">description,</if> <if test="description != null">description,</if>
@@ -50,7 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="unitName != null and unitName != ''">#{unitName},</if> <if test="unitName != null and unitName != ''">#{unitName},</if>
<if test="description != null">#{description},</if> <if test="description != null">#{description},</if>
<if test="orderNum != null">#{orderNum},</if> <if test="orderNum != null">#{orderNum},</if>
@@ -61,10 +110,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
</trim> </trim>
</insert> </insert>
<update id="updateWornMaterialUnit" parameterType="WornMaterialUnit">
update worn_material_unit <update id="updateWornMaterialUnit"
parameterType="com.shzg.project.worn.domain.WornMaterialUnit">
UPDATE worn_material_unit
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if> <if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
<if test="description != null">description = #{description},</if> <if test="description != null">description = #{description},</if>
@@ -76,17 +130,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
</trim> </trim>
where id = #{id}
WHERE id = #{id}
</update> </update>
<delete id="deleteWornMaterialUnitById" parameterType="Long"> <delete id="deleteWornMaterialUnitById" parameterType="Long">
delete from worn_material_unit where id = #{id} DELETE FROM worn_material_unit
WHERE id = #{id}
</delete> </delete>
<delete id="deleteWornMaterialUnitByIds" parameterType="String"> <delete id="deleteWornMaterialUnitByIds" parameterType="String">
delete from worn_material_unit where id in DELETE FROM worn_material_unit
WHERE id IN
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>