物料管理相关代码2.0
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -261,6 +261,13 @@
|
||||
<version>${paho.mqtt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 拼音 -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.shzg.common.utils.poi.ExcelUtil;
|
||||
import com.shzg.framework.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 废旧系统物料类型(支持父子级树结构)Controller
|
||||
* 物料类型Controller
|
||||
*
|
||||
* @author shzg
|
||||
* @date 2026-03-11
|
||||
@@ -35,7 +35,7 @@ public class WornMaterialTypeController extends BaseController
|
||||
private IWornMaterialTypeService wornMaterialTypeService;
|
||||
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)列表
|
||||
* 查询物料类型列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('worn:type:list')")
|
||||
@GetMapping("/list")
|
||||
@@ -46,21 +46,22 @@ public class WornMaterialTypeController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出废旧系统物料类型(支持父子级树结构)列表
|
||||
* 导出物料类型列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('worn:type:export')")
|
||||
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.EXPORT)
|
||||
@Log(title = "物料类型", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WornMaterialType wornMaterialType)
|
||||
{
|
||||
List<WornMaterialType> list = wornMaterialTypeService.selectWornMaterialTypeList(wornMaterialType);
|
||||
ExcelUtil<WornMaterialType> util = new ExcelUtil<WornMaterialType>(WornMaterialType.class);
|
||||
util.exportExcel(response, list, "废旧系统物料类型(支持父子级树结构)数据");
|
||||
util.exportExcel(response, list, "物料类型数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取废旧系统物料类型(支持父子级树结构)详细信息
|
||||
* 获取物料类型详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('worn:type:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@@ -70,10 +71,10 @@ public class WornMaterialTypeController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增废旧系统物料类型(支持父子级树结构)
|
||||
* 新增物料类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('worn:type:add')")
|
||||
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.INSERT)
|
||||
@Log(title = "物料类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody WornMaterialType wornMaterialType)
|
||||
{
|
||||
@@ -81,10 +82,10 @@ public class WornMaterialTypeController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改废旧系统物料类型(支持父子级树结构)
|
||||
* 修改物料类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('worn:type:edit')")
|
||||
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "物料类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody WornMaterialType wornMaterialType)
|
||||
{
|
||||
@@ -92,13 +93,25 @@ public class WornMaterialTypeController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除废旧系统物料类型(支持父子级树结构)
|
||||
* 删除物料类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('worn:type:remove')")
|
||||
@Log(title = "废旧系统物料类型(支持父子级树结构)", businessType = BusinessType.DELETE)
|
||||
@Log(title = "物料类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.shzg.framework.aspectj.lang.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 物料对象 worn_material
|
||||
*
|
||||
*
|
||||
* @author shzg
|
||||
* @date 2026-03-11
|
||||
*/
|
||||
@@ -80,189 +80,249 @@ public class WornMaterial extends BaseEntity
|
||||
@Excel(name = "逻辑删除", readConverterExp = "0=正常,1=删除")
|
||||
private String isDelete;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
// ================== 查询展示字段(不落库) ==================
|
||||
|
||||
/** 单位名称 */
|
||||
private String unitName;
|
||||
|
||||
/** 当前类型名称 */
|
||||
private String typeName;
|
||||
|
||||
/** 类型祖级ID */
|
||||
private String typeAncestors;
|
||||
|
||||
/** 父级类型名称 */
|
||||
private String typeParentNames;
|
||||
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setMaterialName(String materialName)
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.materialName = materialName;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMaterialName()
|
||||
public String getMaterialName()
|
||||
{
|
||||
return materialName;
|
||||
}
|
||||
|
||||
public void setMaterialShortName(String materialShortName)
|
||||
public void setMaterialName(String materialName)
|
||||
{
|
||||
this.materialShortName = materialShortName;
|
||||
this.materialName = materialName;
|
||||
}
|
||||
|
||||
public String getMaterialShortName()
|
||||
public String getMaterialShortName()
|
||||
{
|
||||
return materialShortName;
|
||||
}
|
||||
|
||||
public void setMaterialCode(String materialCode)
|
||||
public void setMaterialShortName(String materialShortName)
|
||||
{
|
||||
this.materialCode = materialCode;
|
||||
this.materialShortName = materialShortName;
|
||||
}
|
||||
|
||||
public String getMaterialCode()
|
||||
public String getMaterialCode()
|
||||
{
|
||||
return materialCode;
|
||||
}
|
||||
|
||||
public void setTypeId(Long typeId)
|
||||
public void setMaterialCode(String materialCode)
|
||||
{
|
||||
this.typeId = typeId;
|
||||
this.materialCode = materialCode;
|
||||
}
|
||||
|
||||
public Long getTypeId()
|
||||
public Long getTypeId()
|
||||
{
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setUnitId(Long unitId)
|
||||
public void setTypeId(Long typeId)
|
||||
{
|
||||
this.unitId = unitId;
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public Long getUnitId()
|
||||
public Long getUnitId()
|
||||
{
|
||||
return unitId;
|
||||
}
|
||||
|
||||
public void setMaterialCategory(String materialCategory)
|
||||
public void setUnitId(Long unitId)
|
||||
{
|
||||
this.materialCategory = materialCategory;
|
||||
this.unitId = unitId;
|
||||
}
|
||||
|
||||
public String getMaterialCategory()
|
||||
public String getMaterialCategory()
|
||||
{
|
||||
return materialCategory;
|
||||
}
|
||||
|
||||
public void setKgFactor(BigDecimal kgFactor)
|
||||
public void setMaterialCategory(String materialCategory)
|
||||
{
|
||||
this.kgFactor = kgFactor;
|
||||
this.materialCategory = materialCategory;
|
||||
}
|
||||
|
||||
public BigDecimal getKgFactor()
|
||||
public BigDecimal getKgFactor()
|
||||
{
|
||||
return kgFactor;
|
||||
}
|
||||
|
||||
public void setSpecification(String specification)
|
||||
public void setKgFactor(BigDecimal kgFactor)
|
||||
{
|
||||
this.specification = specification;
|
||||
this.kgFactor = kgFactor;
|
||||
}
|
||||
|
||||
public String getSpecification()
|
||||
public String getSpecification()
|
||||
{
|
||||
return specification;
|
||||
}
|
||||
|
||||
public void setModel(String model)
|
||||
public void setSpecification(String specification)
|
||||
{
|
||||
this.model = model;
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
public String getModel()
|
||||
public String getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setBarcode(String barcode)
|
||||
public void setModel(String model)
|
||||
{
|
||||
this.barcode = barcode;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getBarcode()
|
||||
public String getBarcode()
|
||||
{
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public void setWeight(BigDecimal weight)
|
||||
public void setBarcode(String barcode)
|
||||
{
|
||||
this.weight = weight;
|
||||
this.barcode = barcode;
|
||||
}
|
||||
|
||||
public BigDecimal getWeight()
|
||||
public BigDecimal getWeight()
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
public void setWeight(BigDecimal weight)
|
||||
{
|
||||
this.description = description;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setOrderNum(Long orderNum)
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getOrderNum()
|
||||
public Long getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
public void setOrderNum(Long orderNum)
|
||||
{
|
||||
this.status = status;
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete)
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getIsDelete()
|
||||
{
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete)
|
||||
{
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
public String getIsDelete()
|
||||
public String getUnitName()
|
||||
{
|
||||
return isDelete;
|
||||
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
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("materialName", getMaterialName())
|
||||
.append("materialShortName", getMaterialShortName())
|
||||
.append("materialCode", getMaterialCode())
|
||||
.append("typeId", getTypeId())
|
||||
.append("unitId", getUnitId())
|
||||
.append("materialCategory", getMaterialCategory())
|
||||
.append("kgFactor", getKgFactor())
|
||||
.append("specification", getSpecification())
|
||||
.append("model", getModel())
|
||||
.append("barcode", getBarcode())
|
||||
.append("weight", getWeight())
|
||||
.append("description", getDescription())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("status", getStatus())
|
||||
.append("isDelete", getIsDelete())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
.append("id", getId())
|
||||
.append("materialName", getMaterialName())
|
||||
.append("materialShortName", getMaterialShortName())
|
||||
.append("materialCode", getMaterialCode())
|
||||
.append("typeId", getTypeId())
|
||||
.append("unitId", getUnitId())
|
||||
.append("materialCategory", getMaterialCategory())
|
||||
.append("kgFactor", getKgFactor())
|
||||
.append("specification", getSpecification())
|
||||
.append("model", getModel())
|
||||
.append("barcode", getBarcode())
|
||||
.append("weight", getWeight())
|
||||
.append("description", getDescription())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("status", getStatus())
|
||||
.append("isDelete", getIsDelete())
|
||||
.append("unitName", getUnitName())
|
||||
.append("typeName", getTypeName())
|
||||
.append("typeAncestors", getTypeAncestors())
|
||||
.append("typeParentNames", getTypeParentNames())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.shzg.framework.aspectj.lang.annotation.Excel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 废旧系统物料类型(支持父子级树结构)对象 worn_material_type
|
||||
*
|
||||
@@ -58,6 +60,9 @@ public class WornMaterialType extends BaseEntity
|
||||
@Excel(name = "逻辑删除")
|
||||
private String isDelete;
|
||||
|
||||
/** 子节点 */
|
||||
private List<WornMaterialType> children;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
@@ -168,6 +173,16 @@ public class WornMaterialType extends BaseEntity
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public List<WornMaterialType> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<WornMaterialType> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@@ -58,4 +58,9 @@ public interface WornMaterialMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWornMaterialByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询当前最大物料编码
|
||||
*/
|
||||
String selectMaxMaterialCode();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
import com.shzg.project.worn.domain.WornMaterialType;
|
||||
|
||||
/**
|
||||
* 废旧系统物料类型(支持父子级树结构)Mapper接口
|
||||
* 物料类型Mapper接口
|
||||
*
|
||||
* @author shzg
|
||||
* @date 2026-03-11
|
||||
@@ -12,50 +12,71 @@ import com.shzg.project.worn.domain.WornMaterialType;
|
||||
public interface WornMaterialTypeMapper
|
||||
{
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)
|
||||
* 查询物料类型
|
||||
*
|
||||
* @param id 废旧系统物料类型(支持父子级树结构)主键
|
||||
* @return 废旧系统物料类型(支持父子级树结构)
|
||||
* @param id 物料类型主键
|
||||
* @return 物料类型
|
||||
*/
|
||||
public WornMaterialType selectWornMaterialTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)列表
|
||||
* 查询物料类型列表
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @return 废旧系统物料类型(支持父子级树结构)集合
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 物料类型集合
|
||||
*/
|
||||
public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType);
|
||||
|
||||
/**
|
||||
* 新增废旧系统物料类型(支持父子级树结构)
|
||||
* 新增物料类型
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWornMaterialType(WornMaterialType wornMaterialType);
|
||||
|
||||
/**
|
||||
* 修改废旧系统物料类型(支持父子级树结构)
|
||||
* 修改物料类型
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWornMaterialType(WornMaterialType wornMaterialType);
|
||||
|
||||
/**
|
||||
* 删除废旧系统物料类型(支持父子级树结构)
|
||||
* 删除物料类型
|
||||
*
|
||||
* @param id 废旧系统物料类型(支持父子级树结构)主键
|
||||
* @param id 物料类型主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWornMaterialTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除废旧系统物料类型(支持父子级树结构)
|
||||
* 批量删除物料类型
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWornMaterialTypeByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询最大类型编码
|
||||
* @return
|
||||
*/
|
||||
String selectMaxTypeCode();
|
||||
|
||||
/**
|
||||
* 查询子节点数量
|
||||
*/
|
||||
int selectChildCountByParentId(Long parentId);
|
||||
|
||||
/**
|
||||
* 查询所有子节点
|
||||
*/
|
||||
List<WornMaterialType> selectChildrenById(Long id);
|
||||
|
||||
/**
|
||||
* 更新子节点祖级信息
|
||||
*/
|
||||
int updateChildrenAncestors(WornMaterialType wornMaterialType);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
import com.shzg.project.worn.domain.WornMaterialType;
|
||||
|
||||
/**
|
||||
* 废旧系统物料类型(支持父子级树结构)Service接口
|
||||
* 物料类型Service接口
|
||||
*
|
||||
* @author shzg
|
||||
* @date 2026-03-11
|
||||
@@ -12,50 +12,49 @@ import com.shzg.project.worn.domain.WornMaterialType;
|
||||
public interface IWornMaterialTypeService
|
||||
{
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)
|
||||
* 查询物料类型
|
||||
*
|
||||
* @param id 废旧系统物料类型(支持父子级树结构)主键
|
||||
* @return 废旧系统物料类型(支持父子级树结构)
|
||||
* @param id 物料类型主键
|
||||
* @return 物料类型
|
||||
*/
|
||||
public WornMaterialType selectWornMaterialTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)列表
|
||||
* 查询物料类型列表
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @return 废旧系统物料类型(支持父子级树结构)集合
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 物料类型集合
|
||||
*/
|
||||
public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType);
|
||||
|
||||
/**
|
||||
* 新增废旧系统物料类型(支持父子级树结构)
|
||||
* 物料类型
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWornMaterialType(WornMaterialType wornMaterialType);
|
||||
|
||||
/**
|
||||
* 修改废旧系统物料类型(支持父子级树结构)
|
||||
* 修改物料类型
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWornMaterialType(WornMaterialType wornMaterialType);
|
||||
|
||||
/**
|
||||
* 批量删除废旧系统物料类型(支持父子级树结构)
|
||||
*
|
||||
* @param ids 需要删除的废旧系统物料类型(支持父子级树结构)主键集合
|
||||
* 批量删除物料类型
|
||||
*
|
||||
* @param ids 需要删除的物料类型主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWornMaterialTypeByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除废旧系统物料类型(支持父子级树结构)信息
|
||||
*
|
||||
* @param id 废旧系统物料类型(支持父子级树结构)主键
|
||||
* @return 结果
|
||||
* 查询物料类型树结构
|
||||
*/
|
||||
public int deleteWornMaterialTypeById(Long id);
|
||||
List<WornMaterialType> selectWornMaterialTypeTree();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,26 @@ public class WornMaterialServiceImpl implements IWornMaterialService
|
||||
public int insertWornMaterial(WornMaterial wornMaterial)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,35 @@
|
||||
package com.shzg.project.worn.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.shzg.common.exception.ServiceException;
|
||||
import com.shzg.common.utils.DateUtils;
|
||||
import com.shzg.project.worn.unit.PinyinUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.shzg.project.worn.mapper.WornMaterialTypeMapper;
|
||||
import com.shzg.project.worn.domain.WornMaterialType;
|
||||
import com.shzg.project.worn.service.IWornMaterialTypeService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 废旧系统物料类型(支持父子级树结构)Service业务层处理
|
||||
* 物料类型Service业务层处理
|
||||
*
|
||||
* @author shzg
|
||||
* @date 2026-03-11
|
||||
*/
|
||||
@Service
|
||||
public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
|
||||
public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
|
||||
{
|
||||
@Autowired
|
||||
private WornMaterialTypeMapper wornMaterialTypeMapper;
|
||||
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)
|
||||
* 查询物料类型
|
||||
*
|
||||
* @param id 废旧系统物料类型(支持父子级树结构)主键
|
||||
* @return 废旧系统物料类型(支持父子级树结构)
|
||||
* @param id 物料类型主键
|
||||
* @return 物料类型
|
||||
*/
|
||||
@Override
|
||||
public WornMaterialType selectWornMaterialTypeById(Long id)
|
||||
@@ -33,10 +38,10 @@ public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询废旧系统物料类型(支持父子级树结构)列表
|
||||
* 查询物料类型列表
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @return 废旧系统物料类型(支持父子级树结构)
|
||||
* @param wornMaterialType 物料类型
|
||||
* @return 物料类型
|
||||
*/
|
||||
@Override
|
||||
public List<WornMaterialType> selectWornMaterialTypeList(WornMaterialType wornMaterialType)
|
||||
@@ -44,53 +49,214 @@ public class WornMaterialTypeServiceImpl implements IWornMaterialTypeService
|
||||
return wornMaterialTypeMapper.selectWornMaterialTypeList(wornMaterialType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增废旧系统物料类型(支持父子级树结构)
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertWornMaterialType(WornMaterialType wornMaterialType)
|
||||
{
|
||||
wornMaterialType.setCreateTime(DateUtils.getNowDate());
|
||||
return wornMaterialTypeMapper.insertWornMaterialType(wornMaterialType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改废旧系统物料类型(支持父子级树结构)
|
||||
* 新增物料类型
|
||||
*
|
||||
* @param wornMaterialType 废旧系统物料类型(支持父子级树结构)
|
||||
* @return 结果
|
||||
*/
|
||||
@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)
|
||||
{
|
||||
wornMaterialType.setUpdateTime(DateUtils.getNowDate());
|
||||
return wornMaterialTypeMapper.updateWornMaterialType(wornMaterialType);
|
||||
Long id = wornMaterialType.getId();
|
||||
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 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteWornMaterialTypeByIds(Long[] ids)
|
||||
{
|
||||
for (Long id : ids)
|
||||
{
|
||||
// 查询是否存在子节点
|
||||
int count = wornMaterialTypeMapper.selectChildCountByParentId(id);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
throw new ServiceException("该物料类型存在子类型,不能删除");
|
||||
}
|
||||
}
|
||||
|
||||
return wornMaterialTypeMapper.deleteWornMaterialTypeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除废旧系统物料类型(支持父子级树结构)信息
|
||||
*
|
||||
* @param id 废旧系统物料类型(支持父子级树结构)主键
|
||||
* @return 结果
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
34
src/main/java/com/shzg/project/worn/unit/PinyinUtils.java
Normal file
34
src/main/java/com/shzg/project/worn/unit/PinyinUtils.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,8 @@ server:
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi: debug
|
||||
root: info
|
||||
com.shzg: debug
|
||||
org.springframework: warn
|
||||
|
||||
# 用户配置
|
||||
@@ -64,7 +65,7 @@ spring:
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
|
||||
@@ -1,111 +1,232 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.shzg.project.worn.mapper.WornMaterialMapper">
|
||||
|
||||
<resultMap type="WornMaterial" id="WornMaterialResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="materialName" column="material_name" />
|
||||
<result property="materialShortName" column="material_short_name" />
|
||||
<result property="materialCode" column="material_code" />
|
||||
<result property="typeId" column="type_id" />
|
||||
<result property="unitId" column="unit_id" />
|
||||
<result property="materialCategory" column="material_category" />
|
||||
<result property="kgFactor" column="kg_factor" />
|
||||
<result property="specification" column="specification" />
|
||||
<result property="model" column="model" />
|
||||
<result property="barcode" column="barcode" />
|
||||
<result property="weight" column="weight" />
|
||||
<result property="description" column="description" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
|
||||
<resultMap id="WornMaterialResult" type="com.shzg.project.worn.domain.WornMaterial">
|
||||
|
||||
<id property="id" column="id"/>
|
||||
|
||||
<result property="materialName" column="material_name"/>
|
||||
<result property="materialShortName" column="material_short_name"/>
|
||||
<result property="materialCode" column="material_code"/>
|
||||
<result property="typeId" column="type_id"/>
|
||||
<result property="unitId" column="unit_id"/>
|
||||
<result property="materialCategory" column="material_category"/>
|
||||
<result property="kgFactor" column="kg_factor"/>
|
||||
<result property="specification" column="specification"/>
|
||||
<result property="model" column="model"/>
|
||||
<result property="barcode" column="barcode"/>
|
||||
<result property="weight" column="weight"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<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>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<select id="selectWornMaterialList" parameterType="WornMaterial" resultMap="WornMaterialResult">
|
||||
|
||||
<select id="selectWornMaterialList"
|
||||
parameterType="com.shzg.project.worn.domain.WornMaterial"
|
||||
resultMap="WornMaterialResult">
|
||||
|
||||
<include refid="selectWornMaterialVo"/>
|
||||
<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="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
|
||||
<if test="typeId != null "> and type_id = #{typeId}</if>
|
||||
<if test="unitId != null "> and unit_id = #{unitId}</if>
|
||||
<if test="materialCategory != null and materialCategory != ''"> and material_category = #{materialCategory}</if>
|
||||
<if test="kgFactor != null "> and kg_factor = #{kgFactor}</if>
|
||||
<if test="specification != null and specification != ''"> and specification = #{specification}</if>
|
||||
<if test="model != null and model != ''"> and model = #{model}</if>
|
||||
<if test="barcode != null and barcode != ''"> and barcode = #{barcode}</if>
|
||||
<if test="weight != null "> and weight = #{weight}</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>
|
||||
|
||||
<if test="materialName != null and materialName != ''">
|
||||
AND wm.material_name LIKE CONCAT('%',#{materialName},'%')
|
||||
</if>
|
||||
|
||||
<if test="materialShortName != null and materialShortName != ''">
|
||||
AND wm.material_short_name LIKE CONCAT('%',#{materialShortName},'%')
|
||||
</if>
|
||||
|
||||
<if test="materialCode != null and materialCode != ''">
|
||||
AND wm.material_code = #{materialCode}
|
||||
</if>
|
||||
|
||||
<if test="typeId != null">
|
||||
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>
|
||||
</select>
|
||||
|
||||
<select id="selectWornMaterialById" parameterType="Long" resultMap="WornMaterialResult">
|
||||
<include refid="selectWornMaterialVo"/>
|
||||
where id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertWornMaterial" parameterType="WornMaterial" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into worn_material
|
||||
|
||||
<select id="selectWornMaterialById"
|
||||
parameterType="Long"
|
||||
resultMap="WornMaterialResult">
|
||||
|
||||
<include refid="selectWornMaterialVo"/>
|
||||
|
||||
WHERE wm.id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertWornMaterial"
|
||||
parameterType="com.shzg.project.worn.domain.WornMaterial"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
|
||||
INSERT INTO worn_material
|
||||
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<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="typeId != null">type_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="specification != null">specification,</if>
|
||||
<if test="model != null">model,</if>
|
||||
<if test="barcode != null">barcode,</if>
|
||||
<if test="specification != null and specification != ''">specification,</if>
|
||||
<if test="model != null and model != ''">model,</if>
|
||||
<if test="barcode != null and barcode != ''">barcode,</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="status != null">status,</if>
|
||||
<if test="isDelete != null">is_delete,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="isDelete != null and isDelete != ''">is_delete,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
</trim>
|
||||
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<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="typeId != null">#{typeId},</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="specification != null">#{specification},</if>
|
||||
<if test="model != null">#{model},</if>
|
||||
<if test="barcode != null">#{barcode},</if>
|
||||
<if test="specification != null and specification != ''">#{specification},</if>
|
||||
<if test="model != null and model != ''">#{model},</if>
|
||||
<if test="barcode != null and barcode != ''">#{barcode},</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="status != null">#{status},</if>
|
||||
<if test="isDelete != null">#{isDelete},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="isDelete != null and isDelete != ''">#{isDelete},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</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>
|
||||
</trim>
|
||||
</trim>
|
||||
|
||||
</insert>
|
||||
|
||||
<update id="updateWornMaterial" parameterType="WornMaterial">
|
||||
update worn_material
|
||||
<update id="updateWornMaterial"
|
||||
parameterType="com.shzg.project.worn.domain.WornMaterial">
|
||||
|
||||
UPDATE worn_material
|
||||
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
|
||||
<if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
|
||||
<if test="materialShortName != null">material_short_name = #{materialShortName},</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="status != null">status = #{status},</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="updateTime != null">update_time = #{updateTime},</if>
|
||||
|
||||
</trim>
|
||||
where id = #{id}
|
||||
|
||||
WHERE id = #{id}
|
||||
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteWornMaterialById" parameterType="Long">
|
||||
delete from worn_material where id = #{id}
|
||||
DELETE FROM worn_material
|
||||
WHERE id = #{id}
|
||||
</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=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectMaxMaterialCode" resultType="java.lang.String">
|
||||
SELECT MAX(material_code)
|
||||
FROM worn_material
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -28,7 +28,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectWornMaterialTypeList" parameterType="WornMaterialType" resultMap="WornMaterialTypeResult">
|
||||
<include refid="selectWornMaterialTypeVo"/>
|
||||
<where>
|
||||
<where>
|
||||
is_delete = '0'
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</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="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
|
||||
order by order_num</where>
|
||||
</select>
|
||||
|
||||
<select id="selectWornMaterialTypeById" parameterType="Long" resultMap="WornMaterialTypeResult">
|
||||
@@ -114,4 +116,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</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>
|
||||
@@ -1,44 +1,92 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.shzg.project.worn.mapper.WornMaterialUnitMapper">
|
||||
|
||||
<resultMap type="WornMaterialUnit" id="WornMaterialUnitResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="unitName" column="unit_name" />
|
||||
<result property="description" column="description" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
|
||||
<resultMap id="WornMaterialUnitResult" type="com.shzg.project.worn.domain.WornMaterialUnit">
|
||||
<id property="id" column="id"/>
|
||||
|
||||
<result property="unitName" column="unit_name"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="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>
|
||||
|
||||
<select id="selectWornMaterialUnitList" parameterType="WornMaterialUnit" resultMap="WornMaterialUnitResult">
|
||||
|
||||
<select id="selectWornMaterialUnitList"
|
||||
parameterType="com.shzg.project.worn.domain.WornMaterialUnit"
|
||||
resultMap="WornMaterialUnitResult">
|
||||
|
||||
<include refid="selectWornMaterialUnitVo"/>
|
||||
<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="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>
|
||||
|
||||
<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="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>
|
||||
</select>
|
||||
|
||||
<select id="selectWornMaterialUnitById" parameterType="Long" resultMap="WornMaterialUnitResult">
|
||||
<include refid="selectWornMaterialUnitVo"/>
|
||||
where id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertWornMaterialUnit" parameterType="WornMaterialUnit" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into worn_material_unit
|
||||
|
||||
<select id="selectWornMaterialUnitById"
|
||||
parameterType="Long"
|
||||
resultMap="WornMaterialUnitResult">
|
||||
|
||||
<include refid="selectWornMaterialUnitVo"/>
|
||||
|
||||
WHERE id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertWornMaterialUnit"
|
||||
parameterType="com.shzg.project.worn.domain.WornMaterialUnit"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
|
||||
INSERT INTO worn_material_unit
|
||||
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="unitName != null and unitName != ''">unit_name,</if>
|
||||
<if test="description != null">description,</if>
|
||||
@@ -49,8 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
</trim>
|
||||
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="unitName != null and unitName != ''">#{unitName},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
@@ -60,11 +109,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
|
||||
</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=",">
|
||||
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</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="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
|
||||
WHERE id = #{id}
|
||||
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteWornMaterialUnitById" parameterType="Long">
|
||||
delete from worn_material_unit where id = #{id}
|
||||
DELETE FROM worn_material_unit
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
<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=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user