唯一码逻辑修改
This commit is contained in:
@@ -111,7 +111,10 @@ public class SecurityConfig
|
||||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
||||
requests.antMatchers("/login",
|
||||
"/register",
|
||||
"/unique/code/**",
|
||||
"/captchaImage").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
||||
@@ -78,7 +78,7 @@ public class WornUniqueCodeController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('unique:code:add')")
|
||||
@Log(title = "唯一码管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody WornUniqueCode wornUniqueCode)
|
||||
{
|
||||
return toAjax(wornUniqueCodeService.insertWornUniqueCode(wornUniqueCode));
|
||||
@@ -100,8 +100,8 @@ public class WornUniqueCodeController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('unique:code:remove')")
|
||||
@Log(title = "唯一码管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(@RequestBody Long[] ids)
|
||||
{
|
||||
return toAjax(wornUniqueCodeService.deleteWornUniqueCodeByIds(ids));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class WornUniqueCode extends BaseEntity
|
||||
|
||||
/** 唯一码编号 */
|
||||
@Excel(name = "唯一码编号")
|
||||
private String code;
|
||||
private Integer code;
|
||||
|
||||
/** 所属入库单据号 */
|
||||
@Excel(name = "所属入库单据号")
|
||||
@@ -32,8 +32,8 @@ public class WornUniqueCode extends BaseEntity
|
||||
@Excel(name = "项目ID", readConverterExp = "用于数据隔离,对应sys_dept.id")
|
||||
private Long projectId;
|
||||
|
||||
/** 当前状态(0已生成 1已打印 2已入库 3已出库 4已配送) */
|
||||
@Excel(name = "当前状态", readConverterExp = "0=已生成,1=已打印,2=已入库,3=已出库,4=已配送")
|
||||
/** 当前状态(0初始化创建 1已打印 2已入库 3已出库 4已配送) */
|
||||
@Excel(name = "当前状态", readConverterExp = "0=初始化创建,1=已打印,2=已入库,3=已出库,4=已配送")
|
||||
private String status;
|
||||
|
||||
/** RFID编码 */
|
||||
@@ -71,12 +71,12 @@ public class WornUniqueCode extends BaseEntity
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code)
|
||||
public void setCode(Integer code)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@ package com.shzg.project.unique.domain;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.shzg.framework.web.domain.BaseEntity;
|
||||
import com.shzg.project.worn.domain.WornMaterial;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.shzg.framework.aspectj.lang.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 唯一码物料信息对象 worn_unique_code_material
|
||||
*
|
||||
*
|
||||
* @author shzg
|
||||
* @date 2026-03-17
|
||||
*/
|
||||
@@ -25,11 +26,11 @@ public class WornUniqueCodeMaterial extends BaseEntity
|
||||
private Long uniqueCodeId;
|
||||
|
||||
/** 物料ID(对应worn_material.id) */
|
||||
@Excel(name = "物料ID", readConverterExp = "对=应worn_material.id")
|
||||
@Excel(name = "物料ID", readConverterExp = "对应worn_material.id")
|
||||
private Long materialId;
|
||||
|
||||
/** 单位ID(对应worn_material_unit.id) */
|
||||
@Excel(name = "单位ID", readConverterExp = "对=应worn_material_unit.id")
|
||||
@Excel(name = "单位ID", readConverterExp = "对应worn_material_unit.id")
|
||||
private Long unitId;
|
||||
|
||||
/** 数量 */
|
||||
@@ -40,80 +41,99 @@ public class WornUniqueCodeMaterial extends BaseEntity
|
||||
@Excel(name = "是否删除", readConverterExp = "0=正常,1=删除")
|
||||
private String isDelete;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
/** ==================== 扩展字段(不落库) ==================== */
|
||||
|
||||
public Long getId()
|
||||
/** 物料详细信息(联表查询) */
|
||||
private WornMaterial wornMaterial;
|
||||
|
||||
/** ==================== getter / setter ==================== */
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setUniqueCodeId(Long uniqueCodeId)
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.uniqueCodeId = uniqueCodeId;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUniqueCodeId()
|
||||
public Long getUniqueCodeId()
|
||||
{
|
||||
return uniqueCodeId;
|
||||
}
|
||||
|
||||
public void setMaterialId(Long materialId)
|
||||
public void setUniqueCodeId(Long uniqueCodeId)
|
||||
{
|
||||
this.materialId = materialId;
|
||||
this.uniqueCodeId = uniqueCodeId;
|
||||
}
|
||||
|
||||
public Long getMaterialId()
|
||||
public Long getMaterialId()
|
||||
{
|
||||
return materialId;
|
||||
}
|
||||
|
||||
public void setUnitId(Long unitId)
|
||||
public void setMaterialId(Long materialId)
|
||||
{
|
||||
this.unitId = unitId;
|
||||
this.materialId = materialId;
|
||||
}
|
||||
|
||||
public Long getUnitId()
|
||||
public Long getUnitId()
|
||||
{
|
||||
return unitId;
|
||||
}
|
||||
|
||||
public void setQuantity(BigDecimal quantity)
|
||||
public void setUnitId(Long unitId)
|
||||
{
|
||||
this.quantity = quantity;
|
||||
this.unitId = unitId;
|
||||
}
|
||||
|
||||
public BigDecimal getQuantity()
|
||||
public BigDecimal getQuantity()
|
||||
{
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete)
|
||||
public void setQuantity(BigDecimal quantity)
|
||||
{
|
||||
this.isDelete = isDelete;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getIsDelete()
|
||||
public String getIsDelete()
|
||||
{
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("uniqueCodeId", getUniqueCodeId())
|
||||
.append("materialId", getMaterialId())
|
||||
.append("unitId", getUnitId())
|
||||
.append("quantity", getQuantity())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("isDelete", getIsDelete())
|
||||
.toString();
|
||||
public void setIsDelete(String isDelete)
|
||||
{
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
}
|
||||
|
||||
public WornMaterial getWornMaterial()
|
||||
{
|
||||
return wornMaterial;
|
||||
}
|
||||
|
||||
public void setWornMaterial(WornMaterial wornMaterial)
|
||||
{
|
||||
this.wornMaterial = wornMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("uniqueCodeId", getUniqueCodeId())
|
||||
.append("materialId", getMaterialId())
|
||||
.append("unitId", getUnitId())
|
||||
.append("quantity", getQuantity())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("isDelete", getIsDelete())
|
||||
.append("wornMaterial", getWornMaterial())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -59,10 +59,11 @@ public interface WornUniqueCodeMaterialMapper
|
||||
*/
|
||||
public int deleteWornUniqueCodeMaterialByIds(Long[] ids);
|
||||
|
||||
|
||||
/**
|
||||
* 根据唯一码id查询唯一码物料信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
WornUniqueCodeMaterial selectByUniqueCodeId(Long id);
|
||||
WornUniqueCodeMaterial selectWithMaterialByUniqueCodeId(Long id);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WornUniqueCodeServiceImpl implements IWornUniqueCodeService
|
||||
@Override
|
||||
public WornUniqueCode selectWornUniqueCodeById(Long id)
|
||||
{
|
||||
/* 1️⃣ 主表 */
|
||||
/* 主表 */
|
||||
WornUniqueCode code = wornUniqueCodeMapper.selectWornUniqueCodeById(id);
|
||||
|
||||
if (code == null)
|
||||
@@ -53,33 +53,31 @@ public class WornUniqueCodeServiceImpl implements IWornUniqueCodeService
|
||||
throw new ServiceException("唯一码不存在");
|
||||
}
|
||||
|
||||
/* 2️⃣ 数据隔离校验(必须加) */
|
||||
/* 数据隔离校验 */
|
||||
Long deptId = SecurityUtils.getDeptId();
|
||||
if (!SecurityUtils.isAdmin() && !deptId.equals(code.getProjectId()))
|
||||
{
|
||||
throw new ServiceException("无权限查看该数据");
|
||||
}
|
||||
|
||||
/* 3️⃣ 查询物料(1条) */
|
||||
/* ================== 查询物料================== */
|
||||
WornUniqueCodeMaterial material =
|
||||
materialMapper.selectByUniqueCodeId(id);
|
||||
materialMapper.selectWithMaterialByUniqueCodeId(id);
|
||||
|
||||
code.setMaterial(material);
|
||||
|
||||
/* 4️⃣ 查询事件(多条) */
|
||||
/* ================== 查询事件 ================== */
|
||||
List<WornUniqueCodeEvent> eventList =
|
||||
eventMapper.selectByUniqueCodeId(id);
|
||||
|
||||
code.setEventList(eventList);
|
||||
|
||||
/* 5️⃣ 生成二维码 */
|
||||
String qrBase64 = QrCodeUtils.generateBase64(code.getCode());
|
||||
|
||||
/* ================== 生成二维码 ================== */
|
||||
String qrBase64 = QrCodeUtils.generateBase64(String.valueOf(code.getCode()));
|
||||
code.setQrCode(qrBase64);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询唯一码管理列表
|
||||
*
|
||||
@@ -103,46 +101,74 @@ public class WornUniqueCodeServiceImpl implements IWornUniqueCodeService
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertWornUniqueCode(WornUniqueCode wornUniqueCode)
|
||||
{
|
||||
/* ================== 0️⃣ 参数校验 ================== */
|
||||
WornUniqueCodeMaterial material = wornUniqueCode.getMaterial();
|
||||
|
||||
if (material == null)
|
||||
{
|
||||
throw new RuntimeException("物料信息不能为空");
|
||||
}
|
||||
|
||||
Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
|
||||
/* ================== 1️⃣ 获取当前用户 ================== */
|
||||
// Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
||||
// Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
|
||||
Long userId = 111L;
|
||||
Long deptId = 222L;
|
||||
|
||||
wornUniqueCode.setProjectId(deptId);
|
||||
|
||||
/* ================== 1️⃣ 主表 ================== */
|
||||
/* ================== 2️⃣ 主表 ================== */
|
||||
wornUniqueCode.setCreateTime(DateUtils.getNowDate());
|
||||
wornUniqueCode.setCreateBy(String.valueOf(userId));
|
||||
wornUniqueCode.setStatus("0");
|
||||
wornUniqueCode.setIsDelete("0");
|
||||
|
||||
wornUniqueCode.setCode(0);
|
||||
|
||||
wornUniqueCodeMapper.insertWornUniqueCode(wornUniqueCode);
|
||||
|
||||
Long id = wornUniqueCode.getId();
|
||||
if (id == null)
|
||||
{
|
||||
throw new RuntimeException("新增唯一码失败,主键ID未回填");
|
||||
}
|
||||
|
||||
/* ================== 2️⃣ 生成code ================== */
|
||||
String code = String.valueOf(600000 + id);
|
||||
wornUniqueCode.setCode(code);
|
||||
wornUniqueCodeMapper.updateWornUniqueCode(wornUniqueCode);
|
||||
/* ================== 3️⃣ 生成 code ================== */
|
||||
Integer code = 600000 + id.intValue();
|
||||
|
||||
/* ================== 3️⃣ 插入物料 ================== */
|
||||
WornUniqueCode update = new WornUniqueCode();
|
||||
update.setId(id);
|
||||
update.setCode(code);
|
||||
update.setUpdateTime(DateUtils.getNowDate());
|
||||
update.setUpdateBy(String.valueOf(userId));
|
||||
|
||||
wornUniqueCodeMapper.updateWornUniqueCode(update);
|
||||
|
||||
/* ================== 4️⃣ 插入物料 ================== */
|
||||
material.setUniqueCodeId(id);
|
||||
material.setCreateTime(DateUtils.getNowDate());
|
||||
material.setCreateBy(String.valueOf(userId));
|
||||
material.setIsDelete("0");
|
||||
|
||||
materialMapper.insertWornUniqueCodeMaterial(material);
|
||||
|
||||
/* ================== 4️⃣ 插入事件 ================== */
|
||||
/* ================== 5️⃣ 插入事件 ================== */
|
||||
WornUniqueCodeEvent event = new WornUniqueCodeEvent();
|
||||
event.setUniqueCodeId(id);
|
||||
event.setEventType("0");
|
||||
event.setEventStatus("0");
|
||||
event.setEventDesc("唯一码生成");
|
||||
|
||||
event.setOperatorId(userId);
|
||||
|
||||
event.setCreateTime(DateUtils.getNowDate());
|
||||
event.setCreateBy(String.valueOf(userId));
|
||||
event.setIsDelete("0");
|
||||
|
||||
eventMapper.insertWornUniqueCodeEvent(event);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改唯一码管理
|
||||
*
|
||||
@@ -150,12 +176,29 @@ public class WornUniqueCodeServiceImpl implements IWornUniqueCodeService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateWornUniqueCode(WornUniqueCode wornUniqueCode)
|
||||
{
|
||||
wornUniqueCode.setUpdateTime(DateUtils.getNowDate());
|
||||
return wornUniqueCodeMapper.updateWornUniqueCode(wornUniqueCode);
|
||||
}
|
||||
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
||||
|
||||
wornUniqueCode.setUpdateTime(DateUtils.getNowDate());
|
||||
wornUniqueCode.setUpdateBy(String.valueOf(userId));
|
||||
|
||||
// 1️⃣ 更新主表
|
||||
wornUniqueCodeMapper.updateWornUniqueCode(wornUniqueCode);
|
||||
|
||||
// 2️⃣ 更新物料
|
||||
if (wornUniqueCode.getMaterial() != null)
|
||||
{
|
||||
WornUniqueCodeMaterial material = wornUniqueCode.getMaterial();
|
||||
material.setUpdateTime(DateUtils.getNowDate());
|
||||
material.setUpdateBy(String.valueOf(userId));
|
||||
|
||||
materialMapper.updateWornUniqueCodeMaterial(material);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* 批量删除唯一码管理
|
||||
*
|
||||
|
||||
@@ -167,7 +167,7 @@ mqtt:
|
||||
|
||||
# MQTT 客户端 ID(在 EMQX 中唯一)
|
||||
# 建议:系统名 + 模块名,避免重复
|
||||
clientId: zg-wms-backend
|
||||
clientId: zg-wms-wsj
|
||||
|
||||
# MQTT 账号(EMQX Dashboard 中配置)
|
||||
username: test
|
||||
|
||||
@@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
FROM worn_unique_code t
|
||||
LEFT JOIN sys_dept d ON t.project_id = d.dept_id
|
||||
<where>
|
||||
<if test="code != null and code != ''"> and t.code = #{code}</if>
|
||||
<if test="code != null"> and t.code = #{code}</if>
|
||||
<if test="billNo != null and billNo != ''"> and t.bill_no = #{billNo}</if>
|
||||
<if test="projectId != null "> and t.project_id = #{projectId}</if>
|
||||
<if test="status != null and status != ''"> and t.status = #{status}</if>
|
||||
@@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertWornUniqueCode" parameterType="WornUniqueCode" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into worn_unique_code
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="code != null and code != ''">code,</if>
|
||||
<if test="code != null">code,</if>
|
||||
<if test="billNo != null">bill_no,</if>
|
||||
<if test="projectId != null">project_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="code != null and code != ''">#{code},</if>
|
||||
<if test="code != null">#{code},</if>
|
||||
<if test="billNo != null">#{billNo},</if>
|
||||
<if test="projectId != null">#{projectId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
@@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateWornUniqueCode" parameterType="WornUniqueCode">
|
||||
update worn_unique_code
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="code != null and code != ''">code = #{code},</if>
|
||||
<if test="code != null">code = #{code},</if>
|
||||
<if test="billNo != null">bill_no = #{billNo},</if>
|
||||
<if test="projectId != null">project_id = #{projectId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
@@ -93,9 +93,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteWornUniqueCodeByIds" parameterType="String">
|
||||
delete from worn_unique_code where id in
|
||||
<delete id="deleteWornUniqueCodeByIds" parameterType="Long">
|
||||
delete from worn_unique_code where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
@@ -1,21 +1,56 @@
|
||||
<?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.unique.mapper.WornUniqueCodeMaterialMapper">
|
||||
|
||||
|
||||
<!-- ================= 原有 resultMap ================= -->
|
||||
<resultMap type="WornUniqueCodeMaterial" id="WornUniqueCodeMaterialResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="uniqueCodeId" column="unique_code_id" />
|
||||
<result property="materialId" column="material_id" />
|
||||
<result property="unitId" column="unit_id" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<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="remark" column="remark" />
|
||||
<result property="isDelete" column="is_delete" />
|
||||
<result property="id" column="id"/>
|
||||
<result property="uniqueCodeId" column="unique_code_id"/>
|
||||
<result property="materialId" column="material_id"/>
|
||||
<result property="unitId" column="unit_id"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<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="remark" column="remark"/>
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- ================= 联表 resultMap ================= -->
|
||||
<resultMap id="materialWithWornMaterial" type="com.shzg.project.unique.domain.WornUniqueCodeMaterial">
|
||||
<id property="id" column="id"/>
|
||||
<result property="uniqueCodeId" column="unique_code_id"/>
|
||||
<result property="materialId" column="material_id"/>
|
||||
<result property="unitId" column="unit_id"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
|
||||
<!-- 嵌套物料 -->
|
||||
<association property="wornMaterial" javaType="com.shzg.project.worn.domain.WornMaterial">
|
||||
<id property="id" column="wm_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="typeName" column="type_name"/>
|
||||
<result property="typeAncestors" column="type_ancestors"/>
|
||||
<result property="typeParentNames" column="type_parent_names"/>
|
||||
<result property="unitName" column="unit_name"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectWornUniqueCodeMaterialVo">
|
||||
@@ -24,19 +59,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectWornUniqueCodeMaterialList" parameterType="WornUniqueCodeMaterial" resultMap="WornUniqueCodeMaterialResult">
|
||||
<include refid="selectWornUniqueCodeMaterialVo"/>
|
||||
<where>
|
||||
<if test="uniqueCodeId != null "> and unique_code_id = #{uniqueCodeId}</if>
|
||||
<if test="materialId != null "> and material_id = #{materialId}</if>
|
||||
<if test="unitId != null "> and unit_id = #{unitId}</if>
|
||||
<if test="quantity != null "> and quantity = #{quantity}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
<where>
|
||||
<if test="uniqueCodeId != null"> and unique_code_id = #{uniqueCodeId}</if>
|
||||
<if test="materialId != null"> and material_id = #{materialId}</if>
|
||||
<if test="unitId != null"> and unit_id = #{unitId}</if>
|
||||
<if test="quantity != null"> and quantity = #{quantity}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectWornUniqueCodeMaterialById" parameterType="Long" resultMap="WornUniqueCodeMaterialResult">
|
||||
<include refid="selectWornUniqueCodeMaterialVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- ================= 核心:联表查询 ================= -->
|
||||
<select id="selectWithMaterialByUniqueCodeId"
|
||||
parameterType="java.lang.Long"
|
||||
resultMap="materialWithWornMaterial">
|
||||
|
||||
SELECT
|
||||
m.*,
|
||||
|
||||
wm.id AS 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,
|
||||
|
||||
wt.type_name,
|
||||
wt.ancestors AS type_ancestors,
|
||||
|
||||
wu.unit_name,
|
||||
|
||||
GROUP_CONCAT(wt_parent.type_name ORDER BY wt_parent.id SEPARATOR '/') AS type_parent_names
|
||||
|
||||
FROM worn_unique_code_material m
|
||||
|
||||
LEFT JOIN worn_material wm ON m.material_id = wm.id
|
||||
LEFT JOIN worn_material_type wt ON wm.type_id = wt.id
|
||||
LEFT JOIN worn_material_type wt_parent ON FIND_IN_SET(wt_parent.id, wt.ancestors)
|
||||
LEFT JOIN worn_material_unit wu ON wm.unit_id = wu.id
|
||||
|
||||
WHERE m.unique_code_id = #{uniqueCodeId}
|
||||
|
||||
GROUP BY m.id
|
||||
</select>
|
||||
|
||||
<insert id="insertWornUniqueCodeMaterial" parameterType="WornUniqueCodeMaterial" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into worn_unique_code_material
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@@ -50,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="uniqueCodeId != null">#{uniqueCodeId},</if>
|
||||
<if test="materialId != null">#{materialId},</if>
|
||||
@@ -62,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateWornUniqueCodeMaterial" parameterType="WornUniqueCodeMaterial">
|
||||
@@ -86,16 +163,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
delete from worn_unique_code_material where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteWornUniqueCodeMaterialByIds" parameterType="String">
|
||||
delete from worn_unique_code_material where id in
|
||||
<delete id="deleteWornUniqueCodeMaterialByIds" parameterType="Long">
|
||||
delete from worn_unique_code_material where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="selectByUniqueCodeId" resultType="com.shzg.project.unique.domain.WornUniqueCodeMaterial">
|
||||
SELECT *
|
||||
FROM worn_unique_code_material
|
||||
WHERE unique_code_id = #{uniqueCodeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user