lius
2023-07-10 f9c42e6879387bdad34e714d7a91add2bb182934
扭矩配置导入导出分页列表接口bug修复
已修改5个文件
已删除1个文件
189 ■■■■ 文件已修改
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcTorqueConfigController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcTorqueConfigMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcTorqueConfigService.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcTorqueConfigServiceImpl.java 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcTorqueConfigVo.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcTorqueConfigController.java
@@ -1,5 +1,6 @@
package org.jeecg.modules.mdc.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,7 +14,6 @@
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.entity.MdcTorqueConfig;
import org.jeecg.modules.mdc.service.IMdcTorqueConfigService;
import org.jeecg.modules.mdc.vo.MdcTorqueConfigVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@@ -54,17 +54,17 @@
    /**
     * æ‰­çŸ©é…ç½®ç®¡ç†-新增
     *
     * @param torqueVo
     * @param mdcTorqueConfig
     * @return
     */
    @AutoLog(value = "扭矩配置管理-新增")
    @ApiOperation(value = "扭矩配置管理-新增", notes = "扭矩配置管理-新增")
    @PostMapping("/addMdcTorqueConfig")
    public Result addMdcTorqueConfig(@RequestBody MdcTorqueConfigVo torqueVo) {
        if (StringUtils.isBlank(torqueVo.getEquipmentIds())) {
    public Result addMdcTorqueConfig(@RequestBody MdcTorqueConfig mdcTorqueConfig) {
        if (StringUtils.isBlank(mdcTorqueConfig.getEquipmentIds())) {
            return Result.error("未选择设备,请排查");
        }
        boolean result = mdcTorqueConfigService.addTorque(torqueVo);
        boolean result = mdcTorqueConfigService.addTorque(mdcTorqueConfig);
        if (!result) {
            return Result.error("时间段数据已存在,请排查");
        }
@@ -125,7 +125,9 @@
    @ApiOperation(value = "扭矩配置管理-导出", notes = "扭矩配置管理-导出")
    @RequestMapping("/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, MdcTorqueConfig mdcTorqueConfig) {
        return super.exportXls(request, mdcTorqueConfig, MdcTorqueConfig.class, "扭矩配置管理导出");
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        return this.mdcTorqueConfigService.exportXls(userId, mdcTorqueConfig);
    }
    /**
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java
@@ -48,13 +48,14 @@
    /**
     * è®¾å¤‡åç§°
     */
    @Excel(name = "设备名称", width = 15)
    @Excel(name = "设备名称", width = 25)
    @ApiModelProperty("设备名称")
    private String equipmentName;
    /**
     * æ—¶é—´
     */
    @Excel(name = "时间", width = 30, format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "时间")
@@ -70,7 +71,7 @@
    /**
     * å¤‡æ³¨
     */
    @Excel(name = "备注", width = 15)
    @Excel(name = "备注", width = 30)
    @ApiModelProperty("备注")
    private String notes;
@@ -104,6 +105,15 @@
    @ApiModelProperty("更新人")
    private String updateBy;
    @TableField(exist = false)
    private String equipmentIds;
    @TableField(exist = false)
    private String startTime;
    @TableField(exist = false)
    private String endTime;
    /**
     * å‰å°ä¼ å…¥ï¼Œåˆ¤æ–­æ¯ä¸ªid
     */
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcTorqueConfigMapper.xml
@@ -5,21 +5,27 @@
    <select id="findSpindleRunningCurve" resultType="org.jeecg.modules.mdc.entity.MdcTorqueConfig">
        select mtc.* from mdc_torque_config mtc where mtc.torque_value=#{torqueValue} and mtc.equipment_id=#{equipmentId}
    </select>
    <!--根据车间层级查询扭矩配置列表-->
    <select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcTorqueConfig">
        select mtc.* from mdc_torque_config mtc,mdc_equipment me where mtc.equipment_id=me.equipment_id
        <if test="mdcTorqueConfig.equipmentName !=null and mdcTorqueConfig.equipmentName !='' ">
            and mtc.equipment_name like concat(concat('%',#{mdcTorqueConfig.equipmentName}),'%')
        </if>
        <if test="mdcTorqueConfig.equipmentId !=null and mdcTorqueConfig.equipmentId !='' ">
            and mtc.equipment_id like concat(concat('%',#{mdcTorqueConfig.equipmentId}),'%')
        </if>
        <if test="mdcTorqueConfig.mdcSectionIds !=null || mdcTorqueConfig.mdcSectionIds.size() > 0 ">
            and mtc.equipment_id in
            <foreach collection="mdcTorqueConfig.mdcSectionIds" item="id" index="index" open="(" close=")"
                     separator=",">
                #{id}
            </foreach>
        </if>
        select * from mdc_torque_config
        <where>
            <if test="mdcTorqueConfig.equipmentId != null and mdcTorqueConfig.equipmentId != '' ">
                AND equipment_id LIKE CONCAT(CONCAT('%',#{mdcTorqueConfig.equipmentId}),'%')
            </if>
            <if test="mdcTorqueConfig.equipmentName != null and mdcTorqueConfig.equipmentName != '' ">
                AND equipment_name LIKE CONCAT(CONCAT('%',#{mdcTorqueConfig.equipmentName}),'%')
            </if>
            <if test="mdcTorqueConfig.startTime != null and mdcTorqueConfig.endTime != null">
                AND torque_date BETWEEN #{ mdcTorqueConfig.startTime } AND #{ mdcTorqueConfig.endTime }
            </if>
            <if test="mdcTorqueConfig.mdcSectionIds != null and mdcTorqueConfig.mdcSectionIds.size() > 0 ">
                AND equipment_id IN
                <foreach collection="mdcTorqueConfig.mdcSectionIds" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
            ORDER BY torque_date ASC
        </where>
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcTorqueConfigService.java
@@ -4,7 +4,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.mdc.entity.MdcTorqueConfig;
import org.jeecg.modules.mdc.vo.MdcTorqueConfigVo;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@@ -27,13 +27,15 @@
    /**
     * æ·»åŠ æ‰­çŸ©é…ç½®
     *
     * @param torqueVo
     * @return
     */
    Boolean addTorque(MdcTorqueConfigVo torqueVo);
    Boolean addTorque(MdcTorqueConfig torqueVo);
    /**
     * ç¼–辑扭矩配置
     *
     * @param mdcTorqueConfig
     * @return
     */
@@ -74,4 +76,13 @@
     * @return
     */
    IPage<MdcTorqueConfig> pageList(String userId, Page page, HttpServletRequest req, MdcTorqueConfig mdcTorqueConfig);
    /**
     * å¯¼å‡º
     *
     * @param userId
     * @param mdcTorqueConfig
     * @return
     */
    ModelAndView exportXls(String userId, MdcTorqueConfig mdcTorqueConfig);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcTorqueConfigServiceImpl.java
@@ -5,15 +5,20 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcTorqueConfig;
import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IMdcTorqueConfigService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.MdcTorqueConfigVo;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@@ -35,18 +40,18 @@
    }
    @Override
    public Boolean addTorque(MdcTorqueConfigVo torqueVo) {
    public Boolean addTorque(MdcTorqueConfig mdcTorqueConfig) {
        boolean result = false;
        String[] equipmentIds = torqueVo.getEquipmentIds().split(",");
        String[] equipmentIds = mdcTorqueConfig.getEquipmentIds().split(",");
        for (String equipmentId : equipmentIds) {
            MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId);
            MdcTorqueConfig mdcTorqueConfig = new MdcTorqueConfig();
            mdcTorqueConfig.setEquipmentId(equipmentId);
            mdcTorqueConfig.setEquipmentName(mdcEquipment.getEquipmentName());
            mdcTorqueConfig.setTorqueDate(torqueVo.getTorqueDate());
            mdcTorqueConfig.setTorqueValue(torqueVo.getTorqueValue());
            mdcTorqueConfig.setNotes(torqueVo.getNotes());
            boolean b = super.save(mdcTorqueConfig);
            MdcTorqueConfig torqueConfig = new MdcTorqueConfig();
            torqueConfig.setEquipmentId(equipmentId);
            torqueConfig.setEquipmentName(mdcEquipment.getEquipmentName());
            torqueConfig.setTorqueDate(mdcTorqueConfig.getTorqueDate());
            torqueConfig.setTorqueValue(mdcTorqueConfig.getTorqueValue());
            torqueConfig.setNotes(mdcTorqueConfig.getNotes());
            boolean b = super.save(torqueConfig);
            if (b) {
                result = true;
            }
@@ -105,4 +110,69 @@
        }
        return this.baseMapper.pageList(page, mdcTorqueConfig);
    }
    /**
     * å¯¼å‡º
     *
     * @param userId
     * @param mdcTorqueConfig
     * @return
     */
    @Override
    public ModelAndView exportXls(String userId, MdcTorqueConfig mdcTorqueConfig) {
        // Step.1 ç»„装查询条件
        LambdaQueryWrapper<MdcTorqueConfig> queryWrapper = new LambdaQueryWrapper<>();
        List<String> equipmentIds = new ArrayList<>();
        if (StringUtils.isNotEmpty(mdcTorqueConfig.getParentId()) && StringUtils.isEmpty(mdcTorqueConfig.getEquipmentId())) {
            if ("2".equals(mdcTorqueConfig.getTypeTree())) {
                //部门层级
                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcTorqueConfig.getParentId());
            } else {
                //产线层级
                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcTorqueConfig.getParentId());
            }
        } else if (StringUtils.isNotEmpty(mdcTorqueConfig.getEquipmentId())) {
            //单台设备信息
            mdcTorqueConfig.setMdcSectionIds(Collections.singletonList(mdcTorqueConfig.getEquipmentId()));
        } else {
            //查询用户所拥有的所有设备信息
            if ("2".equals(mdcTorqueConfig.getTypeTree())) {
                //部门层级
                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
            } else {
                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
            }
        }
        if (mdcTorqueConfig.getMdcSectionIds() == null || mdcTorqueConfig.getMdcSectionIds().isEmpty()) {
            mdcTorqueConfig.setMdcSectionIds(equipmentIds);
        }
        if (mdcTorqueConfig.getMdcSectionIds() == null || mdcTorqueConfig.getMdcSectionIds().isEmpty()) {
            return null;
        } else {
            queryWrapper.in(MdcTorqueConfig::getEquipmentId, mdcTorqueConfig.getMdcSectionIds());
        }
        if (StringUtils.isNotEmpty(mdcTorqueConfig.getEquipmentId())) {
            queryWrapper.like(MdcTorqueConfig::getEquipmentId, mdcTorqueConfig.getEquipmentId());
        }
        if (StringUtils.isNotEmpty(mdcTorqueConfig.getEquipmentName())) {
            queryWrapper.like(MdcTorqueConfig::getEquipmentId, mdcTorqueConfig.getEquipmentId());
        }
        if (StringUtils.isNotEmpty(mdcTorqueConfig.getStartTime()) && StringUtils.isNotEmpty(mdcTorqueConfig.getEndTime())) {
            queryWrapper.between(MdcTorqueConfig::getTorqueDate, mdcTorqueConfig.getStartTime(), mdcTorqueConfig.getEndTime());
        }
        queryWrapper.orderByAsc(MdcTorqueConfig::getTorqueDate);
        // Step.2 AutoPoi å¯¼å‡ºExcel
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        List<MdcTorqueConfig> mdcTorqueConfigs = this.baseMapper.selectList(queryWrapper);
        // å¯¼å‡ºæ–‡ä»¶åç§°
        mv.addObject(NormalExcelConstants.FILE_NAME, "扭矩配置列表");
        mv.addObject(NormalExcelConstants.CLASS, MdcTorqueConfig.class);
        //获取当前登录用户
        //update-begin---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("扭矩配置列表数据", "导出人:"+user.getRealname(), "导出信息"));
        //update-end---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
        mv.addObject(NormalExcelConstants.DATA_LIST, mdcTorqueConfigs);
        return mv;
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcTorqueConfigVo.java
ÎļþÒÑɾ³ý