| | |
| | | @ValueClassify("检验下单") |
| | | @ApiOperation(value = "检验分配") |
| | | @PostMapping("/upInsOrder") |
| | | public Result<?> upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId) { |
| | | return Result.success(insOrderService.upInsOrder(orderId, sampleId, appointed, userId)); |
| | | public Result<?> upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId,String sonLaboratory) { |
| | | return Result.success(insOrderService.upInsOrder(orderId, sampleId, appointed, userId,sonLaboratory)); |
| | | } |
| | | @ValueClassify("检验下单") |
| | | @ApiOperation(value = "添加检验下单数据") |
| | |
| | | @ValueClassify("检验任务") |
| | | @ApiOperation(value = "任务交接") |
| | | @PostMapping("/upPlanUser") |
| | | public Result<?> upPlanUser(Integer userId, Integer orderId) { |
| | | return Result.success(insOrderPlanService.upPlanUser(userId, orderId)); |
| | | public Result<?> upPlanUser(Integer userId, Integer orderId,String sonLaboratory) { |
| | | return Result.success(insOrderPlanService.upPlanUser(userId, orderId, sonLaboratory)); |
| | | } |
| | | |
| | | @ValueClassify("检验任务") |
| | |
| | | */ |
| | | public interface InsSampleMapper extends BaseMapper<InsSample> { |
| | | |
| | | IPage<InsOrderPlanVO> findInsSampleAndOrder(Page page, QueryWrapper<InsOrderPlanDTO> ew, Integer userId); |
| | | IPage<InsOrderPlanVO> findInsSampleAndOrder(Page page, QueryWrapper<InsOrderPlanDTO> ew, Integer userId,String sonLaboratory); |
| | | |
| | | IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, QueryWrapper<InsOrderPlanDTO> ew, Integer userId); |
| | | |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | |
| | | /** |
| | | * 样品负责人记录 |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | public InsSampleUser(Integer insSampleId, Integer userId, Integer state) { |
| | | /** |
| | | * 子试验室 |
| | | * @param insSampleId |
| | | * @param userId |
| | | * @param state |
| | | */ |
| | | private String sonLaboratory; |
| | | |
| | | public InsSampleUser(Integer insSampleId, Integer userId, Integer state,String sonLaboratory) { |
| | | this.insSampleId = insSampleId; |
| | | this.userId = userId; |
| | | this.state = state; |
| | | this.sonLaboratory = sonLaboratory; |
| | | } |
| | | } |
| | |
| | | |
| | | Map<String, Object> doInsOrder(Integer id, String laboratory); |
| | | |
| | | int upPlanUser(Integer userId, Integer orderId); |
| | | int upPlanUser(Integer userId, Integer orderId,String sonLaboratory); |
| | | |
| | | int verifyPlan(Integer orderId, String laboratory, Integer type, String tell); |
| | | |
| | |
| | | Map<String, Object> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto); |
| | | |
| | | //修改检验下单数据 |
| | | int upInsOrder(Integer orderId,Integer sampleId, String appointed, Integer userId); |
| | | int upInsOrder(Integer orderId,Integer sampleId, String appointed, Integer userId,String sonLaboratory); |
| | | |
| | | int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing); |
| | | |
| | |
| | | userId = map1.get("userId"); |
| | | insOrderPlanDTO.setUserId(userId.longValue()); |
| | | } |
| | | IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId); |
| | | String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//试验室 |
| | | IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory); |
| | | map.put("body", insOrderPage); |
| | | return map; |
| | | } |
| | |
| | | return map; |
| | | } |
| | | |
| | | //认领任务 |
| | | @Override |
| | | public boolean claimInsOrderPlan(InsOrderPlanDTO entity) { |
| | | if (Objects.isNull(entity)) { |
| | |
| | | } |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null); |
| | | Integer userId = map1.get("userId"); |
| | | InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1); |
| | | InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1,entity.getSonLaboratory()); |
| | | return insSampleUserMapper.insert(insSampleUser) > 0; |
| | | } |
| | | |
| | |
| | | productVos = productVos.stream().sorted(Comparator.comparing(productVo -> productVo.getInsProduct().getInspectionItemClass())).collect(Collectors.toList()); |
| | | } |
| | | else { |
| | | //电力--热循环 |
| | | //电力--热循环和温升试验 |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem)); |
| | |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass()) |
| | | .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())); |
| | | if (count == 0 && ObjectUtils.isNotEmpty(insProduct.getManHour())) { |
| | | //添加每个人的产量工时 |
| | | //添加每个人的产量工时,要判断当前时间是否是这个人的排班时间,如果不是则是加班 |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//检测父项 |
| | | auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//检测子项 |
| | |
| | | }); |
| | | } |
| | | |
| | | //交接 |
| | | @Override |
| | | public int upPlanUser(Integer userId, Integer orderId) { |
| | | public int upPlanUser(Integer userId, Integer orderId,String sonLaboratory) { |
| | | InsSampleUser insSampleUser = new InsSampleUser(); |
| | | insSampleUser.setUserId(userId); |
| | | insSampleUser.setInsSampleId(orderId); |
| | | insSampleUser.setState(0); |
| | | insSampleUser.setSonLaboratory(sonLaboratory); |
| | | return insSampleUserMapper.insert(insSampleUser); |
| | | } |
| | | |
| | |
| | | info.setViewStatus(false); |
| | | info.setJumpPath("b1-inspect-order-plan"); |
| | | informationNotificationService.addInformationNotification(info); |
| | | upPlanUser(verifyUser, orderId); |
| | | //复核人--检验单相关负责人 |
| | | InsSampleUser insSampleUser = new InsSampleUser(); |
| | | insSampleUser.setUserId(verifyUser); |
| | | insSampleUser.setInsSampleId(orderId); |
| | | insSampleUser.setState(0); |
| | | insSampleUser.setSonLaboratory(laboratory); |
| | | insSampleUserMapper.insert(insSampleUser); |
| | | /*校验一下result表*/ |
| | | CompletableFuture.supplyAsync(() -> { |
| | | List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList()); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId) { |
| | | public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId,String sonLaboratory) { |
| | | InsOrder insOrder = new InsOrder(); |
| | | insOrder.setId(orderId); |
| | | insOrder.setAppointed(LocalDate.parse(appointed)); |
| | |
| | | insSampleUser.setState(0); |
| | | insSampleUser.setUserId(userId); |
| | | insSampleUser.setInsSampleId(orderId); |
| | | insSampleUser.setSonLaboratory(sonLaboratory); |
| | | insSampleUserMapper.insert(insSampleUser); |
| | | } |
| | | return 1; |
| | |
| | | GROUP_CONCAT(b.inspection_item2 |
| | | SEPARATOR ',') |
| | | inspection_item from (select * , |
| | | GROUP_CONCAT(CONCAT(inspection_item,'',inspection_item_subclass) SEPARATOR ',')inspection_item2 from ins_product where state = 1 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP |
| | | GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from ins_product where state = 1 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP |
| | | BY b.ins_sample_id) c ON c.ins_sample_id = isa.id |
| | | where (i.state = 1 or i.state = 3 or i.state = 4) and c.ins_sample_id IS not NULL)A |
| | | GROUP BY |
| | |
| | | LEFT JOIN ( <!--SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id --> |
| | | SELECT * |
| | | FROM ins_sample_user u |
| | | WHERE (ins_sample_id, id) IN ( |
| | | WHERE son_laboratory=#{sonLaboratory} and (ins_sample_id, id) IN ( |
| | | SELECT ins_sample_id, MAX(id) |
| | | FROM ins_sample_user |
| | | WHERE son_laboratory=#{sonLaboratory} |
| | | GROUP BY ins_sample_id |
| | | ) |
| | | ORDER BY ins_sample_id, id |
| | |
| | | ) a |
| | | LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory |
| | | left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM |
| | | ins_sample_user GROUP BY ins_sample_id) md where td.id = md.id |
| | | ins_sample_user where son_laboratory=#{sonLaboratory} GROUP BY ins_sample_id) md where td.id = md.id |
| | | <if test="userId !=null and userId!=''"> |
| | | and user_id = #{userId} OR user_id is NULL |
| | | </if> |
| | |
| | | package com.yuanchu.mom.backup; |
| | | |
| | | import com.yuanchu.mom.dto.PerformanceShiftAddDto; |
| | | import com.yuanchu.mom.mapper.EnumMapper; |
| | | import com.yuanchu.mom.pojo.Enums; |
| | | import com.yuanchu.mom.pojo.PerformanceShift; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.EnumService; |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.time.temporal.WeekFields; |
| | | import java.util.Date; |
| | | import java.util.Dictionary; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.stream.Collectors; |
| | | |
| | | //@Component |
| | | @Component |
| | | @EnableScheduling |
| | | @Slf4j |
| | | public class MysqlDataBackup { |
| | |
| | | @Value("${backup.mysqldump}") |
| | | private String mysqldump; |
| | | |
| | | @Resource |
| | | private PerformanceShiftService performanceShiftService; |
| | | |
| | | @Resource |
| | | private EnumService enumService; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | /** |
| | | * 每天晚上23点05秒执行 【 0 0 4 1/1 * ? 】 |
| | | * 测试 20 秒一次【 0/20 * * * * ? 】@Scheduled(cron = "5 * 23 * * ?") |
| | | */ |
| | | // @Scheduled(cron = "5 0 23 * * ?") |
| | | //@Scheduled(cron = "0/20 * * * * ?") |
| | | private void configureTasks() { |
| | | log.info("【备份数据库】--START"); |
| | | String dbUrl2 = dbUrl.replace("jdbc:mysql://", ""); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时任务,每个月1号的00:00:00 |
| | | * 给每个人都进行排班(默认早班) |
| | | */ |
| | | //@Scheduled(cron = "0 0 0 1 *?") |
| | | //@Scheduled(cron = "0/20 * * * * ?") |
| | | private void timerCreateSchedule(){ |
| | | System.out.println("开始给每个人进行排班,默认早班======start"); |
| | | // TODO 给每个人都进行排班(默认早班) |
| | | PerformanceShiftAddDto performanceShiftAddDto = new PerformanceShiftAddDto(); |
| | | //班次--早(查询字典) |
| | | List<Enums> shiftType = enumService.selectEnumByCategory("班次类型"); |
| | | List<String> collect = shiftType.stream().filter(enums -> enums.getLabel().equals("早")).map(enums -> enums.getValue()).collect(Collectors.toList()); |
| | | performanceShiftAddDto.setShift(collect.get(0)); |
| | | //人员--所有人 |
| | | String userIds = userService.getDeviceManager().stream().map(user -> user.getId().toString()).distinct().collect(Collectors.joining(",")); |
| | | performanceShiftAddDto.setUserId(userIds); |
| | | //周次--当月所有 |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | // 获取本月的第一天和最后一天 |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | // 获取周字段信息(根据区域设置) |
| | | WeekFields weekFields = WeekFields.of(Locale.getDefault()); |
| | | // 获取本月第一天的周一 |
| | | LocalDate startOfWeek = firstDayOfMonth.with(TemporalAdjusters.previousOrSame(weekFields.getFirstDayOfWeek())); |
| | | // 遍历本月所有天数,找出每周的第一天和最后一天 |
| | | LocalDate endOfWeek; |
| | | while (startOfWeek.isBefore(firstDayOfMonth.plusMonths(1))) { |
| | | endOfWeek = startOfWeek.plusDays(6); |
| | | LocalDateTime startDateTime = LocalDateTime.of(startOfWeek, LocalTime.MIDNIGHT); |
| | | LocalDateTime endDateTime = LocalDateTime.of(endOfWeek, LocalTime.MIDNIGHT); |
| | | System.out.println("Week starts on " + startDateTime + " and ends on " + endDateTime); |
| | | performanceShiftAddDto.setStartWeek(startDateTime); |
| | | performanceShiftAddDto.setEndWeek(endDateTime); |
| | | performanceShiftService.performanceShiftAdd(performanceShiftAddDto); |
| | | startOfWeek = startOfWeek.plusWeeks(1); |
| | | } |
| | | |
| | | System.out.println("排班结束======end"); |
| | | } |
| | | |
| | | /** |
| | | * 判断文件是否存在,不存在创建 |
| | | */ |
| | |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.time.temporal.WeekFields; |
| | | import java.util.Locale; |
| | | |
| | | |
| | | @SpringBootTest |
| | | class SystemRunApplicationTest { |
| | | |
| | | @Test |
| | | void contextLoads() throws Exception { |
| | | void contextLoads() { |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | |
| | | // 获取本月的第一天和最后一天 |
| | | LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | |
| | | // 获取周字段信息(根据区域设置) |
| | | WeekFields weekFields = WeekFields.of(Locale.getDefault()); |
| | | |
| | | // 获取本月第一天的周一 |
| | | LocalDate startOfWeek = firstDayOfMonth.with(TemporalAdjusters.previousOrSame(weekFields.getFirstDayOfWeek())); |
| | | |
| | | // 遍历本月所有天数,找出每周的第一天和最后一天 |
| | | LocalDate endOfWeek; |
| | | while (startOfWeek.isBefore(firstDayOfMonth.plusMonths(1))) { |
| | | endOfWeek = startOfWeek.plusDays(6); |
| | | LocalDateTime startDateTime = LocalDateTime.of(startOfWeek, LocalTime.MIDNIGHT); |
| | | LocalDateTime endDateTime = LocalDateTime.of(endOfWeek, LocalTime.MIDNIGHT); |
| | | |
| | | System.out.println("Week starts on " + startDateTime + " and ends on " + endDateTime); |
| | | |
| | | startOfWeek = startOfWeek.plusWeeks(1); |
| | | } |
| | | } |
| | | } |