diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/ProdBaseRoute.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/ProdBaseRoute.java index ae8d3ffa..fc6b03fa 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/ProdBaseRoute.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/domain/ProdBaseRoute.java @@ -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;//映射字段 } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/mapper/ProdBaseRouteMapper.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/mapper/ProdBaseRouteMapper.java index a5e56d14..f1d55ab4 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/mapper/ProdBaseRouteMapper.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/mapper/ProdBaseRouteMapper.java @@ -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 { + + /** + * 查询工艺路线 + * + * @param routeId 工艺路线主键 + * @return 工艺路线 + */ + public ProdBaseRouteVo selectProdBaseRouteByRouteId(Long routeId); + + /** + * 查询工艺路线列表 + * + * @param mesBaseRoute 工艺路线 + * @return 工艺路线集合 + */ + public List 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 mesBaseRouteProcessList); + + + /** + * 通过工艺路线主键删除工艺路线组成信息信息 + * + * @param routeId 工艺路线ID + * @return 结果 + */ + public int deleteProdBaseRouteProcessByRouteId(Long routeId); + + /** + * 根据工艺路线ID查询工位信息 + * @param routeId + * @return + */ + List> getStationByRouteId(Long routeId); } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/IProdBaseRouteService.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/IProdBaseRouteService.java index c7824fb6..b1cc0941 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/IProdBaseRouteService.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/IProdBaseRouteService.java @@ -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 ids, Boolean isValid); + + public List> getStationByRouteId(Long routeId); + + /** + * 查询工艺路线 + * + * @param routeId 工艺路线主键 + * @return 工艺路线 + */ + public ProdBaseRouteVo selectMesBaseRouteByRouteId(Long routeId); } diff --git a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdBaseRouteServiceImpl.java b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdBaseRouteServiceImpl.java index 4a84aa37..359c4fa8 100644 --- a/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdBaseRouteServiceImpl.java +++ b/ruoyi-modules/hwmom-mes/src/main/java/org/dromara/mes/service/impl/ProdBaseRouteServiceImpl.java @@ -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 routeProcessVoList = routeProcessService.queryList(prodBaseRouteProcessBo); + prodBaseRouteVo.setRouteProcessVoList(routeProcessVoList); + + return prodBaseRouteVo; } /** @@ -75,6 +87,7 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService { private MPJLambdaWrapper buildQueryWrapper(ProdBaseRouteBo bo) { Map params = bo.getParams(); MPJLambdaWrapper 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 ids, Boolean isValid) { if(isValid){ //TODO 做一些业务上的校验,判断是否需要校验 } + routeProcessService.deleteWithValidByIds(ids, isValid); return routeMapper.deleteByIds(ids) > 0; } + + /** + * 插入工艺路线过程 + * @param bo 包含工艺路线信息的业务对象 + */ + public void insertProdBaseRouteProcess(ProdBaseRouteBo bo) + { + // 获取工艺路线中的工艺步骤列表 + List mesBaseRouteProcessList = bo.getRouteProcessBoList(); + // 获取工艺路线ID + Long routeId = bo.getRouteId(); + + // 如果工艺步骤列表不为空 + if (ObjectUtil.isNotNull(mesBaseRouteProcessList)) + { + // 创建一个新的工艺步骤列表 + List list = new ArrayList(); + // 遍历每一个工艺步骤 + for (ProdBaseRouteProcessBo mesBaseRouteProcess : mesBaseRouteProcessList) + { + // 设置工艺步骤的工艺路线ID + mesBaseRouteProcess.setRouteId(routeId); + // 将工艺步骤添加到新的列表中 + list.add(mesBaseRouteProcess); + } + // 如果新的工艺步骤列表不为空 + if (!list.isEmpty()) + { + // 批量插入工艺步骤到数据库 + routeMapper.batchProdBaseRouteProcess(list); + } + } + } + + /** + * 根据工艺路线ID查询工位信息 + * @param routeId + * @return + */ + @Override + public List> getStationByRouteId(Long routeId) { + return routeMapper.getStationByRouteId(routeId); + } + + /** + * 查询工艺路线 + * + * @param routeId 工艺路线主键 + * @return 工艺路线 + */ + @Override + public ProdBaseRouteVo selectMesBaseRouteByRouteId(Long routeId) + { + return routeMapper.selectProdBaseRouteByRouteId(routeId); + } } diff --git a/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdBaseRouteMapper.xml b/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdBaseRouteMapper.xml index 081f8550..bbcd36e0 100644 --- a/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdBaseRouteMapper.xml +++ b/ruoyi-modules/hwmom-mes/src/main/resources/mapper/mes/ProdBaseRouteMapper.xml @@ -4,4 +4,209 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into prod_base_route + + route_name, + route_desc, + active_flag, + remark, + create_by, + create_time, + update_by, + update_time, + + tenant_id, + + + + #{routeName}, + #{routeDesc}, + #{activeFlag}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + #{tenantId}, + + + + + + update prod_base_route + + route_name = #{routeName}, + route_desc = #{routeDesc}, + active_flag = #{activeFlag}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + tenant_id = #{tenantId}, + + + where route_id = #{routeId} + + + + delete + from prod_base_route + where route_id = #{routeId} + + + + delete from prod_base_route where route_id in + + #{routeId} + + + + + delete from prod_base_route_process where route_id in + + #{routeId} + + + + + delete + from prod_base_route_process + where route_id = #{routeId} + + + + insert into prod_base_route_process( route_id, process_id, process_order, remark, create_by, + create_time, update_by, update_time) values + + ( #{item.routeId}, #{item.processId}, #{item.processOrder}, #{item.remark}, + #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}) + + + + + + + +