skyouc
3 天以前 037194759439e7799c6728ccd15bcb716b5c7475
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
@@ -57,40 +57,46 @@
            throw new CoolException("物料导入失败!!");
        }
        List<Matnr> matnrs = new ArrayList<>();
        List<Map<String, String>> list = result.getList();
        List<MatnrsTemplate> list = result.getList();
        list.forEach(template -> {
            Matnr matnr = new Matnr();
            matnr.setBarcode(template.get("barcode"))
                    .setCode(template.get("code"))
                    .setDescrible(template.get("describle"))
                    .setColor(template.get("color"))
                    .setFlagCheck(!Objects.isNull(template.get("flagCheck")) ? Short.parseShort(template.get("flagCheck")) : 0)
                    .setWeight(!Objects.isNull(template.get("weight")) ? Double.parseDouble(template.get("weight")) : 0.0)
                    .setValidWarn(!Objects.isNull(template.get("validWarn")) ? Integer.parseInt(template.get("validWarn")): 0)
                    .setValid(!Objects.isNull(template.get("valid")) ? Integer.parseInt( template.get("valid")) : 0)
                    .setUnit(template.get("unit"))
                    .setStockUnit(template.get("purUnit"))
                    .setSpec(template.get("spec"))
                    .setStagn(!Objects.isNull(template.get("stagn")) ? Integer.parseInt(template.get("stagn")) : 0)
                    .setModel(template.get("model"))
                    .setGroupCode(template.get("groupCode"))
                    .setPurUnit(template.get("purUnit"))
                    .setStockLevel(!Objects.isNull(template.get("stockLevel")) ? Short.parseShort(template.get("stockLevel")) : 0)
                    .setSafeQty(!Objects.isNull(template.get("safeQty")) ? Double.parseDouble(template.get("safeQty")) : 0)
                    .setMinQty(!Objects.isNull(template.get("safeQty")) ? Double.parseDouble(template.get("minQty")) : 0);
            if (Objects.isNull(template.get("groupCode")) && Objects.isNull(template.get("groupName"))) {
            matnr.setBarcode(template.getBarcode())
                    .setCode(template.getCode())
                    .setName(template.getName())
                    .setDescrible(template.getDescrible())
                    .setColor(template.getColor())
                    .setFlagCheck(!Objects.isNull(template.getFlagCheck()) ? Short.parseShort(template.getFlagCheck()) : 0)
                    .setWeight(!Objects.isNull(template.getWeight()) ? Double.parseDouble(template.getWeight()) : 0.0)
                    .setValidWarn(!Objects.isNull(template.getValidWarn()) ? Integer.parseInt(template.getValidWarn()): 0)
                    .setValid(!Objects.isNull(template.getValid()) ? Integer.parseInt( template.getValid()) : 0)
                    .setUnit(template.getUnit())
                    .setStockUnit(template.getPurUnit())
                    .setShipperId(template.getShipperId())
                    .setSize(template.getSize())
                    .setSpec(template.getSpec())
                    .setStagn(!Objects.isNull(template.getStagn()) ? Integer.parseInt(template.getStagn()) : 0)
                    .setModel(template.getModel())
                    .setGroupCode(template.getGroupCode())
                    .setPurUnit(template.getPurUnit())
                    .setStockLevel(!Objects.isNull(template.getStockLevel()) ? Short.parseShort(template.getStockLevel()) : 0)
                    .setSafeQty(!Objects.isNull(template.getSafeQty()) ? Double.parseDouble(template.getSafeQty()) : 0)
                    .setMinQty(!Objects.isNull(template.getMinQty()) ? Double.parseDouble(template.getMinQty()) : 0);
            if (Objects.isNull(template.getGroupCode()) && Objects.isNull(template.getGroupName())) {
                MatnrGroup matnrGroups = matnrGroupService.getOne(new LambdaQueryWrapper<MatnrGroup>()
                        .eq(!Objects.isNull(template.get("groupCode")), MatnrGroup::getCode, template.get("groupCode"))
                        .eq(!Objects.isNull(template.get("groupName")),MatnrGroup::getName, template.get("groupName")));
                        .eq(!Objects.isNull(template.getGroupCode()), MatnrGroup::getCode, template.getGroupCode())
                        .eq(!Objects.isNull(template.getGroupName()),MatnrGroup::getName, template.getGroupName()));
                matnr.setGroupId(matnrGroups.getId());
            }
            //获取动态字段,并保存明细内容
            if (!FieldsUtils.getFieldsSta().isEmpty()) {
                String uuid = CommonUtil.randomUUID16();
                matnr.setFieldsIndex(uuid);
                //保存物料扩展属性值
                try {
                    FieldsUtils.saveFields(template, uuid);
                    Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(template), Map.class);
                    String uuid = CommonUtil.randomUUID16();
                    boolean b = FieldsUtils.saveFields(map, uuid);
                    if (b) {
                        matnr.setFieldsIndex(uuid);
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
@@ -106,17 +112,28 @@
    @Override
    public PageParam<Matnr, BaseParam> getMatnrPage(PageParam<Matnr, BaseParam> pageParam, Map<String, Object> params) {
        QueryWrapper<Matnr> queryWrapper = pageParam.buildWrapper(true);
        List<Long> longs = new ArrayList<>();
        if (params.containsKey("groupId")) {
            Object groupId = params.get("groupId");
            if (!Objects.isNull(groupId)) {
                List<MatnrGroup> matnrGroups = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getParentId, Long.parseLong(groupId.toString())).select(MatnrGroup::getId));
                if (!matnrGroups.isEmpty()) {
                    List<Long> longs = matnrGroups.stream().map(MatnrGroup::getId).collect(Collectors.toList());
                    queryWrapper.or().in("group_id", longs);
            MatnrGroup group = matnrGroupService.getById(groupId.toString());
            if (null != group){
                pageParam.getWhere().getMap().remove("groupId");
                if(!group.getCode().equals("01")){
                    List<MatnrGroup> matnrGroups = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>()
                            .eq(MatnrGroup::getParentId, Long.parseLong(groupId.toString()))
                            .select(MatnrGroup::getId));
                    if (!matnrGroups.isEmpty()) {
                        longs = matnrGroups.stream().map(MatnrGroup::getId).collect(Collectors.toList());
                    }
                    longs.add(group.getId());
                }
            }
        }
        QueryWrapper<Matnr> queryWrapper = pageParam.buildWrapper(true);
        queryWrapper.in(!longs.isEmpty(),"group_id", longs);
        FieldsUtils.setFieldsFilters(queryWrapper,pageParam,Matnr.class);
        /**拼接扩展字段*/
        PageParam<Matnr, BaseParam> page = this.page(pageParam, queryWrapper);
        List<Matnr> records = page.getRecords();