数采公式优化+任务切换sql语法错误+检验下单页面展示的数量和里面的数量不一致
| | |
| | | //然后提取公式 |
| | | String strs = formula.substring(0,formula.indexOf("(")); |
| | | String upperStr = strs.toUpperCase(); |
| | | if (upperStr.equals("")) { |
| | | throw new ErrorException(formula + "里面的公式没有函数"); |
| | | if (upperStr.matches(".*\\d.*")){ |
| | | upperStr=""; |
| | | } |
| | | System.out.println(upperStr); |
| | | //然后获取最外面括号里面的值,再根据","分割 |
| | |
| | | } |
| | | // 根据函数名称进行相应计算 |
| | | BigDecimal finalResult; |
| | | switch (upperStr) { |
| | | case "MAX": |
| | | finalResult = results.stream().max(BigDecimal::compareTo) |
| | | .orElseThrow(() -> new IllegalArgumentException("无法计算MAX值")); |
| | | break; |
| | | case "MIN": |
| | | finalResult = results.stream().min(BigDecimal::compareTo) |
| | | .orElseThrow(() -> new IllegalArgumentException("无法计算MIN值")); |
| | | break; |
| | | case "SUM": |
| | | finalResult = results.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | break; |
| | | case "ABS": |
| | | finalResult = results.stream().map(BigDecimal::abs).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | break; |
| | | case "AVERAGE": |
| | | finalResult = results.stream().reduce(BigDecimal.ZERO, BigDecimal::divide) |
| | | .divide(BigDecimal.valueOf(results.size()), 2, BigDecimal.ROUND_HALF_UP); |
| | | break; |
| | | case "MEDIAN": |
| | | int size = results.size(); |
| | | if (size % 2 == 1) { |
| | | finalResult = results.get(size / 2); |
| | | } else { |
| | | BigDecimal sum = results.get(size / 2 - 1).add(results.get(size / 2)); |
| | | finalResult = sum.divide(BigDecimal.valueOf(2), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | break; |
| | | default: |
| | | throw new UnsupportedOperationException("暂不支持函数: " + upperStr); |
| | | if (upperStr.equals("")||upperStr==null) { |
| | | finalResult=results.get(0); |
| | | }else { |
| | | switch (upperStr) { |
| | | case "MAX": |
| | | finalResult = results.stream().max(BigDecimal::compareTo) |
| | | .orElseThrow(() -> new IllegalArgumentException("无法计算MAX值")); |
| | | break; |
| | | case "MIN": |
| | | finalResult = results.stream().min(BigDecimal::compareTo) |
| | | .orElseThrow(() -> new IllegalArgumentException("无法计算MIN值")); |
| | | break; |
| | | case "SUM": |
| | | finalResult = results.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | break; |
| | | case "ABS": |
| | | finalResult = results.stream().map(BigDecimal::abs).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | break; |
| | | case "AVERAGE": |
| | | finalResult = results.stream().reduce(BigDecimal.ZERO, BigDecimal::divide) |
| | | .divide(BigDecimal.valueOf(results.size()), 2, BigDecimal.ROUND_HALF_UP); |
| | | break; |
| | | case "MEDIAN": |
| | | int size = results.size(); |
| | | if (size % 2 == 1) { |
| | | finalResult = results.get(size / 2); |
| | | } else { |
| | | BigDecimal sum = results.get(size / 2 - 1).add(results.get(size / 2)); |
| | | finalResult = sum.divide(BigDecimal.valueOf(2), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | break; |
| | | default: |
| | | throw new UnsupportedOperationException("暂不支持函数: " + upperStr); |
| | | } |
| | | } |
| | | System.out.println(results); |
| | | System.out.println("计算结果: " + finalResult); |
| | |
| | | return Result.success(); |
| | | } |
| | | |
| | | //待检的撤销 |
| | | @PutMapping("/updateInspected") |
| | | @ValueAuth |
| | | public Result<?> updateInspected(Integer id){ |
| | |
| | | @ApiModelProperty("样品型号") |
| | | private String sampleModel; |
| | | |
| | | private String assign; |
| | | |
| | | @ValueTableShow(5) |
| | | @ApiModelProperty("样品数量") |
| | | private Integer sampleNum; |
| | |
| | | public interface InsOrderMapper extends BaseMapper<InsOrder> { |
| | | |
| | | //获取检验下单数据 |
| | | IPage<SampleOrderDto> selectInsOrderPage(IPage<InsOrder> page, @Param("ew") QueryWrapper<SampleOrderDto> ew, @Param("laboratory") String laboratory); |
| | | IPage<SampleOrderDto> selectInsOrderPage(IPage<InsOrder> page, QueryWrapper<SampleOrderDto> ew, String laboratory); |
| | | |
| | | //修改检验下单数据 |
| | | int upInsOrderParameter(InsOrder itemParameter); |
| | |
| | | LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma); |
| | | LocalTime endTime = LocalTime.parse(shiftTime.getEndTime(), forma); |
| | | // 检查当前时间是否在范围内(包括边界) |
| | | boolean isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime); |
| | | boolean isWithinRange; |
| | | if (endTime.isAfter(startTime)) { |
| | | // 不跨天的情况 |
| | | isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime); |
| | | } else { |
| | | // 跨天的情况 |
| | | isWithinRange = !now.isBefore(startTime) || !now.isAfter(endTime); |
| | | } |
| | | //加班 |
| | | AuxiliaryOutputWorkingHours count1 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .eq(AuxiliaryOutputWorkingHours::getCheck, userId) |
| | |
| | | } |
| | | } |
| | | //判断是否是全部权限 |
| | | Power power = powerMapper.selectOne(Wrappers.<Power>lambdaQuery().eq(Power::getRoleId, roleId).eq(Power::getMenuMethod, "selectAllInsOrder")); |
| | | Power power = powerMapper.selectOne(Wrappers.<Power>lambdaQuery().eq(Power::getRoleId, roleId).eq(Power::getMenuMethod, "selectInsOrderParameter")); |
| | | if (ObjectUtils.isEmpty(power)) { |
| | | if (map1.get("look") == 1) { |
| | | //个人 |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.common.GetLook; |
| | |
| | | |
| | | @Override |
| | | public List<InsOrderTemplate> selectInsOrderTemplate(String company) { |
| | | if (company == null) { |
| | | if (ObjectUtils.isEmpty(company) || company.equals("")) { |
| | | return insOrderTemplateMapper.selectList(Wrappers.<InsOrderTemplate>lambdaQuery() |
| | | .select(InsOrderTemplate.class, info -> !info.getColumn().equals("thing"))); |
| | | } else { |
| | |
| | | } |
| | | String[] split1 = insSample.getFactory().split(" - "); |
| | | //判断长度 |
| | | if (split1.length > 3) { |
| | | if (split1.length > 4) { |
| | | if (ObjectUtils.isNotEmpty(split1[3])) { |
| | | list = list.stream().filter(list1 -> list1.getSample().equals(split1[3])).collect(Collectors.toList()); |
| | | }else if (split1[3].equals("")) { |
| | |
| | | private Integer userId; |
| | | |
| | | private String sonLaboratory; |
| | | private String laboratory; |
| | | |
| | | private Integer orderUserId; |
| | | |
| | |
| | | <select id="selectInsOrderPage" resultType="com.yuanchu.mom.dto.SampleOrderDto"> |
| | | select * |
| | | from ( |
| | | <!--SELECT |
| | | io.*, |
| | | ir.id report_id, |
| | | ir.url, |
| | | ir.url_s, |
| | | (select count(*) from ins_sample isa2 |
| | | where isa2.ins_order_id = io.id and CHAR_LENGTH(isa2.sample_code) <32 ) sample_num, |
| | | concat(ROUND((select count(*) from ins_product ip |
| | | where state = 1 and ins_result is not null and ip.ins_sample_id in (select id from ins_sample where |
| | | ins_sample.ins_order_id= io.id )) / (select count(*) from ins_product ip2 |
| | | where state = 1 and ip2.ins_sample_id in (select id from ins_sample where ins_sample.ins_order_id= io.id )) * |
| | | 100, 2), '%') insProgress, |
| | | group_concat(distinct isa.sample_code,' ') sample_code, |
| | | group_concat(distinct isa.sample,' ') sample_name, |
| | | group_concat(distinct isa.model,' ') sample_model, |
| | | u.name |
| | | FROM |
| | | ins_order io |
| | | LEFT JOIN ins_sample isa ON io.id = isa.ins_order_id |
| | | LEFT JOIN ( SELECT id, ins_order_id, is_ratify, url,url_s FROM ins_report WHERE is_ratify = 1 ) ir ON io.id = |
| | | ir.ins_order_id |
| | | left join user u on io.create_user = u.id |
| | | where 1=1 |
| | | <if test="laboratory!=null and laboratory!=''"> |
| | | and io.laboratory=#{laboratory} |
| | | </if> |
| | | GROUP BY |
| | | io.id--> |
| | | |
| | | SELECT |
| | | io.*, |
| | | isau.user_id assign, |
| | | ir.id report_id, |
| | | ir.url, |
| | | ir.url_s, |
| | |
| | | ins_order io |
| | | LEFT JOIN |
| | | ins_sample isa ON io.id = isa.ins_order_id |
| | | LEFT JOIN |
| | | ins_sample_user isau ON isau.ins_sample_id = io.id |
| | | LEFT JOIN |
| | | (SELECT id, ins_order_id, is_ratify, url, url_s FROM ins_report WHERE is_ratify = 1) ir ON io.id = ir.ins_order_id |
| | | LEFT JOIN |
| | |
| | | <if test="laboratory!=null and laboratory!=''"> |
| | | AND io.laboratory=#{laboratory} |
| | | </if> |
| | | GROUP BY |
| | | io.id |
| | | GROUP BY io.id,type |
| | | order by type desc,io.id desc |
| | | ) a |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | |
| | | io.type, |
| | | io.appointed, |
| | | io.send_time, |
| | | group_concat(distinct isa.sample,' ') sample, |
| | | group_concat(distinct isa.sample,' ') sampleType, |
| | | isu.user_id, |
| | | user.name userName, |
| | | ip.son_laboratory, |
| | |
| | | and (isu.user_id = #{userId} OR isu.user_id is NULL ) |
| | | </if> |
| | | OR isu.user_id is NULL |
| | | |
| | | GROUP BY |
| | | ip.son_laboratory, |
| | | io.id |
| | |
| | | OR user_id is NULL |
| | | ) isu2 on |
| | | isu2.ins_sample_id = a.id |
| | | where ins_state is not null |
| | | <if test="laboratory != null and laboratory!=''"> |
| | | and laboratory=#{laboratory} |
| | | </if> |
| | | ORDER BY |
| | | <!--a.user_id DESC,--> |
| | | a.type DESC, |
| | | a.id |
| | | ) b |
| | | where ins_state is not null |
| | | <if test="laboratory!=null and laboratory!=''"> |
| | | and laboratory=#{laboratory} |
| | | </if> |
| | | )A |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | |
| | | method, |
| | | man_day, |
| | | bsm, |
| | | ask, |
| | | tell , |
| | | ask, |
| | | tell, |
| | | `last_value`, |
| | | ip.ins_result ip_ins_result, |
| | | state, |