Crunchy
2024-04-23 4f986140a10e71c07c7001ccbcda6e93e17736b1
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -123,9 +123,9 @@
    public Map<String, Object> doInsOrder(Integer id, String laboratory) {
        InsOrder insOrder = new InsOrder();
        insOrder.setId(id);
        insOrder.setInsState(1);
        InsOrder order = insOrderMapper.selectById(id);
        if (BeanUtil.isEmpty(order.getInsTime())) {
            insOrder.setInsState(1);
            insOrder.setInsTime(LocalDateTime.now());
            insOrderMapper.updateById(insOrder);
        }
@@ -165,7 +165,7 @@
                        map.put("v", JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v"));
                        try {
                            if ((insValue.get("u") == null || insValue.get("u").equals("")) && StrUtil.isNotEmpty(JSON.parseObject(JSON.toJSONString(insValue.get("v"))).get("v").toString())) {
                                map.put("u", userId);
                                map.put("u", userId + "");
                            } else {
                                map.put("u", insValue.get("u"));
                            }
@@ -190,14 +190,23 @@
                if (resValue.get("v") != null) {
                    insProduct.setLastValue(JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v") + "");
                }
                JSONObject equipValue = JSON.parseObject(JSON.toJSONString(jo.get("equipValue")));
                try {
                    result.setEquipValue(JSON.parseObject(JSON.toJSONString(equipValue.get("v"))).get("v") + "");
                } catch (Exception ignored) {
                    result.setEquipValue(null);
                if (jo.get("equipValue") != null) {
                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue")));
                    List<Map<String, Object>> ev = new ArrayList<>();
                    for (Object o : jsonArray2) {
                        JSONObject equipValue = JSON.parseObject(JSON.toJSONString(o));
                        Map<String, Object> map = new HashMap<>();
                        map.put("v", JSON.parseObject(JSON.toJSONString(equipValue.get("v"))).get("v"));
                        ev.add(map);
                    }
                    result.setEquipValue(JSON.toJSONString(ev));
                }
                JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult")));
                insProduct.setInsResult(Integer.parseInt(JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + ""));
                try {
                    JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult")));
                    String ir = JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + "";
                    insProduct.setInsResult(Integer.parseInt(ir));
                } catch (Exception e) {
                }
                if (BeanUtil.isEmpty(result.getId())) {
                    result.setCreateUser(userId);
                    result.setUpdateUser(userId);
@@ -496,33 +505,9 @@
                JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0)));
                JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config")));
                List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class);
//                List<JSONObject> tableData = new ArrayList<>();
                Map<String, Object> style = new HashMap<>();
                style.put("rowlen", config.get("rowlen"));
                style.put("columnlen", config.get("columnlen"));
                /*int r = -1;
                if (BeanUtil.isNotEmpty(cellData)) {
                    for (JSONObject o : cellData) {
                        JSONObject v = JSON.parseObject(JSON.toJSONString(o.get("v")));
                        tableData.add(o);
                        if (BeanUtil.isNotEmpty(v.get("ps"))) {
                            JSONObject ps = JSON.parseObject(JSON.toJSONString(v.get("ps")));
                            if (ps.get("value").equals("检验项") && v.get("v").equals(product.getInspectionItem())) {
                                tableData.add(o);
                                r = Integer.parseInt(o.get("r") + "");
                                continue;
                            }
                        }
                        if (tableData.size() > 0) {
                            if ((Integer.parseInt(o.get("r") + "") == r + 1 || Integer.parseInt(o.get("r") + "") == r) && !(o.get("v") + "").equals("{\"ht\":\"0\"}")) {
                                r = Integer.parseInt(o.get("r") + "");
                                tableData.add(o);
                            } else {
                                break;
                            }
                        }
                    }
                }*/
                product.setTemplate(cellData);
                product.setStyle(style);
            }
@@ -533,9 +518,13 @@
    public int submitPlan(Integer orderId, String laboratory) {
        List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId));
        List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList());
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getSonLaboratory, laboratory).isNotNull(InsProduct::getInsResult));
        if (insProducts.size() == 0) {
            return 0;
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getSonLaboratory, laboratory).eq(InsProduct::getState, 1).isNull(InsProduct::getInsResult));
        if (insProducts.size() > 0) {
            String str = "";
            for (InsProduct product : insProducts) {
                str += product.getInspectionItem()+product.getInspectionItemSubclass()+";";
            }
            throw new ErrorException("以下是未检验的项目:"+str);
        }
        insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, orderId).eq(InsOrderState::getLaboratory, laboratory).set(InsOrderState::getInsTime, LocalDateTime.now()).set(InsOrderState::getInsState, 3));
        return 1;