| | |
| | | @AutoLog(value = "è®¾å¤æ
éåæºæ¶é¿è¡¨-计ç®MTBF") |
| | | @ApiOperation(value = "è®¾å¤æ
éåæºæ¶é¿è¡¨-计ç®MTBF", notes = "è®¾å¤æ
éåæºæ¶é¿è¡¨-计ç®MTBF") |
| | | @PostMapping(value = "/computeMtbf") |
| | | public Result<?> computeMtbf(@RequestBody String month) { |
| | | public Result<?> computeMtbf(@RequestParam(name = "month", required = true) String month) { |
| | | mdcDownTimeService.computeMtbf(month); |
| | | return Result.OK("è®¡ç®æåï¼"); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcOeeInfo; |
| | | import org.jeecg.modules.mdc.service.IMdcMttrInfoService; |
| | | import org.jeecg.modules.mdc.vo.MdcMttrInfoVo; |
| | | import org.jeecg.modules.mdc.vo.MdcOeeInfoVo; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * @Description: è®¾å¤æ
é维修表 |
| | | * @Author: lius |
| | | * @Date: 2025-02-18 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "è®¾å¤æ
é维修表") |
| | | @RestController |
| | | @RequestMapping("/mdc/mdcMttrInfo") |
| | | public class MdcMttrInfoController extends JeecgController<MdcMttrInfo, IMdcMttrInfoService> { |
| | | |
| | | @Resource |
| | | private IMdcMttrInfoService mdcMttrInfoService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param mdcMttrInfoVo |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ
é维修表-å页å表æ¥è¯¢") |
| | | @ApiOperation(value = "è®¾å¤æ
é维修表-å页å表æ¥è¯¢", notes = "è®¾å¤æ
é维修表-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(MdcMttrInfoVo mdcMttrInfoVo, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | Page<MdcMttrInfo> page = new Page<MdcMttrInfo>(pageNo, pageSize); |
| | | IPage<MdcMttrInfo> pageList = mdcMttrInfoService.pageList(userId, page, mdcMttrInfoVo, req); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param mdcMttrInfoVo |
| | | */ |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, MdcMttrInfoVo mdcMttrInfoVo) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | return mdcMttrInfoService.exportXls(userId, mdcMttrInfoVo); |
| | | } |
| | | |
| | | } |
| | |
| | | @AutoLog(value = "设å¤ç»´ä¿®æ¶é¿è¡¨-计ç®MTTR") |
| | | @ApiOperation(value = "设å¤ç»´ä¿®æ¶é¿è¡¨-计ç®MTTR", notes = "设å¤ç»´ä¿®æ¶é¿è¡¨-计ç®MTTR") |
| | | @PostMapping(value = "/computeMttr") |
| | | public Result<?> computeMttr(@RequestBody String month) { |
| | | public Result<?> computeMttr(@RequestParam(name = "month", required = true) String month) { |
| | | mdcRepairInfoService.computeMttr(month); |
| | | return Result.OK("è®¡ç®æåï¼"); |
| | | } |
| | |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Description: è®¾å¤æ
éåæºæ¶é¿è¡¨ |
| | |
| | | @ApiModelProperty(value = "æ¥æ") |
| | | private String theDate; |
| | | /** |
| | | * æ
éåæºæ¶é¿(min) |
| | | * æ
éåæºæ¶é¿(hour) |
| | | */ |
| | | @Excel(name = "æ
éåæºæ¶é¿(min)", width = 15) |
| | | @ApiModelProperty(value = "æ
éåæºæ¶é¿(min)") |
| | | private Integer downLong; |
| | | @Excel(name = "æ
éåæºæ¶é¿(hour)", width = 15) |
| | | @ApiModelProperty(value = "æ
éåæºæ¶é¿(hour)") |
| | | private BigDecimal downLong; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecg.common.system.base.entity.JeecgEntity; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2025/2/7 9:31 |
| | | */ |
| | | @Data |
| | | @TableName("mdc_mttr_info") |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @ApiModel(value = "mdc_mttr_info对象", description = "è®¾å¤æ
é维修表") |
| | | public class MdcMttrInfo extends JeecgEntity implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -4164370727294921773L; |
| | | |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | @Excel(name = "设å¤ç¼å·", width = 15) |
| | | @ApiModelProperty(value = "设å¤ç¼å·") |
| | | private String equipmentId; |
| | | |
| | | /** |
| | | * æ¥æ |
| | | */ |
| | | @Excel(name = "æ¥æ", width = 15) |
| | | @ApiModelProperty(value = "æ¥æ") |
| | | private String theDate; |
| | | |
| | | /** |
| | | * æ¥åæ¶é´ |
| | | */ |
| | | @Excel(name = "æ¥åæ¶é´", width = 15) |
| | | @ApiModelProperty(value = "æ¥åæ¶é´(hour)") |
| | | private BigDecimal calendarLong = BigDecimal.ZERO; |
| | | |
| | | /** |
| | | * æ»æ
éåæºæ¶é´ |
| | | */ |
| | | @Excel(name = "æ»æ
éåæºæ¶é´", width = 15) |
| | | @ApiModelProperty(value = "æ»æ
éåæºæ¶é´(hour)") |
| | | private BigDecimal totalDownLong = BigDecimal.ZERO; |
| | | |
| | | /** |
| | | * æ»æ
鿬¡æ° |
| | | */ |
| | | @Excel(name = "æ»æ
鿬¡æ°", width = 15) |
| | | @ApiModelProperty(value = "æ»æ
鿬¡æ°") |
| | | private Integer totalDownCount = 0; |
| | | |
| | | /** |
| | | * MTBF |
| | | */ |
| | | @Excel(name = "MTBF", width = 15) |
| | | @ApiModelProperty(value = "MTBF(hour)") |
| | | private BigDecimal mtbf = BigDecimal.ZERO; |
| | | |
| | | /** |
| | | * æ»ç»´ä¿®æ¶é´ |
| | | */ |
| | | @Excel(name = "æ»ç»´ä¿®æ¶é´", width = 15) |
| | | @ApiModelProperty(value = "æ»ç»´ä¿®æ¶é´(hour)") |
| | | private BigDecimal totalRepairLong = BigDecimal.ZERO; |
| | | |
| | | /** |
| | | * æ»ç»´ä¿®æ¬¡æ° |
| | | */ |
| | | @Excel(name = "æ»ç»´ä¿®æ¬¡æ°", width = 15) |
| | | @ApiModelProperty(value = "æ»ç»´ä¿®æ¬¡æ°") |
| | | private Integer totalRepairCount = 0; |
| | | |
| | | /** |
| | | * MTTR |
| | | */ |
| | | @Excel(name = "MTTR", width = 15) |
| | | @ApiModelProperty(value = "MTTR(hour)") |
| | | private BigDecimal mttr = BigDecimal.ZERO; |
| | | |
| | | } |
| | |
| | | @ApiModel(value = "mdc_oee_info对象", description = "OEE表") |
| | | public class MdcOeeInfo extends JeecgEntity implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -1029070983514140912L; |
| | | |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Description: 设å¤ç»´ä¿®æ¶é¿è¡¨ |
| | |
| | | */ |
| | | @Excel(name = "设å¤ç¼å·", width = 15) |
| | | @ApiModelProperty(value = "设å¤ç¼å·") |
| | | private java.lang.String equipmentId; |
| | | private String equipmentId; |
| | | /** |
| | | * æ¥æ |
| | | */ |
| | | @Excel(name = "æ¥æ", width = 15) |
| | | @ApiModelProperty(value = "æ¥æ") |
| | | private java.lang.String theDate; |
| | | private String theDate; |
| | | /** |
| | | * ç»´ä¿®æ¶é¿(min) |
| | | * ç»´ä¿®æ¶é¿(hour) |
| | | */ |
| | | @Excel(name = "ç»´ä¿®æ¶é¿(min)", width = 15) |
| | | @ApiModelProperty(value = "ç»´ä¿®æ¶é¿(min)") |
| | | private java.lang.Integer repairLong; |
| | | @Excel(name = "ç»´ä¿®æ¶é¿(hour)", width = 15) |
| | | @ApiModelProperty(value = "ç»´ä¿®æ¶é¿(hour)") |
| | | private BigDecimal repairLong; |
| | | |
| | | } |
| | |
| | | import org.jeecg.modules.mdc.entity.MdcDownTime; |
| | | import org.jeecg.modules.mdc.vo.MdcDownTimeVo; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Description: è®¾å¤æ
éåæºæ¶é¿è¡¨ |
| | | * @Author: Lius |
| | |
| | | */ |
| | | IPage<MdcDownTime> pageList(Page<MdcDownTime> page, @Param("mdcDownTimeVo") MdcDownTimeVo mdcDownTimeVo); |
| | | |
| | | /** |
| | | * æ¥è¯¢å½ææ»æ
éåæºæ¶é´ |
| | | * |
| | | * @param month |
| | | * @return |
| | | */ |
| | | BigDecimal findTotalDownLong(@Param("month") String month); |
| | | |
| | | /** |
| | | * æ¥è¯¢å½ææ»æ
éåæºæ¬¡æ° |
| | | * |
| | | * @param month |
| | | * @return |
| | | */ |
| | | Integer findTotalDownCount(@Param("month") String month); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | import org.jeecg.modules.mdc.vo.MdcMttrInfoVo; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2025/2/18 13:53 |
| | | */ |
| | | public interface MdcMttrInfoMapper extends BaseMapper<MdcMttrInfo> { |
| | | |
| | | /** |
| | | * å页å表 |
| | | * |
| | | * @param page |
| | | * @param mdcMttrInfoVo |
| | | * @return |
| | | */ |
| | | IPage<MdcMttrInfo> pageList(Page<MdcMttrInfo> page, @Param("mdcMttrInfoVo") MdcMttrInfoVo mdcMttrInfoVo); |
| | | } |
| | |
| | | import org.jeecg.modules.mdc.entity.MdcRepairInfo; |
| | | import org.jeecg.modules.mdc.vo.MdcRepairInfoVo; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Description: 设å¤ç»´ä¿®æ¶é¿è¡¨ |
| | | * @Author: Lius |
| | |
| | | * @return |
| | | */ |
| | | IPage<MdcRepairInfo> pageList(Page<MdcRepairInfo> page, @Param("mdcRepairInfoVo") MdcRepairInfoVo mdcRepairInfoVo); |
| | | |
| | | /** |
| | | * æ¥è¯¢å½ææ»ç»´ä¿®æ¶é´ |
| | | * |
| | | * @param month |
| | | * @return |
| | | */ |
| | | BigDecimal findTotalRepairLong(@Param("month") String month); |
| | | |
| | | /** |
| | | * æ¥è¯¢å½ææ»ç»´ä¿®æ¬¡æ° |
| | | * |
| | | * @param month |
| | | * @return |
| | | */ |
| | | Integer findTotalRepairCount(@Param("month") String month); |
| | | } |
| | |
| | | </where> |
| | | ORDER BY the_date DESC, equipment_id ASC |
| | | </select> |
| | | |
| | | <!--æ¥è¯¢å½ææ»æ
éåæºæ¶é´--> |
| | | <select id="findTotalDownLong" resultType="java.math.BigDecimal"> |
| | | SELECT |
| | | SUM(down_long) |
| | | FROM |
| | | mdc_down_time |
| | | WHERE |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | </select> |
| | | |
| | | <!--æ¥è¯¢å½ææ»æ
éåæºæ¬¡æ°--> |
| | | <select id="findTotalDownCount" resultType="java.lang.Integer"> |
| | | SELECT |
| | | COUNT(down_long) |
| | | FROM |
| | | mdc_down_time |
| | | WHERE |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.MdcMttrInfoMapper"> |
| | | |
| | | <!--å页å表--> |
| | | <select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcMttrInfo"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | mdc_mttr_info |
| | | <where> |
| | | <if test="MdcMttrInfoVo.equipmentId != null and MdcMttrInfoVo.equipmentId != ''"> |
| | | AND equipment_id = #{ MdcMttrInfoVo.equipmentId } |
| | | </if> |
| | | <if test="MdcMttrInfoVo.startTime != null and MdcMttrInfoVo.startTime != ''"> |
| | | AND the_date >= #{ MdcMttrInfoVo.startTime } |
| | | </if> |
| | | <if test="MdcMttrInfoVo.endTime != null and MdcMttrInfoVo.endTime != ''"> |
| | | AND the_date <= #{MdcMttrInfoVo.endTime } |
| | | </if> |
| | | <if test="MdcMttrInfoVo.equipmentIdList != null and MdcMttrInfoVo.equipmentIdList.size() > 0 "> |
| | | AND equipment_id IN |
| | | <foreach collection="MdcMttrInfoVo.equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | ORDER BY the_date DESC, equipment_id ASC |
| | | </select> |
| | | </mapper> |
| | |
| | | </where> |
| | | ORDER BY the_date DESC, equipment_id ASC |
| | | </select> |
| | | |
| | | <!--æ¥è¯¢å½ææ»ç»´ä¿®æ¶é´--> |
| | | <select id="findTotalRepairLong" resultType="java.math.BigDecimal"> |
| | | SELECT |
| | | SUM(repair_long) |
| | | FROM |
| | | mdc_repair_info |
| | | WHERE |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | </select> |
| | | |
| | | <!--æ¥è¯¢å½ææ»ç»´ä¿®æ¬¡æ°--> |
| | | <select id="findTotalRepairCount" resultType="java.lang.Integer"> |
| | | SELECT |
| | | COUNT(repair_long) |
| | | FROM |
| | | mdc_repair_info |
| | | WHERE |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | import org.jeecg.modules.mdc.vo.MdcMttrInfoVo; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2025/2/18 13:48 |
| | | */ |
| | | public interface IMdcMttrInfoService extends IService<MdcMttrInfo> { |
| | | |
| | | /** |
| | | * å页å表 |
| | | * |
| | | * @param userId |
| | | * @param page |
| | | * @param mdcMttrInfoVo |
| | | * @param req |
| | | * @return |
| | | */ |
| | | IPage<MdcMttrInfo> pageList(String userId, Page<MdcMttrInfo> page, MdcMttrInfoVo mdcMttrInfoVo, HttpServletRequest req); |
| | | |
| | | /** |
| | | * å¯¼åº |
| | | * |
| | | * @param userId |
| | | * @param mdcMttrInfoVo |
| | | * @return |
| | | */ |
| | | ModelAndView exportXls(String userId, MdcMttrInfoVo mdcMttrInfoVo); |
| | | } |
| | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.net.InetAddress; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * @author Lius |
| | |
| | | @Resource |
| | | private IMdcPassLogService mdcPassLogService; |
| | | |
| | | private static final String TYPE = "01"; |
| | | private static final String TYPE = "18"; |
| | | |
| | | @Resource |
| | | private SqlExecutor sqlExecutor; |
| | |
| | | |
| | | // æä»¶è·¯å¾ |
| | | String locFilePath = localFilePath + TYPE + today + String.format("%06d", sequenceNumber) + ".xml"; |
| | | FileWriter writer = new FileWriter(locFilePath); |
| | | writer.writeLines(sqlList); |
| | | // FileWriter writer = new FileWriter(locFilePath); |
| | | // writer.writeLines(sqlList); |
| | | String listSql = String.join("\n", sqlList); |
| | | try { |
| | | FileUtils.fileWriterSql(locFilePath, listSql); |
| | | } catch (Exception e) { |
| | | throw new JeecgBootException("æ°æ®åå
¥æä»¶å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | // step.4 æ¨éç½é¸ |
| | | // step.4.1 æµè¯æå¡å¨è¿éæ§ |
| | | boolean ping = NetUtil.ping(host + ":" + port); |
| | | /* boolean ping = NetUtil.ping(host + ":" + port); |
| | | if (!ping) { |
| | | FileUtil.del(locFilePath); |
| | | throw new JeecgBootException("æå¡å¨è¿æ¥ï¼ " + host + ":" + port + " å¼å¸¸ï¼"); |
| | | } |
| | | }*/ |
| | | |
| | | // step.4.2 è·åtoken |
| | | String token = ""; |
| | |
| | | objectName.setDestination(host); |
| | | objectName.setResult("失败"); |
| | | // æ¬å°æä»¶è·¯å¾ |
| | | String loFilePath = localFilePath + "\\" + file.getName(); |
| | | String loFilePath = localFilePath + file.getName(); |
| | | // ç®æ æä»¶è·¯å¾ |
| | | String servicePathName = servicePath + "\\" + file.getName(); |
| | | String servicePathName = servicePath + file.getName(); |
| | | String result = FileClient.uploadFile(host, port, token, file.getName(), servicePathName, loFilePath, addressUploadFile); |
| | | if ("æå".equals(result)) { |
| | | FileUtil.del(loFilePath); |
| | | if (sequenceNumber == 1) { |
| | | // å 餿¨æ¥å¤ä»½æä»¶å¤¹ä¸å岿件 |
| | | FileUtil.clean(newFilePath); |
| | | } |
| | | // æåä¹åå°æä»¶å¤ä»½èµ° |
| | | FileUtil.move(new File(locFilePath), new File(newFilePath + fileName), true); |
| | | // FileUtil.copy(locFilePath, newFilePath + fileName, true); |
| | | // FileUtil.del(loFilePath); |
| | | objectName.setResult("æå"); |
| | | SyslogClient.sendClient(logIp, Integer.valueOf(logPort), objectName.toString()); |
| | | } else { |
| | |
| | | File[] files = FileUtil.ls(localFilePath); |
| | | for (File file : files) { |
| | | if (file.isFile()) { |
| | | String loFilePath = localFilePath + "\\" + file.getName(); |
| | | String loFilePath = localFilePath + file.getName(); |
| | | FileReader fileReader = new FileReader(loFilePath); |
| | | String sqlList = fileReader.readString(); |
| | | try { |
| | |
| | | } catch (Exception e) { |
| | | throw new JeecgBootException("æ§è¡sql失败ï¼"); |
| | | } |
| | | if (Integer.parseInt(file.getName().substring(file.getName().length() - 10, file.getName().length() - 4)) == 1) { |
| | | // å é¤å岿件 |
| | | FileUtil.clean(newFilePath); |
| | | } |
| | | |
| | | // å¤ä»½ |
| | | FileUtil.move(new File(loFilePath), new File(newFilePath + "\\" + file.getName()), true); |
| | | FileUtil.move(new File(loFilePath), new File(newFilePath + file.getName()), true); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcDownTime; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcOeeInfo; |
| | | import org.jeecg.modules.mdc.mapper.MdcDownTimeMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcDownTimeService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcMttrInfoService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcDownTimeVo; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | @Resource |
| | | private IMdcMttrInfoService mdcMttrInfoService; |
| | | |
| | | @Override |
| | | public IPage<MdcDownTime> pageList(String userId, Page<MdcDownTime> page, MdcDownTimeVo mdcDownTimeVo, HttpServletRequest req) { |
| | |
| | | */ |
| | | @Override |
| | | public void computeMtbf(String month) { |
| | | /* |
| | | 设å¤å¹³åæ
éé´éæ(MTBF) = (æ¥åæ¶é´ - æ»æ
éåæºæ¶é´) / æ»æ
鿬¡æ° |
| | | */ |
| | | // step.1 |
| | | List<MdcMttrInfo> mdcMttrInfos = mdcMttrInfoService.list(new LambdaQueryWrapper<MdcMttrInfo>().eq(MdcMttrInfo::getTheDate, month)); |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtils.STR_DATE); |
| | | LocalDate parse = LocalDate.parse(month + "-01", df); |
| | | int calendarLong = parse.lengthOfMonth() * 24; |
| | | if (mdcMttrInfos != null && !mdcMttrInfos.isEmpty()) { |
| | | for (MdcMttrInfo mdcMttrInfo : mdcMttrInfos) { |
| | | // æ¥åæ¶é´ |
| | | mdcMttrInfo.setCalendarLong(new BigDecimal(calendarLong)); |
| | | // æ»æ
éåæºæ¶é´ |
| | | BigDecimal totalDownLong = this.baseMapper.findTotalDownLong(month); |
| | | if (totalDownLong != null) { |
| | | mdcMttrInfo.setTotalDownLong(totalDownLong); |
| | | } |
| | | // æ»æ
鿬¡æ° |
| | | Integer totalDownCount = this.baseMapper.findTotalDownCount(month); |
| | | if (totalDownLong != null) { |
| | | mdcMttrInfo.setTotalDownCount(totalDownCount); |
| | | } |
| | | // MTBF |
| | | if (mdcMttrInfo.getTotalDownCount() != 0) { |
| | | BigDecimal mtbf = (mdcMttrInfo.getCalendarLong().subtract(mdcMttrInfo.getTotalDownLong())).divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP); |
| | | mdcMttrInfo.setMtbf(mtbf); |
| | | } |
| | | } |
| | | mdcMttrInfoService.updateBatchById(mdcMttrInfos); |
| | | } else { |
| | | List<MdcEquipment> equipmentList = mdcEquipmentService.list(); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | List<MdcMttrInfo> mmi = new ArrayList<>(); |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcMttrInfo mdcMttrInfo = new MdcMttrInfo(); |
| | | mdcMttrInfo.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | mdcMttrInfo.setTheDate(month); |
| | | // æ¥åæ¶é´ |
| | | mdcMttrInfo.setCalendarLong(new BigDecimal(calendarLong)); |
| | | // æ»æ
éåæºæ¶é´ |
| | | BigDecimal totalDownLong = this.baseMapper.findTotalDownLong(month); |
| | | if (totalDownLong != null) { |
| | | mdcMttrInfo.setTotalDownLong(totalDownLong); |
| | | } |
| | | // æ»æ
鿬¡æ° |
| | | Integer totalDownCount = this.baseMapper.findTotalDownCount(month); |
| | | if (totalDownLong != null) { |
| | | mdcMttrInfo.setTotalDownCount(totalDownCount); |
| | | } |
| | | // MTBF |
| | | if (mdcMttrInfo.getTotalDownCount() != 0) { |
| | | BigDecimal mtbf = (mdcMttrInfo.getCalendarLong().subtract(mdcMttrInfo.getTotalDownLong())).divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP); |
| | | mdcMttrInfo.setMtbf(mtbf); |
| | | } |
| | | mmi.add(mdcMttrInfo); |
| | | } |
| | | mdcMttrInfoService.saveBatch(mmi); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcOeeInfo; |
| | | import org.jeecg.modules.mdc.mapper.MdcMttrInfoMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcMttrInfoService; |
| | | import org.jeecg.modules.mdc.vo.MdcMttrInfoVo; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2025/2/18 13:52 |
| | | */ |
| | | @Service |
| | | public class MdcMttrInfoServiceImpl extends ServiceImpl<MdcMttrInfoMapper, MdcMttrInfo> implements IMdcMttrInfoService { |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | /** |
| | | * å页å表 |
| | | * |
| | | * @param userId |
| | | * @param page |
| | | * @param mdcMttrInfoVo |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<MdcMttrInfo> pageList(String userId, Page<MdcMttrInfo> page, MdcMttrInfoVo mdcMttrInfoVo, HttpServletRequest req) { |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcMttrInfoVo.getParentId()) && StringUtils.isEmpty(mdcMttrInfoVo.getEquipmentId())) { |
| | | if ("2".equals(mdcMttrInfoVo.getTypeTree())) { |
| | | //é¨é¨å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcMttrInfoVo.getParentId()); |
| | | } else { |
| | | //产线å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcMttrInfoVo.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mdcMttrInfoVo.getEquipmentId())) { |
| | | //åå°è®¾å¤ä¿¡æ¯ |
| | | mdcMttrInfoVo.setEquipmentIdList(Collections.singletonList(mdcMttrInfoVo.getEquipmentId())); |
| | | } else { |
| | | //æ¥è¯¢ç¨æ·æ¥æçææè®¾å¤ä¿¡æ¯ |
| | | if ("2".equals(mdcMttrInfoVo.getTypeTree())) { |
| | | //é¨é¨å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | //产线å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | |
| | | if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) { |
| | | mdcMttrInfoVo.setEquipmentIdList(equipmentIds); |
| | | } |
| | | |
| | | if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) { |
| | | return null; |
| | | } |
| | | return this.baseMapper.pageList(page, mdcMttrInfoVo); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åº |
| | | * |
| | | * @param userId |
| | | * @param mdcMttrInfoVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ModelAndView exportXls(String userId, MdcMttrInfoVo mdcMttrInfoVo) { |
| | | LambdaQueryWrapper<MdcMttrInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcMttrInfoVo.getParentId()) && StringUtils.isEmpty(mdcMttrInfoVo.getEquipmentId())) { |
| | | if ("2".equals(mdcMttrInfoVo.getTypeTree())) { |
| | | //é¨é¨å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcMttrInfoVo.getParentId()); |
| | | } else { |
| | | //产线å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcMttrInfoVo.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mdcMttrInfoVo.getEquipmentId())) { |
| | | //åå°è®¾å¤ä¿¡æ¯ |
| | | mdcMttrInfoVo.setEquipmentIdList(Collections.singletonList(mdcMttrInfoVo.getEquipmentId())); |
| | | } else { |
| | | //æ¥è¯¢ç¨æ·æ¥æçææè®¾å¤ä¿¡æ¯ |
| | | if ("2".equals(mdcMttrInfoVo.getTypeTree())) { |
| | | //é¨é¨å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | //产线å±çº§ |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | |
| | | if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) { |
| | | mdcMttrInfoVo.setEquipmentIdList(equipmentIds); |
| | | } |
| | | |
| | | if (mdcMttrInfoVo.getEquipmentIdList() == null || mdcMttrInfoVo.getEquipmentIdList().isEmpty()) { |
| | | return null; |
| | | } else { |
| | | queryWrapper.in(MdcMttrInfo::getEquipmentId, mdcMttrInfoVo.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcMttrInfoVo.getEquipmentId())) { |
| | | queryWrapper.eq(MdcMttrInfo::getEquipmentId, mdcMttrInfoVo.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcMttrInfoVo.getStartTime()) && StringUtils.isNotEmpty(mdcMttrInfoVo.getEndTime())) { |
| | | queryWrapper.between(MdcMttrInfo::getTheDate, mdcMttrInfoVo.getStartTime(), mdcMttrInfoVo.getEndTime()); |
| | | } |
| | | queryWrapper.orderByDesc(MdcMttrInfo::getTheDate).orderByDesc(MdcMttrInfo::getEquipmentId); |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcMttrInfo> mdcMttrInfos = this.baseMapper.selectList(queryWrapper); |
| | | // å¯¼åºæä»¶åç§° |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "设å¤MTTR表"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcMttrInfo.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("设å¤MTTRè¡¨æ°æ®", "导åºäºº:" + user.getRealname(), "设å¤MTTR")); |
| | | //update-end---author:wangshuai ---date:20211227 forï¼[JTC-116]导åºäººåæ»äº------------ |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, mdcMttrInfos); |
| | | return mv; |
| | | } |
| | | } |
| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcDownTime; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | import org.jeecg.modules.mdc.entity.MdcRepairInfo; |
| | | import org.jeecg.modules.mdc.mapper.MdcRepairInfoMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcMttrInfoService; |
| | | import org.jeecg.modules.mdc.service.IMdcRepairInfoService; |
| | | import org.jeecg.modules.mdc.vo.MdcRepairInfoVo; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | @Resource |
| | | private IMdcMttrInfoService mdcMttrInfoService; |
| | | |
| | | /** |
| | | * å页å表 |
| | |
| | | */ |
| | | @Override |
| | | public void computeMttr(String month) { |
| | | |
| | | /* |
| | | 设å¤å¹³åä¿®çæ¶é´(MTTR) = æ»ç»´ä¿®æ¶é´ / æ»ç»´ä¿®æ¬¡æ° |
| | | */ |
| | | List<MdcMttrInfo> mdcMttrInfos = mdcMttrInfoService.list(new LambdaQueryWrapper<MdcMttrInfo>().eq(MdcMttrInfo::getTheDate, month)); |
| | | if (mdcMttrInfos != null && !mdcMttrInfos.isEmpty()) { |
| | | for (MdcMttrInfo mdcMttrInfo : mdcMttrInfos) { |
| | | // æ»ç»´ä¿®æ¶é´ |
| | | BigDecimal totalRepairLong = this.baseMapper.findTotalRepairLong(month); |
| | | mdcMttrInfo.setTotalRepairLong(totalRepairLong); |
| | | // æ»ç»´ä¿®æ¬¡æ° |
| | | Integer totalRepairCount = this.baseMapper.findTotalRepairCount(month); |
| | | mdcMttrInfo.setTotalRepairCount(totalRepairCount); |
| | | // MTTR |
| | | if (mdcMttrInfo.getTotalRepairCount() != 0) { |
| | | BigDecimal mttr = mdcMttrInfo.getTotalRepairLong().divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP); |
| | | mdcMttrInfo.setMttr(mttr); |
| | | } |
| | | } |
| | | mdcMttrInfoService.updateBatchById(mdcMttrInfos); |
| | | } else { |
| | | List<MdcEquipment> equipmentList = mdcEquipmentService.list(); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | List<MdcMttrInfo> mmi = new ArrayList<>(); |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcMttrInfo mdcMttrInfo = new MdcMttrInfo(); |
| | | mdcMttrInfo.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | mdcMttrInfo.setTheDate(month); |
| | | // æ»ç»´ä¿®æ¶é´ |
| | | BigDecimal totalRepairLong = this.baseMapper.findTotalRepairLong(month); |
| | | mdcMttrInfo.setTotalRepairLong(totalRepairLong); |
| | | // æ»ç»´ä¿®æ¬¡æ° |
| | | Integer totalRepairCount = this.baseMapper.findTotalRepairCount(month); |
| | | mdcMttrInfo.setTotalRepairCount(totalRepairCount); |
| | | // MTTR |
| | | if (mdcMttrInfo.getTotalRepairCount() != 0) { |
| | | BigDecimal mttr = mdcMttrInfo.getTotalRepairLong().divide(new BigDecimal(mdcMttrInfo.getTotalDownCount()), 4, RoundingMode.HALF_UP); |
| | | mdcMttrInfo.setMttr(mttr); |
| | | } |
| | | mmi.add(mdcMttrInfo); |
| | | } |
| | | mdcMttrInfoService.saveBatch(mmi); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.util; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStreamWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * Created by YangBin on 2017/9/15. |
| | | */ |
| | | public class FileUtils { |
| | | private static final long MAX_FILE_SIZE = 10*1024*1024; |
| | | /** |
| | | * è·åæå¡å¨ä¸´æ¶è·¯å¾ |
| | | * |
| | | * @param request |
| | | * @return */ |
| | | public static String serverTempPath(HttpServletRequest request) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath(""); |
| | | if (path.lastIndexOf(fsep) == path.length() - 1) { |
| | | path += "upload" + fsep +"voucher"+ fsep ; |
| | | } else { |
| | | path += fsep + "upload" + fsep +"voucher"+ fsep ; |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | public static String serverTempPathIntactReg(HttpServletRequest request) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath(""); |
| | | if (path.lastIndexOf(fsep) == path.length() - 1) { |
| | | path += "upload" + fsep +"log"+ fsep +"error"+ fsep ; |
| | | } else { |
| | | path += fsep + "upload" + fsep +"log"+ fsep +"error"+ fsep; |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | public static String serverTempPathProcess(HttpServletRequest request) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath(""); |
| | | if (path.lastIndexOf(fsep) == path.length() - 1) { |
| | | path += "upload" + fsep +"process"+ fsep ; |
| | | } else { |
| | | path += fsep + "upload" + fsep +"process"+ fsep ; |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | public static String changeFileFormatKb(String flow) { |
| | | BigDecimal flows = new BigDecimal(flow); |
| | | if (flows.compareTo(new BigDecimal(0)) > 0 && flows.compareTo(new BigDecimal(1024)) < 0) {//å°äº1M |
| | | return flows.toString() + "B"; |
| | | } else if(flows.compareTo(new BigDecimal(1024)) >= 0){ |
| | | BigDecimal result = flows.divide(new BigDecimal(1024),2,BigDecimal.ROUND_HALF_UP); |
| | | return result.toString() + "KB"; |
| | | } else { |
| | | return "0"; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å¾å°é¡¹ç®æ ¹ç®å½ä¸çç»å¯¹è·¯å¾ï¼ç£ççç©çè·¯å¾ï¼ |
| | | * @param request |
| | | * @param newPath |
| | | * @return |
| | | */ |
| | | public static String getFilePath(HttpServletRequest request, String newPath) { |
| | | String fsep = System.getProperty("file.separator"); |
| | | String path = request.getSession().getServletContext().getRealPath("/upload"); |
| | | path += fsep + newPath; |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°é¡¹ç®æ ¹ç®å½ä¸çç¸å¯¹è·¯å¾ ï¼ç¸å¯¹äºé¡¹ç®ä¸ºæ ¹è·¯å¾ï¼ |
| | | * @param newPath |
| | | * @return |
| | | */ |
| | | public static String getRelativePath(String newPath) { |
| | | return "/upload/" + newPath; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¹æ³ä¸:ä½¿ç¨ FileWriter åæä»¶ |
| | | * @param filepath æä»¶ç®å½ |
| | | * @param content å¾
åå
¥å
容 |
| | | * @throws IOException |
| | | */ |
| | | public static void fileWriterSql(String filepath, String content) throws IOException { |
| | | OutputStreamWriter outputStreamWriter = null; |
| | | try { |
| | | File file = new File(filepath); |
| | | if (!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileOutputStream outputStream = new FileOutputStream(file); |
| | | if (outputStream != null){ |
| | | outputStreamWriter = new OutputStreamWriter(outputStream, "utf-8"); |
| | | outputStreamWriter.write(content); |
| | | outputStreamWriter.flush(); |
| | | } |
| | | } |
| | | catch (IOException e) { |
| | | e.getMessage(); |
| | | } |
| | | finally { |
| | | try { |
| | | if (outputStreamWriter != null){ |
| | | outputStreamWriter.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | File file=new File(filepath); |
| | | Writer writer = new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8"); |
| | | writer.append(content); |
| | | */ |
| | | } |
| | | |
| | | /** |
| | | * æä»¶å¤§å°æºè½è½¬æ¢ |
| | | * ä¼å°æä»¶å¤§å°è½¬æ¢ä¸ºæå¤§æ»¡è¶³åä½ |
| | | * @param sizeï¼æä»¶å¤§å°ï¼åä½ä¸ºBï¼ |
| | | * @return æä»¶å¤§å° |
| | | */ |
| | | public static String formatFileSize(Long size) { |
| | | String sizeName = null; |
| | | if(1024*1024 > size && size >= 1024 ) { |
| | | sizeName = String.format("%.2f",size.doubleValue()/1024) + "KB"; |
| | | }else if(1024*1024*1024 > size && size >= 1024*1024 ) { |
| | | sizeName = String.format("%.2f",size.doubleValue()/(1024*1024)) + "MB"; |
| | | }else if(size >= 1024*1024*1024 ) { |
| | | sizeName = String.format("%.2f",size.doubleValue()/(1024*1024*1024)) + "GB"; |
| | | }else { |
| | | sizeName = size.toString() + "B"; |
| | | } |
| | | return sizeName; |
| | | } |
| | | |
| | | /** |
| | | * ä¸ä¼ æä»¶å·¥å
·ç±» |
| | | * @param userPic |
| | | * @param path |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static boolean uploadFile(MultipartFile userPic, String path, String fileName) { |
| | | Long fileSize = userPic.getSize(); |
| | | if(fileSize > MAX_FILE_SIZE) { |
| | | return false; |
| | | } |
| | | File targetFile = new File(path, fileName); |
| | | if(!targetFile.exists()){ |
| | | targetFile.mkdirs(); |
| | | } |
| | | try { |
| | | userPic.transferTo(targetFile); |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * éå½åæä»¶å å å
¥æ¶é´æ³ |
| | | // * @param fileName |
| | | // * @return |
| | | // */ |
| | | // public static String newFileName(String fileName) { |
| | | // String suffix = fileName.substring(fileName.lastIndexOf('.')); |
| | | // String dateStr = "_"+ DateUtil.format(new Date(), DateUtil.STR_DATE_TIME_FULL); |
| | | // String nameFile = fileName.substring(0, fileName.indexOf(".")); |
| | | // //æ°æä»¶å |
| | | // return nameFile + dateStr + suffix; |
| | | // } |
| | | } |
| | |
| | | SqlRunner runner = new SqlRunner(sqlSession.getConnection()); |
| | | runner.run(sql); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | // e.printStackTrace(); |
| | | throw new RuntimeException("Error executing SQL: " + sql, e); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.vo; |
| | | |
| | | import lombok.Data; |
| | | import org.jeecg.modules.mdc.entity.MdcMttrInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author Lius |
| | | * @date 2025/2/18 13:50 |
| | | */ |
| | | @Data |
| | | public class MdcMttrInfoVo extends MdcMttrInfo { |
| | | private String startTime; |
| | | private String endTime; |
| | | private String parentId; |
| | | private String typeTree; |
| | | private List<String> equipmentIdList; |
| | | private String equipmentIds; |
| | | } |
| | |
| | | String token = JwTUtil.sign(appId, pwd); |
| | | return new TokenResp("200", "è®¤è¯æå", token); |
| | | } else { |
| | | return new TokenResp("", "å¯ç é误", null); |
| | | return new TokenResp("101", "å¯ç é误", null); |
| | | } |
| | | } else { |
| | | return new TokenResp("", "è´¦å·é误", null); |
| | | return new TokenResp("101", "è´¦å·é误", null); |
| | | } |
| | | } |
| | | |
| | | @PostMapping(value = "/fileUpload") |
| | | public RespData uploadFiles(HttpServletRequest request) { |
| | | |
| | | log.info("ä¸ä¼ æ¥å£è°ç¨å¼å§"); |
| | | FileDetail fileDetail = new FileDetail(); |
| | | try { |
| | | request.setCharacterEncoding("UTF-8"); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | log.info("ä¸ä¼ æ¥å£è°ç¨ç»æ"); |
| | | return new RespData("200", "æä»¶ä¸ä¼ æå"); |
| | | } |
| | | |
| | |
| | | and del_flag='0' |
| | | </select> |
| | | |
| | | <select id="getDepartTreeByParentId" parameterType="String" resultType="org.jeecg.common.system.vo.SelectTreeModel"> |
| | | select |
| | | id as "key", |
| | | depart_name as "title", |
| | | parent_id as parentId |
| | | from sys_depart |
| | | where parent_id = #{parentId} |
| | | and del_flag='0' |
| | | </select> |
| | | <!-- <select id="getDepartTreeByParentId" parameterType="String" resultType="org.jeecg.common.system.vo.SelectTreeModel">--> |
| | | <!-- select--> |
| | | <!-- id as "key",--> |
| | | <!-- depart_name as "title",--> |
| | | <!-- parent_id as parentId--> |
| | | <!-- from sys_depart--> |
| | | <!-- where parent_id = #{parentId}--> |
| | | <!-- and del_flag='0'--> |
| | | <!-- </select>--> |
| | | </mapper> |
| | |
| | | } |
| | | FileOutputStream outputStream = new FileOutputStream(file); |
| | | if (outputStream != null) { |
| | | outputStreamWriter = new OutputStreamWriter(outputStream, "utf-8"); |
| | | outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8"); |
| | | outputStreamWriter.write(content); |
| | | outputStreamWriter.flush(); |
| | | } |