| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | |
| | | |
| | | @Resource |
| | | private InsProductUserMapper insProductUserMapper; |
| | | |
| | | @Resource |
| | | AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper; |
| | | |
| | | @Resource |
| | | private InformationNotificationService informationNotificationService; |
| | |
| | | insProduct.setUpdateUser(userId); |
| | | insProductMapper.updateById(insProduct); |
| | | insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId())); |
| | | |
| | | //查询检验单信息 |
| | | InsOrder insOrder = insOrderMapper.selectById(insSampleMapper.selectById(insProduct.getInsSampleId()).getInsOrderId()); |
| | | //校验如果这个人这个检测项目已经添加过了则不需要再新增 |
| | | Long count = auxiliaryOutputWorkingHoursMapper.selectCount(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheck, userMapper.selectById(userId).getName()) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectProject, insProduct.getInspectionItemSubclass() + insProduct.getInspectionItem()) |
| | | .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())); |
| | | if (count == 0) { |
| | | //添加每个人的产量工时 |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | auxiliaryOutputWorkingHours.setInspectProject(insProduct.getInspectionItemSubclass() + insProduct.getInspectionItem());//检测项目 |
| | | auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号 |
| | | auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//非加班工时 |
| | | auxiliaryOutputWorkingHours.setAmount(1);//非加班数量 |
| | | auxiliaryOutputWorkingHours.setOutputWorkTime(insProduct.getManHour());//产量工时 |
| | | auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组 |
| | | auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now());//日期 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTime parse = DateUtil.parse(localDateTime.format(formatter)); |
| | | auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期 |
| | | auxiliaryOutputWorkingHours.setWeek(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1)));//周次 |
| | | auxiliaryOutputWorkingHours.setCheck(userMapper.selectById(userId).getName());//检测人 |
| | | auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours); |
| | | } |
| | | |
| | | InsSample insSample = insSampleMapper.selectById(insProductMapper.selectById(insProduct.getId()).getInsSampleId()); |
| | | insSample.setInsState(1); |
| | | Long l = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | |
| | | public int pxToCm(int px) { |
| | | return px / 9; |
| | | } |
| | | |
| | | // 获取两个localDateTime的每一天 |
| | | public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) { |
| | | List<LocalDateTime> localDateTimes = new ArrayList<>(); |
| | | LocalDate currentDate = start.toLocalDate(); |
| | | LocalDateTime currentLocalDateTime = start; |
| | | while (!currentDate.isAfter(end.toLocalDate())) { |
| | | localDateTimes.add(currentLocalDateTime); |
| | | currentLocalDateTime = currentLocalDateTime.plusDays(1); |
| | | currentDate = currentDate.plusDays(1); |
| | | } |
| | | return localDateTimes; |
| | | } |
| | | |
| | | public static String getWeek(String dayStr) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | try { |
| | | Date date = sdf.parse(dayStr); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | return day + " " + getWeekDay(dayOfWeek); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String getWeekDay(int dayOfWeek) { |
| | | switch (dayOfWeek) { |
| | | case Calendar.MONDAY: |
| | | return "周一"; |
| | | case Calendar.TUESDAY: |
| | | return "周二"; |
| | | case Calendar.WEDNESDAY: |
| | | return "周三"; |
| | | case Calendar.THURSDAY: |
| | | return "周四"; |
| | | case Calendar.FRIDAY: |
| | | return "周五"; |
| | | case Calendar.SATURDAY: |
| | | return "周六"; |
| | | case Calendar.SUNDAY: |
| | | return "周日"; |
| | | default: |
| | | return "未知"; |
| | | } |
| | | } |
| | | } |