src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java
@@ -3,6 +3,7 @@ import java.util.List; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.jeecg.modules.base.entity.Factory; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -14,4 +15,9 @@ */ public interface FactoryMapper extends BaseMapper<Factory> { /** * æ ¹æ®idä¸çº§äº§çº¿ */ @Select("SELECT * FROM base_factory where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}") List<Factory> queryFacByPid(@Param("parentId") String parentId); } src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java
@@ -14,4 +14,8 @@ */ public interface UserFactoryMapper extends BaseMapper<UserFactory> { /** * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿idéå */ List<String> queryFactoryIdsByUserId(@Param("userId") String userId); } src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml
@@ -2,4 +2,8 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.base.mapper.UserFactoryMapper"> <select id="queryFactoryIdsByUserId" resultType="java.lang.String"> SELECT factory_id FROM base_user_factory WHERE user_id = #{userId} </select> </mapper> src/main/java/org/jeecg/modules/base/service/IFactoryService.java
@@ -38,4 +38,9 @@ * æ¥è¯¢ææfactoryIdä¿¡æ¯,å¹¶åèç¹è¿è¡æ¾ç¤º */ List<FactoryIdModel> queryFactoryIdTreeList(); /** * è·åä¸çº§äº§çº¿ */ List<Factory> queryFacByPid(String pid); } src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java
@@ -18,4 +18,9 @@ * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿ä¿¡æ¯ */ List<FactoryIdModel> queryFactoryIdsOfUser(String userId); /** * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿idéå */ List<String> queryFactoryIdsByUserId(String userId); } src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java
@@ -24,6 +24,7 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** @@ -159,6 +160,14 @@ } /** * æ ¹æ®idæ¥è¯¢ä¸çº§äº§çº¿ */ @Override public List<Factory> queryFacByPid(String pid) { return this.baseMapper.queryFacByPid(pid); } /** * æå¼ ç¶èç¹ å 以ä¸çmdcæ è®° * @param parentId */ src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** @@ -56,4 +57,12 @@ } return null; } /** * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿idéå */ @Override public List<String> queryFactoryIdsByUserId(String userId) { return this.baseMapper.queryFactoryIdsByUserId(userId); } } src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
@@ -13,10 +13,12 @@ import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.base.model.FactoryIdModel; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; import org.jeecg.modules.mdc.model.MdcEquipmentTree; import org.jeecg.modules.mdc.model.ProductionIdModel; import org.jeecg.modules.mdc.service.IFactoryEquipmentService; import org.jeecg.modules.mdc.service.IMdcEquipmentDepartService; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService; @@ -55,7 +57,10 @@ private IMdcEquipmentDepartService mdcEquipmentDepartService; @Resource private IMdcProductionEquipmentService mdcProductionEquipmentService; private IFactoryEquipmentService factoryEquipmentService; // @Resource // private IMdcProductionEquipmentService mdcProductionEquipmentService; /** * å页å表æ¥è¯¢ @@ -244,7 +249,7 @@ public Result<MdcEquipment> add(@RequestBody MdcEquipment mdcEquipment) { Result<MdcEquipment> result = new Result<>(); String selectedDeparts = mdcEquipment.getSelectedDeparts(); String selectedProduction = mdcEquipment.getSelectedProduction(); String selectedProduction = mdcEquipment.getSelectedFactory(); mdcEquipment.setEquipmentStatus(CommonConstant.STATUS_NORMAL); try { mdcEquipmentService.saveMdcEquipment(mdcEquipment, selectedDeparts, selectedProduction); @@ -367,11 +372,11 @@ */ @AutoLog(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ®") @ApiOperation(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ®", notes = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ®") @GetMapping(value = "/equipmentProductionList") public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { Result<List<ProductionIdModel>> result = new Result<>(); @GetMapping(value = "/equipmentFactoryList") public Result<List<FactoryIdModel>> equipmentFactoryList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { Result<List<FactoryIdModel>> result = new Result<>(); try { List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId); List<FactoryIdModel> proIdModelList = this.factoryEquipmentService.queryFactoryIdsOfEquipment(equipmentId); if (proIdModelList != null && !proIdModelList.isEmpty()) { result.setSuccess(true); result.setMessage("æ¥æ¾æå"); @@ -388,6 +393,33 @@ return result; } } // /** // * æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ® // */ // @AutoLog(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ®") // @ApiOperation(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ®", notes = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åäº§çº¿å ³èçæ°æ®") // @GetMapping(value = "/equipmentProductionList") // public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { // Result<List<ProductionIdModel>> result = new Result<>(); // try { // List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId); // if (proIdModelList != null && !proIdModelList.isEmpty()) { // result.setSuccess(true); // result.setMessage("æ¥æ¾æå"); // result.setResult(proIdModelList); // } else { // result.setSuccess(false); // result.setMessage("æ¥æ¾å¤±è´¥"); // } // return result; // } catch (Exception e) { // log.error(e.getMessage(), e); // result.setSuccess(false); // result.setMessage("æ¥æ¾è¿ç¨ä¸åºç°äºå¼å¸¸: " + e.getMessage()); // return result; // } // } /** * å è½½é¨é¨è®¾å¤æ @@ -430,6 +462,26 @@ } /** * å è½½äº§çº¿è®¾å¤æ */ @AutoLog(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") @ApiOperation(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ", notes = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") @GetMapping(value = "/queryTreeListByFactory") public Result<List<MdcEquipmentTree>> queryTreeListByFactory() { Result<List<MdcEquipmentTree>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); try { List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId); result.setSuccess(true); result.setResult(mdcEquipmentTreeList); } catch (Exception e) { log.error(e.getMessage(), e); } return result; } /** * 导åºexcel * * @param request src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,53 @@ package org.jeecg.modules.mdc.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.io.Serializable; /** * äº§çº¿è®¾å¤ * * @author: LiuS * @create: 2023-03-24 15:54 */ @Data @TableName("base_equipment_factory") @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @ApiModel(value = "base_equipment_factory对象", description = "产线设å¤è¡¨") public class FactoryEquipment implements Serializable { private static final long serialVersionUID = 1684188898785392096L; /** * 主é®id */ @TableId(type = IdType.ASSIGN_ID) private String id; /** * 产线id */ private String factoryId; /** * 设å¤id */ private String equipmentId; public FactoryEquipment(String id, String factoryId, String equipmentId) { super(); this.id = id; this.factoryId = factoryId; this.equipmentId = equipmentId; } public FactoryEquipment(String id, String factoryId) { this.equipmentId = id; this.factoryId = factoryId; } } src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java
@@ -172,7 +172,7 @@ @TableField(exist = false) @ApiModelProperty(value = "éæ©ç产线idéå") private String selectedProduction; private String selectedFactory; // å ³è产线ï¼éæ°æ®åºåæ®µï¼ private transient String productionId; src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,13 @@ package org.jeecg.modules.mdc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.jeecg.modules.mdc.entity.FactoryEquipment; /** * 产线设å¤mapperæ¥å£ * * @author: LiuS * @create: 2023-03-24 16:00 */ public interface FactoryEquipmentMapper extends BaseMapper<FactoryEquipment> { } src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
@@ -144,4 +144,9 @@ List<String> getEquIdsByProIds(@Param("proIds") List<String> proIds); List<MdcEquipment> getEquipmentList(@Param("allProductionIds") List<String> allProductionIds); List<MdcEquipment> queryByFactoryId(@Param("factoryId") String factoryId); List<String> queryIdsByFactorys(@Param("allFactoryIds") List<String> allFactoryIds); } src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,5 @@ <?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"> <mapper namespace="org.jeecg.modules.mdc.mapper.FactoryEquipmentMapper"> </mapper> src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
@@ -12,7 +12,7 @@ <!--æ¥è¯¢è®¾å¤çæå±äº§çº¿åç§°ä¿¡æ¯--> <select id="getProNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentProVo"> SELECT p.production_name, pe.equipment_id FROM mdc_production_equipment pe, mdc_production p WHERE p.id = pe.production_id AND pe.equipment_id IN SELECT f.factory_name, bef.equipment_id FROM base_equipment_factory bef, base_factory f WHERE f.id = bef.factory_id AND bef.equipment_id IN <foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> @@ -402,4 +402,29 @@ </where> </select> <select id="queryByFactoryId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment"> SELECT me.* FROM base_equipment_factory bef, mdc_equipment me WHERE bef.equipment_id = me.id AND bef.factory_id = #{ factoryId } ORDER BY me.equipment_id </select> <select id="queryIdsByFactorys" resultType="java.lang.String"> SELECT me.equipment_id FROM mdc_equipment me LEFT JOIN base_equipment_factory bef ON me.id = bef.equipment_id WHERE bef.factory_id IN <foreach collection="allFactoryIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </select> </mapper> src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,112 @@ package org.jeecg.modules.mdc.model; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.modules.base.entity.Factory; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * @author: LiuS * @create: 2023-03-23 14:16 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @ApiModel(value = "产线表æ ç»ææ°æ®å®ä½", description = "产线表") public class FactoryTreeModel implements Serializable { private static final long serialVersionUID = -1309711609760828658L; /** * 对åºMdcProductionä¸çidåæ®µ,åç«¯æ°æ®æ ä¸çkey */ private String key; /** * 对åºMdcProductionä¸çidåæ®µ,åç«¯æ°æ®æ ä¸çvalue */ private String value; /** * 对åºdepart_nameåæ®µ,åç«¯æ°æ®æ ä¸çtitle */ private String title; private boolean isLeaf; /** * ç±»å */ private Integer type; //以䏿æå段åä¸MdcProductionç¸å private String id; private String createBy; private Date createTime; private String updateBy; private Date updateTime; private Integer delFlag; private String factoryName; private String factoryCode; private String parentId; private String factoryStatus; private String factoryCategory; private Integer sorter; private String address; private String mdcFlag; private String remark; /** * 产线è´è´£äººids */ private String directorUserIds; private List<FactoryTreeModel> children = new ArrayList<>(); public FactoryTreeModel() { } /** * å°MdcProductionå¯¹è±¡è½¬æ¢æMdcProductionTreeModel对象 * * @param factory */ public FactoryTreeModel(Factory factory) { this.key = factory.getId(); this.value = factory.getId(); this.title = factory.getFactoryName(); this.id = factory.getId(); this.parentId = factory.getParentId(); this.factoryName = factory.getFactoryName(); this.sorter = factory.getSorter(); this.factoryCode = factory.getFactoryCode(); this.address = factory.getAddress(); this.delFlag = factory.getDelFlag(); this.createBy = factory.getCreateBy(); this.createTime = factory.getCreateTime(); this.updateBy = factory.getUpdateBy(); this.updateTime = factory.getUpdateTime(); this.mdcFlag = factory.getMdcFlag(); } } src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java
@@ -122,5 +122,18 @@ return this; } /** * å°mdcProductionTreeModelçé¨åæ°æ®æ¾å¨è¯¥å¯¹è±¡å½ä¸ * @param treeModel * @return */ public MdcEquipmentTree convertByFactory(FactoryTreeModel treeModel) { this.key = treeModel.getId(); this.value = treeModel.getId(); this.title = treeModel.getFactoryName(); this.type = treeModel.getType(); return this; } } src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,30 @@ package org.jeecg.modules.mdc.service; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.base.model.FactoryIdModel; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.FactoryEquipment; import java.util.List; /** * @author: LiuS * @create: 2023-03-28 10:30 */ public interface IFactoryEquipmentService extends IService<FactoryEquipment> { /** * æ ¹æ®æå®è®¾å¤idæ¥è¯¢äº§çº¿ä¿¡æ¯ */ List<FactoryIdModel> queryFactoryIdsOfEquipment(String equipmentId); /** * æ ¹æ®æå®äº§çº¿idæ¥è¯¢è®¾å¤ä¿¡æ¯ */ List<MdcEquipment> queryEquipmentsOfFactory(String factoryId); /** * æ ¹æ®æå®äº§çº¿idsæ¥è¯¢è®¾å¤ä¿¡æ¯ */ List<MdcEquipment> queryEquipmentsOfFactorys(List<String> factoryIds); } src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,87 @@ package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.base.entity.Factory; import org.jeecg.modules.base.model.FactoryIdModel; import org.jeecg.modules.base.service.IFactoryService; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.FactoryEquipment; import org.jeecg.modules.mdc.mapper.FactoryEquipmentMapper; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.mdc.service.IFactoryEquipmentService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @author: LiuS * @create: 2023-03-28 10:31 */ @Service public class FactoryEquipmentServiceImpl extends ServiceImpl<FactoryEquipmentMapper, FactoryEquipment> implements IFactoryEquipmentService { @Resource private IFactoryService mdcFactoryService; @Resource private IMdcEquipmentService mdcEquipmentService; /** * æ ¹æ®è®¾å¤idæ¥è¯¢äº§çº¿ä¿¡æ¯ */ @Override public List<FactoryIdModel> queryFactoryIdsOfEquipment(String equipmentId) { LambdaQueryWrapper<FactoryEquipment> queryEquipmentFac = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Factory> queryFac = new LambdaQueryWrapper<>(); try { queryEquipmentFac.eq(FactoryEquipment::getEquipmentId, equipmentId); List<String> facIdList = new ArrayList<>(); List<FactoryIdModel> facIdModelList = new ArrayList<>(); List<FactoryEquipment> equipmentProList = this.list(queryEquipmentFac); if (equipmentProList != null && !equipmentProList.isEmpty()) { for (FactoryEquipment factoryEquipment : equipmentProList) { facIdList.add(factoryEquipment.getFactoryId()); } queryFac.in(Factory::getId, facIdList); List<Factory> proList = mdcFactoryService.list(queryFac); if (proList != null && !proList.isEmpty()) { for (Factory mdcFactory : proList) { facIdModelList.add(new FactoryIdModel().convertByUserFactory(mdcFactory)); } } return facIdModelList; } } catch (Exception e) { e.fillInStackTrace(); } return null; } /** * æ ¹æ®æå®äº§çº¿idæ¥è¯¢è®¾å¤ä¿¡æ¯ */ @Override public List<MdcEquipment> queryEquipmentsOfFactory(String factoryId){ List<String> equipmentIds = this.list(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getFactoryId, factoryId)) .stream().map(FactoryEquipment::getEquipmentId).collect(Collectors.toList()); if (!equipmentIds.isEmpty()) { return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); } return null; } /** * æ ¹æ®æå®äº§çº¿idsæ¥è¯¢è®¾å¤ä¿¡æ¯ */ @Override public List<MdcEquipment> queryEquipmentsOfFactorys(List<String> factoryIds){ List<String> equipmentIds = this.list(new LambdaQueryWrapper<FactoryEquipment>() .in(FactoryEquipment::getFactoryId, factoryIds)).stream().map(FactoryEquipment::getEquipmentId).collect(Collectors.toList()); if (!equipmentIds.isEmpty()) { return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); } return null; } } src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -15,24 +15,23 @@ import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.base.entity.Factory; import org.jeecg.modules.base.service.IFactoryService; import org.jeecg.modules.base.service.IUserFactoryService; import org.jeecg.modules.base.service.impl.FactoryServiceImpl; import org.jeecg.modules.mdc.dto.MdcEquDepDto; import org.jeecg.modules.mdc.dto.MdcEquProDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDto; import org.jeecg.modules.mdc.entity.*; import org.jeecg.modules.mdc.mapper.MdcEquipmentDepartMapper; import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper; import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; import org.jeecg.modules.mdc.mapper.*; import org.jeecg.modules.mdc.model.MdcEquipmentTree; import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.util.DncCopyEquipment; import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil; import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; import org.jeecg.modules.mdc.util.*; import org.jeecg.modules.mdc.vo.*; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.service.*; import org.jeecg.modules.system.util.FindsFactorysChildrenUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.CacheEvict; @@ -91,6 +90,15 @@ @Autowired private IEquipmentService equipmentService; @Autowired private IFactoryService factoryService; @Autowired private IUserFactoryService userFactoryService; @Autowired private FactoryEquipmentMapper factoryEquipmentMapper; @Override public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { @@ -104,7 +112,7 @@ public Map<String, String> getProNamesByEquipmentIds(List<String> equipmentIds) { List<MdcEquipmentProVo> list = this.baseMapper.getProNamesByEquipmentIds(equipmentIds); Map<String, String> res = new HashMap(5); list.forEach(item -> res.merge(item.getEquipmentId(), item.getProductionName(), (a, b) -> a + "," + b)); list.forEach(item -> res.merge(item.getEquipmentId(), item.getFactoryName(), (a, b) -> a + "," + b)); return res; } @@ -125,8 +133,8 @@ if (oConvertUtils.isNotEmpty(selectedProduction)) { String[] arr = selectedProduction.split(","); for (String productionId : arr) { MdcProductionEquipment mdcProductionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId); mdcProductionEquipmentMapper.insert(mdcProductionEquipment); FactoryEquipment mdcProductionEquipment = new FactoryEquipment(mdcEquipment.getId(), productionId); factoryEquipmentMapper.insert(mdcProductionEquipment); } } } @@ -152,17 +160,17 @@ } } //step.3 ä¿®æ¹äº§çº¿ String productions = mdcEquipment.getSelectedProduction(); String productions = mdcEquipment.getSelectedFactory(); String[] array = {}; if (oConvertUtils.isNotEmpty(productions)) { array = productions.split(","); } //å å åå mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, mdcEquipment.getId())); factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getEquipmentId, mdcEquipment.getId())); if (oConvertUtils.isNotEmpty(productions)) { for (String productionId : array) { MdcProductionEquipment productionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId); mdcProductionEquipmentMapper.insert(productionEquipment); FactoryEquipment productionEquipment = new FactoryEquipment(mdcEquipment.getId(), productionId); factoryEquipmentMapper.insert(productionEquipment); } } } @@ -176,7 +184,7 @@ // 2. å é¤è®¾å¤é¨é¨å ³ç³» line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getEquipmentId, id)); // 3. å é¤è®¾å¤äº§çº¿å ³ç³» line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, id)); line += factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getEquipmentId, id)); return line != 0; } @@ -189,7 +197,7 @@ // 2. å é¤è®¾å¤é¨é¨å ³ç³» line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().in(MdcEquipmentDepart::getEquipmentId, equipmentIds)); // 3. å é¤è®¾å¤äº§çº¿å ³ç³» line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getEquipmentId, equipmentIds)); line += factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().in(FactoryEquipment::getEquipmentId, equipmentIds)); return line != 0; } @@ -293,23 +301,84 @@ @Override public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { //è·åææäº§çº¿æ°æ® List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).orderByAsc(MdcProduction::getProductionOrder)); List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(Factory::getSorter)); //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); List<String> allProductionIds = new ArrayList<>(); List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId); List<String> allFactoryIds = new ArrayList<>(); //æ¾å°ææäº§çº¿idçä¸çº§id if (productionIds != null && !productionIds.isEmpty()) { for (String productionId : productionIds) { this.getAllProductionIds(productionList, productionId, allProductionIds); if (factoryIds != null && !factoryIds.isEmpty()) { for (String factoryId : factoryIds) { this.getAllFactoryIds(factoryList, factoryId, allFactoryIds); } } //è¿æ»¤äº§çº¿æ°æ® List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); List<Factory> list = factoryList.stream().filter((Factory factory) -> allFactoryIds.contains(factory.getId())).collect(Collectors.toList()); //ç»è£ äº§çº¿è®¾å¤æ List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); List<MdcEquipmentTree> treeList = FindsEquipmentFactoryUtil.wrapEquipmentFactoryTreeList(list); //å¡«å è®¾å¤æ°æ® FillEquipmentByProduction(treeList); FillEquipmentByFactory(treeList); // //è·åææäº§çº¿æ°æ® // List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).orderByAsc(MdcProduction::getProductionOrder)); // //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå // List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); // List<String> allProductionIds = new ArrayList<>(); // //æ¾å°ææäº§çº¿idçä¸çº§id // if (productionIds != null && !productionIds.isEmpty()) { // for (String productionId : productionIds) { // this.getAllProductionIds(productionList, productionId, allProductionIds); // } // } // //è¿æ»¤äº§çº¿æ°æ® // List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); // //ç»è£ äº§çº¿è®¾å¤æ // List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); // å¡«å è®¾å¤æ°æ® // FillEquipmentByProduction(treeList); return treeList; } /** * äº§çº¿è®¾å¤æ å¡«å è®¾å¤æ°æ® */ private void FillEquipmentByFactory(List<MdcEquipmentTree> treeList) { for (MdcEquipmentTree mdcEquipmentTree : treeList) { List<MdcEquipment> equipmentList = this.baseMapper.queryByFactoryId(mdcEquipmentTree.getKey()); if (equipmentList != null && !equipmentList.isEmpty()) { for (MdcEquipment mdcEquipment : equipmentList) { MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); tree.setParentId(mdcEquipmentTree.getKey()); tree.setEntity(mdcEquipment); tree.setType(2); mdcEquipmentTree.getChildren().add(tree); } mdcEquipmentTree.setLeaf(false); } if (!mdcEquipmentTree.getChildren().isEmpty()) { FillEquipmentByFactory(mdcEquipmentTree.getChildren()); } } } /** * è·åææç产线idï¼å 嫿æä¸çº§ï¼ */ private void getAllFactoryIds(List<Factory> factoryList, String factoryId, List<String> allFactoryIds) { if (!allFactoryIds.contains(factoryId)) { allFactoryIds.add(factoryId); } for (Factory factory : factoryList) { if (StringUtils.isEmpty(factory.getParentId())) { continue; } if (factoryId.equals(factory.getId())) { if (!allFactoryIds.contains(factory.getParentId())) { allFactoryIds.add(factory.getParentId()); getAllFactoryIds(factoryList, factory.getParentId(), allFactoryIds); } } } } /** @@ -513,30 +582,74 @@ @Override public List<String> getEquipmentIdsProduction(String userId, String key) { //è·åææäº§çº¿æ°æ® List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0).orderByAsc(Factory::getSorter)); //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); List<String> allProductionIds = new ArrayList<>(); List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId); List<String> allFactoryIds = new ArrayList<>(); //æ¾å°ææäº§çº¿idçä¸çº§id if (productionIds != null && !productionIds.isEmpty()) { for (String productionId : productionIds) { this.getAllProductionIds(productionList, productionId, allProductionIds); if (factoryIds != null && !factoryIds.isEmpty()) { for (String productionId : factoryIds) { this.getAllFactoryIds(factoryList, productionId, allFactoryIds); } } //æ ¹æ®äº§çº¿éåæ¥æ¾ææè®¾å¤id if (allProductionIds.isEmpty()) { if (allFactoryIds.isEmpty()) { return null; } List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds); List<String> equipmentIds = this.baseMapper.queryIdsByFactorys(allFactoryIds); if (StringUtils.isNotEmpty(key)) { //keyä¸ä¸ºç©ºï¼æ¥è¯¢ææä¸çº§äº§çº¿id List<String> partProduction = this.findAllProductions(key); partProduction.add(key); List<String> partFactory = this.findAllFactorys(key); partFactory.add(key); //è¿æ»¤æ æé产线id List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList()); equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey); List<String> allFactoryIdsByKey = partFactory.stream().filter(allFactoryIds::contains).collect(Collectors.toList()); equipmentIds = this.baseMapper.queryIdsByFactorys(allFactoryIdsByKey); } return equipmentIds; //è·åææäº§çº¿æ°æ® // List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); // //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå // List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); // List<String> allProductionIds = new ArrayList<>(); // //æ¾å°ææäº§çº¿idçä¸çº§id // if (productionIds != null && !productionIds.isEmpty()) { // for (String productionId : productionIds) { // this.getAllProductionIds(productionList, productionId, allProductionIds); // } // } // //æ ¹æ®äº§çº¿éåæ¥æ¾ææè®¾å¤id // if (allProductionIds.isEmpty()) { // return null; // } // List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds); // if (StringUtils.isNotEmpty(key)) { // //keyä¸ä¸ºç©ºï¼æ¥è¯¢ææä¸çº§äº§çº¿id // List<String> partProduction = this.findAllProductions(key); // partProduction.add(key); // //è¿æ»¤æ æé产线id // List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList()); // equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey); // } // return equipmentIds; // } /** * æ ¹æ®ç¶çº§idé彿¥è¯¢ææä¸çº§idéå */ private List<String> findAllFactorys(String key) { List<String> factoryIds = new ArrayList<>(); List<Factory> factorys = factoryService.queryFacByPid(key); if (factorys != null && !factorys.isEmpty()) { List<String> ids = factorys.stream().map(Factory::getId).collect(Collectors.toList()); factoryIds.addAll(ids); for (Factory factory : factorys) { List<String> allFactorys = findAllFactorys(factory.getId()); factoryIds.addAll(allFactorys); } } return factoryIds; } /** src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,80 @@ package org.jeecg.modules.mdc.util; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.base.entity.Factory; import org.jeecg.modules.mdc.model.MdcEquipmentTree; import org.jeecg.modules.mdc.model.FactoryTreeModel; import org.jeecg.modules.mdc.model.MdcProductionTreeModel; import java.util.ArrayList; import java.util.List; /** * äº§çº¿è®¾å¤æ * @author: LiuS * @create: 2023-04-03 15:59 */ public class FindsEquipmentFactoryUtil { /** * è·å MdcEquipmentTree */ public static List<MdcEquipmentTree> wrapEquipmentFactoryTreeList(List<Factory> recordList) { List<MdcEquipmentTree> idList = new ArrayList<>(); List<FactoryTreeModel> records = new ArrayList<>(); for (Factory factory : recordList) { records.add(new FactoryTreeModel(factory)); } getChildren(records, idList); setEmptyChildrenAsNull(idList); return idList; } /** * è¯¥æ¹æ³æ¯æ¾å°å¹¶å°è£ 顶级ç¶ç±»çèç¹å°TreeListéå */ private static void getChildren(List<FactoryTreeModel> recordList, List<MdcEquipmentTree> idList) { List<FactoryTreeModel> treeList = new ArrayList<>(); for (FactoryTreeModel factoryTreeModel : recordList) { if (oConvertUtils.isEmpty(factoryTreeModel.getParentId())) { factoryTreeModel.setType(1); treeList.add(factoryTreeModel); idList.add(new MdcEquipmentTree().convertByFactory(factoryTreeModel)); } } getGrandChildren(treeList, recordList, idList); } /** *è¯¥æ¹æ³æ¯æ¾å°é¡¶çº§ç¶ç±»ä¸çææåèç¹éåå¹¶å°è£ å°TreeListéå */ private static void getGrandChildren(List<FactoryTreeModel> treeList, List<FactoryTreeModel> recordList, List<MdcEquipmentTree> idList) { for (int i = 0; i < treeList.size(); i++) { FactoryTreeModel model = treeList.get(i); MdcEquipmentTree mdcEquipmentTree = idList.get(i); for (int i1 = 0; i1 < recordList.size(); i1++) { FactoryTreeModel m = recordList.get(i1); if (m.getParentId() != null && m.getParentId().equals(model.getId())) { model.getChildren().add(m); m.setType(1); mdcEquipmentTree.getChildren().add(new MdcEquipmentTree().convertByFactory(m)); } } getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren()); } } /** * è¯¥æ¹æ³æ¯å°åèç¹ä¸ºç©ºçListéå设置为Nullå¼ */ private static void setEmptyChildrenAsNull(List<MdcEquipmentTree> idList) { for (MdcEquipmentTree mdcEquipmentTree : idList) { if (mdcEquipmentTree.getChildren().isEmpty()) { mdcEquipmentTree.setLeaf(true); } else { setEmptyChildrenAsNull(mdcEquipmentTree.getChildren()); mdcEquipmentTree.setLeaf(false); } } } } src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java
@@ -9,5 +9,5 @@ @Data public class MdcEquipmentProVo { private String equipmentId; private String productionName; private String factoryName; } src/main/java/org/jeecg/modules/system/controller/SysUserController.java
@@ -253,7 +253,7 @@ Result<SysUser> result = new Result<SysUser>(); String selectedRoles = jsonObject.getString("selectedroles"); String selectedDeparts = jsonObject.getString("selecteddeparts"); String selectedProductions = jsonObject.getString("selectedProduction"); String selectedProductions = jsonObject.getString("selectedFactorys"); try { SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); user.setCreateTime(new Date());//设置å建æ¶é´ @@ -295,7 +295,7 @@ user.setPassword(sysUser.getPassword()); String roles = jsonObject.getString("selectedroles"); String departs = jsonObject.getString("selecteddeparts"); String productions = jsonObject.getString("selectedProduction"); String productions = jsonObject.getString("selectedFactorys"); if (oConvertUtils.isEmpty(departs)) { //vue3.0å端åªä¼ éäºdepartIds departs = user.getDepartIds(); @@ -476,17 +476,17 @@ } @AutoLog(value = "ç¨æ·è¡¨-æ¥è¯¢æå®ç¨æ·åäº§çº¿å ³èçæ°æ®") @ApiOperation(value = "ç¨æ·è¡¨-æ¥è¯¢æå®ç¨æ·åäº§çº¿å ³èçæ°æ®", notes = "ç¨æ·è¡¨-æ¥è¯¢æå®ç¨æ·åäº§çº¿å ³èçæ°æ®") @GetMapping(value = "/userProductionList") public Result<List<ProductionIdModel>> getUserProductionsList(@RequestParam(name = "userId", required = true) String userId) { Result<List<ProductionIdModel>> result = new Result<>(); @AutoLog(value = "ç¨æ·è¡¨-æ¥è¯¢æå®ç¨æ·åå·¥åå»ºæ¨¡å ³èçæ°æ®") @ApiOperation(value = "ç¨æ·è¡¨-æ¥è¯¢æå®ç¨æ·åå·¥åå»ºæ¨¡å ³èçæ°æ®", notes = "ç¨æ·è¡¨-æ¥è¯¢æå®ç¨æ·åå·¥åå»ºæ¨¡å ³èçæ°æ®") @GetMapping(value = "/userFactorysList") public Result<List<FactoryIdModel>> getUserFactorysList(@RequestParam(name = "userId", required = true) String userId) { Result<List<FactoryIdModel>> result = new Result<>(); try { List<ProductionIdModel> proIdModelList = this.userProductionService.queryProductionIdsOfUser(userId); if (proIdModelList != null && !proIdModelList.isEmpty()) { List<FactoryIdModel> facIdModelList = this.userFactoryService.queryFactoryIdsOfUser(userId); if (facIdModelList != null && !facIdModelList.isEmpty()) { result.setSuccess(true); result.setMessage("æ¥æ¾æå"); result.setResult(proIdModelList); result.setResult(facIdModelList); } else { result.setSuccess(false); result.setMessage("æ¥æ¾å¤±è´¥"); src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
@@ -185,7 +185,7 @@ <!-- æ¥è¯¢ç¨æ·çæå±äº§çº¿åç§°ä¿¡æ¯ --> <select id="getProNamesByUserIds" resultType="org.jeecg.modules.system.vo.MdcUserProVo"> SELECT p.production_name, up.user_id FROM mdc_user_production up, mdc_production p WHERE p.id = up.pro_id AND up.user_id IN SELECT p.factory_name productionName, up.user_id FROM base_user_factory up, base_factory p WHERE p.id = up.factory_id AND up.user_id IN <foreach collection="userIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
@@ -522,7 +522,7 @@ // 2. å é¤ç¨æ·é¨é¨å ³ç³» line += sysUserDepartMapper.delete(new LambdaQueryWrapper<SysUserDepart>().in(SysUserDepart::getUserId, userIds)); // 3. å é¤ç¨æ·äº§çº¿å ³ç³» line += mdcUserProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getUserId, userIds)); line += userFactoryMapper.delete(new LambdaQueryWrapper<UserFactory>().in(UserFactory::getUserId, userIds)); //3. å é¤ç¨æ·è§è²å ³ç³» line += sysUserRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, userIds)); //4.忥å é¤ç¬¬ä¸æ¹Appçç¨æ· @@ -592,8 +592,8 @@ if (oConvertUtils.isNotEmpty(selectedProductions)) { arr = selectedProductions.split(","); for (String productionId : arr) { MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); mdcUserProductionMapper.insert(mdcUserProduction); UserFactory mdcUserProduction = new UserFactory(productionId, user.getId()); userFactoryMapper.insert(mdcUserProduction); } } //step.5 ä¿åè®¾å¤æé @@ -661,13 +661,14 @@ array = productions.split(","); } //å å åå mdcUserProductionMapper.delete(new QueryWrapper<MdcUserProduction>().lambda().eq(MdcUserProduction::getUserId, user.getId())); userFactoryMapper.delete(new QueryWrapper<UserFactory>().lambda().eq(UserFactory::getUserId, user.getId())); if (oConvertUtils.isNotEmpty(productions)) { for (String productionId : array) { MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); mdcUserProductionMapper.insert(mdcUserProduction); UserFactory mdcUserProduction = new UserFactory(productionId, user.getId()); userFactoryMapper.insert(mdcUserProduction); } } //step.5 ä¿®æ¹è®¾å¤æé //å å åå // dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getUserId, user.getId()));