change(hwmom-mes): 新增修改工艺路线相关功能

- 在 IProdBaseRouteService 接口中添加了 getStationByRouteId 和 selectMesBaseRouteByRouteId 方法
- 在 ProdBaseRoute 类中添加了 prodBaseRouteProcessList
- 在 ProdBaseRouteMapper接口中添加了多个工艺路线相关的方法
- 在 ProdBaseRouteMapper.xml 中添加了对应的 SQL 语句
- 在 ProdBaseRouteServiceImpl 类中实现了新增的接口方法,并添加了事务处理
master
zch 2 weeks ago
parent 5f45eeb9f2
commit 9de0c66d40

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.List;
/**
* 线 prod_base_route
@ -48,4 +49,7 @@ public class ProdBaseRoute extends TenantEntity {
private String remark;
@TableField(exist = false)
List<ProdBaseRouteProcess> prodBaseRouteProcess;//映射字段
}

@ -1,9 +1,15 @@
package org.dromara.mes.mapper;
import org.dromara.mes.domain.ProdBaseRoute;
import org.dromara.mes.domain.ProdBaseRouteProcess;
import org.dromara.mes.domain.bo.ProdBaseRouteBo;
import org.dromara.mes.domain.bo.ProdBaseRouteProcessBo;
import org.dromara.mes.domain.vo.ProdBaseRouteVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.util.HashMap;
import java.util.List;
/**
* 线Mapper
*
@ -12,4 +18,84 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface ProdBaseRouteMapper extends BaseMapperPlus<ProdBaseRoute, ProdBaseRouteVo> {
/**
* 线
*
* @param routeId 线
* @return 线
*/
public ProdBaseRouteVo selectProdBaseRouteByRouteId(Long routeId);
/**
* 线
*
* @param mesBaseRoute 线
* @return 线
*/
public List<ProdBaseRoute> selectProdBaseRouteList(ProdBaseRoute mesBaseRoute);
/**
* 线
*
* @param mesBaseRoute 线
* @return
*/
public int insertProdBaseRoute(ProdBaseRoute mesBaseRoute);
/**
* 线
*
* @param mesBaseRoute 线
* @return
*/
public int updateProdBaseRoute(ProdBaseRoute mesBaseRoute);
/**
* 线
*
* @param routeId 线
* @return
*/
public int deleteProdBaseRouteByRouteId(Long routeId);
/**
* 线
*
* @param routeIds
* @return
*/
public int deleteProdBaseRouteByRouteIds(Long[] routeIds);
/**
* 线
*
* @param routeIds
* @return
*/
public int deleteProdBaseRouteProcessByRouteIds(Long[] routeIds);
/**
* 线
*
* @param mesBaseRouteProcessList 线
* @return
*/
public int batchProdBaseRouteProcess(List<ProdBaseRouteProcessBo> mesBaseRouteProcessList);
/**
* 线线
*
* @param routeId 线ID
* @return
*/
public int deleteProdBaseRouteProcessByRouteId(Long routeId);
/**
* 线ID
* @param routeId
* @return
*/
List<HashMap<String, Object>> getStationByRouteId(Long routeId);
}

@ -7,6 +7,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
/**
@ -66,4 +67,14 @@ public interface IProdBaseRouteService {
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
public List<HashMap<String, Object>> getStationByRouteId(Long routeId);
/**
* 线
*
* @param routeId 线
* @return 线
*/
public ProdBaseRouteVo selectMesBaseRouteByRouteId(Long routeId);
}

@ -1,5 +1,7 @@
package org.dromara.mes.service.impl;
import cn.hutool.core.util.ObjectUtil;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -9,6 +11,9 @@ import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.mes.domain.ProdBaseRouteProcess;
import org.dromara.mes.domain.bo.ProdBaseRouteProcessBo;
import org.dromara.mes.domain.vo.ProdBaseRouteProcessVo;
import org.dromara.mes.service.IProdBaseRouteProcessService;
import org.springframework.stereotype.Service;
import org.dromara.mes.domain.bo.ProdBaseRouteBo;
@ -16,10 +21,10 @@ import org.dromara.mes.domain.vo.ProdBaseRouteVo;
import org.dromara.mes.domain.ProdBaseRoute;
import org.dromara.mes.mapper.ProdBaseRouteMapper;
import org.dromara.mes.service.IProdBaseRouteService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.*;
/**
* 线Service
@ -43,7 +48,14 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
*/
@Override
public ProdBaseRouteVo queryById(Long routeId){
return routeMapper.selectVoById(routeId);
ProdBaseRouteVo prodBaseRouteVo = routeMapper.selectVoById(routeId);
// queryList方法查询工艺路线组陈工艺步骤
ProdBaseRouteProcessBo prodBaseRouteProcessBo = new ProdBaseRouteProcessBo();
prodBaseRouteProcessBo.setRouteId(routeId);
List<ProdBaseRouteProcessVo> routeProcessVoList = routeProcessService.queryList(prodBaseRouteProcessBo);
prodBaseRouteVo.setRouteProcessVoList(routeProcessVoList);
return prodBaseRouteVo;
}
/**
@ -75,6 +87,7 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
private MPJLambdaWrapper<ProdBaseRoute> buildQueryWrapper(ProdBaseRouteBo bo) {
Map<String, Object> params = bo.getParams();
MPJLambdaWrapper<ProdBaseRoute> lqw = JoinWrappers.lambda(ProdBaseRoute.class)
.selectAll(ProdBaseRoute.class)
.eq(bo.getRouteId() != null, ProdBaseRoute::getRouteId, bo.getRouteId())
.like(StringUtils.isNotBlank(bo.getRouteName()), ProdBaseRoute::getRouteName, bo.getRouteName())
@ -90,10 +103,13 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
* @param bo 线
* @return
*/
@Transactional
@Override
public Boolean insertByBo(ProdBaseRouteBo bo) {
ProdBaseRoute add = MapstructUtils.convert(bo, ProdBaseRoute.class);
validEntityBeforeSave(add);
insertProdBaseRouteProcess(bo);
boolean flag = routeMapper.insert(add) > 0;
if (flag) {
bo.setRouteId(add.getRouteId());
@ -107,11 +123,16 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
* @param bo 线
* @return
*/
@Transactional
@Override
public Boolean updateByBo(ProdBaseRouteBo bo) {
ProdBaseRoute update = MapstructUtils.convert(bo, ProdBaseRoute.class);
int updateResult = routeMapper.updateById(update);
Long routeId = bo.getRouteId();
routeMapper.deleteProdBaseRouteProcessByRouteId(routeId);
insertProdBaseRouteProcess(bo);
validEntityBeforeSave(update);
return routeMapper.updateById(update) > 0;
return updateResult > 0;
}
/**
@ -128,11 +149,68 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
* @param isValid
* @return
*/
@Transactional
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
routeProcessService.deleteWithValidByIds(ids, isValid);
return routeMapper.deleteByIds(ids) > 0;
}
/**
* 线
* @param bo 线
*/
public void insertProdBaseRouteProcess(ProdBaseRouteBo bo)
{
// 获取工艺路线中的工艺步骤列表
List<ProdBaseRouteProcessBo> mesBaseRouteProcessList = bo.getRouteProcessBoList();
// 获取工艺路线ID
Long routeId = bo.getRouteId();
// 如果工艺步骤列表不为空
if (ObjectUtil.isNotNull(mesBaseRouteProcessList))
{
// 创建一个新的工艺步骤列表
List<ProdBaseRouteProcessBo> list = new ArrayList<ProdBaseRouteProcessBo>();
// 遍历每一个工艺步骤
for (ProdBaseRouteProcessBo mesBaseRouteProcess : mesBaseRouteProcessList)
{
// 设置工艺步骤的工艺路线ID
mesBaseRouteProcess.setRouteId(routeId);
// 将工艺步骤添加到新的列表中
list.add(mesBaseRouteProcess);
}
// 如果新的工艺步骤列表不为空
if (!list.isEmpty())
{
// 批量插入工艺步骤到数据库
routeMapper.batchProdBaseRouteProcess(list);
}
}
}
/**
* 线ID
* @param routeId
* @return
*/
@Override
public List<HashMap<String, Object>> getStationByRouteId(Long routeId) {
return routeMapper.getStationByRouteId(routeId);
}
/**
* 线
*
* @param routeId 线
* @return 线
*/
@Override
public ProdBaseRouteVo selectMesBaseRouteByRouteId(Long routeId)
{
return routeMapper.selectProdBaseRouteByRouteId(routeId);
}
}

@ -4,4 +4,209 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.mes.mapper.ProdBaseRouteMapper">
<resultMap type="ProdBaseRoute" id="ProdBaseRouteResult">
<result property="routeId" column="route_id"/>
<result property="routeName" column="route_name"/>
<result property="routeDesc" column="route_desc"/>
<result property="activeFlag" column="active_flag"/>
<result property="remark" column="remark"/>
<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="productionTime" column="production_time"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<resultMap id="ProdBaseRouteProdBaseRouteProcessResult" type="ProdBaseRoute" extends="ProdBaseRouteResult">
<collection property="prodBaseRouteProcessList" notNullColumn="sub_route_process_id" javaType="java.util.List"
resultMap="ProdBaseRouteProcessResult"/>
</resultMap>
<resultMap type="ProdBaseRouteProcess" id="ProdBaseRouteProcessResult">
<result property="routeProcessId" column="sub_route_process_id"/>
<result property="routeId" column="sub_route_id"/>
<result property="processId" column="sub_process_id"/>
<result property="processOrder" column="sub_process_order"/>
<result property="remark" column="sub_remark"/>
<result property="createBy" column="sub_create_by"/>
<result property="createTime" column="sub_create_time"/>
<result property="updateBy" column="sub_update_by"/>
<result property="updateTime" column="sub_update_time"/>
</resultMap>
<sql id="selectProdBaseRouteVo">
select a.route_id,
a.route_name,
a.route_desc,
a.active_flag,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
sum(p.production_time) production_time,
a.tenant_id
from prod_base_route a
left join prod_base_route_process b on b.route_id = a.route_id
left join mes_base_process_info p on p.process_id = b.process_id
</sql>
<select id="selectProdBaseRouteList" parameterType="ProdBaseRoute" resultMap="ProdBaseRouteResult">
<include refid="selectProdBaseRouteVo"/>
<where>
<if test="routeName != null and routeName != ''">and a.route_name like concat('%', #{routeName}, '%')</if>
<if test="routeDesc != null and routeDesc != ''">and a.route_desc = #{routeDesc}</if>
<if test="activeFlag != null and activeFlag != ''">and a.active_flag = #{activeFlag}</if>
<if test="createBy != null and createBy != ''">and a.create_by = #{createBy}</if>
<if test="createTime != null ">and a.create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and a.update_by = #{updateBy}</if>
<if test="updateTime != null ">and a.update_time = #{updateTime}</if>
<if test="tenantId != null and tenantId != ''">and a.tenant_id = #{tenantId}</if>
</where>
group by a.route_id, a.route_name, a.route_desc, a.active_flag, a.remark, a.create_by, a.create_time, a.update_by,
a.update_time
</select>
<select id="selectProdBaseRouteByRouteId" parameterType="Long" resultMap="ProdBaseRouteProdBaseRouteProcessResult">
select a.route_id,
a.route_name,
a.route_desc,
a.active_flag,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.tenant_id,
b.route_process_id as sub_route_process_id,
b.route_id as sub_route_id,
b.process_id as sub_process_id,
b.process_order as sub_process_order,
b.remark as sub_remark,
b.create_by as sub_create_by,
b.create_time as sub_create_time,
b.update_by as sub_update_by,
b.update_time as sub_update_time
from prod_base_route a
left join prod_base_route_process b on b.route_id = a.route_id
where a.route_id = #{routeId}
order by b.process_order
</select>
<insert id="insertProdBaseRoute" parameterType="ProdBaseRoute" useGeneratedKeys="true" keyProperty="routeId">
insert into prod_base_route
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="routeName != null and routeName != ''">route_name,</if>
<if test="routeDesc != null">route_desc,</if>
<if test="activeFlag != null and activeFlag != ''">active_flag,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="routeName != null and routeName != ''">#{routeName},</if>
<if test="routeDesc != null">#{routeDesc},</if>
<if test="activeFlag != null and activeFlag != ''">#{activeFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
</trim>
</insert>
<update id="updateProdBaseRoute" parameterType="ProdBaseRoute">
update prod_base_route
<trim prefix="SET" suffixOverrides=",">
<if test="routeName != null and routeName != ''">route_name = #{routeName},</if>
<if test="routeDesc != null">route_desc = #{routeDesc},</if>
<if test="activeFlag != null and activeFlag != ''">active_flag = #{activeFlag},</if>
<if test="remark != null">remark = #{remark},</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>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
</trim>
where route_id = #{routeId}
</update>
<delete id="deleteProdBaseRouteByRouteId" parameterType="Long">
delete
from prod_base_route
where route_id = #{routeId}
</delete>
<delete id="deleteProdBaseRouteByRouteIds" parameterType="String">
delete from prod_base_route where route_id in
<foreach item="routeId" collection="array" open="(" separator="," close=")">
#{routeId}
</foreach>
</delete>
<delete id="deleteProdBaseRouteProcessByRouteIds" parameterType="String">
delete from prod_base_route_process where route_id in
<foreach item="routeId" collection="array" open="(" separator="," close=")">
#{routeId}
</foreach>
</delete>
<delete id="deleteProdBaseRouteProcessByRouteId" parameterType="Long">
delete
from prod_base_route_process
where route_id = #{routeId}
</delete>
<insert id="batchProdBaseRouteProcess">
insert into prod_base_route_process( route_id, process_id, process_order, remark, create_by,
create_time, update_by, update_time) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.routeId}, #{item.processId}, #{item.processOrder}, #{item.remark},
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<select id="getStationByRouteId" parameterType="Long" resultType="java.util.HashMap">
select brp.process_id processId,
bpi.process_name processName,
brp.process_order processOrder,
bsi.station_id stationId,
bsi.station_name stationName,
bsi.production_time productionTime,
mf.multiStationFlag
from prod_base_route_process brp
left join mes_base_process_info bpi on bpi.process_id = brp.process_id
left join mes_base_station_info bsi on bsi.process_id = bpi.process_id
left join (select brp.process_id, count(*) multiStationFlag
from prod_base_route_process brp
left join mes_base_station_info bsi on bsi.process_id = brp.process_id
where brp.route_id = #{routeId}
group by brp.process_id) mf on mf.process_id = bsi.process_id
where brp.route_id = #{routeId}
order by brp.process_order
</select>
</mapper>

Loading…
Cancel
Save