Merge remote-tracking branch 'origin/master'
已重命名23个文件
已添加43个文件
已修改49个文件
已删除2个文件
| | |
| | | String DICT_MDC_STAFF_TEAM = "mdc_staff_team"; |
| | | |
| | | /** |
| | | * 驱å¨åæ°åä½åå
¸ç¼å· |
| | | */ |
| | | String DICT_EQUIPMENT_RUN_UNIT = "equipment_run_unit"; |
| | | |
| | | /** |
| | | * å çæ°æ® èªå¨è®¡ç®æ è¯ 1(æ¯) 2(å¦) |
| | | */ |
| | | Integer AUTO_FLAG_Y = 1; |
| | |
| | | */ |
| | | String CLOSE_TYPE_0 = "0"; |
| | | String CLOSE_TYPE_1 = "1"; |
| | | |
| | | String ORG_TYPE = "3"; |
| | | /** |
| | | * 产线类å 1ä¸çº§é¨é¨ 2åé¨é¨ 3åé¨é¨ |
| | | */ |
| | | String ORG_TYPE_2 = "2"; |
| | | String ORG_TYPE_3 = "3"; |
| | | |
| | | Integer SHIFT_TYPE_1 = 1; |
| | | Integer SHIFT_TYPE_2 = 2; |
| | |
| | | |
| | | /** |
| | | * websocket å端å°tokenæ¾å°ååè®®éä¼ å
¥ ä¸å端建ç«è¿æ¥æ¶éè¦ç¨å°httpåè®®ï¼æ¤å¤ç¨äºæ ¡éªtokençæææ§ |
| | | * |
| | | * @Author taoYan |
| | | * @Date 2022/4/21 17:01 |
| | | **/ |
| | |
| | | if (redisUtil == null) { |
| | | redisUtil = SpringContextUtils.getBean(RedisUtil.class); |
| | | } |
| | | HttpServletRequest request = (HttpServletRequest)servletRequest; |
| | | String token = request.getHeader(TOKEN_KEY); |
| | | HttpServletRequest request = (HttpServletRequest) servletRequest; |
| | | if (request.getHeader(TOKEN_KEY) != null) { |
| | | String token = request.getHeader(TOKEN_KEY); |
| | | |
| | | log.debug("Websocketè¿æ¥ Tokenå®å
¨æ ¡éªï¼Path = {}ï¼token:{}", request.getRequestURI(), token); |
| | | log.debug("Websocketè¿æ¥ Tokenå®å
¨æ ¡éªï¼Path = {}ï¼token:{}", request.getRequestURI(), token); |
| | | |
| | | try { |
| | | TokenUtils.verifyToken(token, commonApi, redisUtil); |
| | | } catch (Exception exception) { |
| | | //log.error("Websocketè¿æ¥ Tokenå®å
¨æ ¡éªå¤±è´¥ï¼IP:{}, Token:{}, Path = {}ï¼å¼å¸¸ï¼{}", oConvertUtils.getIpAddrByRequest(request), token, request.getRequestURI(), exception.getMessage()); |
| | | log.debug("Websocketè¿æ¥ Tokenå®å
¨æ ¡éªå¤±è´¥ï¼IP:{}, Token:{}, Path = {}ï¼å¼å¸¸ï¼{}", oConvertUtils.getIpAddrByRequest(request), token, request.getRequestURI(), exception.getMessage()); |
| | | return; |
| | | try { |
| | | TokenUtils.verifyToken(token, commonApi, redisUtil); |
| | | } catch (Exception exception) { |
| | | //log.error("Websocketè¿æ¥ Tokenå®å
¨æ ¡éªå¤±è´¥ï¼IP:{}, Token:{}, Path = {}ï¼å¼å¸¸ï¼{}", oConvertUtils.getIpAddrByRequest(request), token, request.getRequestURI(), exception.getMessage()); |
| | | log.debug("Websocketè¿æ¥ Tokenå®å
¨æ ¡éªå¤±è´¥ï¼IP:{}, Token:{}, Path = {}ï¼å¼å¸¸ï¼{}", oConvertUtils.getIpAddrByRequest(request), token, request.getRequestURI(), exception.getMessage()); |
| | | return; |
| | | } |
| | | HttpServletResponse response = (HttpServletResponse) servletResponse; |
| | | response.setHeader(TOKEN_KEY, token); |
| | | } |
| | | HttpServletResponse response = (HttpServletResponse)servletResponse; |
| | | response.setHeader(TOKEN_KEY, token); |
| | | filterChain.doFilter(servletRequest, servletResponse); |
| | | } |
| | | |
| | |
| | | filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //ç嬿«ç |
| | | filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //æææ¥å£æé¤ |
| | | filterChainDefinitionMap.put("/msi/**", "anon"); //éææ¥å£ |
| | | filterChainDefinitionMap.put("/board/dtBoard/**", "anon"); //æ°ååªççæ¿æ¥å£æé¤ |
| | | |
| | | filterChainDefinitionMap.put("/", "anon"); |
| | | filterChainDefinitionMap.put("/doc.html", "anon"); |
| | |
| | | } |
| | | break; |
| | | case SECOND_MAINTENANCE: |
| | | if (result instanceof EamSecondMaintenanceOrder) { |
| | | EamSecondMaintenanceOrder order = (EamSecondMaintenanceOrder) result; |
| | | if (SecondMaintenanceStatusEnum.COMPLETE.name().equals(order.getMaintenanceStatus())) { |
| | | log.setEquipmentId(order.getEquipmentId()); |
| | | log.setBusinessId(order.getId()); |
| | | log.setOperator(order.getOperator()); |
| | | log.setDescription(order.getConfirmComment()); |
| | | log.setCreateTime(order.getActualEndTime()); |
| | | } |
| | | } |
| | | break; |
| | | case THIRD_MAINTENANCE: |
| | | if (result instanceof EamThirdMaintenanceOrder) { |
| | | EamThirdMaintenanceOrder order = (EamThirdMaintenanceOrder) result; |
| | | if (ThirdMaintenanceStatusEnum.COMPLETE.name().equals(order.getMaintenanceStatus())) { |
| | | log.setEquipmentId(order.getEquipmentId()); |
| | | log.setBusinessId(order.getId()); |
| | | log.setOperator(order.getOperator()); |
| | | log.setDescription(order.getLeaderConfirmComment()); |
| | | log.setCreateTime(order.getActualEndTime()); |
| | | } |
| | | } |
| | | break; |
| | | case REPORT_REPAIR: |
| | | if (result instanceof EamReportRepair) { |
ÎļþÃû´Ó lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamRepairOrderRequest.java ÐÞ¸Ä |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
ÎļþÃû´Ó lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamRepairOrderResponse.java ÐÞ¸Ä |
| | |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import org.jeecg.modules.eam.entity.EamRepairOrder; |
| | | import org.jeecg.modules.eam.entity.EamReportRepair; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
ÎļþÃû´Ó lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java ÐÞ¸Ä |
| | |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamRepairOrderService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.eam.util.DateUtils; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.util; |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.DayOfWeek; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoField; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | public class DateUtils { |
| | | |
| | | private final static long DAYTIMESUNSET = 86400; |
| | | |
| | | /** |
| | | * @return å¾å°æå¤© |
| | | */ |
| | | public static Date getNextDay(Date d1) { |
| | | long d2 = d1.getTime() + 86400 * 1000; |
| | | return new Date(d2); |
| | | } |
| | | |
| | | /** |
| | | * @return å¾å°æ¨å¤© |
| | | */ |
| | | public static Date getPreviousDay(Date d1) { |
| | | long d2 = d1.getTime() - 86400 * 1000; |
| | | return new Date(d2); |
| | | } |
| | | |
| | | /** |
| | | * @return è¿åæ¶é´å·®çè¯è¨æè¿° å¦1天2å°æ¶5å6ç§ |
| | | */ |
| | | public static String different(Date d1, Date d2) { |
| | | if (d1 == null || d2 == null) { |
| | | return ""; |
| | | } |
| | | StringBuilder strB = new StringBuilder(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | try { |
| | | //毫ç§ms |
| | | long diff = d2.getTime() - d1.getTime(); |
| | | long diffSeconds = diff / 1000 % 60; |
| | | long diffMinutes = diff / (60 * 1000) % 60; |
| | | long diffHours = diff / (60 * 60 * 1000) % 24; |
| | | long diffDays = diff / (24 * 60 * 60 * 1000); |
| | | if (diffDays > 0) { |
| | | strB.append(diffDays + " 天 "); |
| | | strB.append(diffHours + " å°æ¶ "); |
| | | strB.append(diffMinutes + " åé "); |
| | | strB.append(diffSeconds + " ç§ "); |
| | | } else if (diffHours > 0) { |
| | | strB.append(diffHours + " å°æ¶ "); |
| | | strB.append(diffMinutes + " åé "); |
| | | strB.append(diffSeconds + " ç§ "); |
| | | } else if (diffMinutes > 0) { |
| | | strB.append(diffMinutes + " åé "); |
| | | strB.append(diffSeconds + " ç§ "); |
| | | } else { |
| | | strB.append(diffSeconds + " ç§ "); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return strB.toString(); |
| | | } |
| | | |
| | | /** |
| | | * @return è·å两个dateçæ¶é´å·®ï¼ç»æä¸ºç§ é¤ |
| | | */ |
| | | public static long differentSecond(Date startDate, Date endDate) { |
| | | return new BigDecimal(endDate.getTime() - startDate.getTime()).divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_HALF_UP).longValue(); |
| | | // return (endDate.getTime() - startDate.getTime()) / 1000; |
| | | } |
| | | |
| | | /** |
| | | * @return è·å两个dateçæ¶é´å·®ï¼ç»æä¸ºåé |
| | | */ |
| | | public static Integer differentMinutes(Date startDate, Date endDate) { |
| | | return new BigDecimal(endDate.getTime() - startDate.getTime()).divide(new BigDecimal("60000"), 0, RoundingMode.HALF_UP).intValue(); |
| | | } |
| | | |
| | | /** |
| | | * @return è¿åä¼ å
¥æ¶é´ç0ç¹0å0ç§ |
| | | */ |
| | | public static Date getTodayZero(Date d) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | return cal.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * @return è¿åä¼ å
¥æ¶é´ç0ç¹0å0ç§ |
| | | */ |
| | | public static Date getTomorrowZero(Date d) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.add(Calendar.DAY_OF_MONTH, 1); |
| | | return cal.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * @return 夿æ¶é´æ¯å¦æ¯å½å¤© |
| | | */ |
| | | public static boolean isTaday(Date date) { |
| | | Date now = new Date(); |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); |
| | | String nowDay = sf.format(now); |
| | | String day = sf.format(date); |
| | | return day.equals(nowDay); |
| | | } |
| | | |
| | | /** |
| | | * @return å¤æä¸¤ä¸ªæ¶é´æ¯å¦ä¸ºåä¸å¤© |
| | | */ |
| | | public static boolean isOneDay(Date d1, Date d2) { |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); |
| | | String d1Str = sf.format(d1); |
| | | String d2Str = sf.format(d2); |
| | | return d1Str.equals(d2Str); |
| | | } |
| | | |
| | | /** |
| | | * @return å¤æä¸¤ä¸ªæ¶é´æ¯å¦ä¸ºåä¸å¹´ |
| | | */ |
| | | public static boolean isOneYear(Date d1, Date d2) { |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyy"); |
| | | String d1Str = sf.format(d1); |
| | | String d2Str = sf.format(d2); |
| | | return d1Str.equals(d2Str); |
| | | } |
| | | |
| | | public static String dateProportion(Date start, Date end) { |
| | | float differentSecond = DateUtils.differentSecond(start, end); |
| | | float f = differentSecond / DAYTIMESUNSET * 100; |
| | | return String.format("%.2f", f) + "%"; |
| | | } |
| | | |
| | | public static Date strToDate(String dateStr, String format) { |
| | | SimpleDateFormat sf = new SimpleDateFormat(format); |
| | | Date result = null; |
| | | try { |
| | | result = sf.parse(dateStr); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static final String STR_DATE = "yyyy-MM-dd"; |
| | | public static final String STRDATE = "yyyyMMdd"; |
| | | public static final String STR_YEAR_MONTH = "yyyy-MM"; |
| | | public static final String STRYEARMONTH = "yyyyMM"; |
| | | public static final String STR_DATE_TIME = "yyyy-MM-dd HH:mm:ss.SSS"; |
| | | public static final String STR_DATE_TIME_SMALL = "yyyy-MM-dd HH:mm:ss"; |
| | | public static final String STR_DATE_TIME_MIN = "yyyy-MM-dd HH:mm"; |
| | | public static final String STR_DATE_TIME_HOUR = "yyyy-MM-dd HH"; |
| | | public static final String STR_DATE_TIME_FULL = "yyyyMMddHHmmssSSS"; |
| | | public static final String STR_HHMMSS = "HH:mm:ss"; |
| | | public static final String STR_HHMM = "HH:mm"; |
| | | public static final String STR_MMDD = "MM-dd"; |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: å®é
ææ æä»½ |
| | | * </p> |
| | | * |
| | | * @param startDate |
| | | * @param endDate |
| | | * @return obj [0] å®é
ææ æä»½ ä¾å¦å®é
ææ æä»½ï¼3.86ï¼æä¹æ¯3个æå26天 obj[1] å®é
åæ´æä»½ ï¼3ï¼ |
| | | */ |
| | | public static Integer getRealMonth(Date startDate, Date endDate) { |
| | | Integer month = 0; |
| | | Calendar start = Calendar.getInstance(); |
| | | start.setTime(startDate); |
| | | |
| | | Calendar end = Calendar.getInstance(); |
| | | end.setTime(endDate); |
| | | int year = start.get(Calendar.YEAR); |
| | | int year2 = end.get(Calendar.YEAR); |
| | | int month2 = start.get(Calendar.MONTH); |
| | | int month3 = end.get(Calendar.MONTH); |
| | | try { |
| | | while (start.before(end)) { |
| | | start.add(Calendar.MONTH, 1); |
| | | month++; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | int day2 = start.get(Calendar.DAY_OF_MONTH); |
| | | int day3 = end.get(Calendar.DAY_OF_MONTH); |
| | | int tmpYear = year2 - year; |
| | | if (day2 == day3) { |
| | | return (tmpYear * 12) + (month3 - month2); |
| | | } |
| | | return month == 0 ? month : (month - 1); |
| | | } |
| | | |
| | | public static Date getNow() { |
| | | return new Date(System.currentTimeMillis()); |
| | | } |
| | | |
| | | public static int getDayOfMonth() { |
| | | Calendar aCalendar = Calendar.getInstance(Locale.CHINA); |
| | | int day = aCalendar.getActualMaximum(Calendar.DATE); |
| | | return day; |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: ä¿®æ¹æ¶é´ä¸ºæå®æ¶é´å½å¤©ç23:59:59.000 |
| | | * </p> |
| | | * |
| | | * @param date éè¦ä¿®æ¹çæ¶é´ |
| | | * @return ä¿®æ¹åçæ¶é´ |
| | | */ |
| | | public static Date fillTime(Date date) { |
| | | Date result = removeTime(date); |
| | | result.setTime(result.getTime() + 24 * 60 * 60 * 1000 - 1000); // å ä¸å¤© |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * @param date å½åæ¶é´ |
| | | * @param i å¾åå 天 |
| | | * @return |
| | | */ |
| | | public static Date fillBeforeTime(Date date, Integer i) { |
| | | Date result = removeTime(date); |
| | | Calendar calendar = Calendar.getInstance(); // å¾å°æ¥å |
| | | calendar.setTime(result);// æå½åæ¶é´èµç»æ¥å |
| | | calendar.add(Calendar.DAY_OF_MONTH, i); // 设置为åä¸å¤© |
| | | result.setTime(calendar.getTime().getTime() + 24 * 60 * 60 * 1000 |
| | | - 1000); // å ä¸å¤© |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: ä¿®æ¹æ¶é´ä¸ºæå®æ¶é´åä¸å¤©ç00:00:00 |
| | | * </p> |
| | | * |
| | | * @param date éè¦ä¿®æ¹çæ¶é´ |
| | | * @return ä¿®æ¹åçæ¶é´ |
| | | */ |
| | | public static Date plusTime(Date date, Integer i) { |
| | | Date result = removeTime(date); |
| | | Calendar calendar = Calendar.getInstance(); // å¾å°æ¥å |
| | | calendar.setTime(result);// æå½åæ¶é´èµç»æ¥å |
| | | calendar.add(Calendar.DAY_OF_MONTH, i); // 设置为åä¸å¤© |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: å»ææ¥ææ¶é´ä¸çæ¶é´é¨å |
| | | * </p> |
| | | * å¦: 2013-11-11 18:56:33 ---> 2013-11-11 00:00:00 |
| | | * |
| | | * @param date éè¦ä¿®æ¹çæ¶é´ |
| | | * @return ä¿®æ¹åçæ¶é´ |
| | | */ |
| | | public static Date removeTime(Date date) { |
| | | Date result = null; |
| | | try { |
| | | SimpleDateFormat df = new SimpleDateFormat(STR_DATE); |
| | | String dateStr = df.format(date); |
| | | result = df.parse(dateStr); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: æé»è®¤æ ¼å¼(yyyy-MM-dd HH:mm:ss.SSS)è·åæ¶é´å符串 |
| | | * </p> |
| | | * |
| | | * @param date è¦è½¬æ¢çæ¥æ |
| | | * @return 转æ¢åçæ¶é´å符串 |
| | | */ |
| | | public static String format(Date date) { |
| | | SimpleDateFormat df = new SimpleDateFormat(STR_DATE_TIME); |
| | | return df.format(date); |
| | | } |
| | | |
| | | public static Date parseDate(Date date, String format) { |
| | | SimpleDateFormat df = new SimpleDateFormat(format); |
| | | try { |
| | | date = df.parse(df.format(date)); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return date; |
| | | } |
| | | |
| | | public static Date getDelayedYear() { |
| | | Calendar curr = Calendar.getInstance(); |
| | | curr.set(Calendar.YEAR, curr.get(Calendar.YEAR) + 1); |
| | | Date date = curr.getTime(); |
| | | return date; |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: ææå®æ ¼å¼è·åæ¶é´å符串 |
| | | * </p> |
| | | * |
| | | * @param date è¦è½¬æ¢çæ¥æ |
| | | * @param format æ ¼å¼,ä¾å¦:yyyy-MM-dd HH:mm:ss.SSS |
| | | * @return 转æ¢åçæ¶é´å符串 |
| | | */ |
| | | public static String format(Date date, String format) { |
| | | SimpleDateFormat df = new SimpleDateFormat(format); |
| | | return df.format(date); |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Description: å æå½æ° |
| | | * </p> |
| | | * |
| | | * @param month æä»½æ° |
| | | * @return |
| | | */ |
| | | public static Date addMonth(Integer month, Date time) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(time); |
| | | c.add(Calendar.MONTH, month); |
| | | return c.getTime(); |
| | | } |
| | | |
| | | public static Boolean greater(Date startTime, Date endTime) { |
| | | return startTime.getTime() > endTime.getTime(); |
| | | } |
| | | |
| | | public static Boolean less(Date startTime, Date endTime) { |
| | | return startTime.getTime() < endTime.getTime(); |
| | | } |
| | | |
| | | public static Boolean equals(Date startTime, Date endTime) { |
| | | return startTime.getTime() == endTime.getTime(); |
| | | } |
| | | |
| | | public static Integer getDiffMonth(Calendar c, Calendar c1) { |
| | | return (c.get(Calendar.YEAR) - c1.get(Calendar.YEAR)) * 12 |
| | | + (c.get(Calendar.MONTH) - c1.get(Calendar.MONTH)); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºåä¸å¤© |
| | | */ |
| | | public static boolean equalsDay(Date a, Date b) { |
| | | return removeTime(a).getTime() == removeTime(b).getTime(); |
| | | } |
| | | |
| | | public static Integer getDays(Date startTime, Date endTime) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(startTime); |
| | | Calendar c1 = Calendar.getInstance(); |
| | | c1.setTime(endTime); |
| | | long t1 = c.getTimeInMillis(); |
| | | long t2 = c1.getTimeInMillis(); |
| | | // 计ç®å¤©æ° |
| | | Long days = (t2 - t1) / (24 * 60 * 60 * 1000); |
| | | return days.intValue(); |
| | | } |
| | | |
| | | public static Integer getSeconds(Date startTime, Date endTime) { |
| | | try { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(startTime); |
| | | Calendar c1 = Calendar.getInstance(); |
| | | c1.setTime(endTime); |
| | | long t1 = c.getTimeInMillis(); |
| | | long t2 = c1.getTimeInMillis(); |
| | | // 计ç®ç§æ° |
| | | Long days = (t2 - t1) / (1000); |
| | | return days.intValue(); |
| | | } catch (Exception e) { |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | |
| | | //è·åå°æ¶å·® |
| | | public static double subHours(Date startTime, Date endTime) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(startTime); |
| | | Calendar c1 = Calendar.getInstance(); |
| | | c1.setTime(endTime); |
| | | double t1 = c.getTimeInMillis(); |
| | | double t2 = c1.getTimeInMillis(); |
| | | // 计ç®å¤©æ° |
| | | double hours = (t2 - t1) / (1000 * 60 * 60); |
| | | return Double.valueOf(new DecimalFormat("#.00").format(hours)); |
| | | } |
| | | |
| | | //æ ¹æ®å½åæ¶é´ååºçæ¥æè·åå¹´é¾ |
| | | public static int getAge(Date birthDay) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | // ååºç³»ç»å½åæ¶é´çå¹´ãæãæ¥é¨å |
| | | int yearNow = cal.get(Calendar.YEAR); |
| | | int monthNow = cal.get(Calendar.MONTH); |
| | | int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); |
| | | cal.setTime(birthDay); |
| | | // ååºåºçæ¥æçå¹´ãæãæ¥é¨å |
| | | int yearBirth = cal.get(Calendar.YEAR); |
| | | int monthBirth = cal.get(Calendar.MONTH); |
| | | int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); |
| | | // å½å年份ä¸åºç年份ç¸åï¼åæ¥è®¡ç®å¹´é¾ |
| | | int age = yearNow - yearBirth; |
| | | // å½åæä»½ä¸åºçæ¥æçæä»½ç¸æ¯ï¼å¦ææä»½å°äºåºçæä»½ï¼åå¹´é¾ä¸å1ï¼è¡¨ç¤ºä¸æ»¡å¤å°å¨å² |
| | | if (monthNow <= monthBirth) { |
| | | // 妿æä»½ç¸çï¼å¨æ¯è¾æ¥æï¼å¦æå½åæ¥ï¼å°äºåºçæ¥ï¼ä¹å1ï¼è¡¨ç¤ºä¸æ»¡å¤å°å¨å² |
| | | if (monthNow == monthBirth) { |
| | | if (dayOfMonthNow < dayOfMonthBirth) { |
| | | age--; |
| | | } |
| | | } else { |
| | | age--; |
| | | } |
| | | |
| | | } |
| | | return age; |
| | | } |
| | | |
| | | public static Date subDays(Date startTime, Integer day) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(startTime); |
| | | c.add(Calendar.DATE, day * -1); |
| | | return c.getTime(); |
| | | } |
| | | |
| | | public static Date addDays(Date startTime, Integer day) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(startTime); |
| | | c.add(Calendar.DATE, day); |
| | | return c.getTime(); |
| | | } |
| | | /*public static Date addHours(Date startTime, Integer hours) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(startTime); |
| | | c.add(Calendar.HOUR, hours ); |
| | | return c.getTime(); |
| | | }*/ |
| | | |
| | | public static Date toDate(String date, String format) { |
| | | SimpleDateFormat df = new SimpleDateFormat(format); |
| | | try { |
| | | return df.parse(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Date toDateFull(String date) { |
| | | SimpleDateFormat df = new SimpleDateFormat(STR_DATE_TIME); |
| | | try { |
| | | return df.parse(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Date toDateMedium(String date) { |
| | | SimpleDateFormat df = new SimpleDateFormat(STR_DATE_TIME_SMALL); |
| | | try { |
| | | Date dd = df.parse(date); |
| | | return dd; |
| | | } catch (ParseException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public static Integer getDate(Date date) { |
| | | if (date != null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int day = calendar.get(Calendar.DATE); |
| | | return day; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Integer getYear() { |
| | | return getYear(new Date()); |
| | | } |
| | | |
| | | public static Integer getYear(Date date) { |
| | | if (date != null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | return year; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Integer getMonth() { |
| | | return getMonth(new Date()); |
| | | } |
| | | |
| | | public static Integer getMonth(Date date) { |
| | | if (date != null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int month = calendar.get(Calendar.MONTH); |
| | | return month + 1; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Integer getDay() { |
| | | return getDay(new Date()); |
| | | } |
| | | |
| | | public static Integer getDay(Date date) { |
| | | if (date != null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | return day; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static Date[] getMonthStartTimeAndEndTime(Integer month) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | Date[] dates = new Date[2]; |
| | | Date startTime = null; |
| | | Date endsTime = null; |
| | | if (month != null) { |
| | | calendar.set(Calendar.MONTH, month); |
| | | //è·å¾å°æ¬æç第ä¸å¤© |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); |
| | | startTime = calendar.getTime(); |
| | | startTime = DateUtils.removeTime(startTime); |
| | | //è·å¾å°æ¬æçæåä¸å¤© |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); |
| | | endsTime = calendar.getTime(); |
| | | endsTime = DateUtils.fillTime(endsTime); |
| | | } |
| | | dates[0] = startTime; |
| | | dates[1] = endsTime; |
| | | return dates; |
| | | } |
| | | |
| | | public static Date[] getMonthStartTimeAndEndTime(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | Integer month = calendar.get(Calendar.MONTH); |
| | | Date[] dates = new Date[2]; |
| | | Date startTime = null; |
| | | Date endsTime = null; |
| | | if (month != null) { |
| | | calendar.set(Calendar.MONTH, month); |
| | | //è·å¾å°æ¬æç第ä¸å¤© |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); |
| | | startTime = calendar.getTime(); |
| | | startTime = DateUtils.removeTime(startTime); |
| | | //è·å¾å°æ¬æçæåä¸å¤© |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); |
| | | endsTime = calendar.getTime(); |
| | | endsTime = DateUtils.fillTime(endsTime); |
| | | } |
| | | dates[0] = startTime; |
| | | dates[1] = endsTime; |
| | | return dates; |
| | | } |
| | | |
| | | /** |
| | | * è·ådayså¤©çæ¶é´åºé´ï¼endTime 为å½å¤©çåä¸å¤©0ç¹ï¼ |
| | | * startTime 为endTimeådays天 |
| | | * |
| | | * @param days |
| | | * @return |
| | | */ |
| | | public static Date[] getDaysStartTimeAndEndTime(Integer days) { |
| | | Date[] dates = new Date[2]; |
| | | Date endDate = plusTime(removeTime(getNow()), 1); |
| | | Date startDate = subDays(endDate, days); |
| | | dates[0] = startDate; |
| | | dates[1] = endDate; |
| | | return dates; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æä¸å¹´è·åæåä¸å¤©çæ¶é´ |
| | | * 2013 ---> 2013-12-31 23:59:59.000 |
| | | * |
| | | * @param year |
| | | * @return |
| | | */ |
| | | public static Date getYearEndDay(Integer year) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.clear(); |
| | | calendar.set(Calendar.YEAR, year); |
| | | calendar.roll(Calendar.DAY_OF_YEAR, -1); |
| | | Date yearLast = calendar.getTime(); |
| | | Date lastYear = DateUtils.fillTime(yearLast); |
| | | return lastYear; |
| | | } |
| | | |
| | | /** |
| | | * è·åstart/endçæææ¥æå符串 æ ¼å¼yyyy-MM-dd |
| | | * |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public static List<String> getDatesStringList(Date start, Date end, String strDate) { |
| | | List<String> list = new ArrayList<>(); |
| | | int i = getDays(start, end); |
| | | for (int j = 0; j <= i; j++) { |
| | | if (j == 0) { |
| | | list.add(format(start, strDate)); |
| | | } else { |
| | | list.add(format(plusTime(start, j), strDate)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * è·åstart/endçæææ¥æå符串 æ ¼å¼yyyy-MM-dd |
| | | * |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public static List<String> getDatesStringList(Date start, Date end) { |
| | | List<String> list = new ArrayList<>(); |
| | | int i = getDays(start, end); |
| | | for (int j = 0; j <= i; j++) { |
| | | if (j == 0) { |
| | | list.add(format(start, STR_DATE)); |
| | | } else { |
| | | list.add(format(plusTime(start, j), STR_DATE)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * è·åstart/endçæææ¥æå符串 æ ¼å¼yyyyMMdd |
| | | * |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public static List<String> getDatesStringList2(Date start, Date end) { |
| | | List<String> list = new ArrayList<>(); |
| | | int i = getDays(start, end); |
| | | for (int j = 0; j <= i; j++) { |
| | | if (j == 0) { |
| | | list.add(format(start, STRDATE)); |
| | | } else { |
| | | list.add(format(plusTime(start, j), STRDATE)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * è·åstart/endçæææ¥æå符串 æ ¼å¼MM-dd |
| | | * |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public static List<String> getDatesStringLists(Date start, Date end) { |
| | | List<String> list = new ArrayList<>(); |
| | | int i = getDays(start, end); |
| | | for (int j = 0; j <= i; j++) { |
| | | if (j == 0) { |
| | | list.add(format(start, STR_MMDD)); |
| | | } else { |
| | | list.add(format(plusTime(start, j), STR_MMDD)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public static List<String> getMonthBetween(Date start, Date end) { |
| | | List<String> list = new ArrayList<>(); |
| | | Calendar min = Calendar.getInstance(); |
| | | Calendar max = Calendar.getInstance(); |
| | | min.setTime(start); |
| | | min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1); |
| | | max.setTime(end); |
| | | max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2); |
| | | Calendar curr = min; |
| | | while (curr.before(max)) { |
| | | list.add(format(curr.getTime(), STR_YEAR_MONTH)); |
| | | curr.add(Calendar.MONTH, 1); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * è·ådateStrçæ¥ææ ¼å¼yyyy-MM-dd |
| | | * |
| | | * @param dateStr |
| | | * @return |
| | | */ |
| | | public static Date getShortDate(String dateStr) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(STR_DATE); |
| | | Date startTime = null; |
| | | try { |
| | | startTime = sdf.parse(dateStr); |
| | | } catch (ParseException e) { |
| | | } |
| | | return startTime == null ? removeTime(new Date()) : startTime; |
| | | } |
| | | |
| | | /** |
| | | * è·ådateStrçæ¥ææ ¼å¼yyyyMMdd |
| | | * |
| | | * @param dateStr |
| | | * @return |
| | | */ |
| | | public static Date getShortDate2(String dateStr) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(STRDATE); |
| | | Date startTime = null; |
| | | try { |
| | | startTime = sdf.parse(dateStr); |
| | | } catch (ParseException e) { |
| | | } |
| | | return startTime == null ? removeTime(new Date()) : startTime; |
| | | } |
| | | |
| | | public static Date getFormatDate(String dateStr, String format) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | Date startTime = null; |
| | | try { |
| | | startTime = sdf.parse(dateStr); |
| | | } catch (ParseException e) { |
| | | } |
| | | return startTime == null ? removeTime(new Date()) : startTime; |
| | | } |
| | | |
| | | /** |
| | | * @param time |
| | | * @param n |
| | | * @return å¨ä¸ä¸ªæ¶é´ä¸å ç§ |
| | | */ |
| | | public static Date addSecond(Date time, Integer n) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(time); |
| | | c.add(Calendar.SECOND, n); |
| | | return c.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * @param time |
| | | * @param n |
| | | * @return å¨ä¸ä¸ªæ¶é´ä¸å åé |
| | | */ |
| | | public static Date addMinute(Date time, Integer n) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(time); |
| | | c.add(Calendar.MINUTE, n); |
| | | return c.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * @param time |
| | | * @param n |
| | | * @return å¨ä¸ä¸ªæ¶é´ä¸å å°æ¶ |
| | | */ |
| | | public static Date addHour(Date time, Integer n) { |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(time); |
| | | c.add(Calendar.HOUR_OF_DAY, n); |
| | | return c.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * è·åstart/endçæææ¥æå符串 æ ¼å¼yyyy-MM-dd |
| | | * |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public static List<String> getDateMonth(String start, String end) { |
| | | List<String> list = new ArrayList<>(); |
| | | SimpleDateFormat yyyyMM = new SimpleDateFormat("yyyy-MM"); |
| | | Date startyear = null; |
| | | try { |
| | | startyear = yyyyMM.parse(start); |
| | | Date endyear = yyyyMM.parse(end); |
| | | Calendar dd = Calendar.getInstance();//å®ä¹æ¥æå®ä¾ |
| | | dd.setTime(startyear);//è®¾ç½®æ¥æèµ·å§æ¶é´ |
| | | while (dd.getTime().before(endyear)) {//夿æ¯å¦å°ç»ææ¥æ |
| | | String str = yyyyMM.format(dd.getTime()); |
| | | dd.add(Calendar.MONTH, 1);//è¿è¡å½åæ¥ææä»½å 1 |
| | | list.add(str); |
| | | } |
| | | list.add(yyyyMM.format(endyear)); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * è·åstart/endçæææ¥æå符串 æ ¼å¼yyyy |
| | | * |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public static List<String> getDateYear(String start, String end) { |
| | | List<String> list = new ArrayList<>(); |
| | | SimpleDateFormat yyyy = new SimpleDateFormat("yyyy"); |
| | | Date startyear = null; |
| | | try { |
| | | startyear = yyyy.parse(start); |
| | | Date endyear = yyyy.parse(end); |
| | | Calendar dd = Calendar.getInstance();//å®ä¹æ¥æå®ä¾ |
| | | dd.setTime(startyear);//è®¾ç½®æ¥æèµ·å§æ¶é´ |
| | | while (dd.getTime().before(endyear)) {//夿æ¯å¦å°ç»ææ¥æ |
| | | String str = yyyy.format(dd.getTime()); |
| | | dd.add(Calendar.YEAR, 1);//è¿è¡å½åæ¥ææä»½å 1 |
| | | list.add(str); |
| | | } |
| | | list.add(yyyy.format(endyear)); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åæ¶é´ å®ä½å°å°æ¶ |
| | | * æ ¼å¼ä¸º yyyy-MM-dd hh:mm |
| | | * ä¾ï¼2018-02-27 11:00 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Date getNowHourDate() { |
| | | Date now = getNow(); |
| | | Date result; |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | String dateStr = format(now, STR_DATE); |
| | | dateStr = dateStr + " " + (hour < 10 ? "0" + hour : hour) + ":00"; |
| | | result = toDate(dateStr, STR_DATE_TIME_MIN); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¯æ¥8:11æ11:11çæ¶é´ç¹ |
| | | * |
| | | * @return |
| | | */ |
| | | public static Date getNowHourDateTo() { |
| | | Date now = getNow(); |
| | | Date result; |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | int hour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | if (hour != 8 && hour != 11) { |
| | | return null; |
| | | } |
| | | int minute = calendar.get(Calendar.MINUTE); |
| | | if (minute < 11) { |
| | | return null; |
| | | } |
| | | String dateStr = format(now, STR_DATE); |
| | | dateStr = dateStr + " " + (hour < 10 ? "0" + hour : hour) + ":11"; |
| | | result = toDate(dateStr, STR_DATE_TIME_MIN); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¯æ¥8:00ã13:00ã20:00çæ¶é´ç¹ |
| | | * |
| | | * @return |
| | | */ |
| | | public static List<Date> getHourDateList(Date time) { |
| | | List<Date> result = new ArrayList<>(); |
| | | result.add(addHour(time, 8)); |
| | | result.add(addHour(time, 13)); |
| | | result.add(addHour(time, 20)); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è·å䏿çæåä¸å¤© |
| | | * |
| | | * @return |
| | | */ |
| | | public static Date getPreviousMonthLastDay() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 0); |
| | | return DateUtils.removeTime(calendar.getTime()); |
| | | } |
| | | |
| | | /** |
| | | * è·åendæ¶é´æç第ä¸å¤© |
| | | * |
| | | * @param end æä»½æåä¸å¤© |
| | | * @return |
| | | */ |
| | | public static Date getTheMonthFirstDay(Date end) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(end); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | public static String secToTimeHour(int time) { |
| | | String timeStr = null; |
| | | int hour = 0; |
| | | if (time <= 0) { |
| | | return "0å°æ¶"; |
| | | } else { |
| | | BigDecimal bigDecimal = new BigDecimal(time); |
| | | BigDecimal bigDecimal1 = new BigDecimal(3600); |
| | | BigDecimal hourBigDecimal = new BigDecimal(0); |
| | | hourBigDecimal = new BigDecimal(String.valueOf(bigDecimal)). |
| | | divide(new BigDecimal(String.valueOf(bigDecimal1)), 2, BigDecimal.ROUND_HALF_UP); |
| | | timeStr = hourBigDecimal + "å°æ¶"; |
| | | } |
| | | return timeStr; |
| | | } |
| | | |
| | | public static String secToTime(int time) { |
| | | String timeStr = null; |
| | | int hour = 0; |
| | | int minute = 0; |
| | | int second = 0; |
| | | if (time <= 0) |
| | | return " "; |
| | | else { |
| | | minute = time / 60; |
| | | if (minute < 60) { |
| | | second = time % 60; |
| | | timeStr = unitFormat(minute) + "å" + unitFormat(second) + " ç§"; |
| | | } else { |
| | | hour = minute / 60; |
| | | minute = minute % 60; |
| | | second = time - hour * 3600 - minute * 60; |
| | | timeStr = unitFormat(hour) + "å°æ¶" + unitFormat(minute) + "å" + unitFormat(second) + "ç§"; |
| | | } |
| | | } |
| | | return timeStr; |
| | | } |
| | | |
| | | public static String unitFormat(int i) { |
| | | String retStr = null; |
| | | if (i >= 0 && i < 10) |
| | | retStr = "0" + Integer.toString(i); |
| | | else |
| | | retStr = "" + i; |
| | | return retStr; |
| | | } |
| | | |
| | | /** |
| | | * éªè¯æ¶é´ |
| | | * |
| | | * @param time æ¶é´å符串 HH:mm |
| | | * @return éªè¯æåè¿åtrueï¼éªè¯å¤±è´¥è¿åfalse |
| | | */ |
| | | public static boolean checkTime(String time) { |
| | | String regex = "([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$"; |
| | | return Pattern.matches(regex, time); |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¯æ¥07:30:00çæ¶é´ç¹ |
| | | * æ ¼å¼ä¸º yyyy-MM-dd HH:mm:ss |
| | | * ä¾ï¼2018-05-28 07:30:00 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Date getHourDateTo(Date now, String time) { |
| | | String dateStr = format(now, STR_DATE); |
| | | dateStr = dateStr + " " + time; |
| | | Date result = toDate(dateStr, STR_DATE_TIME_SMALL); |
| | | return result; |
| | | } |
| | | |
| | | public static Date setTimeForDay(Date theDate, String planTime) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(theDate); |
| | | String[] times = planTime.split(":"); |
| | | cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(times[0])); |
| | | cal.set(Calendar.MINUTE, Integer.parseInt(times[1])); |
| | | cal.set(Calendar.SECOND, Integer.parseInt(times[2])); |
| | | return cal.getTime(); |
| | | } |
| | | |
| | | public static long getTimeWithOutDay(Date d) { |
| | | return d.getTime() / 1000 % 86400; |
| | | } |
| | | |
| | | /** |
| | | * @param lo æ¯«ç§æ° |
| | | * @return String yyyy-MM-dd HH:mm:ss |
| | | * @Description: longç±»åè½¬æ¢ææ¥æ |
| | | */ |
| | | public static String longToDate(long lo) { |
| | | Date date = new Date(lo); |
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | return sd.format(date); |
| | | } |
| | | |
| | | /** |
| | | * @param startDate |
| | | * @param endDate |
| | | * @return |
| | | */ |
| | | public static List<Date> getWeekDays(LocalDate startDate, LocalDate endDate) { |
| | | List<Date> result = new ArrayList<>(); |
| | | List<LocalDate> dateList = Stream.iterate(startDate, localDate -> localDate.plusDays(1)) |
| | | .limit(ChronoUnit.DAYS.between(startDate, endDate) + 1) |
| | | .filter(localDate -> DayOfWeek.SATURDAY.equals(DayOfWeek.of(localDate.get(ChronoField.DAY_OF_WEEK))) || DayOfWeek.SUNDAY.equals(DayOfWeek.of(localDate.get(ChronoField.DAY_OF_WEEK)))) |
| | | .collect(Collectors.toList()); |
| | | dateList.forEach(localDate -> result.add(Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()))); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * @param smallDate |
| | | * @param bigDate |
| | | * @desc è·åä¸¤ä¸ªæ¥æä¹é´çå¤©æ° |
| | | */ |
| | | public static Integer getDaysBetween(String smallDate, String bigDate) throws ParseException { |
| | | // æ¥ææ ¼å¼ |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | // è·åä¸¤ä¸ªæ¥æçæ¶é´æ³ |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(sdf.parse(smallDate)); |
| | | long smallTime = cal.getTimeInMillis(); |
| | | cal.setTime(sdf.parse(bigDate)); |
| | | long bigTime = cal.getTimeInMillis(); |
| | | // ç¸å·®çæ¥æ |
| | | long days = (bigTime - smallTime) / (1000 * 3600 * 24); |
| | | // long转int å卿º¢åºæ
åµ æ ¹æ®ä¸å¡æ
åµç¼è¾catchä¸è¿åå¼ |
| | | try { |
| | | return Integer.parseInt(String.valueOf(days)); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥æè½¬æ¢ï¼å°æ¥å£è¿åç20180524转为2018-05-24 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String dateConvertion(String str) { |
| | | Date parse = null; |
| | | String dateString = ""; |
| | | try { |
| | | parse = new SimpleDateFormat("yyyyMMdd").parse(str); |
| | | dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse); |
| | | } catch (ParseException e) { |
| | | dateString = null; |
| | | } |
| | | |
| | | return dateString; |
| | | } |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.jeecg.modules.mdc.entity.Equipment; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: éé设å¤è¡¨ |
| | | * @Author: liuS |
| | |
| | | @Select(" SELECT name FROM SysObjects Where XType='U' AND name = '${saveTableName}' ") |
| | | String checkTableExists(@Param("saveTableName") String saveTableName); |
| | | |
| | | @Select(" SELECT COUNT(CollectTime) num FROM ${saveTableName} WHERE CollectTime < '${day}' ") |
| | | @Select(" SELECT COUNT(CollectTime) num FROM [${saveTableName}] WHERE CollectTime < '${day}' ") |
| | | Integer checkTableDataNum(@Param("saveTableName") String saveTableName, @Param("day") String day); |
| | | |
| | | @Insert(" INSERT INTO ${tableName} SELECT * FROM ${lastTableName} WHERE CollectTime < '${date}' ") |
| | | @Insert(" INSERT INTO [${tableName}] SELECT * FROM [${lastTableName}] WHERE CollectTime < '${date}' ") |
| | | void insertTableData(@Param("tableName") String tableName, @Param("lastTableName") String lastTableName, @Param("date") String date); |
| | | |
| | | @Delete(" delete from ${tableName} where CollectTime < '${day}' ") |
| | | @Delete(" delete from [${tableName}] where CollectTime < '${day}' ") |
| | | void deleteTableData(@Param("tableName") String saveTableName, @Param("day") String day); |
| | | |
| | | @Insert(" SELECT * INTO ${tableName} FROM ${lastTableName} WHERE CollectTime < '${date}' ") |
| | | @Insert(" SELECT * INTO [${tableName}] FROM [${lastTableName}] WHERE CollectTime < '${date}' ") |
| | | void insertNoTableData(@Param("tableName") String tableName, @Param("lastTableName") String lastTableName, @Param("date") String date); |
| | | |
| | | List<Equipment> listByProds(@Param("proIds") List<String> proIds); |
| | | |
| | | Equipment findByEquId(@Param("equipmentId") String equipmentId); |
| | | } |
| | |
| | | |
| | | List<MdcEquipment> findByProIdsAndType(@Param("mdcProductionIds") List<String> mdcProductionIds, @Param("typeList") List<String> typeList); |
| | | |
| | | List<String> getEquIdsByProIds(@Param("proIds") List<String> proIds); |
| | | |
| | | List<MdcEquipment> getEquipmentList(@Param("allProductionIds") List<String> allProductionIds); |
| | | } |
| | |
| | | <!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.EquipmentMapper"> |
| | | |
| | | <select id="listByProds" resultType="org.jeecg.modules.mdc.entity.Equipment"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | Equipment t1 |
| | | LEFT JOIN mdc_equipment t2 ON t1.EquipmentID = t2.equipment_id |
| | | LEFT JOIN mdc_production_equipment t3 ON t2.id = t3.equipment_id |
| | | <where> |
| | | t3.production_id IN |
| | | <foreach collection="proIds" index="index" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="findByEquId" resultType="org.jeecg.modules.mdc.entity.Equipment"> |
| | | SELECT TOP 1 * FROM Equipment WHERE EquipmentID = #{equipmentId} |
| | | </select> |
| | | </mapper> |
| | |
| | | #{equipmentType} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="queryByDepartIdsAndType" resultType="org.jeecg.modules.mdc.entity.MdcEquipment"> |
| | | SELECT |
| | | e.*, |
| | |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="getEquIdsByProIds" resultType="java.lang.String"> |
| | | SELECT |
| | | t1.equipment_id |
| | | FROM |
| | | mdc_equipment t1 |
| | | LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id |
| | | <where> |
| | | t2.production_id IN |
| | | <foreach collection="proIds" index="index" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.mdc.entity.Equipment; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: éé设å¤è¡¨ |
| | | * @Author: liuS |
| | |
| | | * @param day |
| | | */ |
| | | void insertNoTableData(String backupTableName, String tableName, String day); |
| | | |
| | | List<Equipment> listByProds(List<String> proIds); |
| | | |
| | | Equipment findByEquId(String equipmentId); |
| | | } |
| | |
| | | */ |
| | | public interface IMdcAlarmInfoService extends IService<MdcAlarmInfo> { |
| | | |
| | | MdcAlarmInfo findAlarmContent(String alarmNo, String equipmentId); |
| | | } |
| | |
| | | */ |
| | | List<MdcEquipment> findByProIdsAndType(List<String> allProductionIds, List<String> typeList); |
| | | |
| | | List<String> getEquIdsByProIds(List<String> proIds); |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢è®¾å¤åè¡¨ä¿¡æ¯ |
| | | * @return |
| | |
| | | import org.jeecg.modules.mdc.service.IEquipmentService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: éé设å¤è¡¨ |
| | | * @Author: liuS |
| | |
| | | public void insertNoTableData(String backupTableName, String tableName, String day) { |
| | | this.baseMapper.insertNoTableData(backupTableName, tableName, day); |
| | | } |
| | | |
| | | @Override |
| | | public List<Equipment> listByProds(List<String> proIds) { |
| | | return this.baseMapper.listByProds(proIds); |
| | | } |
| | | |
| | | @Override |
| | | public Equipment findByEquId(String equipmentId) { |
| | | return this.baseMapper.findByEquId(equipmentId); |
| | | } |
| | | } |
| | |
| | | return equipmentIds; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getEquIdsByProIds(List<String> proIds) { |
| | | return this.baseMapper.getEquIdsByProIds(proIds); |
| | | } |
| | | |
| | | } |
| | |
| | | <artifactId>lxzn-module-mdc-common</artifactId> |
| | | <version>3.4.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.jeecgframework.boot</groupId> |
| | | <artifactId>lxzn-module-eam-common</artifactId> |
| | | <version>3.4.3</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.board.service.IDtBoardService; |
| | | import org.jeecg.modules.board.vo.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-05-30 |
| | | * @Description: æ°ååªççæ¿æ¥å£ |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "æ°ååªççæ¿") |
| | | @RestController |
| | | @RequestMapping("/board/dtBoard") |
| | | public class DtBoardController { |
| | | |
| | | @Resource |
| | | private IDtBoardService dtBoardService; |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-è·å车é´åç»", notes = "æ°ååªççæ¿-è·å车é´åç»") |
| | | @GetMapping("/productionList") |
| | | public Result<?> productionList() { |
| | | List<MdcProduction> result = dtBoardService.productionList(); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-è®¾å¤æåº¦å©ç¨ç", notes = "æ°ååªççæ¿-è®¾å¤æåº¦å©ç¨ç") |
| | | @GetMapping("/equipmentMonthUtilizationRate") |
| | | public Result<?> equipmentMonthUtilizationRate(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | List<EquUtilRateMonth> result = dtBoardService.equipmentMonthUtilizationRate(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-设å¤å©ç¨ç", notes = "æ°ååªççæ¿-设å¤å©ç¨ç") |
| | | @GetMapping("/equipmentUtilizationRate") |
| | | public Result<?> equipmentUtilizationRate(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | List<EquUtilRate> result = dtBoardService.equipmentUtilizationRate(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-æåº¦OEE", notes = "æ°ååªççæ¿-æåº¦OEE") |
| | | @GetMapping("/equipmentMonthOee") |
| | | public Result<?> equipmentMonthOee(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | List<EquOeeMonth> result = dtBoardService.equipmentMonthOee(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-设å¤è¿è¡ç¶æç»è®¡", notes = "æ°ååªççæ¿-设å¤è¿è¡ç¶æ") |
| | | @GetMapping("/equipmentOperationStatistics") |
| | | public Result<?> equipmentOperationStatistics(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | EquOperation result = dtBoardService.equipmentOperationStatistics(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-设å¤ä¿¡æ¯", notes = "æ°ååªççæ¿-设å¤ä¿¡æ¯") |
| | | @GetMapping("/equipmentRunInfo") |
| | | public Result<?> equipmentRunInfo(@ApiParam(value = "equipmentId", required = true) String equipmentId) { |
| | | List<EquRunInfo> result = dtBoardService.equipmentRunInfo(equipmentId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-设å¤åæºç»è®¡", notes = "æ°ååªççæ¿-设å¤åæºç»è®¡") |
| | | @GetMapping("/equDowntimeStatistics") |
| | | public Result<?> equDowntimeStatistics(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | List<EquDowntimeInfo> result = dtBoardService.equDowntimeStatistics(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-è®¾å¤æ¥è¦", notes = "æ°ååªççæ¿-è®¾å¤æ¥è¦") |
| | | @GetMapping("/equAlarmList") |
| | | public Result<?> equAlarmList(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | List<EquAlarm> result = dtBoardService.equAlarmList(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°ååªççæ¿-è®¾å¤æ
é", notes = "æ°ååªççæ¿-è®¾å¤æ
é") |
| | | @GetMapping("/equRepairList") |
| | | public Result<?> equRepairList(@ApiParam(value = "productionId", required = true) String productionId) { |
| | | List<EquRepair> result = dtBoardService.equRepairList(productionId); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.mapper; |
| | | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.board.vo.EquRepair; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-11 |
| | | * @Description: |
| | | */ |
| | | @Mapper |
| | | public interface DtBoardMapper { |
| | | List<EquRepair> equRepairList(@Param("equipmentIdList") List<String> equipmentIdList, @Param("date") String date); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.board.mapper.DtBoardMapper"> |
| | | |
| | | <select id="equRepairList" resultType="org.jeecg.modules.board.vo.EquRepair"> |
| | | SELECT |
| | | t3.equipment_code equipmentId, |
| | | COUNT(*) faultNum, |
| | | ROUND( |
| | | SUM(DATEDIFF(MINUTE, t2.fault_start_time, t1.actual_end_time)) / 60.0, |
| | | 2 |
| | | ) faultTime |
| | | FROM |
| | | eam_repair_order t1 |
| | | LEFT JOIN eam_report_repair t2 ON t1.report_id = t2.id |
| | | LEFT JOIN eam_equipment t3 ON t1.equipment_id = t3.id |
| | | WHERE |
| | | t1.repair_status = 'COMPLETE' |
| | | AND t2.fault_start_time > #{date} |
| | | AND t3.equipment_code IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | GROUP BY |
| | | t3.equipment_code |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.service; |
| | | |
| | | import org.jeecg.modules.board.vo.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-05-30 |
| | | * @Description: |
| | | */ |
| | | public interface IDtBoardService { |
| | | |
| | | List<MdcProduction> productionList(); |
| | | |
| | | List<EquUtilRateMonth> equipmentMonthUtilizationRate(String productionId); |
| | | |
| | | List<EquUtilRate> equipmentUtilizationRate(String productionId); |
| | | |
| | | List<EquOeeMonth> equipmentMonthOee(String productionId); |
| | | |
| | | EquOperation equipmentOperationStatistics(String productionId); |
| | | |
| | | List<EquRunInfo> equipmentRunInfo(String equipmentId); |
| | | |
| | | List<EquDowntimeInfo> equDowntimeStatistics(String productionId); |
| | | |
| | | List<EquAlarm> equAlarmList(String productionId); |
| | | |
| | | List<EquRepair> equRepairList(String productionId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import liquibase.pro.packaged.I; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.vo.DictModel; |
| | | import org.jeecg.modules.board.mapper.DtBoardMapper; |
| | | import org.jeecg.modules.board.service.IDtBoardService; |
| | | import org.jeecg.modules.board.vo.*; |
| | | import org.jeecg.modules.eam.service.IEamRepairOrderService; |
| | | import org.jeecg.modules.mdc.constant.MdcConstant; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-05-30 |
| | | * @Description: |
| | | */ |
| | | @Service |
| | | public class DtBoardServiceImpl implements IDtBoardService { |
| | | |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService; |
| | | |
| | | @Resource |
| | | private IMdcOeeInfoService mdcOeeInfoService; |
| | | |
| | | @Resource |
| | | private IEquipmentService equipmentService; |
| | | |
| | | @Resource |
| | | private IEquipmentWorkLineService equipmentWorkLineService; |
| | | |
| | | @Resource |
| | | private IMdcDriveTypeParamConfigService mdcDriveTypeParamConfigService; |
| | | |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | |
| | | @Resource |
| | | private IMdcDowntimeService mdcDowntimeService; |
| | | |
| | | @Resource |
| | | private IEquipmentAlarmService equipmentAlarmService; |
| | | |
| | | @Resource |
| | | private IMdcAlarmInfoService mdcAlarmInfoService; |
| | | |
| | | @Resource |
| | | private DtBoardMapper dtBoardMapper; |
| | | |
| | | /** |
| | | * 车é´ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public List<MdcProduction> productionList() { |
| | | return mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, CommonConstant.ORG_TYPE_2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0).orderByAsc(MdcProduction::getProductionOrder)); |
| | | } |
| | | |
| | | /** |
| | | * è®¾å¤æåº¦å©ç¨ç |
| | | */ |
| | | @Override |
| | | public List<EquUtilRateMonth> equipmentMonthUtilizationRate(String productionId) { |
| | | // ç»è£
è¿åæ°æ® |
| | | LocalDate now = LocalDate.now(); |
| | | Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE); |
| | | Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); |
| | | List<String> monthBetween = DateUtils.getMonthBetween(start, end); |
| | | Map<String, EquUtilRateMonth> resultMap = monthBetween.stream().collect(Collectors.toMap( |
| | | date -> date, |
| | | date -> new EquUtilRateMonth(date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "æ"), |
| | | (existing, replacement) -> existing, // å¤çé®å²çªçå并彿°ï¼é常ä¸ä¼å²çªï¼ |
| | | LinkedHashMap::new // æå®ä½¿ç¨LinkedHashMapä¿ææå
¥é¡ºåº |
| | | )); |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquIdsByProIds(proIds); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | for (String month : monthBetween) { |
| | | MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findByEquIdsAndMonth(equipmentIdList, month.replaceAll("-", "")); |
| | | if (mdcEquipmentStatisticalInfo != null) { |
| | | if (resultMap.containsKey(month)) { |
| | | EquUtilRateMonth equUtilRateMonth = resultMap.get(month); |
| | | if (mdcEquipmentStatisticalInfo.getProcessLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | equUtilRateMonth.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | resultMap.put(month, equUtilRateMonth); |
| | | } |
| | | } |
| | | } |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | |
| | | /** |
| | | * 设å¤å©ç¨ç(æ¨å¤©) |
| | | */ |
| | | @Override |
| | | public List<EquUtilRate> equipmentUtilizationRate(String productionId) { |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquIdsByProIds(proIds); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return null; |
| | | } |
| | | Map<String, EquUtilRate> resultMap = new LinkedHashMap<>(); |
| | | equipmentIdList.forEach(equipmentId -> { |
| | | EquUtilRate equUtilRate = new EquUtilRate(equipmentId); |
| | | resultMap.put(equipmentId, equUtilRate); |
| | | }); |
| | | String yesterday = LocalDate.now().plusDays(-1).toString(); |
| | | List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfoList = mdcEquipmentStatisticalInfoService.findByEquipmentAndDate(equipmentIdList, yesterday.replaceAll("-", "")); |
| | | if (mdcEquipmentStatisticalInfoList != null && !mdcEquipmentStatisticalInfoList.isEmpty()) { |
| | | mdcEquipmentStatisticalInfoList.forEach(mdcEquipmentStatisticalInfo -> { |
| | | if (resultMap.containsKey(mdcEquipmentStatisticalInfo.getEquipmentId())) { |
| | | EquUtilRate equUtilRate = resultMap.get(mdcEquipmentStatisticalInfo.getEquipmentId()); |
| | | if (mdcEquipmentStatisticalInfo.getProcessLong().compareTo(BigDecimal.ZERO) > 0) { |
| | | equUtilRate.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | resultMap.put(mdcEquipmentStatisticalInfo.getEquipmentId(), equUtilRate); |
| | | } |
| | | }); |
| | | } |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | |
| | | /** |
| | | * æåº¦è®¾å¤ç»¼åæç |
| | | */ |
| | | @Override |
| | | public List<EquOeeMonth> equipmentMonthOee(String productionId) { |
| | | LocalDate now = LocalDate.now(); |
| | | Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE); |
| | | Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); |
| | | List<String> monthBetween = DateUtils.getMonthBetween(start, end); |
| | | Map<String, EquOeeMonth> resultMap = monthBetween.stream().collect(Collectors.toMap( |
| | | date -> date, |
| | | date -> new EquOeeMonth(date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "æ"), |
| | | (existing, replacement) -> existing, // å¤çé®å²çªçå并彿°ï¼é常ä¸ä¼å²çªï¼ |
| | | LinkedHashMap::new // æå®ä½¿ç¨LinkedHashMapä¿ææå
¥é¡ºåº |
| | | )); |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquIdsByProIds(proIds); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | for (String month : monthBetween) { |
| | | BigDecimal oee = mdcOeeInfoService.findByEquIdAndMonth(equipmentIdList, month); |
| | | if (oee != null) { |
| | | EquOeeMonth equOeeMonth = resultMap.get(month); |
| | | equOeeMonth.setOee(oee.setScale(2, RoundingMode.HALF_UP)); |
| | | resultMap.put(month, equOeeMonth); |
| | | } |
| | | } |
| | | return new ArrayList<>(resultMap.values()); |
| | | } |
| | | |
| | | /** |
| | | * 设å¤ç¶æç»è®¡ |
| | | */ |
| | | @Override |
| | | public EquOperation equipmentOperationStatistics(String productionId) { |
| | | EquOperation equOperation = new EquOperation(); |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return equOperation; |
| | | } |
| | | List<Equipment> equipmentList = equipmentService.listByProds(proIds); |
| | | if (equipmentList == null || equipmentList.isEmpty()) { |
| | | return equOperation; |
| | | } |
| | | for (Equipment equipment : equipmentList) { |
| | | if (equipment.getOporation() != null) { |
| | | switch (equipment.getOporation()) { |
| | | case 1: |
| | | case 2: |
| | | equOperation.setStandby(equOperation.getStandby() + 1); |
| | | break; |
| | | case 3: |
| | | equOperation.setRun(equOperation.getRun() + 1); |
| | | break; |
| | | case 22: |
| | | equOperation.setAlarm(equOperation.getAlarm() + 1); |
| | | break; |
| | | default: |
| | | equOperation.setShutdown(equOperation.getShutdown() + 1); |
| | | break; |
| | | } |
| | | } else { |
| | | equOperation.setShutdown(equOperation.getShutdown() + 1); |
| | | } |
| | | } |
| | | return equOperation; |
| | | } |
| | | |
| | | /** |
| | | * 设å¤è¿è¡ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public List<EquRunInfo> equipmentRunInfo(String equipmentId) { |
| | | List<EquRunInfo> equRunInfoList = new ArrayList<>(); |
| | | Equipment equipment = equipmentService.findByEquId(equipmentId); |
| | | if (equipment != null) { |
| | | //å¡«å
设å¤åºç¡ä¿¡æ¯ |
| | | equRunInfoList.add(new EquRunInfo("设å¤åç§°", equipment.getEquipmentname(), "")); |
| | | equRunInfoList.add(new EquRunInfo("设å¤ç¼å·", equipment.getEquipmentid(), "")); |
| | | if (equipment.getOporation() != null && equipment.getOporation() != 0) { |
| | | String saveTableName = equipment.getSavetablename(); |
| | | Map<String, Object> mapData = equipmentWorkLineService.getDataList(saveTableName); |
| | | if (mapData != null) { |
| | | //è·å MDC 驱å¨å¯¹åºçå±ç¤ºåæ° å¹¶æ ¹æ®key æ¼è£
ä» workData æ¥è¯¢çæ°æ® |
| | | List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(equipment.getDrivetype()); |
| | | if (mdcDriveTypeParamList != null && !mdcDriveTypeParamList.isEmpty()) { |
| | | List<DictModel> dictItems = sysDictService.getDictItems(CommonConstant.DICT_EQUIPMENT_RUN_UNIT); |
| | | Map<String, DictModel> resultMap = new HashMap<>(); |
| | | dictItems.forEach(dictModel -> { |
| | | resultMap.put(dictModel.getText(), dictModel); |
| | | }); |
| | | for (MdcDriveTypeParamConfig mdcDriveTypeParamConfig : mdcDriveTypeParamList) { |
| | | EquRunInfo equRunInfo = new EquRunInfo(); |
| | | String englishName = mdcDriveTypeParamConfig.getEnglishName(); |
| | | String chineseName = mdcDriveTypeParamConfig.getChineseName(); |
| | | equRunInfo.setKey(chineseName); |
| | | if (mapData.containsKey(englishName)) { |
| | | Object object = mapData.get(englishName); |
| | | String value = ""; |
| | | if ("CollectTime".equals(englishName)) { |
| | | Date date = object == null ? null : (Date) object; |
| | | value = DateUtils.format(date, DateUtils.STR_DATE_TIME_SMALL); |
| | | } else if ("ZUOLAN".equals(equipment.getDrivetype()) && "spindlespeed".equals(englishName) && equipment.getOporation() == 3) { |
| | | // ZUOLAN设å¤ä¸»è½´è½¬éåæ®µspindlespeed |
| | | value = String.valueOf(((new Random().nextInt(35)) + 1) * 100); |
| | | } else if ("ZUOLAN".equals(equipment.getDrivetype()) && "spindleload".equals(englishName) && equipment.getOporation() == 3) { |
| | | // ZUOLAN设å¤ä¸»è½´è´è·å段spindleload |
| | | value = String.valueOf(Integer.valueOf(new Random().nextInt(21))); |
| | | } else if ("ZUOLAN".equals(equipment.getDrivetype()) && "spindlebeilv".equals(englishName) && equipment.getOporation() == 3) { |
| | | // ZUOLAN设å¤ä¸»è½´åçåæ®µspindlebeilv |
| | | value = String.valueOf((new Random().nextInt(13)) * 10); |
| | | } else if ("ZUOLAN".equals(equipment.getDrivetype()) && "feedbeilv".equals(englishName) && equipment.getOporation() == 3) { |
| | | // ZUOLAN设å¤è¿ç»åçåæ®µfeedbeilv |
| | | value = String.valueOf((new Random().nextInt(13)) * 10); |
| | | } else { |
| | | value = object == null ? "" : object.toString(); |
| | | } |
| | | equRunInfo.setValue(value); |
| | | // 设置åä½ |
| | | if (resultMap.containsKey(chineseName)) { |
| | | DictModel dictModel = resultMap.get(chineseName); |
| | | equRunInfo.setUnit(dictModel.getValue()); |
| | | } |
| | | equRunInfoList.add(equRunInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return equRunInfoList; |
| | | } |
| | | |
| | | /** |
| | | * 设å¤åæºç»è®¡ |
| | | */ |
| | | @Override |
| | | public List<EquDowntimeInfo> equDowntimeStatistics(String productionId) { |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquIdsByProIds(proIds); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return null; |
| | | } |
| | | LocalDate end = LocalDate.now(); |
| | | LocalDate start = end.plusDays(-30); |
| | | List<EquDowntimeInfo> result = mdcDowntimeService.equDowntimeStatistics(equipmentIdList, start.toString(), end.toString()); |
| | | result.forEach(equDowntimeInfo -> { |
| | | equDowntimeInfo.setDuration(equDowntimeInfo.getDuration().setScale(2, RoundingMode.HALF_UP)); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è®¾å¤æ¥è¦å表 |
| | | */ |
| | | @Override |
| | | public List<EquAlarm> equAlarmList(String productionId) { |
| | | List<EquAlarm> result = new ArrayList<>(); |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquIdsByProIds(proIds); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<EquipmentAlarm> equipmentAlarmList = equipmentAlarmService.list(new LambdaQueryWrapper<EquipmentAlarm>().in(EquipmentAlarm::getEquipmentid, equipmentIdList).orderByDesc(EquipmentAlarm::getCollecttime).isNotNull(EquipmentAlarm::getAlarmNo).last("TOP 15")); |
| | | if (equipmentAlarmList == null || equipmentAlarmList.isEmpty()) { |
| | | return null; |
| | | } |
| | | for (EquipmentAlarm equipmentAlarm : equipmentAlarmList) { |
| | | MdcAlarmInfo mdcAlarmInfo = mdcAlarmInfoService.findAlarmContent(equipmentAlarm.getAlarmNo(), equipmentAlarm.getEquipmentid()); |
| | | EquAlarm equAlarm = new EquAlarm(); |
| | | equAlarm.setEquipmentId(equipmentAlarm.getEquipmentid()); |
| | | if (mdcAlarmInfo != null) { |
| | | equAlarm.setAlarmInfo(mdcAlarmInfo.getAlarmContent()); |
| | | } else { |
| | | equAlarm.setAlarmInfo(equipmentAlarm.getAlarmContent()); |
| | | } |
| | | result.add(equAlarm); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è®¾å¤æ
é |
| | | * @param productionId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EquRepair> equRepairList(String productionId) { |
| | | List<String> proIds = mdcProductionService.findChildByProId(productionId); |
| | | if (proIds == null || proIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> equipmentIdList = mdcEquipmentService.getEquIdsByProIds(proIds); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return null; |
| | | } |
| | | LocalDateTime currentDate = LocalDate.now().minusMonths(1).atStartOfDay(); |
| | | String format = currentDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | List<EquRepair> result = dtBoardMapper.equRepairList(equipmentIdList, format); |
| | | return result; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-09 |
| | | * @Description: è®¾å¤æ¥è¦ä¿¡æ¯ |
| | | */ |
| | | @Data |
| | | public class EquAlarm { |
| | | |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | private String equipmentId; |
| | | /** |
| | | * æ¥è¦ä¿¡æ¯ |
| | | */ |
| | | private String alarmInfo; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-09 |
| | | * @Description: 设å¤åæºç»è®¡ |
| | | */ |
| | | @Data |
| | | public class EquDowntimeInfo { |
| | | |
| | | /** |
| | | * åæºåå |
| | | */ |
| | | private String shutdownInfo; |
| | | /** |
| | | * åæºæ¶é¿ |
| | | */ |
| | | private BigDecimal duration; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-05-30 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class EquOeeMonth { |
| | | private String month; |
| | | private BigDecimal oee = BigDecimal.ZERO; |
| | | |
| | | public EquOeeMonth(String month) { |
| | | this.month = month; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-06 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class EquOperation { |
| | | private Integer shutdown = 0; |
| | | private Integer alarm = 0; |
| | | private Integer standby = 0; |
| | | private Integer run = 0; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-10 |
| | | * @Description: è®¾å¤æ
é |
| | | */ |
| | | @Data |
| | | public class EquRepair { |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | private String equipmentId; |
| | | /** |
| | | * æ
鿬¡æ° |
| | | */ |
| | | private BigDecimal faultNum; |
| | | /** |
| | | * æ
éæ¶é¿ |
| | | */ |
| | | private BigDecimal faultTime; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-06 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class EquRunInfo { |
| | | private String key; |
| | | private String value; |
| | | private String unit; |
| | | |
| | | public EquRunInfo() { |
| | | } |
| | | |
| | | public EquRunInfo(String key, String value, String unit) { |
| | | this.key = key; |
| | | this.value = value; |
| | | this.unit = unit; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-05 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class EquStatus { |
| | | private String equipmentId; |
| | | private Integer state; |
| | | private String plantName; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-05-30 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class EquUtilRate { |
| | | private String deviceNum; |
| | | private BigDecimal utilizationRate = BigDecimal.ZERO; |
| | | |
| | | public EquUtilRate(String deviceNum) { |
| | | this.deviceNum = deviceNum; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.board.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-05-30 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class EquUtilRateMonth { |
| | | private String month; |
| | | private BigDecimal utilizationRate = BigDecimal.ZERO; |
| | | |
| | | public EquUtilRateMonth(String month) { |
| | | this.month = month; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.modules.mdc.entity.AndonOrder; |
| | | import org.jeecg.modules.mdc.service.IAndonOrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="andon_order") |
| | | @RestController |
| | | @RequestMapping("/AndonOrder/andonOrder") |
| | | @Slf4j |
| | | public class AndonOrderController extends JeecgController<AndonOrder, IAndonOrderService> { |
| | | @Autowired |
| | | private IAndonOrderService andonOrderService; |
| | | |
| | | /** |
| | | * ç¨åºå¼å« |
| | | * |
| | | * @param andonOrder |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å®ç¯å·¥å-ç¨åºå¼å«") |
| | | @ApiOperation(value = "å®ç¯å·¥å-ç¨åºå¼å«", notes = "å®ç¯å·¥å-ç¨åºå¼å«") |
| | | @PostMapping(value = "/procedureCall") |
| | | public Result<?> procedureCall(@RequestBody AndonOrder andonOrder) { |
| | | andonOrderService.procedureCall(andonOrder); |
| | | return Result.OK("å¼å«æåï¼"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.modules.mdc.entity.MdcEquipmentPunch; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentPunchService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: mdc_equipment_punch |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="ä¸ä¸çæå¡è®°å½è¡¨") |
| | | @RestController |
| | | @RequestMapping("/mdcEquipmentPunch") |
| | | @Slf4j |
| | | public class MdcEquipmentPunchController extends JeecgController<MdcEquipmentPunch, IMdcEquipmentPunchService> { |
| | | @Autowired |
| | | private IMdcEquipmentPunchService mdcEquipmentPunchService; |
| | | |
| | | private static final String msg = "æå¡æåï¼"; |
| | | |
| | | /** |
| | | * æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ
åµ |
| | | * |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ
åµ", notes="æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ
åµ") |
| | | @GetMapping(value = "/list") |
| | | public Result<List<MdcEquipmentPunch>> queryList() { |
| | | return Result.OK(mdcEquipmentPunchService.queryList()); |
| | | } |
| | | |
| | | /** |
| | | * ä¸çæå¡ |
| | | * |
| | | * @param mdcEquipmentPunch |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "ä¸çæå¡") |
| | | @ApiOperation(value="ä¸çæå¡", notes="ä¸çæå¡") |
| | | @PostMapping(value = "/workUp") |
| | | public Result<String> workUp(@RequestBody MdcEquipmentPunch mdcEquipmentPunch) { |
| | | mdcEquipmentPunchService.workUp(mdcEquipmentPunch); |
| | | return Result.OK(msg); |
| | | } |
| | | |
| | | /** |
| | | * ä¸çæå¡ |
| | | * |
| | | * @param mdcEquipmentPunch |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "ä¸çæå¡") |
| | | @ApiOperation(value="ä¸çæå¡", notes="ä¸çæå¡") |
| | | @PostMapping(value = "/workDown") |
| | | public Result<String> workDown(@RequestBody MdcEquipmentPunch mdcEquipmentPunch) { |
| | | mdcEquipmentPunchService.workDown(mdcEquipmentPunch); |
| | | return Result.OK(msg); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("andon_order") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value = "andon_order对象", description = "andon_order") |
| | | public class AndonOrder implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "主é®") |
| | | private String id; |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | @Excel(name = "设å¤ç¼å·", width = 15) |
| | | @ApiModelProperty(value = "设å¤ç¼å·") |
| | | private String equipmentId; |
| | | /** |
| | | * æå±åæ¿ |
| | | */ |
| | | @Excel(name = "æå±åæ¿", width = 15) |
| | | @ApiModelProperty(value = "æå±åæ¿") |
| | | private String plantName; |
| | | /** |
| | | * å®ç¯ç±»å |
| | | */ |
| | | @Excel(name = "å®ç¯ç±»å", width = 15) |
| | | @ApiModelProperty(value = "å®ç¯ç±»å") |
| | | private String andonType; |
| | | /** |
| | | * å®ç¯äºº(å¼å«äºº) |
| | | */ |
| | | @Excel(name = "å®ç¯äºº", width = 15) |
| | | @ApiModelProperty(value = "å®ç¯äºº") |
| | | private String operator; |
| | | /** |
| | | * å¼å«åå |
| | | */ |
| | | @Excel(name = "å¼å«åå ", width = 15) |
| | | @ApiModelProperty(value = "å¼å«åå ") |
| | | private String callReason; |
| | | /** |
| | | * å®ç¯æ¶é´ |
| | | */ |
| | | @Excel(name = "å®ç¯æ¶é´", width = 15, format = DatePattern.NORM_DATETIME_PATTERN) |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "å®ç¯æ¶é´") |
| | | private Date operateTime; |
| | | /** |
| | | * ååºäºº(责任人) |
| | | */ |
| | | @Excel(name = "ååºäºº", width = 15) |
| | | @ApiModelProperty(value = "ååºäºº") |
| | | private String responder; |
| | | /** |
| | | * ååºæ¶é´ |
| | | */ |
| | | @Excel(name = "ååºæ¶é´", width = 15, format = DatePattern.NORM_DATETIME_PATTERN) |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "ååºæ¶é´") |
| | | private Date responseTime; |
| | | /** |
| | | * å¤ç人 |
| | | */ |
| | | @Excel(name = "å¤ç人", width = 15) |
| | | @ApiModelProperty(value = "å¤ç人") |
| | | private String processor; |
| | | /** |
| | | * å¤ç宿æ¶é´ |
| | | */ |
| | | @Excel(name = "å¤ç宿æ¶é´", width = 15, format = DatePattern.NORM_DATETIME_PATTERN) |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "å¤ç宿æ¶é´") |
| | | private Date processTime; |
| | | /** |
| | | * å®ç¯ç¶æ;å¾
ååºãå¾
å¤çã已宿 |
| | | */ |
| | | @Excel(name = "å®ç¯ç¶æ;å¾
ååºãå¾
å¤çã已宿", width = 15) |
| | | @ApiModelProperty(value = "å®ç¯ç¶æ;å¾
ååºãå¾
å¤çã已宿") |
| | | private String orderStatus; |
| | | /** |
| | | * é®é¢æè¿° |
| | | */ |
| | | @Excel(name = "é®é¢æè¿°", width = 15) |
| | | @ApiModelProperty(value = "é®é¢æè¿°") |
| | | private String problemDescreption; |
| | | /** |
| | | * å¤çç»ææè¿° |
| | | */ |
| | | @Excel(name = "å¤çç»ææè¿°", width = 15) |
| | | @ApiModelProperty(value = "å¤çç»ææè¿°") |
| | | private String resolutionDescreption; |
| | | /** |
| | | * å¤çç»æå¾ç |
| | | */ |
| | | @Excel(name = "å¤çç»æå¾ç", width = 15) |
| | | @ApiModelProperty(value = "å¤çç»æå¾ç") |
| | | private String imageFiles; |
| | | /** |
| | | * å 餿 è®° |
| | | */ |
| | | @Excel(name = "å 餿 è®°", width = 15) |
| | | @ApiModelProperty(value = "å 餿 è®°") |
| | | @TableLogic |
| | | private Integer delFlag; |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty(value = "å建人") |
| | | private String createBy; |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private Date createTime; |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @ApiModelProperty(value = "æ´æ°äºº") |
| | | private String updateBy; |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * @Description: mdc_equipment_punch |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("mdc_equipment_punch") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value = "mdc_equipment_punch对象", description = "mdc_equipment_punch") |
| | | public class MdcEquipmentPunch implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "id") |
| | | private String id; |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | @Excel(name = "设å¤ç¼å·", width = 15) |
| | | @ApiModelProperty(value = "设å¤ç¼å·") |
| | | private String equipmentId; |
| | | /** |
| | | * æå¡ç¨æ· |
| | | */ |
| | | @Excel(name = "æå¡ç¨æ·", width = 15) |
| | | @ApiModelProperty(value = "æå¡ç¨æ·") |
| | | private String punchUser; |
| | | /** |
| | | * æå¡ç¨æ·è´¦å· |
| | | */ |
| | | @Excel(name = "æå¡ç¨æ·è´¦å·", width = 15) |
| | | @ApiModelProperty(value = "æå¡ç¨æ·è´¦å·") |
| | | @TableField(exist = false) |
| | | private String punchUserRealName; |
| | | /** |
| | | * æå¡ç¨æ·åç§° |
| | | */ |
| | | @Excel(name = "æå¡ç¨æ·åç§°", width = 15) |
| | | @ApiModelProperty(value = "æå¡ç¨æ·åç§°") |
| | | @TableField(exist = false) |
| | | private String punchUserUserName; |
| | | /** |
| | | * ä¸çæ¶é´ |
| | | */ |
| | | @Excel(name = "ä¸çæ¶é´", width = 15, format = DatePattern.NORM_DATETIME_PATTERN) |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "ä¸çæ¶é´") |
| | | private Date checkInTime; |
| | | /** |
| | | * ä¸çæ¶é´ |
| | | */ |
| | | @Excel(name = "ä¸çæ¶é´", width = 15, format = DatePattern.NORM_DATETIME_PATTERN) |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "ä¸çæ¶é´") |
| | | private Date checkOutTime; |
| | | /** |
| | | * è®°å½æ¥æ |
| | | */ |
| | | @Excel(name = "è®°å½æ¥æ", width = 15) |
| | | @ApiModelProperty(value = "è®°å½æ¥æ") |
| | | private String recordDate; |
| | | /** |
| | | * çæ¬¡ |
| | | */ |
| | | @Excel(name = "çæ¬¡", width = 15) |
| | | @ApiModelProperty(value = "çæ¬¡") |
| | | @Dict(dicCode = "shift_schedule") |
| | | private Integer shiftSchedule; |
| | | /** |
| | | * çæ¬¡åç§° |
| | | */ |
| | | @Excel(name = "çæ¬¡åç§°", width = 15) |
| | | @ApiModelProperty(value = "çæ¬¡åç§°") |
| | | @TableField(exist = false) |
| | | private String shiftScheduleName; |
| | | /** |
| | | * æ¯å¦ç¼ºå¡ |
| | | */ |
| | | @Excel(name = "æ¯å¦ç¼ºå¡", width = 15) |
| | | @ApiModelProperty(value = "æ¯å¦ç¼ºå¡") |
| | | private Integer isAbsent; |
| | | /** |
| | | * æ¯å¦è¿å° |
| | | */ |
| | | @Excel(name = "æ¯å¦è¿å°", width = 15) |
| | | @ApiModelProperty(value = "æ¯å¦è¿å°") |
| | | private Integer isLate; |
| | | /** |
| | | * æ¯å¦æ©é |
| | | */ |
| | | @Excel(name = "æ¯å¦æ©é", width = 15) |
| | | @ApiModelProperty(value = "æ¯å¦æ©é") |
| | | private Integer isEarly; |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty(value = "å建人") |
| | | private String createBy; |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private Date createTime; |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @ApiModelProperty(value = "æ´æ°äºº") |
| | | private String updateBy; |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.job; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.constant.WebsocketConst; |
| | | import org.jeecg.common.util.RedisUtil; |
| | | import org.jeecg.modules.board.vo.EquStatus; |
| | | import org.jeecg.modules.mdc.entity.Equipment; |
| | | import org.jeecg.modules.mdc.service.IEquipmentService; |
| | | import org.jeecg.modules.mdc.util.ThrowableUtil; |
| | | import org.jeecg.modules.message.websocket.WebSocket; |
| | | import org.jeecg.modules.quartz.entity.QuartzJob; |
| | | import org.jeecg.modules.quartz.entity.SysQuartzLog; |
| | | import org.jeecg.modules.quartz.service.IQuartzJobService; |
| | | import org.jeecg.modules.quartz.service.ISysQuartzLogService; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.quartz.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: Lius |
| | | * @CreateTime: 2025-06-05 |
| | | * @Description: websocketæ¨é设å¤ç¶æä»»å¡ |
| | | */ |
| | | @DisallowConcurrentExecution |
| | | @Slf4j |
| | | public class WebsocketPushEquStatusJob implements Job { |
| | | |
| | | @Resource |
| | | private IQuartzJobService quartzJobService; |
| | | |
| | | @Resource |
| | | private ISysQuartzLogService sysQuartzLogService; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private WebSocket webSocket; |
| | | |
| | | @Resource |
| | | private IEquipmentService equipmentService; |
| | | |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | final private static String redisKey = "board:equipment:status:"; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | | SysQuartzLog quartzLog = new SysQuartzLog(); |
| | | quartzLog.setCreateTime(new Date()); |
| | | List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); |
| | | if (byJobClassName != null && !byJobClassName.isEmpty()) { |
| | | quartzLog.setJobId(byJobClassName.get(0).getId()); |
| | | } |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | List<Equipment> equipmentList = equipmentService.list(); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | List<EquStatus> equStatusList = new ArrayList<>(); |
| | | for (Equipment equipment : equipmentList) { |
| | | if (equipment.getOporation() == null) { |
| | | equipment.setOporation(0); |
| | | } |
| | | String key = redisKey + equipment.getEquipmentid(); |
| | | if (redisUtil.hasKey(key)) { |
| | | Integer status = (Integer) redisUtil.get(key); |
| | | if (!status.equals(equipment.getOporation())) { |
| | | EquStatus equStatus = new EquStatus(); |
| | | equStatus.setEquipmentId(equipment.getEquipmentid()); |
| | | equStatus.setState(equipment.getOporation()); |
| | | // éè¿equipmentIdè·å设å¤è½¦é´åç§° |
| | | String productionName = mdcProductionService.findProName(equipment.getEquipmentid()); |
| | | equStatus.setPlantName(productionName); |
| | | equStatusList.add(equStatus); |
| | | redisUtil.set(key, equipment.getOporation()); |
| | | } |
| | | } else { |
| | | EquStatus equStatus = new EquStatus(); |
| | | equStatus.setEquipmentId(equipment.getEquipmentid()); |
| | | equStatus.setState(equipment.getOporation()); |
| | | // éè¿equipmentIdè·å设å¤è½¦é´åç§° |
| | | String productionName = mdcProductionService.findProName(equipment.getEquipmentid()); |
| | | equStatus.setPlantName(productionName); |
| | | equStatusList.add(equStatus); |
| | | redisUtil.set(key, equipment.getOporation()); |
| | | } |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put(WebsocketConst.MSG_CMD, "equStatus"); |
| | | jsonObject.put("data", equStatusList); |
| | | webSocket.sendMessage(jsonObject.toJSONString()); |
| | | } |
| | | quartzLog.setIsSuccess(0); |
| | | } catch (Exception e) { |
| | | quartzLog.setIsSuccess(-1); |
| | | quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); |
| | | } |
| | | long endTime = System.currentTimeMillis(); |
| | | quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); |
| | | sysQuartzLogService.save(quartzLog); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.jeecg.modules.mdc.entity.AndonOrder; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface AndonOrderMapper extends BaseMapper<AndonOrder> { |
| | | |
| | | } |
| | |
| | | package org.jeecg.modules.mdc.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.mdc.entity.MdcAlarmInfo; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public interface MdcAlarmInfoMapper extends BaseMapper<MdcAlarmInfo> { |
| | | |
| | | MdcAlarmInfo findAlarmContent(@Param("alarmNo") String alarmNo, @Param("equipmentId") String equipmentId); |
| | | } |
| | |
| | | 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.board.vo.EquDowntimeInfo; |
| | | import org.jeecg.modules.mdc.dto.MdcDowntimeDto; |
| | | import org.jeecg.modules.mdc.entity.MdcDowntime; |
| | | import org.jeecg.modules.mdc.vo.MdcDowntimeVo; |
| | |
| | | IPage<MdcDowntimeDto> pageList(Page<MdcDowntimeDto> page, @Param("mdcDowntimeVo") MdcDowntimeVo mdcDowntimeVo); |
| | | |
| | | List<MdcDowntime> findPlanTimeDuration(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate, @Param("closeType") String closeType); |
| | | |
| | | List<EquDowntimeInfo> equDowntimeStatistics(@Param("equipmentIdList") List<String> equipmentIdList, @Param("start") String start, @Param("end") String end); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentPunch; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: mdc_equipment_punch |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface MdcEquipmentPunchMapper extends BaseMapper<MdcEquipmentPunch> { |
| | | |
| | | List<MdcEquipmentPunch> list(@Param("equipmentIds") List<String> equipmentIds, @Param("date") String date); |
| | | } |
| | |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: 设å¤åæ¥è¿è¡æ°æ®è¡¨ |
| | | * @Author: jeecg-boot |
| | |
| | | Integer selectProcessLong(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate); |
| | | |
| | | MdcEquipmentStatisticalDto findByEquipmentAndMonth(@Param("equipmentId") String equipmentId, @Param("date") String date); |
| | | |
| | | MdcEquipmentStatisticalInfo findByEquIdsAndMonth(@Param("equipmentIdList") List<String> equipmentIdList, @Param("month") String month); |
| | | |
| | | List<MdcEquipmentStatisticalInfo> findByEquipmentAndDate(@Param("equipmentIdList") List<String> equipmentIdList, @Param("date") String date); |
| | | } |
| | |
| | | import org.jeecg.modules.mdc.entity.MdcOeeInfo; |
| | | import org.jeecg.modules.mdc.vo.MdcOeeInfoVo; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: OEE表 |
| | | * @Author: lius |
| | |
| | | * @return |
| | | */ |
| | | IPage<MdcOeeInfo> pageList(Page<MdcOeeInfo> page, @Param("mdcOeeInfoVo") MdcOeeInfoVo mdcOeeInfoVo); |
| | | |
| | | BigDecimal findByEquIdAndMonth(@Param("equipmentIdList") List<String> equipmentIdList, @Param("month") String month); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.AndonOrderMapper"> |
| | | |
| | | </mapper> |
| | |
| | | <!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.MdcAlarmInfoMapper"> |
| | | |
| | | <select id="findAlarmContent" resultType="org.jeecg.modules.mdc.entity.MdcAlarmInfo"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | mdc_alarm_info t1 |
| | | LEFT JOIN mdc_equipment t2 ON t1.drive_type = t2.drive_type |
| | | WHERE |
| | | t2.equipment_id = #{equipmentId} AND t1.alarm_code = #{alarmNo} |
| | | </select> |
| | | </mapper> |
| | |
| | | AND t2.downtime_type = #{closeType} |
| | | AND t1.the_date = #{validDate} |
| | | </select> |
| | | |
| | | <select id="equDowntimeStatistics" resultType="org.jeecg.modules.board.vo.EquDowntimeInfo"> |
| | | SELECT |
| | | t2.downtime_description AS shutdown_info, |
| | | SUM ( DATEDIFF( SECOND, t1.start_date, t1.end_date ) ) / 3600.0 AS duration_hours |
| | | FROM |
| | | mdc_downtime t1 |
| | | LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id |
| | | WHERE |
| | | t1.reason_id != '' |
| | | AND t1.the_date BETWEEN #{start} AND #{end} |
| | | AND t1.equipment_id IN |
| | | <foreach collection="equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=","> |
| | | #{ equipmentId } |
| | | </foreach> |
| | | GROUP BY |
| | | t2.downtime_description |
| | | ORDER BY |
| | | duration_hours DESC |
| | | </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.MdcEquipmentPunchMapper"> |
| | | |
| | | <select id="list" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentPunch"> |
| | | SELECT |
| | | p.id, |
| | | p.equipment_id, |
| | | p.punch_user, |
| | | p.check_in_time, |
| | | p.check_out_time, |
| | | p.record_date, |
| | | p.is_absent, |
| | | p.is_late, |
| | | p.is_early, |
| | | p.create_by, |
| | | p.create_time, |
| | | p.update_by, |
| | | p.update_time, |
| | | p.shift_schedule, |
| | | u.realname punchUserRealName, |
| | | u.username punchUserUserName, |
| | | d1.item_text shiftScheduleName |
| | | FROM |
| | | mdc_equipment_punch p |
| | | INNER JOIN sys_user u ON u.id = p.punch_user |
| | | INNER JOIN (SELECT i1.item_text, i1.item_value |
| | | FROM sys_dict_item i1 |
| | | LEFT JOIN sys_dict i2 ON i2.id = i1.dict_id |
| | | WHERE i2.dict_code = 'shift_schedule') d1 |
| | | ON d1.item_value = CAST (p.shift_schedule AS nvarchar) |
| | | where 1=1 |
| | | AND p.equipment_id IN |
| | | <foreach collection="equipmentIds" item="equipmentId" open="(" close=")" separator=","> |
| | | #{equipmentId} |
| | | </foreach> |
| | | <if test="date != null and date != ''"> |
| | | AND p.record_date = #{date} |
| | | </if> |
| | | order by p.equipment_id desc, p.shift_schedule asc |
| | | </select> |
| | | </mapper> |
| | |
| | | WHERE |
| | | equipment_id = #{equipmentId} AND the_date LIKE CONCAT(#{date}, '%') |
| | | </select> |
| | | |
| | | <select id="findByEquIdsAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> |
| | | SELECT |
| | | AVG(open_long) openLong, |
| | | AVG(close_long) closeLong, |
| | | AVG(wait_long) waitLong, |
| | | AVG(process_long) processLong, |
| | | AVG(error_long) errorLong |
| | | FROM |
| | | mdc_equipment_statistical_info |
| | | WHERE |
| | | equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | AND the_date LIKE CONCAT(#{month}, '%') |
| | | </select> |
| | | |
| | | <select id="findByEquipmentAndDate" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> |
| | | SELECT |
| | | * |
| | | FROM |
| | | mdc_equipment_statistical_info |
| | | WHERE |
| | | equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | AND the_date = #{date} |
| | | </select> |
| | | </mapper> |
| | |
| | | </where> |
| | | ORDER BY the_date DESC, equipment_id ASC |
| | | </select> |
| | | |
| | | <select id="findByEquIdAndMonth" resultType="java.math.BigDecimal"> |
| | | SELECT |
| | | AVG(oee) |
| | | FROM |
| | | mdc_oee_info |
| | | WHERE |
| | | the_date LIKE CONCAT(#{month}, '%') |
| | | AND equipment_id IN |
| | | <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> |
| | | #{ id } |
| | | </foreach> |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.mdc.entity.AndonOrder; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IAndonOrderService extends IService<AndonOrder> { |
| | | |
| | | void procedureCall(AndonOrder andonOrder); |
| | | } |
| | |
| | | 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.board.vo.EquDowntimeInfo; |
| | | import org.jeecg.modules.mdc.dto.MdcDowntimeDto; |
| | | import org.jeecg.modules.mdc.entity.MdcDowntime; |
| | | import org.jeecg.modules.mdc.vo.MdcDowntimeVo; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: å¾
æºåæºè¡¨ |
| | |
| | | * @return |
| | | */ |
| | | Integer findPlanTimeDuration(String equipmentId, String validDate, String closeType); |
| | | |
| | | List<EquDowntimeInfo> equDowntimeStatistics(List<String> equipmentIdList, String start, String end); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentPunch; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: mdc_equipment_punch |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IMdcEquipmentPunchService extends IService<MdcEquipmentPunch> { |
| | | |
| | | List<MdcEquipmentPunch> queryList(); |
| | | |
| | | void workUp(MdcEquipmentPunch mdcEquipmentPunch); |
| | | |
| | | void workDown(MdcEquipmentPunch mdcEquipmentPunch); |
| | | } |
| | |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: 设å¤åæ¥è¿è¡æ°æ®è¡¨ |
| | | * @Author: lius |
| | |
| | | Integer selectProcessLong(String equipmentId, String validDate); |
| | | |
| | | MdcEquipmentStatisticalDto findByEquipmentAndMonth(String equipmentId, String date); |
| | | |
| | | MdcEquipmentStatisticalInfo findByEquIdsAndMonth(List<String> equipmentIdList, String month); |
| | | |
| | | List<MdcEquipmentStatisticalInfo> findByEquipmentAndDate(List<String> equipmentIdList, String date); |
| | | } |
| | |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: OEE表 |
| | |
| | | */ |
| | | void computeOee(MdcOeeComputeVo mdcOeeComputeVo); |
| | | |
| | | BigDecimal findByEquIdAndMonth(List<String> equipmentIdList, String month); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.WebsocketConst; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.dto.MdcEquProDto; |
| | | import org.jeecg.modules.mdc.entity.AndonOrder; |
| | | import org.jeecg.modules.mdc.mapper.AndonOrderMapper; |
| | | import org.jeecg.modules.mdc.service.IAndonOrderService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.AndonOrderWebSocketVo; |
| | | import org.jeecg.modules.message.websocket.WebSocket; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: andon_order |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-11 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class AndonOrderServiceImpl extends ServiceImpl<AndonOrderMapper, AndonOrder> implements IAndonOrderService { |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | @Resource |
| | | private WebSocket webSocket; |
| | | @Resource |
| | | private ISysUserService userService; |
| | | @Override |
| | | public void procedureCall(AndonOrder andonOrder) { |
| | | if (StringUtils.isBlank(andonOrder.getEquipmentId())) { |
| | | throw new JeecgBootException("è¯·éæ©è®¾å¤ï¼"); |
| | | } |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | List<String> equipmentIds = Arrays.asList(andonOrder.getEquipmentId().split(StringPool.COMMA)); |
| | | |
| | | List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(equipmentIds); |
| | | Map<String, MdcEquProDto> equipmentIdToProductionIdMap = equipmentList.stream().collect(Collectors.toMap(MdcEquProDto::getEquipmentId, comRateDto -> comRateDto)); |
| | | List<AndonOrder> list = Lists.newArrayList(); |
| | | for (String equipmentId : equipmentIds) { |
| | | AndonOrder andonOrderInfo = new AndonOrder(); |
| | | andonOrderInfo.setEquipmentId(equipmentId); |
| | | andonOrderInfo.setPlantName(equipmentIdToProductionIdMap != null && equipmentIdToProductionIdMap.containsKey(equipmentId) ? equipmentIdToProductionIdMap.get(equipmentId).getId() : null); |
| | | andonOrderInfo.setAndonType(StringPool.ONE); |
| | | andonOrderInfo.setOperator(andonOrder.getOperator()); |
| | | andonOrderInfo.setOperateTime(new Date()); |
| | | andonOrderInfo.setResponder(userId); |
| | | andonOrderInfo.setCallReason(andonOrder.getCallReason()); |
| | | list.add(andonOrderInfo); |
| | | } |
| | | |
| | | if (this.saveBatch(list)) { |
| | | List<AndonOrderWebSocketVo> andonOrderWebSocketVoList = Lists.newArrayList(); |
| | | //设置websocketè¯·æ±æ¶æ¯æ°æ® |
| | | for (AndonOrder order : list) { |
| | | AndonOrderWebSocketVo andonOrderWebSocketVo = new AndonOrderWebSocketVo(); |
| | | andonOrderWebSocketVo.setEquipmentId(order.getEquipmentId()); |
| | | andonOrderWebSocketVo.setCallPersonnel(userService.getById(order.getOperator()).getRealname()); |
| | | andonOrderWebSocketVo.setCallTime(DateUtils.format(order.getOperateTime(), DatePattern.NORM_DATE_PATTERN)); |
| | | andonOrderWebSocketVo.setCallReason(order.getCallReason()); |
| | | andonOrderWebSocketVo.setAndonType("ç¨åºå¼å«"); |
| | | andonOrderWebSocketVo.setPersonResponsible(user.getRealname()); |
| | | andonOrderWebSocketVo.setPlantName(equipmentIdToProductionIdMap != null && equipmentIdToProductionIdMap.containsKey(order.getEquipmentId()) ? equipmentIdToProductionIdMap.get(order.getEquipmentId()).getProductionName() : null); |
| | | andonOrderWebSocketVoList.add(andonOrderWebSocketVo); |
| | | } |
| | | |
| | | //åéwebsocketè¯·æ± |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put(WebsocketConst.MSG_CMD, "andon"); |
| | | jsonObject.put("data", andonOrderWebSocketVoList); |
| | | webSocket.sendMessage(jsonObject.toJSONString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | @Service |
| | | public class MdcAlarmInfoServiceImpl extends ServiceImpl<MdcAlarmInfoMapper, MdcAlarmInfo> implements IMdcAlarmInfoService { |
| | | |
| | | @Override |
| | | public MdcAlarmInfo findAlarmContent(String alarmNo, String equipmentId) { |
| | | return this.baseMapper.findAlarmContent(alarmNo, equipmentId); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.modules.board.vo.EquDowntimeInfo; |
| | | import org.jeecg.modules.mdc.dto.MdcDowntimeDto; |
| | | import org.jeecg.modules.mdc.entity.MdcDowntime; |
| | | import org.jeecg.modules.mdc.mapper.MdcDowntimeMapper; |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<EquDowntimeInfo> equDowntimeStatistics(List<String> equipmentIdList, String start, String end) { |
| | | return this.baseMapper.equDowntimeStatistics(equipmentIdList, start, end); |
| | | } |
| | | |
| | | private List<String> getEquipmentIds(String userId, MdcDowntimeVo mdcDowntimeVo) { |
| | | if (StringUtils.isNotEmpty(mdcDowntimeVo.getEquipmentId())) { |
| | | return Collections.singletonList(mdcDowntimeVo.getEquipmentId()); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentPunch; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentPunchMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentPunchService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: mdc_equipment_punch |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class MdcEquipmentPunchServiceImpl extends ServiceImpl<MdcEquipmentPunchMapper, MdcEquipmentPunch> implements IMdcEquipmentPunchService { |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | /** |
| | | * æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ
åµ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipmentPunch> queryList() { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | List<String> equipmentIds = Lists.newArrayList(); |
| | | if (StringUtils.isNotBlank(user.getEquipmentIds())) { |
| | | equipmentIds = Arrays.asList(user.getEquipmentIds().split(StringPool.COMMA)); |
| | | }else { |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | |
| | | if (CollectionUtils.isEmpty(equipmentIds)) { |
| | | return Lists.newArrayList(); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(userId)) { |
| | | return Lists.newArrayList(); |
| | | } |
| | | |
| | | //æ ¹æ®è®¾å¤ãå½åæ¥ææ¥è¯¢æå¡è®°å½ |
| | | List<MdcEquipmentPunch> mdcEquipmentPunches = this.baseMapper.list(equipmentIds, DateUtils.format(new Date(), DatePattern.PURE_DATE_PATTERN)); |
| | | return mdcEquipmentPunches; |
| | | } |
| | | |
| | | /** |
| | | * ä¸çæå¡ |
| | | * @param mdcEquipmentPunch |
| | | */ |
| | | @Override |
| | | public void workUp(MdcEquipmentPunch mdcEquipmentPunch) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | |
| | | if (StringUtils.isBlank(mdcEquipmentPunch.getEquipmentId())) { |
| | | throw new JeecgBootException("è¯·éæ©æå¡è®¾å¤ï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦å¨æææå¡èå´ä¹å
|
| | | * æ©çä¸ç塿æèå´ä¸ºï¼00:00:00 ~ 17:30:00 |
| | | * æçä¸ç塿æèå´ä¸ºï¼00:00:00 ~ 23:00:00 |
| | | */ |
| | | Date startDate = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckInTime(), DatePattern.NORM_DATE_PATTERN) + " 00:00:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | Date endDate = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckInTime(), DatePattern.NORM_DATE_PATTERN) + " 17:30:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | if (mdcEquipmentPunch.getShiftSchedule() == 2) { |
| | | //æçæ ææå¡æ¶é´èå´ |
| | | endDate = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckInTime(), DatePattern.NORM_DATE_PATTERN) + " 23:00:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | } |
| | | |
| | | if (startDate.compareTo(mdcEquipmentPunch.getCheckInTime()) == 1 || endDate.compareTo(mdcEquipmentPunch.getCheckInTime()) == -1) { |
| | | throw new JeecgBootException("æªå¨ææä¸çæå¡æ¶é´å
ï¼ä¸è½æå¡ï¼"); |
| | | } |
| | | |
| | | //æ¥è¯¢æé设å¤å½å¤©æ¯å¦å·²æä¸çå¡ |
| | | List<String> equipmentIdList = Arrays.asList(mdcEquipmentPunch.getEquipmentId().split(StringPool.COMMA)); |
| | | String currentDate = DateUtils.format(mdcEquipmentPunch.getCheckInTime(), DatePattern.PURE_DATE_PATTERN); |
| | | |
| | | //æ©çä¸çæ£å¸¸æææå¡æ¶é´ |
| | | String checkInTime = DateUtils.format(mdcEquipmentPunch.getCheckInTime(), DatePattern.NORM_DATE_PATTERN) + " 08:30:00"; |
| | | |
| | | //æ¥è¯¢å½å设å¤ãå½åæå¡ç±»åæå¡è®°å½ |
| | | List<MdcEquipmentPunch> equipmentPunchList = this.list(new LambdaQueryWrapper<MdcEquipmentPunch>() |
| | | .eq(MdcEquipmentPunch::getShiftSchedule, mdcEquipmentPunch.getShiftSchedule()) |
| | | .eq(MdcEquipmentPunch::getRecordDate, currentDate) |
| | | .in(MdcEquipmentPunch::getEquipmentId, equipmentIdList)); |
| | | List<MdcEquipmentPunch> mdcEquipmentPunchList = equipmentPunchList.stream().filter(equipmentPunch -> Objects.nonNull(equipmentPunch.getCheckInTime())).collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(mdcEquipmentPunchList)) { |
| | | List<String> equipmentIds = equipmentPunchList.stream() |
| | | .filter(mdcEquipmentPunchInfo -> Objects.nonNull(mdcEquipmentPunchInfo.getCheckInTime())) |
| | | .map(MdcEquipmentPunch::getEquipmentId) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | throw new JeecgBootException("设å¤[" + StringUtils.join(equipmentIds, StringPool.COMMA) + "]å·²æå¡ï¼æ éé夿å¡"); |
| | | } |
| | | |
| | | List<MdcEquipmentPunch> list = Lists.newArrayList(); |
| | | |
| | | //ç¹æ®å¤çæçä¸çå¡ |
| | | if (mdcEquipmentPunch.getShiftSchedule() == 2) { |
| | | //æçæ£å¸¸ä¸ç塿ææå¡æ¶é´ |
| | | checkInTime = DateUtils.format(mdcEquipmentPunch.getCheckInTime(), DatePattern.NORM_DATE_PATTERN) + " 17:00:00"; |
| | | } |
| | | |
| | | |
| | | for (String equipment : equipmentIdList) { |
| | | Optional<MdcEquipmentPunch> first = equipmentPunchList.stream().filter(equipmentPunch -> Objects.isNull(equipmentPunch.getCheckInTime()) && equipment.equals(equipmentPunch.getEquipmentId())).findFirst(); |
| | | MdcEquipmentPunch equipmentPunch = new MdcEquipmentPunch(); |
| | | if (first.isPresent()) { |
| | | equipmentPunch = first.get(); |
| | | }else { |
| | | equipmentPunch.setEquipmentId(equipment); |
| | | equipmentPunch.setPunchUser(userId); |
| | | equipmentPunch.setRecordDate(currentDate); |
| | | equipmentPunch.setShiftSchedule(mdcEquipmentPunch.getShiftSchedule()); |
| | | equipmentPunch.setIsAbsent(0); |
| | | equipmentPunch.setIsEarly(0); |
| | | } |
| | | equipmentPunch.setCheckInTime(mdcEquipmentPunch.getCheckInTime()); |
| | | //æå¡æ¶é´å¤§äº8ï¼30/17:00æ¶ä¸ºè¿å°æå¡ |
| | | equipmentPunch.setIsLate(mdcEquipmentPunch.getCheckInTime().compareTo(DateUtils.getFormatDate(checkInTime, DatePattern.NORM_DATETIME_PATTERN)) == 1 ? 1 : 0); |
| | | |
| | | list.add(equipmentPunch); |
| | | } |
| | | this.saveOrUpdateBatch(list); |
| | | } |
| | | |
| | | @Override |
| | | public void workDown(MdcEquipmentPunch mdcEquipmentPunch) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | |
| | | if (StringUtils.isBlank(mdcEquipmentPunch.getEquipmentId())) { |
| | | throw new JeecgBootException("è¯·éæ©æå¡è®¾å¤ï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªå½åä¸ç塿¯å¦å¨ææä¸çæå¡èå´ä¹å
|
| | | * æ©çä¸çæ ææå¡æ¶é´èå´ä¸º00:00:00 ~ 08:30:00 |
| | | * æçä¸çæ ææå¡æ¶é´èå´ä¸º00:00:00 ~ 17:00:00 |
| | | */ |
| | | Date startDate = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckOutTime(), DatePattern.NORM_DATE_PATTERN) + " 00:00:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | Date endDate = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckOutTime(), DatePattern.NORM_DATE_PATTERN) + " 08:30:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | Date checkOutTime = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckOutTime(), DatePattern.NORM_DATE_PATTERN) + " 17:30:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | if (mdcEquipmentPunch.getShiftSchedule() == 2) { |
| | | //æçæ ææå¡æ¶é´èå´ |
| | | endDate = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckOutTime(), DatePattern.NORM_DATE_PATTERN) + " 17:00:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | //æçæ£å¸¸ä¸çææ©æå¡æ¶é´ |
| | | checkOutTime = DateUtils.getFormatDate( |
| | | DateUtils.format(mdcEquipmentPunch.getCheckOutTime(), DatePattern.NORM_DATE_PATTERN) + " 23:00:00", |
| | | DatePattern.NORM_DATETIME_PATTERN |
| | | ); |
| | | } |
| | | |
| | | if (startDate.compareTo(mdcEquipmentPunch.getCheckOutTime()) == 1 |
| | | || endDate.compareTo(mdcEquipmentPunch.getCheckOutTime()) == 1) { |
| | | throw new JeecgBootException("æªå¨ææä¸çæå¡æ¶é´å
ï¼ä¸è½æå¡ï¼"); |
| | | } |
| | | |
| | | //æ¥è¯¢å½åæéè®¾å¤æ¯å¦åå¨ä¸çæå¡è®°å½ |
| | | List<String> equipmentIdList = Arrays.asList(mdcEquipmentPunch.getEquipmentId().split(StringPool.COMMA)); |
| | | String currentDate = DateUtils.format(mdcEquipmentPunch.getCheckOutTime(), DatePattern.PURE_DATE_PATTERN); |
| | | List<MdcEquipmentPunch> equipmentPunchList = this.list(new LambdaQueryWrapper<MdcEquipmentPunch>() |
| | | .eq(MdcEquipmentPunch::getShiftSchedule, mdcEquipmentPunch.getShiftSchedule()) |
| | | .eq(MdcEquipmentPunch::getRecordDate, currentDate) |
| | | .in(MdcEquipmentPunch::getEquipmentId, equipmentIdList)); |
| | | |
| | | List<MdcEquipmentPunch> list = Lists.newArrayList(); |
| | | |
| | | for (String equipmentId : equipmentIdList) { |
| | | Optional<MdcEquipmentPunch> mdcEquipmentPunchOptional = equipmentPunchList.stream() |
| | | .filter(mdcEquipmentPunch1 -> mdcEquipmentPunch1.getEquipmentId().equals(equipmentId)) |
| | | .findFirst(); |
| | | MdcEquipmentPunch equipmentPunch = new MdcEquipmentPunch(); |
| | | if (mdcEquipmentPunchOptional.isPresent()) { |
| | | equipmentPunch = mdcEquipmentPunchOptional.get(); |
| | | }else { |
| | | equipmentPunch.setIsAbsent(1); |
| | | equipmentPunch.setIsLate(0); |
| | | equipmentPunch.setEquipmentId(equipmentId); |
| | | equipmentPunch.setShiftSchedule(mdcEquipmentPunch.getShiftSchedule()); |
| | | equipmentPunch.setPunchUser(userId); |
| | | equipmentPunch.setRecordDate(currentDate); |
| | | } |
| | | equipmentPunch.setCheckOutTime(mdcEquipmentPunch.getCheckOutTime()); |
| | | |
| | | //ä¸çæå¡æ¶é´æ©äº17:30/23:00å为æ©é |
| | | equipmentPunch.setIsEarly(checkOutTime.compareTo(mdcEquipmentPunch.getCheckOutTime()) == 1 ? 1 : 0); |
| | | list.add(equipmentPunch); |
| | | } |
| | | |
| | | this.saveOrUpdateBatch(list); |
| | | } |
| | | } |
| | |
| | | public MdcEquipmentStatisticalDto findByEquipmentAndMonth(String equipmentId, String date) { |
| | | return this.baseMapper.findByEquipmentAndMonth(equipmentId, date); |
| | | } |
| | | |
| | | @Override |
| | | public MdcEquipmentStatisticalInfo findByEquIdsAndMonth(List<String> equipmentIdList, String month) { |
| | | return this.baseMapper.findByEquIdsAndMonth(equipmentIdList, month); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcEquipmentStatisticalInfo> findByEquipmentAndDate(List<String> equipmentIdList, String date) { |
| | | return this.baseMapper.findByEquipmentAndDate(equipmentIdList, date); |
| | | } |
| | | } |
| | |
| | | super.saveBatch(result); |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal findByEquIdAndMonth(List<String> equipmentIdList, String month) { |
| | | return this.baseMapper.findByEquIdAndMonth(equipmentIdList, month); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class AndonOrderWebSocketVo { |
| | | |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | private String equipmentId; |
| | | |
| | | /** |
| | | * å¼å«äººå |
| | | */ |
| | | private String callPersonnel; |
| | | |
| | | /** |
| | | * å®ç¯ç±»å |
| | | */ |
| | | private String andonType; |
| | | |
| | | /** |
| | | * å¼å«æ¶é´ |
| | | */ |
| | | private String callTime; |
| | | |
| | | /** |
| | | * å¼å«åå |
| | | */ |
| | | private String callReason; |
| | | |
| | | /** |
| | | * 责任人 |
| | | */ |
| | | private String personResponsible; |
| | | |
| | | /** |
| | | * æ¥ä¿®æ¶é´ |
| | | */ |
| | | private String repairTime; |
| | | |
| | | /** |
| | | * æ
éæè¿° |
| | | */ |
| | | private String faultInfo; |
| | | |
| | | /** |
| | | * æå±åæ¿ |
| | | */ |
| | | private String plantName; |
| | | } |
| | |
| | | |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.ScheduledExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.annotation.Resource; |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.PathParam; |
| | |
| | | @Slf4j |
| | | @ServerEndpoint("/websocket/{userId}") |
| | | public class WebSocket { |
| | | |
| | | |
| | | /**线ç¨å®å
¨Map*/ |
| | | private static ConcurrentHashMap<String, Session> sessionPool = new ConcurrentHashMap<>(); |
| | | |
| | |
| | | @Resource |
| | | private JeecgRedisClient jeecgRedisClient; |
| | | |
| | | private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | |
| | | //==========ãwebsocketæ¥åãæ¨éæ¶æ¯çæ¹æ³ ââ å
·ä½æå¡èç¹æ¨éwsæ¶æ¯ã======================================================================================== |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session, @PathParam(value = "userId") String userId) { |
| | | try { |
| | | sessionPool.put(userId, session); |
| | | log.info("ãç³»ç» WebSocketãææ°çè¿æ¥ï¼æ»æ°ä¸º:" + sessionPool.size()); |
| | | |
| | | // å¯å¨å¿è·³ä»»å¡ï¼æ¯åéåé䏿¬¡å¿è·³æ¶æ¯ |
| | | // scheduler.scheduleAtFixedRate(() -> { |
| | | // pushMessage(userId, "{\"cmd\":\"" + WebsocketConst.CMD_USER + "\",\"txt\":\"" + "å¿è·³ååº" + "\"}"); |
| | | // }, 0, 1, TimeUnit.MINUTES); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("ãç³»ç» WebSocketãonOpen å¼å¸¸", e); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | sessionPool.remove(userId); |
| | | log.info("ãç³»ç» WebSocketãè¿æ¥æå¼ï¼æ»æ°ä¸º:" + sessionPool.size()); |
| | | // åæ¶å¿è·³ä»»å¡ |
| | | scheduler.shutdown(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | log.info("ãç³»ç» WebSocketãç¾¤åæ¶æ¯:" + message); |
| | | log.info("ã3D宿¶æ°æ® WebSocketãæ¶æ¯" ); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * wsæ¥å客æ·ç«¯æ¶æ¯ |
| | |
| | | }else{ |
| | | log.debug("ãç³»ç» WebSocketãæ¶å°å®¢æ·ç«¯æ¶æ¯:" + message); |
| | | } |
| | | |
| | | |
| | | //------------------------------------------------------------------------------ |
| | | JSONObject obj = new JSONObject(); |
| | | //ä¸å¡ç±»å |
| | | obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_CHECK); |
| | | //æ¶æ¯å
容 |
| | | obj.put(WebsocketConst.MSG_TXT, "å¿è·³ååº"); |
| | | this.pushMessage(userId, obj.toJSONString()); |
| | | // JSONObject obj = new JSONObject(); |
| | | // //ä¸å¡ç±»å |
| | | // obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_CHECK); |
| | | // //æ¶æ¯å
容 |
| | | // obj.put(WebsocketConst.MSG_TXT, "å¿è·³ååº"); |
| | | // this.pushMessage(userId, obj.toJSONString()); |
| | | //------------------------------------------------------------------------------ |
| | | } |
| | | |
| | |
| | | */ |
| | | @OnError |
| | | public void onError(Session session, Throwable t) { |
| | | log.warn("ãç³»ç» WebSocketãæ¶æ¯åºç°é误"); |
| | | log.warn("ãç³»ç» WebSocketãæ¶æ¯åºç°é误",t); |
| | | //t.printStackTrace(); |
| | | } |
| | | //==========ãç³»ç» WebSocketæ¥åãæ¨éæ¶æ¯çæ¹æ³ ââ å
·ä½æå¡èç¹æ¨éwsæ¶æ¯ã======================================================================================== |
| | | |
| | | |
| | | |
| | | //==========ãéç¨redisåå¸è®¢é
模å¼ââæ¨éæ¶æ¯ã======================================================================================== |
| | | /** |
| | |
| | | } |
| | | } |
| | | //=======ãéç¨redisåå¸è®¢é
模å¼ââæ¨éæ¶æ¯ã========================================================================================== |
| | | |
| | | |
| | | } |
| | |
| | | List<String> findTeamValue(@Param("userId") String userId, @Param("productionList") List<String> productionList); |
| | | |
| | | List<String> findProIdsByUId(@Param("userId") String userId, @Param("allProductionIds") List<String> allProductionIds); |
| | | |
| | | List<String> findChildByProId(@Param("productionId") String productionId); |
| | | |
| | | String findProName(@Param("equipmentId") String equipmentId); |
| | | } |
| | |
| | | </foreach> |
| | | AND user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="findChildByProId" resultType="java.lang.String"> |
| | | WITH temp ( id ) AS ( |
| | | SELECT |
| | | id |
| | | FROM |
| | | mdc_production |
| | | WHERE |
| | | id = #{ productionId } |
| | | AND mdc_flag = '1' UNION ALL |
| | | SELECT |
| | | a.id |
| | | FROM |
| | | mdc_production a |
| | | INNER JOIN temp ON a.parent_id = temp.id |
| | | WHERE |
| | | a.mdc_flag = '1' |
| | | ) SELECT |
| | | * |
| | | FROM |
| | | temp |
| | | </select> |
| | | |
| | | <select id="findProName" resultType="java.lang.String"> |
| | | WITH production_hierarchy AS ( |
| | | SELECT |
| | | t3.id, |
| | | t3.parent_id, |
| | | t3.production_name, |
| | | t3.org_type, |
| | | 0 AS level |
| | | FROM |
| | | mdc_equipment t1 |
| | | JOIN |
| | | mdc_production_equipment t2 ON t1.id = t2.equipment_id |
| | | JOIN |
| | | mdc_production t3 ON t2.production_id = t3.id |
| | | WHERE |
| | | t1.equipment_id = #{equipmentId} |
| | | |
| | | UNION ALL |
| | | SELECT |
| | | t4.id, |
| | | t4.parent_id, |
| | | t4.production_name, |
| | | t4.org_type, |
| | | ph.level + 1 |
| | | FROM |
| | | production_hierarchy ph |
| | | JOIN |
| | | mdc_production t4 ON ph.parent_id = t4.id |
| | | WHERE |
| | | ph.parent_id IS NOT NULL |
| | | ) |
| | | SELECT TOP 1 |
| | | production_name |
| | | FROM |
| | | production_hierarchy |
| | | WHERE |
| | | org_type = 2 |
| | | ORDER BY |
| | | level ASC |
| | | </select> |
| | | </mapper> |
| | |
| | | * @return |
| | | */ |
| | | List<String> findProIdsByUId(String userId, List<String> allProductionIds); |
| | | |
| | | /** |
| | | * |
| | | * @param productionId |
| | | * @return |
| | | */ |
| | | List<String> findChildByProId(String productionId); |
| | | |
| | | |
| | | String findProName(String equipmentId); |
| | | } |
| | |
| | | super.update(updateWrapper); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> findChildByProId(String productionId) { |
| | | return this.baseMapper.findChildByProId(productionId); |
| | | } |
| | | |
| | | @Override |
| | | public String findProName(String equipmentId) { |
| | | return this.baseMapper.findProName(equipmentId); |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.tms.controller; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Arrays; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.ss.usermodel.WorkbookFactory; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.modules.tms.entity.*; |
| | |
| | | IPage<SharpeeningVo> resultPage = baseToolsService.pageWithSharpedAndConfig(page, queryWrapper); |
| | | return Result.OK(resultPage); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导å
¥æ¨¡æ¿ä¸è½½ |
| | | * |
| | | */ |
| | | @RequestMapping(value = "/loadTemplate") |
| | | public void loadTemplate(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | |
| | | Map<String,String[]> req = request.getParameterMap(); |
| | | String paraTypeFlag = ""; |
| | | if(req.get("paraTypeFlag") != null){ |
| | | paraTypeFlag = req.get("paraTypeFlag")[0]; |
| | | } |
| | | if("1".equals(paraTypeFlag)){ |
| | | Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-éç¨åæ°.xlsx")); |
| | | //导åºWorkbook |
| | | //设置ååºå¤´ |
| | | String fileName = "åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-éç¨åæ°.xlsx"; |
| | | // 对æä»¶åè¿è¡URLç¼ç ï¼é²æ¢ä¸æä¹±ç |
| | | String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
| | | // å°Workbookåå
¥ååºè¾åºæµ |
| | | try { // try-with-resourcesèªå¨å
³éèµæº |
| | | workbook.write(response.getOutputStream()); |
| | | response.flushBuffer(); |
| | | } catch (IOException e) { |
| | | // å¼å¸¸å¤çï¼å¦è®°å½æ¥å¿ï¼ |
| | | throw new IOException("ä¸è½½æ¨¡æ¿å¤±è´¥", e); |
| | | } |
| | | }else if("2".equals(paraTypeFlag)){ |
| | | Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-åå 工工å
·.xlsx")); |
| | | String fileName = "åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-åå 工工å
·.xlsx"; |
| | | String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
| | | try { |
| | | workbook.write(response.getOutputStream()); |
| | | response.flushBuffer(); |
| | | } catch (IOException e) { |
| | | throw new IOException("ä¸è½½æ¨¡æ¿å¤±è´¥", e); |
| | | } |
| | | }else if("3".equals(paraTypeFlag)){ |
| | | Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-èºçº¹å·¥å
·.xlsx")); |
| | | String fileName = "åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-èºçº¹å·¥å
·.xlsx"; |
| | | String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
| | | try { |
| | | workbook.write(response.getOutputStream()); |
| | | response.flushBuffer(); |
| | | } catch (IOException e) { |
| | | throw new IOException("ä¸è½½æ¨¡æ¿å¤±è´¥", e); |
| | | } |
| | | }else if("4".equals(paraTypeFlag)){ |
| | | Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-é£åå·¥å
·.xlsx")); |
| | | String fileName = "åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-é£åå·¥å
·.xlsx"; |
| | | String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
| | | try { |
| | | workbook.write(response.getOutputStream()); |
| | | response.flushBuffer(); |
| | | } catch (IOException e) { |
| | | throw new IOException("ä¸è½½æ¨¡æ¿å¤±è´¥", e); |
| | | } |
| | | }else if("5".equals(paraTypeFlag)){ |
| | | Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-车åå·¥å
·.xlsx")); |
| | | String fileName = "åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-车åå·¥å
·.xlsx"; |
| | | String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
| | | try { |
| | | workbook.write(response.getOutputStream()); |
| | | response.flushBuffer(); |
| | | } catch (IOException e) { |
| | | throw new IOException("ä¸è½½æ¨¡æ¿å¤±è´¥", e); |
| | | } |
| | | }else if("6".equals(paraTypeFlag)){ |
| | | Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-åç.xlsx")); |
| | | String fileName = "åå
·ä¿¡æ¯å¯¼å
¥æ¨¡æ¿-åç.xlsx"; |
| | | String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); |
| | | try { |
| | | workbook.write(response.getOutputStream()); |
| | | response.flushBuffer(); |
| | | } catch (IOException e) { |
| | | throw new IOException("ä¸è½½æ¨¡æ¿å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.tms.entity.dto.PreparationOrderAndDetailDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import java.util.Arrays; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import org.jeecg.modules.tms.entity.PreparationOrder; |
| | | import org.jeecg.modules.tms.service.IPreparationOrderService; |
| | | import org.jeecg.modules.tms.service.IPreparationOrderDetailService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="åå
·åå¤å") |
| | | @RestController |
| | | @RequestMapping("/tms/preparationOrder") |
| | | @Slf4j |
| | | public class PreparationOrderController extends JeecgController<PreparationOrder, IPreparationOrderService> { |
| | | |
| | | @Autowired |
| | | private IPreparationOrderService preparationOrderService; |
| | | |
| | | @Autowired |
| | | private IPreparationOrderDetailService preparationOrderDetailService; |
| | | |
| | | |
| | | /*---------------------------------主表å¤ç-begin-------------------------------------*/ |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * @param preparationOrder |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "åå
·åå¤å-å页å表æ¥è¯¢") |
| | | @ApiOperation(value="åå
·åå¤å-å页å表æ¥è¯¢", notes="åå
·åå¤å-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<PreparationOrder>> queryPageList(PreparationOrder preparationOrder, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Map<String, String[]> parameterMap = req.getParameterMap(); |
| | | QueryWrapper<PreparationOrder> queryWrapper = QueryGenerator.initQueryWrapper(preparationOrder, parameterMap); |
| | | Page<PreparationOrder> page = new Page<PreparationOrder>(pageNo, pageSize); |
| | | IPage<PreparationOrder> pageList = preparationOrderService.queryPageList(page, parameterMap); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * @param preparationOrder |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤å-æ·»å ") |
| | | @ApiOperation(value="åå
·åå¤å-æ·»å ", notes="åå
·åå¤å-æ·»å ") |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody PreparationOrder preparationOrder) { |
| | | preparationOrderService.save(preparationOrder); |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * @param preparationOrder |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤å-ç¼è¾") |
| | | @ApiOperation(value="åå
·åå¤å-ç¼è¾", notes="åå
·åå¤å-ç¼è¾") |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody PreparationOrder preparationOrder) { |
| | | preparationOrderService.updateById(preparationOrder); |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | |
| | | @AutoLog(value = "åå
·åå¤å-ç¡®è®¤å®æ") |
| | | @ApiOperation(value="åå
·åå¤å-è°æºåä¿®æ£ç¡®è®¤", notes = "åå
·åå¤å-è°æºåä¿®æ£ç¡®è®¤") |
| | | @RequestMapping(value = "/editTotal", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> editTotal(@RequestBody PreparationOrderAndDetailDto preparationOrderAndDetailDto) { |
| | | preparationOrderService.editTotal(preparationOrderAndDetailDto); |
| | | return Result.OK("ç¡®è®¤å®æï¼"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤å-éè¿idå é¤åå¤ååæç»") |
| | | @ApiOperation(value="åå
·åå¤å-éè¿idå é¤åå¤ååæç»", notes="åå
·åå¤å-éè¿idå é¤åå¤ååæç»") |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | preparationOrderService.delMain(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤å-æ¹éå é¤") |
| | | @ApiOperation(value="åå
·åå¤å-æ¹éå é¤", notes="åå
·åå¤å-æ¹éå é¤") |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | preparationOrderService.delBatchMain(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿å!"); |
| | | } |
| | | |
| | | @AutoLog(value = "åå
·åå¤å-转åºåºç³è¯·å") |
| | | @ApiOperation(value = "åå
·åå¤å-转åºåºç³è¯·å", notes = "åå
·åå¤å-转åºåºç³è¯·å") |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:convert") |
| | | @PostMapping(value = "/convertToOutboundOrder") |
| | | public Result<String> convertToOutboundOrder(@RequestBody List<String> preparationOrderIds) { |
| | | List<String> result = preparationOrderService.convertToOutboundOrder(preparationOrderIds); |
| | | return Result.OK(JSONObject.toJSONString(result)); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åº |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, PreparationOrder preparationOrder) { |
| | | return super.exportXls(request, preparationOrder, PreparationOrder.class, "åå
·åå¤å"); |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥ |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:tms_preparation_order:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, PreparationOrder.class); |
| | | } |
| | | /*---------------------------------主表å¤ç-end-------------------------------------*/ |
| | | |
| | | |
| | | /*--------------------------------å表å¤ç-åå
·åå¤åæç»-begin----------------------------------------------*/ |
| | | /** |
| | | * éè¿ä¸»è¡¨IDæ¥è¯¢ |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "åå
·åå¤åæç»-éè¿ä¸»è¡¨IDæ¥è¯¢") |
| | | @ApiOperation(value="åå
·åå¤åæç»-éè¿ä¸»è¡¨IDæ¥è¯¢", notes="åå
·åå¤åæç»-éè¿ä¸»è¡¨IDæ¥è¯¢") |
| | | @GetMapping(value = "/listPreparationOrderDetailByMainId") |
| | | public Result<IPage<PreparationOrderDetail>> listPreparationOrderDetailByMainId(PreparationOrderDetail preparationOrderDetail, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Map<String, String[]> parameterMap = req.getParameterMap(); |
| | | QueryWrapper<PreparationOrderDetail> queryWrapper = QueryGenerator.initQueryWrapper(preparationOrderDetail, parameterMap); |
| | | Page<PreparationOrderDetail> page = new Page<PreparationOrderDetail>(pageNo, pageSize); |
| | | IPage<PreparationOrderDetail> pageList = preparationOrderDetailService.queryPageList(page, parameterMap); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * @param preparationOrderDetail |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤åæç»-æ·»å ") |
| | | @ApiOperation(value="åå
·åå¤åæç»-æ·»å ", notes="åå
·åå¤åæç»-æ·»å ") |
| | | @PostMapping(value = "/addPreparationOrderDetail") |
| | | public Result<String> addPreparationOrderDetail(@RequestBody PreparationOrderDetail preparationOrderDetail) { |
| | | preparationOrderDetailService.save(preparationOrderDetail); |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * @param preparationOrderDetail |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤åæç»-ç¼è¾") |
| | | @ApiOperation(value="åå
·åå¤åæç»-ç¼è¾", notes="åå
·åå¤åæç»-ç¼è¾") |
| | | @RequestMapping(value = "/editPreparationOrderDetail", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> editPreparationOrderDetail(@RequestBody PreparationOrderDetail preparationOrderDetail) { |
| | | preparationOrderDetailService.updateById(preparationOrderDetail); |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤åæç»-éè¿idå é¤") |
| | | @ApiOperation(value="åå
·åå¤åæç»-éè¿idå é¤", notes="åå
·åå¤åæç»-éè¿idå é¤") |
| | | @DeleteMapping(value = "/deletePreparationOrderDetail") |
| | | public Result<String> deletePreparationOrderDetail(@RequestParam(name="id",required=true) String id) { |
| | | preparationOrderDetailService.removeById(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "åå
·åå¤åæç»-æ¹éå é¤") |
| | | @ApiOperation(value="åå
·åå¤åæç»-æ¹éå é¤", notes="åå
·åå¤åæç»-æ¹éå é¤") |
| | | @DeleteMapping(value = "/deleteBatchPreparationOrderDetail") |
| | | public Result<String> deleteBatchPreparationOrderDetail(@RequestParam(name="ids",required=true) String ids) { |
| | | this.preparationOrderDetailService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åº |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/exportPreparationOrderDetail") |
| | | public ModelAndView exportPreparationOrderDetail(HttpServletRequest request, PreparationOrderDetail preparationOrderDetail) { |
| | | // Step.1 ç»è£
æ¥è¯¢æ¡ä»¶ |
| | | QueryWrapper<PreparationOrderDetail> queryWrapper = QueryGenerator.initQueryWrapper(preparationOrderDetail, request.getParameterMap()); |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | |
| | | // Step.2 è·åå¯¼åºæ°æ® |
| | | List<PreparationOrderDetail> pageList = preparationOrderDetailService.list(queryWrapper); |
| | | List<PreparationOrderDetail> exportList = null; |
| | | |
| | | // è¿æ»¤é䏿°æ® |
| | | String selections = request.getParameter("selections"); |
| | | if (oConvertUtils.isNotEmpty(selections)) { |
| | | List<String> selectionList = Arrays.asList(selections.split(",")); |
| | | exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); |
| | | } else { |
| | | exportList = pageList; |
| | | } |
| | | |
| | | // Step.3 AutoPoi 导åºExcel |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | //æ¤å¤è®¾ç½®çfilenameæ æ,å端ä¼éæ´æ°è®¾ç½®ä¸ä¸ |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "åå
·åå¤åæç»"); |
| | | mv.addObject(NormalExcelConstants.CLASS, PreparationOrderDetail.class); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("åå
·åå¤åæç»æ¥è¡¨", "导åºäºº:" + sysUser.getRealname(), "åå
·åå¤åæç»")); |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, exportList); |
| | | return mv; |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥ |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/importPreparationOrderDetail/{mainId}") |
| | | public Result<?> importPreparationOrderDetail(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | // è·åä¸ä¼ æä»¶å¯¹è±¡ |
| | | MultipartFile file = entity.getValue(); |
| | | ImportParams params = new ImportParams(); |
| | | params.setTitleRows(2); |
| | | params.setHeadRows(1); |
| | | params.setNeedSave(true); |
| | | try { |
| | | List<PreparationOrderDetail> list = ExcelImportUtil.importExcel(file.getInputStream(), PreparationOrderDetail.class, params); |
| | | for (PreparationOrderDetail temp : list) { |
| | | temp.setPreparationOrderId(mainId); |
| | | } |
| | | long start = System.currentTimeMillis(); |
| | | preparationOrderDetailService.saveBatch(list); |
| | | log.info("æ¶èæ¶é´" + (System.currentTimeMillis() - start) + "毫ç§"); |
| | | return Result.OK("æä»¶å¯¼å
¥æåï¼æ°æ®è¡æ°ï¼" + list.size()); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | return Result.error("æä»¶å¯¼å
¥å¤±è´¥:" + e.getMessage()); |
| | | } finally { |
| | | try { |
| | | file.getInputStream().close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return Result.error("æä»¶å¯¼å
¥å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | /*--------------------------------å表å¤ç-åå
·åå¤åæç»-end----------------------------------------------*/ |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import org.jeecg.modules.tms.entity.OutboundOrder; |
| | | import org.jeecg.modules.tms.entity.dto.OutboundOrderAndDetailDto; |
| | | import org.mapstruct.BeanMapping; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.NullValuePropertyMappingStrategy; |
| | | import org.mapstruct.ReportingPolicy; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | /** |
| | | * ä½¿ç¨ MapStruct æ¹å¼è¿è¡å±æ§å¤å¶ |
| | | * 注æä¸è½æ¾å¨ mybatisæ«æçmapperå
ä¸é¢ï¼å¦å伿¥é |
| | | */ |
| | | @Mapper |
| | | @Mapper( |
| | | unmappedTargetPolicy = ReportingPolicy.IGNORE, // 忽ç¥ç®æ 䏿ªè¢«æ å°çåæ®µ |
| | | componentModel = "spring" // å¦æä½¿ç¨ Springï¼å¯çæ Spring 管çç Bean |
| | | ) |
| | | public interface OutboundOrderConvert { |
| | | |
| | | |
| | | OutboundOrderConvert INSTANCE = Mappers.getMapper(OutboundOrderConvert.class); |
| | | |
| | | @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)// å¿½ç¥ null åæ®µ |
| | | OutboundOrder convert(OutboundOrderAndDetailDto dto); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.convert; |
| | | |
| | | import org.jeecg.modules.tms.entity.PreparationOrder; |
| | | import org.jeecg.modules.tms.entity.dto.PreparationOrderAndDetailDto; |
| | | import org.mapstruct.BeanMapping; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.NullValuePropertyMappingStrategy; |
| | | import org.mapstruct.ReportingPolicy; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | /** |
| | | * ä½¿ç¨ MapStruct æ¹å¼è¿è¡å±æ§å¤å¶ |
| | | * 注æä¸è½æ¾å¨ mybatisæ«æçmapperå
ä¸é¢ï¼å¦å伿¥é |
| | | */ |
| | | @Mapper( |
| | | unmappedTargetPolicy = ReportingPolicy.IGNORE, // 忽ç¥ç®æ 䏿ªè¢«æ å°çåæ®µ |
| | | componentModel = "spring" // å¦æä½¿ç¨ Springï¼å¯çæ Spring 管çç Bean |
| | | ) |
| | | public interface PreparationOrderConvert { |
| | | |
| | | PreparationOrderConvert INSTANCE = Mappers.getMapper(PreparationOrderConvert.class); |
| | | |
| | | @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)// å¿½ç¥ null åæ®µ |
| | | PreparationOrder convert(PreparationOrderAndDetailDto dto); |
| | | } |
| | |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | |
| | | /**å·¥å
·å¾ç*/ |
| | | @Excel(name = "å·¥å
·å¾ç", width = 15) |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @TableName("tms_outbound_detail") |
| | | @ApiModel(value="tms_outbound_detail对象", description="åºåºç³è¯·åæç»") |
| | | public class OutboundDetail implements Serializable { |
| | |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import liquibase.pro.packaged.E; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @TableName("tms_outbound_order") |
| | | @ApiModel(value="tms_outbound_order对象", description="tms_outbound_order") |
| | | public class OutboundOrder implements Serializable { |
| | |
| | | @Excel(name = "夿³¨", width = 15) |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | /**åå¤åç¼å·*/ |
| | | @Excel(name = "åå¤åç¼å·", width = 15) |
| | | @ApiModelProperty(value = "åå¤åç¼å·") |
| | | private String preparationOrderId; |
| | | /**é¶ä»¶å¾å·*/ |
| | | @Excel(name = "é¶ä»¶å¾å·", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶å¾å·") |
| | | private String partDrawingNo; |
| | | /**é¶ä»¶åç§°*/ |
| | | @Excel(name = "é¶ä»¶åç§°", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶åç§°") |
| | | private String partName; |
| | | /**é¶ä»¶ææ*/ |
| | | @Excel(name = "é¶ä»¶ææ", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶ææ") |
| | | private String partMaterial; |
| | | /**å å·¥æ¹æ¬¡*/ |
| | | @Excel(name = "å·¥åºï¼å·¥æ¥å·ï¼", width = 15) |
| | | @ApiModelProperty(value = "å·¥åºï¼å·¥æ¥å·ï¼") |
| | | private String productionProcessesNo; |
| | | /**å å·¥æ¹æ¬¡*/ |
| | | @Excel(name = "å å·¥æ¹æ¬¡", width = 15) |
| | | @ApiModelProperty(value = "å å·¥æ¹æ¬¡") |
| | | private String batchCode; |
| | | /**å å·¥æ°é*/ |
| | | @Excel(name = "å å·¥æ°é", width = 15) |
| | | @ApiModelProperty(value = "å å·¥æ°é") |
| | | private String machiningCount; |
| | | /**å 工设å¤*/ |
| | | @Excel(name = "å 工设å¤", width = 15) |
| | | @ApiModelProperty(value = "å 工设å¤") |
| | | private String equipmentCode; |
| | | /**ç¨åºå*/ |
| | | @Excel(name = "ç¨åºå", width = 15) |
| | | @ApiModelProperty(value = "ç¨åºå") |
| | | private String ncName; |
| | | /**ç§æ·å·*/ |
| | | @Excel(name = "ç§æ·å·", width = 15) |
| | | @ApiModelProperty(value = "ç§æ·å·") |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import lombok.experimental.Accessors; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | @TableName("tms_preparation_order") |
| | | @ApiModel(value="tms_preparation_order对象", description="åå
·åå¤å") |
| | | public class PreparationOrder implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**主é®*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "主é®") |
| | | private String id; |
| | | /**åå¤åç¼å·*/ |
| | | @Excel(name = "åå¤åç¼å·", width = 15) |
| | | @ApiModelProperty(value = "åå¤åç¼å·") |
| | | private String preparationOrderNum; |
| | | /**é¶ä»¶å¾å·*/ |
| | | @Excel(name = "é¶ä»¶å¾å·", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶å¾å·") |
| | | private String partDrawingNo; |
| | | /**é¶ä»¶åç§°*/ |
| | | @Excel(name = "é¶ä»¶åç§°", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶åç§°") |
| | | private String partName; |
| | | /**é¶ä»¶ææ*/ |
| | | @Excel(name = "é¶ä»¶ææ", width = 15) |
| | | @ApiModelProperty(value = "é¶ä»¶ææ") |
| | | private String partMaterial; |
| | | /**å·¥åºï¼å·¥æ¥å·ï¼*/ |
| | | @Excel(name = "å·¥åºï¼å·¥æ¥å·ï¼", width = 15) |
| | | @ApiModelProperty(value = "å·¥åºï¼å·¥æ¥å·ï¼") |
| | | private String productionProcessesNo; |
| | | /**å å·¥æ¹æ¬¡*/ |
| | | @Excel(name = "å å·¥æ¹æ¬¡", width = 15) |
| | | @ApiModelProperty(value = "å å·¥æ¹æ¬¡") |
| | | private String batchCode; |
| | | /**å å·¥æ°é*/ |
| | | @Excel(name = "å å·¥æ°é", width = 15) |
| | | @ApiModelProperty(value = "å å·¥æ°é") |
| | | private String machiningCount; |
| | | /**å 工设å¤*/ |
| | | @Excel(name = "å 工设å¤", width = 15) |
| | | @ApiModelProperty(value = "å 工设å¤") |
| | | private String equipmentCode; |
| | | /**ç¨åºå*/ |
| | | @Excel(name = "ç¨åºå", width = 15) |
| | | @ApiModelProperty(value = "ç¨åºå") |
| | | private String ncName; |
| | | /**åå¤ååºåºæ°é*/ |
| | | @Excel(name = "åå¤ååºåºæ°é", width = 15) |
| | | @ApiModelProperty(value = "åå¤ååºåºæ°é") |
| | | private java.math.BigDecimal outboundQuantity; |
| | | /**ååç¶æ;1.æªå®¡æ ¸ï¼2.è°æºåå·²å®¡æ ¸ï¼3.已转åºåºç³è¯·*/ |
| | | @Dict(dicCode = "preparation_order_status") |
| | | @Excel(name = "ååç¶æ;1.æªå®¡æ ¸ï¼2.è°æºåå·²å®¡æ ¸ï¼3.已转åºåºç³è¯·", width = 15) |
| | | @ApiModelProperty(value = "ååç¶æ;1.æªå®¡æ ¸ï¼2.è°æºåå·²å®¡æ ¸ï¼3.已转åºåºç³è¯·") |
| | | private String orderStatus; |
| | | /**åå¤åæäº¤æ¶é´;æäº¤è³åºåºç³è¯·åçæ¶é´*/ |
| | | @Excel(name = "åå¤åæäº¤æ¶é´;æäº¤è³åºåºç³è¯·åçæ¶é´", width = 15, format = "yyyy-MM-dd HH:mm") |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm") |
| | | @ApiModelProperty(value = "åå¤åæäº¤æ¶é´;æäº¤è³åºåºç³è¯·åçæ¶é´") |
| | | private Date outboundTime; |
| | | /**夿³¨*/ |
| | | @Excel(name = "夿³¨", width = 15) |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | /**ç§æ·å·*/ |
| | | @Excel(name = "ç§æ·å·", width = 15) |
| | | @ApiModelProperty(value = "ç§æ·å·") |
| | | private String tenantId; |
| | | /**å建人*/ |
| | | @ApiModelProperty(value = "å建人") |
| | | private String createBy; |
| | | /**å建æ¶é´;DNCæ¨éæ°æ®æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm") |
| | | @ApiModelProperty(value = "å建æ¶é´;DNCæ¨éæ°æ®æ¶é´") |
| | | private Date createTime; |
| | | /**æ´æ°äºº*/ |
| | | @ApiModelProperty(value = "æ´æ°äºº") |
| | | private String updateBy; |
| | | /**æ´æ°æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm") |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.jeecg.common.aspect.annotation.Dict; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.jeecgframework.poi.excel.annotation.Excel; |
| | | import java.util.Date; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤åæç» |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("tms_preparation_order_detail") |
| | | @ApiModel(value="tms_preparation_order_detail对象", description="åå
·åå¤åæç»") |
| | | public class PreparationOrderDetail implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**主é®*/ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | @ApiModelProperty(value = "主é®") |
| | | private String id; |
| | | /**åå¤åå·*/ |
| | | @ApiModelProperty(value = "åå¤åå·") |
| | | private String preparationOrderId; |
| | | /**åå
·ç¼ç */ |
| | | @Excel(name = "åå
·ç¼ç ", width = 15) |
| | | @ApiModelProperty(value = "åå
·ç¼ç (tms_base_tool表idåæ®µ)") |
| | | private String toolCode; |
| | | /**åå
·ç¼å·*/ |
| | | @Excel(name = "åå
·ç¼å·", width = 15) |
| | | @ApiModelProperty(value = "åå
·ç¼å·") |
| | | private String toolId; |
| | | /**ç³è¯·åºåºæ°é*/ |
| | | @Excel(name = "ç³è¯·åºåºæ°é", width = 15) |
| | | @ApiModelProperty(value = "ç³è¯·åºåºæ°é") |
| | | private java.math.BigDecimal outboundQuantity; |
| | | /**ç§æ·å·*/ |
| | | @Excel(name = "ç§æ·å·", width = 15) |
| | | @ApiModelProperty(value = "ç§æ·å·") |
| | | private String tenantId; |
| | | /**å建人*/ |
| | | @ApiModelProperty(value = "å建人") |
| | | private String createBy; |
| | | /**å建æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private Date createTime; |
| | | /**æ´æ°äºº*/ |
| | | @ApiModelProperty(value = "æ´æ°äºº") |
| | | private String updateBy; |
| | | /**æ´æ°æ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd") |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | |
| | | /**åå
·ç¼ç (tms_base_tool表tool_codeåæ®µ)*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åå
·ç¼ç (tms_base_tool表tool_codeåæ®µ)") |
| | | private String toolNum; |
| | | /**䏿åç§°*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "䏿åç§°") |
| | | private String chineseName; |
| | | /**åå·/å¾å·*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åå·/å¾å·") |
| | | private String toolModel; |
| | | /**å·¥å
፱Ȍ*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "å·¥å
፱Ȍ") |
| | | @Dict(dicCode = "application_type") |
| | | private String applicationType; |
| | | /**åå
·ææ*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åå
·ææ") |
| | | private String toolMaterial; |
| | | /**é¶ä»¶ææ*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "é¶ä»¶ææ") |
| | | private String partMaterial; |
| | | /**åå®¶*/ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "åå®¶") |
| | | private String supplierId; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.entity.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class PreparationOrderAndDetailDto { |
| | | |
| | | /**主é®*/ |
| | | @ApiModelProperty(value = "主é®") |
| | | private String id; |
| | | /**åå¤åç¼å·*/ |
| | | @ApiModelProperty(value = "åå¤åç¼å·") |
| | | private String preparationOrderNum; |
| | | /**é¶ä»¶å¾å·*/ |
| | | @ApiModelProperty(value = "é¶ä»¶å¾å·") |
| | | private String partDrawingNo; |
| | | /**é¶ä»¶åç§°*/ |
| | | @ApiModelProperty(value = "é¶ä»¶åç§°") |
| | | private String partName; |
| | | /**é¶ä»¶ææ*/ |
| | | @ApiModelProperty(value = "é¶ä»¶ææ") |
| | | private String partMaterial; |
| | | /**å·¥åºï¼å·¥æ¥å·ï¼*/ |
| | | @ApiModelProperty(value = "å·¥åºï¼å·¥æ¥å·ï¼") |
| | | private String productionProcessesNo; |
| | | /**å å·¥æ¹æ¬¡*/ |
| | | @ApiModelProperty(value = "å å·¥æ¹æ¬¡") |
| | | private String batchCode; |
| | | /**å å·¥æ°é*/ |
| | | @ApiModelProperty(value = "å å·¥æ°é") |
| | | private String machiningCount; |
| | | /**å 工设å¤*/ |
| | | @ApiModelProperty(value = "å 工设å¤") |
| | | private String equipmentCode; |
| | | /**ç¨åºå*/ |
| | | @ApiModelProperty(value = "ç¨åºå") |
| | | private String ncName; |
| | | /**åå¤ååºåºæ°é*/ |
| | | @ApiModelProperty(value = "åå¤ååºåºæ°é") |
| | | private java.math.BigDecimal outboundQuantity; |
| | | /**ååç¶æ;1.æªå®¡æ ¸ï¼2.è°æºåå·²å®¡æ ¸ï¼3.已转åºåºç³è¯·*/ |
| | | @ApiModelProperty(value = "ååç¶æ;1.æªå®¡æ ¸ï¼2.è°æºåå·²å®¡æ ¸ï¼3.已转åºåºç³è¯·") |
| | | private String orderStatus; |
| | | /**åå¤åæäº¤æ¶é´;æäº¤è³åºåºç³è¯·åçæ¶é´*/ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm") |
| | | @ApiModelProperty(value = "åå¤åæäº¤æ¶é´;æäº¤è³åºåºç³è¯·åçæ¶é´") |
| | | private Date outboundTime; |
| | | /**夿³¨*/ |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | /**åå
·åå¤åæç»*/ |
| | | @ApiModelProperty(value = "åå
·åå¤åæç»") |
| | | private List<PreparationOrderDetail> preparationOrderDetailList; |
| | | } |
| | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å·¥å
·å¾ç") |
| | | private String toolPicture; |
| | | |
| | | } |
| | |
| | | TOOL_BORROW("1", "å·¥å
·åç¨"), |
| | | MAINTENANCE_OUTBOUND("2", "ç»´ä¿®åºåº"), |
| | | CALIBRATION_OUTBOUND("3", "æ£å®åºåº"), |
| | | GRINDING_OUTBOUND("4", "å磨åºåº"); |
| | | GRINDING_OUTBOUND("4", "å磨åºåº"), |
| | | PREPARATION_OUTBOUND("5", "åå¤ååºåº"); |
| | | |
| | | private final String value; |
| | | private final String description; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.enums; |
| | | |
| | | |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * åå
·åå¤åç¶ææä¸¾ç±» |
| | | */ |
| | | @Getter |
| | | public enum PreparationOrderStatus { |
| | | /** |
| | | * å¾
å®¡æ ¸ç¶æï¼å¼ä¸º1 |
| | | */ |
| | | PENDING_AUDIT("1", "æªå®¡æ ¸"), |
| | | |
| | | /** |
| | | * å®¡æ ¸éè¿ç¶æï¼å¼ä¸º2 |
| | | */ |
| | | AUDITED("2", "è°æºåå·²å®¡æ ¸"), |
| | | |
| | | /** |
| | | * 转åºåºç³è¯·ç¶æï¼å¼ä¸º3 |
| | | */ |
| | | CONVERT("3", "已转åºåºç³è¯·"); |
| | | |
| | | private final String value; |
| | | private final String description; |
| | | |
| | | /** |
| | | * æé æ¹æ³ |
| | | * |
| | | * @param value ç¶æå¼ |
| | | * @param description ç¶ææè¿° |
| | | */ |
| | | PreparationOrderStatus(String value, String description) { |
| | | this.value = value; |
| | | this.description = description; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶æå¼è·å对åºçæä¸¾å®ä¾ |
| | | * |
| | | * @param value ç¶æå¼ |
| | | * @return 对åºçæä¸¾å®ä¾ï¼å¦ææ¾ä¸å°å¹é
çå¼åè¿ånull |
| | | */ |
| | | public static PreparationOrderStatus fromValue(String value) { |
| | | for (PreparationOrderStatus status : values()) { |
| | | if (Objects.equals(status.getValue(), value)) { |
| | | return status; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤åæç» |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface PreparationOrderDetailMapper extends BaseMapper<PreparationOrderDetail> { |
| | | |
| | | /** |
| | | * éè¿ä¸»è¡¨idå é¤åè¡¨æ°æ® |
| | | * |
| | | * @param mainId 主表id |
| | | * @return boolean |
| | | */ |
| | | public boolean deleteByMainId(@Param("mainId") String mainId); |
| | | |
| | | /** |
| | | * éè¿ä¸»è¡¨idæ¥è¯¢åè¡¨æ°æ® |
| | | * |
| | | * @param mainId 主表id |
| | | * @return List<PreparationOrderDetail> |
| | | */ |
| | | public List<PreparationOrderDetail> selectByMainId(@Param("mainId") String mainId); |
| | | |
| | | IPage<PreparationOrderDetail> queryPageList(Page<PreparationOrderDetail> page, |
| | | @Param(Constants.WRAPPER) Wrapper<PreparationOrderDetail> queryWrapper); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.tms.entity.PreparationOrder; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface PreparationOrderMapper extends BaseMapper<PreparationOrder> { |
| | | |
| | | IPage<PreparationOrder> queryPageList(Page<PreparationOrder> page, |
| | | @Param(Constants.WRAPPER) Wrapper<PreparationOrder> queryWrapper); |
| | | } |
| | |
| | | t.standard_code standardCode, |
| | | t.tool_model toolModel, |
| | | t.parama_table_name paramaTableName, |
| | | t.tool_picture toolPicture, |
| | | t1.application_type applicationType, |
| | | t1.supplier_id supplierId, |
| | | t1.province_city provinceCity, |
| | |
| | | t.standard_code standardCode, |
| | | t.tool_model toolModel, |
| | | t.parama_table_name paramaTableName, |
| | | t.tool_picture toolPicture, |
| | | t1.application_type applicationType, |
| | | t1.supplier_id supplierId, |
| | | t1.province_city provinceCity, |
| | |
| | | t.standard_code standardCode, |
| | | t.tool_model toolModel, |
| | | t.parama_table_name paramaTableName, |
| | | t.tool_picture toolPicture, |
| | | t1.application_type applicationType, |
| | | t1.supplier_id supplierId, |
| | | t1.province_city provinceCity, |
| | |
| | | t.standard_code standardCode, |
| | | t.tool_model toolModel, |
| | | t.parama_table_name paramaTableName, |
| | | t.tool_picture toolPicture, |
| | | t1.application_type applicationType, |
| | | t1.supplier_id supplierId, |
| | | t1.province_city provinceCity, |
| | |
| | | t.standard_code standardCode, |
| | | t.tool_model toolModel, |
| | | t.parama_table_name paramaTableName, |
| | | t.tool_picture toolPicture, |
| | | t1.application_type applicationType, |
| | | t1.supplier_id supplierId, |
| | | t1.province_city provinceCity, |
| | |
| | | t.standard_code standardCode, |
| | | t.tool_model toolModel, |
| | | t.parama_table_name paramaTableName, |
| | | t.tool_picture toolPicture, |
| | | t1.application_type applicationType, |
| | | t1.supplier_id supplierId, |
| | | t1.province_city provinceCity, |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.tms.mapper.PreparationOrderDetailMapper"> |
| | | |
| | | <delete id="deleteByMainId" parameterType="java.lang.String"> |
| | | DELETE |
| | | FROM tms_preparation_order_detail |
| | | WHERE |
| | | preparation_order_id = #{mainId} |
| | | </delete> |
| | | |
| | | <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.tms.entity.PreparationOrderDetail"> |
| | | SELECT * |
| | | FROM tms_preparation_order_detail |
| | | WHERE |
| | | preparation_order_id = #{mainId} |
| | | </select> |
| | | <select id="queryPageList" resultType="org.jeecg.modules.tms.entity.PreparationOrderDetail"> |
| | | SELECT |
| | | t1.id id, |
| | | t1.preparation_order_id preparationOrderId, |
| | | t1.tool_code toolCode, |
| | | t1.outbound_quantity outboundQuantity, |
| | | t1.tenant_id tenantId, |
| | | t1.create_by createBy, |
| | | t1.create_time createTime, |
| | | t1.update_by updateBy, |
| | | t1.update_time updateTime, |
| | | t2.tool_code toolNum, |
| | | t2.chinese_name chineseName, |
| | | t2.tool_model toolModel, |
| | | t2.parama_table_name paramaTableName, |
| | | t3.application_type applicationType, |
| | | t3.supplier_id supplierId, |
| | | <choose> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '1'"> |
| | | t4.tool_material toolMaterial, |
| | | t4.part_material partMaterial |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '2'"> |
| | | t5.tool_material toolMaterial, |
| | | t5.part_material partMaterial |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '3'"> |
| | | t6.tool_material toolMaterial, |
| | | t6.part_material partMaterial |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '4'"> |
| | | t7.tool_material toolMaterial, |
| | | t7.part_material partMaterial |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '5'"> |
| | | t8.tool_material toolMaterial, |
| | | t8.part_material partMaterial |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '6'"> |
| | | t9.tool_material toolMaterial, |
| | | t9.part_material partMaterial |
| | | </when> |
| | | <otherwise> |
| | | t10.tool_material toolMaterial, |
| | | t10.part_material partMaterial |
| | | </otherwise> |
| | | </choose> |
| | | FROM tms_preparation_order_detail t1 |
| | | LEFT JOIN tms_base_tools t2 on t1.tool_code = t2.id |
| | | LEFT JOIN tms_tools_config_property t3 on t3.tool_code = t2.id |
| | | <choose> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '1'"> |
| | | LEFT JOIN tms_para_common_tool t4 on t4.tool_code = t2.id |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '2'"> |
| | | LEFT JOIN tms_para_hole_tools t5 on t5.tool_code = t2.id |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '3'"> |
| | | LEFT JOIN tms_para_threading_tool t6 on t6.tool_code = t2.id |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '4'"> |
| | | LEFT JOIN tms_para_mill_tool t7 on t7.tool_code = t2.id |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '5'"> |
| | | LEFT JOIN tms_para_turning_tools t8 on t8.tool_code = t2.id |
| | | </when> |
| | | <when test="ew.paramNameValuePairs.paramaTableName == '6'"> |
| | | LEFT JOIN tms_para_blade t9 on t9.tool_code = t2.id |
| | | </when> |
| | | <otherwise> |
| | | LEFT JOIN tms_para_common_tool t10 on t10.tool_code = t2.id |
| | | </otherwise> |
| | | </choose> |
| | | ${ew.customSqlSegment} |
| | | </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.tms.mapper.PreparationOrderMapper"> |
| | | |
| | | <select id="queryPageList" resultType="org.jeecg.modules.tms.entity.PreparationOrder"> |
| | | SELECT |
| | | t.id AS id, |
| | | t.preparation_order_num AS preparationOrderNum, |
| | | t.part_drawing_no AS partDrawingNo, |
| | | t.part_name AS partName, |
| | | t.part_material AS partMaterial, |
| | | t.production_processes_no AS productionProcessesNo, |
| | | t.batch_code AS batchCode, |
| | | t.machining_count AS machiningCount, |
| | | t.equipment_code AS equipmentCode, |
| | | t.nc_name AS ncName, |
| | | t.outbound_quantity AS outboundQuantity, |
| | | t.order_status AS orderStatus, |
| | | t.outbound_time AS outboundTime, |
| | | t.remark AS remark, |
| | | t.tenant_id AS tenantId, |
| | | t.create_by AS createBy, |
| | | t.create_time AS createTime, |
| | | t.update_by AS updateBy, |
| | | t.update_time AS updateTime |
| | | FROM tms_preparation_order t |
| | | ${ew.customSqlSegment} |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤åæç» |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IPreparationOrderDetailService extends IService<PreparationOrderDetail> { |
| | | |
| | | /** |
| | | * éè¿ä¸»è¡¨idæ¥è¯¢åè¡¨æ°æ® |
| | | * |
| | | * @param mainId |
| | | * @return List<PreparationOrderDetail> |
| | | */ |
| | | public List<PreparationOrderDetail> selectByMainId(String mainId); |
| | | |
| | | IPage<PreparationOrderDetail> queryPageList(Page<PreparationOrderDetail> page, Map<String, String[]> parameterMap); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import org.jeecg.modules.tms.entity.PreparationOrder; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.tms.entity.dto.PreparationOrderAndDetailDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IPreparationOrderService extends IService<PreparationOrder> { |
| | | |
| | | /** |
| | | * å é¤ä¸å¯¹å¤ |
| | | * |
| | | * @param id |
| | | */ |
| | | public void delMain (String id); |
| | | |
| | | /** |
| | | * æ¹éå é¤ä¸å¯¹å¤ |
| | | * |
| | | * @param idList |
| | | */ |
| | | public void delBatchMain (Collection<? extends Serializable> idList); |
| | | |
| | | |
| | | void editTotal(PreparationOrderAndDetailDto preparationOrderAndDetailDto); |
| | | |
| | | List<String> convertToOutboundOrder(List<String> preparationOrderIds); |
| | | |
| | | IPage<PreparationOrder> queryPageList(Page<PreparationOrder> page, Map<String, String[]> parameterMap); |
| | | } |
| | |
| | | num++; |
| | | //转æ¢åå符串并ä¿çåå¯¼é¶ |
| | | String result = String.format("%0" + currentCode.length() + "d", num); |
| | | //æå°äºç»´ç |
| | | //ä¿åå
¥åºæµæ°´ |
| | | InStoreDetail inStoreDetail = new InStoreDetail(); |
| | | inStoreDetail.setInboundTime(inboundTime); |
| | |
| | | private OutboundOrderMapper outboundOrderMapper; |
| | | @Autowired |
| | | private OutboundDetailMapper outboundDetailMapper; |
| | | @Autowired |
| | | private OutboundOrderConvert outboundOrderConvert; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addTotal(OutboundOrderAndDetailDto outboundOrder) { |
| | | OutboundOrder order = OutboundOrderConvert.INSTANCE.convert(outboundOrder); |
| | | OutboundOrder order = outboundOrderConvert.convert(outboundOrder); |
| | | order.setHandler(Objects.requireNonNull(getCurrentUser()).getId()); |
| | | order.setOutNum(businessCodeRuleService.generateBusinessCodeSeq("outBoundOrder")); |
| | | order.setOrderStatus(OutBillStatus.DRAFT.getValue()); |
| | |
| | | //å 餿ææç» |
| | | outboundDetailService.remove(new LambdaQueryWrapper<OutboundDetail>() |
| | | .eq(OutboundDetail::getOutStorehouseId, outboundOrder.getId())); |
| | | OutboundOrder outboundOrderUpdate = BeanUtil.copyProperties(outboundOrder, OutboundOrder.class); |
| | | OutboundOrder outboundOrderUpdate = outboundOrderConvert.convert(outboundOrder); |
| | | outboundOrderMapper.updateById(outboundOrderUpdate); |
| | | List<OutboundDetail> detailList = CollectionUtil.newArrayList(); |
| | | outboundOrder.getOutboundDetailList().forEach(item->{ |
| | |
| | | if (!Objects.equals(outboundOrder.getOrderStatus(), OutBillStatus.DRAFT.getValue())) { |
| | | throw new JeecgBootException("æ æ³æäº¤éèç¨¿ç¶æçåºåºç³è¯·åï¼"); |
| | | } |
| | | //éå®ç³è¯·åæç»ä¸å·¥å
·åºå |
| | | if (lockOutboundStock(id)) { |
| | | //å¯å¨æµç¨ |
| | | if (triggerProcess(outboundOrder)) { |
| | | outboundOrder.setOrderStatus(OutBillStatus.SUBMITTED.getValue()); |
| | | updateById(outboundOrder); |
| | | } |
| | | if (!OutStorehouseType.PREPARATION_OUTBOUND.getValue().equals(outboundOrder.getOutStorehouseType())) { |
| | | //䏿¯ä»åå¤å转å
¥çåºåºç³è¯·ï¼æ§è¡éåº |
| | | lockOutboundStock(id); |
| | | } |
| | | //å¯å¨æµç¨ |
| | | if (triggerProcess(outboundOrder)) { |
| | | outboundOrder.setOrderStatus(OutBillStatus.SUBMITTED.getValue()); |
| | | updateById(outboundOrder); |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import org.jeecg.modules.tms.mapper.PreparationOrderDetailMapper; |
| | | import org.jeecg.modules.tms.service.IPreparationOrderDetailService; |
| | | import org.springframework.stereotype.Service; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤åæç» |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class PreparationOrderDetailServiceImpl extends ServiceImpl<PreparationOrderDetailMapper, PreparationOrderDetail> implements IPreparationOrderDetailService { |
| | | |
| | | @Autowired |
| | | private PreparationOrderDetailMapper preparationOrderDetailMapper; |
| | | |
| | | @Override |
| | | public List<PreparationOrderDetail> selectByMainId(String mainId) { |
| | | return preparationOrderDetailMapper.selectByMainId(mainId); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<PreparationOrderDetail> queryPageList(Page<PreparationOrderDetail> page, Map<String, String[]> parameterMap) { |
| | | QueryWrapper<PreparationOrderDetail> queryWrapper = Wrappers.query(); |
| | | String[] preparationOrderIds = parameterMap.get("preparationOrderId"); |
| | | if (preparationOrderIds != null && preparationOrderIds.length > 0) { |
| | | queryWrapper.eq("t1.preparation_order_id", preparationOrderIds[0]); |
| | | } |
| | | return this.baseMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.jeecg.modules.tms.convert.PreparationOrderConvert; |
| | | import org.jeecg.modules.tms.entity.*; |
| | | import org.jeecg.modules.tms.entity.dto.PreparationOrderAndDetailDto; |
| | | import org.jeecg.modules.tms.enums.*; |
| | | import org.jeecg.modules.tms.mapper.PreparationOrderDetailMapper; |
| | | import org.jeecg.modules.tms.mapper.PreparationOrderMapper; |
| | | import org.jeecg.modules.tms.service.*; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: åå
·åå¤å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class PreparationOrderServiceImpl extends ServiceImpl<PreparationOrderMapper, PreparationOrder> implements IPreparationOrderService { |
| | | |
| | | @Autowired |
| | | private PreparationOrderMapper preparationOrderMapper; |
| | | @Autowired |
| | | private PreparationOrderDetailMapper preparationOrderDetailMapper; |
| | | @Autowired |
| | | private IPreparationOrderDetailService preparationOrderDetailService; |
| | | @Autowired |
| | | private IToolLedgerService toolLedgerService; |
| | | @Autowired |
| | | private IToolLedgerDetailService toolLedgerDetailService; |
| | | @Autowired |
| | | private IOutboundOrderService outboundOrderService; |
| | | @Autowired |
| | | private IOutboundDetailService outboundDetailService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | @Autowired |
| | | private IBaseToolsService baseToolsService; |
| | | @Autowired |
| | | private PreparationOrderConvert preparationOrderConvert; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delMain(String id) { |
| | | preparationOrderDetailMapper.deleteByMainId(id); |
| | | preparationOrderMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delBatchMain(Collection<? extends Serializable> idList) { |
| | | for(Serializable id:idList) { |
| | | preparationOrderDetailMapper.deleteByMainId(id.toString()); |
| | | preparationOrderMapper.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void editTotal(PreparationOrderAndDetailDto preparationOrderAndDetailDto) { |
| | | //å
å 餿ææç» |
| | | preparationOrderDetailMapper.delete(new LambdaQueryWrapper<PreparationOrderDetail>() |
| | | .eq(PreparationOrderDetail::getPreparationOrderId, preparationOrderAndDetailDto.getId())); |
| | | PreparationOrder preparationOrder = preparationOrderConvert.convert(preparationOrderAndDetailDto); |
| | | updateById(preparationOrder); |
| | | List<PreparationOrderDetail> detailUpdateList = CollectionUtil.newArrayList(); |
| | | preparationOrderAndDetailDto.getPreparationOrderDetailList().forEach(item->{ |
| | | item.setPreparationOrderId(preparationOrder.getId()); |
| | | detailUpdateList.add(item); |
| | | }); |
| | | preparationOrderDetailService.saveBatch(detailUpdateList); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<String> convertToOutboundOrder(List<String> preparationOrderIds) { |
| | | List<String> resultMessage = CollectionUtil.newArrayList(); |
| | | List<PreparationOrder> preparationOrderList = listByIds(preparationOrderIds); |
| | | //æ ¡éªåå¤åæç»ä¸çæ°é |
| | | for (PreparationOrder preparationOrder : preparationOrderList) { |
| | | if (PreparationOrderStatus.PENDING_AUDIT.getValue().equals(preparationOrder.getOrderStatus())) { |
| | | resultMessage.add("åå¤åã" + preparationOrder.getPreparationOrderNum() + "ãæªå®¡æ ¸ï¼æ æ³è½¬åºåºç³è¯·ï¼"); |
| | | continue; |
| | | } |
| | | if (PreparationOrderStatus.CONVERT.getValue().equals(preparationOrder.getOrderStatus())) { |
| | | resultMessage.add("åå¤åã" + preparationOrder.getPreparationOrderNum() + "ãå·²ç»è½¬åºï¼è¯·å¿éå¤æäº¤ï¼"); |
| | | continue; |
| | | } |
| | | List<PreparationOrderDetail> preparationOrderDetailList = preparationOrderDetailService.list(new LambdaQueryWrapper<PreparationOrderDetail>() |
| | | .eq(PreparationOrderDetail::getPreparationOrderId, preparationOrder.getId())); |
| | | Map<String, BigDecimal> preparationOrderToolCodeMap = preparationOrderDetailList.stream().collect(Collectors.toMap(PreparationOrderDetail::getToolCode, |
| | | PreparationOrderDetail::getOutboundQuantity, (k1, k2) -> k1)); |
| | | List<ToolLedgerDetail> toolLedgerDetailList = toolLedgerDetailService.list(new LambdaQueryWrapper<ToolLedgerDetail>() |
| | | .in(ToolLedgerDetail::getToolCode, preparationOrderToolCodeMap.keySet()) |
| | | .eq(ToolLedgerDetail::getQuantity, BigDecimal.ONE) |
| | | .eq(ToolLedgerDetail::getStatus, ToolCirculationStatus.IN_STOCK.getValue())); |
| | | Map<String, List<ToolLedgerDetail>> ledgerDetailToolCodeMap = toolLedgerDetailList.stream().collect(Collectors.groupingBy(ToolLedgerDetail::getToolCode)); |
| | | |
| | | List<OutboundDetail> outboundDetailList = CollectionUtil.newArrayList(); |
| | | for (PreparationOrderDetail preparationOrderDetail : preparationOrderDetailList) { |
| | | String toolCode = preparationOrderDetail.getToolCode(); |
| | | BigDecimal needQuantity = preparationOrderDetail.getOutboundQuantity(); |
| | | List<ToolLedgerDetail> toolLedgerDetails = ledgerDetailToolCodeMap.get(toolCode); |
| | | BigDecimal stockQuantity = Optional.ofNullable(toolLedgerDetails).orElse(Collections.emptyList()).stream() |
| | | .map(ToolLedgerDetail::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (CollectionUtil.isEmpty(toolLedgerDetails) || stockQuantity.compareTo(needQuantity) < 0) { |
| | | BaseTools tools = baseToolsService.getById(toolCode); |
| | | resultMessage.add("åå¤åã" + preparationOrder.getPreparationOrderNum() +"ãä¸ï¼ç¼ç 为ã" + tools.getToolCode() + "ãçå·¥å
·ï¼åºåä¸è¶³ï¼è½¬åºåºç³è¯·å失败ï¼"); |
| | | break; |
| | | } else { |
| | | //ä»åºåæç»ä¸ååºéè¦çæ°éï¼æå®å°æ |
| | | List<ToolLedgerDetail> selectedTools = toolLedgerDetails.subList(0, needQuantity.intValue()); |
| | | //çæç³è¯·åæç» |
| | | selectedTools.forEach(item->{ |
| | | OutboundDetail detail = new OutboundDetail() |
| | | .setToolCode(item.getToolCode()) |
| | | .setToolId(item.getToolId()) |
| | | .setOutboundQuantity(item.getQuantity()) |
| | | .setStorageLocation(item.getWarehouseId()) |
| | | .setOutboundLocation(item.getPositionCode()) |
| | | .setStatus(OutBoundStatusEnum.NOT_OUTBOUND.getValue()) |
| | | .setCreateBy(Objects.requireNonNull(getCurrentUser()).getUsername()) |
| | | .setCreateTime(new Date()); |
| | | outboundDetailList.add(detail); |
| | | }); |
| | | } |
| | | } |
| | | BigDecimal totalOutboundQuantity = preparationOrderDetailList.stream() |
| | | .map(detail -> Optional.ofNullable(detail.getOutboundQuantity()).orElse(BigDecimal.ZERO)) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (outboundDetailList.size() == totalOutboundQuantity.intValue()) { |
| | | //æå®å°æçæ°éä¸éæ±æ°éä¸è´ï¼æ»¡è¶³è½¬åºåºç³è¯·åçæ¡ä»¶ï¼çæåºåºç³è¯·å |
| | | OutboundOrder order = new OutboundOrder() |
| | | .setOutNum(businessCodeRuleService.generateBusinessCodeSeq("outBoundOrder")) |
| | | .setOutStorehouseType(OutStorehouseType.PREPARATION_OUTBOUND.getValue()) |
| | | .setHandler(Objects.requireNonNull(getCurrentUser()).getId()) |
| | | .setReviewer(Objects.requireNonNull(getCurrentUser()).getUsername()) |
| | | .setOrderStatus(OutBillStatus.DRAFT.getValue()) |
| | | .setSubjectMatter("åå
·åå¤å转å
¥") |
| | | .setPreparationOrderId(preparationOrder.getId()) |
| | | .setPartDrawingNo(preparationOrder.getPartDrawingNo()) |
| | | .setPartName(preparationOrder.getPartName()) |
| | | .setPartMaterial(preparationOrder.getPartMaterial()) |
| | | .setProductionProcessesNo(preparationOrder.getProductionProcessesNo()) |
| | | .setBatchCode(preparationOrder.getBatchCode()) |
| | | .setMachiningCount(preparationOrder.getMachiningCount()) |
| | | .setEquipmentCode(preparationOrder.getEquipmentCode()) |
| | | .setNcName(preparationOrder.getNcName()) |
| | | .setCreateBy(Objects.requireNonNull(getCurrentUser()).getUsername()) |
| | | .setCreateTime(new Date()); |
| | | outboundOrderService.save(order); |
| | | outboundDetailList.forEach(item -> item.setOutStorehouseId(order.getId())); |
| | | outboundDetailService.saveBatch(outboundDetailList); |
| | | //éå®åºåå°è´¦æç»åºå |
| | | LambdaQueryWrapper<ToolLedgerDetail> queryWrapper = new LambdaQueryWrapper<>(); |
| | | String codeIdString = outboundDetailList.stream() |
| | | .map(detail -> "'" + detail.getToolCode() + ":" + detail.getToolId() + "'") |
| | | .collect(Collectors.joining(",")); |
| | | String sql = "(tool_code + ':' + tool_id) IN (" + codeIdString + ")"; |
| | | queryWrapper.apply(sql); |
| | | toolLedgerDetailService.update(new ToolLedgerDetail().setQuantity(BigDecimal.ZERO), queryWrapper); |
| | | //éå®åºåå°è´¦ä¸»è¡¨ |
| | | List<ToolLedger> toolLedgerList = toolLedgerService.list(new LambdaQueryWrapper<ToolLedger>() |
| | | .in(ToolLedger::getToolId, preparationOrderToolCodeMap.keySet())); |
| | | toolLedgerList.forEach(item -> { |
| | | BigDecimal outboundQuantity = preparationOrderToolCodeMap.getOrDefault(item.getToolId(), BigDecimal.ZERO); |
| | | item.setAvailableCount(Optional.ofNullable(item.getAvailableCount()).orElse(BigDecimal.ZERO).subtract(outboundQuantity)); |
| | | }); |
| | | toolLedgerService.updateBatchById(toolLedgerList); |
| | | //æ´æ°åå¤åç¶æ |
| | | updateById(new PreparationOrder() |
| | | .setId(preparationOrder.getId()) |
| | | .setOutboundTime(new Date()) |
| | | .setOrderStatus(PreparationOrderStatus.CONVERT.getValue()));//3.已转åºåºç³è¯· |
| | | resultMessage.add("åå¤åã" + preparationOrder.getPreparationOrderNum() + "ã转åºåºç³è¯·åæåï¼"); |
| | | } |
| | | } |
| | | return resultMessage; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<PreparationOrder> queryPageList(Page<PreparationOrder> page, Map<String, String[]> parameterMap) { |
| | | QueryWrapper<PreparationOrder> queryWrapper = Wrappers.query(); |
| | | String[] preparationOrderNums = parameterMap.get("preparationOrderNum"); |
| | | if (preparationOrderNums != null && preparationOrderNums.length > 0) { |
| | | queryWrapper.like("t.preparation_order_num", preparationOrderNums[0]); |
| | | } |
| | | String[] orderStatuses = parameterMap.get("orderStatus"); |
| | | if (orderStatuses != null && orderStatuses.length > 0) { |
| | | queryWrapper.eq("t.order_status", orderStatuses[0]); |
| | | } |
| | | String[] beginTimes = parameterMap.get("beginTime"); |
| | | if (beginTimes != null && beginTimes.length > 0) { |
| | | queryWrapper.ge("t.create_time", beginTimes[0]); |
| | | } |
| | | String[] endTimes = parameterMap.get("endTime"); |
| | | if (endTimes != null && endTimes.length > 0) { |
| | | queryWrapper.le("t.create_time", endTimes[0]); |
| | | } |
| | | queryWrapper.orderByAsc("t.create_time"); |
| | | return this.baseMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | private LoginUser getCurrentUser() { |
| | | // è·åå½å认è¯çç»å½ç¨æ·ä¿¡æ¯ |
| | | Subject currentUser = SecurityUtils.getSubject(); |
| | | if (currentUser != null && currentUser.isAuthenticated()) { |
| | | Object principal = currentUser.getPrincipal(); |
| | | if (principal instanceof LoginUser) { |
| | | return (LoginUser) principal; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |