shichongfu
2023-10-08 73f1492a2e14fec08df159d4ab9a88e1d660c572
设备
已添加3个文件
已修改2个文件
463 ■■■■■ 文件已修改
src/main/java/com/product/mobile/core/controller/SystemTableMetaController.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/NavBarManagerService.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/SystemTableMetaService.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/ide/INavBarManagerService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/device/controller/DeviceManagerController.java 232 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/controller/SystemTableMetaController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
package com.product.mobile.core.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import com.product.admin.config.SystemCode;
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.mobile.core.service.ApplicationsService;
import com.product.mobile.core.service.SystemTableMetaService;
import com.product.module.sys.version.ApiVersion;
/**
 * App指定表结构信息
 *
 * @author shicf
 */
@RequestMapping("/api/mobile")
@RestController
public class SystemTableMetaController extends AbstractBaseController {
    @Autowired
    SystemTableMetaService systemTableMetaService;
    /**
     * èŽ·å–æŒ‡å®šè¡¨çš„æ•°æ®ç»“æž„ä¿¡æ¯
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/system/table/list-meta/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String tableMetaList(HttpServletRequest request) {
        FieldSetEntity fse = null;
        Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
        if (bean != null) {
            RequestParameterEntity reqp = (RequestParameterEntity) bean;
            fse = reqp.getFormData();
        }
        if (bean == null || fse == null) {
            SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
        }
        return this.OK_List(systemTableMetaService.getSystemTableMeta(fse));
    }
}
src/main/java/com/product/mobile/core/service/NavBarManagerService.java
@@ -199,6 +199,89 @@
        }
        return null;
    }
    /**
     * è®¾å¤‡ç®¡ç†
     * ç§»åŠ¨ç«¯èŽ·å–å¯¼èˆªæ ï¼ˆå±•ç¤ºè·³è½¬ï¼‰
     *
     * @return
     * @throws BaseException
     */
    @Override
    public List<Object> getDeviceNarBarTree() throws BaseException {
        SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
        if (currentUser == null) {
            return null;
        }
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT ");
        sql.append(" a.function_uuid, ");
        sql.append(" a.nav_bar_img, ");
        sql.append(" a.nav_bar_name, ");
        sql.append(" a.module_category, ");
        sql.append(" b.route_name, ");
        sql.append(" concat( '/', b.uuid ) path, ");
        sql.append(" a.uuid, ");
        sql.append(" a.sequence,a.module_sequence ");
        sql.append(" FROM ");
        sql.append(" product_sys_app_nav_bar a ");
        sql.append(" JOIN product_sys_functions c ON a.function_uuid = c.uuid ");
        sql.append(" AND c.status_uuid = 1 ");
        sql.append(" and c.function_type_uuid=1 ");
        sql.append(" AND concat( ',', c.client_type_uuid, ',' ) LIKE '%,App,%' ");
        sql.append(" JOIN product_sys_function_buttons b ON a.function_uuid = b.function_uuid ");
        sql.append(" AND b.button_type = 1 ");
        sql.append(" AND b.is_main = 1 ");
        sql.append(" AND b.client_type_uuid = 'App' ");
        sql.append(" JOIN product_sys_function_permission permission ON concat( ',', permission.button_uuid, ',' ) LIKE concat( ',%', b.uuid, '%,' ) ");
        sql.append(" JOIN product_sys_role role on role.uuid=permission.role_uuid and role.is_used=1 ");
        //使用角色做功能权限限制
        sql.append(" and ").append(BaseUtil.buildQuestionMarkFilter("role.uuid", currentUser.getRoles().split(","), true));
        //添加设备管理模块过滤条件
        //sql.append(" and a.module_category='设备管理' ");
        sql.append(" GROUP BY a.function_uuid, ");
        sql.append(" a.nav_bar_img, ");
        sql.append(" a.nav_bar_name, ");
        sql.append(" a.module_category, ");
        sql.append(" a.uuid ,");
        sql.append(" concat( '/', b.uuid ) ,");
        sql.append(" a.sequence, ");
        sql.append(" b.route_name,a.module_sequence ");
        sql.append(" order by a.module_sequence,a.sequence");
        DataTableEntity dt = getBaseDao().listTable(sql.toString(), new Object[]{});
        if (!DataTableEntity.isEmpty(dt)) {
            Map<String, List<NavBarEntity>> map = new LinkedHashMap<>();
            for (int i = 0; i < dt.getRows(); i++) {
                String module_name = dt .getString(i, MobileCoreConst.MODULE_CATEGORY);
                List<NavBarEntity> navBarEntities = map.get(module_name);
                if (navBarEntities == null) {
                    navBarEntities = new ArrayList<>();
                    map.put(module_name, navBarEntities);
                }
                String file_uuid = dt.getString(i, MobileCoreConst.NAV_BAR_IMG);
                try {
                    String bytes = null;
                    byte[] fileContent = fileManagerService.getFileContent(file_uuid);
                    if (fileContent != null && fileContent.length > 0) {
                        bytes = Base64.encodeBase64String(fileContent);
                    }
                    dt.setFieldValue(i, MobileCoreConst.NAV_BAR_IMG, bytes);
                } catch (Exception e) {
                    dt.setFieldValue(i, MobileCoreConst.NAV_BAR_IMG, null);
                }
                navBarEntities.add(new NavBarEntity(dt.getFieldSetEntity(i)));
            }
            List<Object> list = new ArrayList<>();
            map.forEach((k, v) -> {
                Map<String, Object> m = new HashMap<>();
                m.put("name", k);
                m.put("functions", v);
                list.add(m);
            });
            return list;
        }
        return null;
    }
}
src/main/java/com/product/mobile/core/service/SystemTableMetaService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,86 @@
package com.product.mobile.core.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.product.common.lang.StringUtils;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.util.BaseUtil;
/**
 * æ‰‹æœºç«¯ï¼ŒèŽ·å–ç”¨æˆ·æ‰€æœ‰åº”ç”¨
 * @author Administrator
 *
 */
@Component
public class SystemTableMetaService extends AbstractBaseService{
    @Autowired
    public BaseDao baseDao;
    /**
     *     æ•°æ®è¡¨ç»“构信息
     * @param cpage
     * @param pagesize
     * @return
     * @throws BaseException
     */
    public FieldSetEntity getSystemTableMeta(FieldSetEntity fse) throws BaseException{
        Map<Object,Object> vs=fse.getValues();
        StringBuilder b=new StringBuilder();
        b.append("select t.table_name,f.field_name,f.field_length,f.field_show_name,f.field_type,f.field_reference,f.is_more_value from product_sys_datamodel_field f left join product_sys_datamodel_table t on f.table_uuid=t.uuid");
        List<Object> ps=new ArrayList<>();
        if(vs!=null && vs.size()>0) {
            b.append(" where ");
            Iterator keys=vs.keySet().iterator();
            int c=0;
            while(keys.hasNext()) {
                Object key=keys.next();
                Object field=vs.get(key);
//                if(StringUtils.isEmpty(field)) {
//                    continue;
//                }
                if(c>0) {
                    b.append(" or ");
                }
                Object fp[]=BaseUtil.buildQuestionMarkFilter("f.field_name","in",field.toString());
                b.append("(t.table_name=? ");
                ps.add(key);
                if(fp!=null && fp.length>1) {
                    b.append(" and ");
                    b.append(fp[0]);
                    ps.addAll((List)fp[1]);
                }
                b.append(")");
                c++;
            }
            b.append(" order by  t.table_name ");
            FieldSetEntity fs=new FieldSetEntity("product_sys_datamodel_field");
            DataTableEntity dt=baseDao.listTable(b.toString(), ps.toArray());
            String table=null;
            DataTableEntity sub=new DataTableEntity();
            for(int i=0;i<dt.getRows();i++) {
                String tb=dt.getString(i, "table_name");
                if(table!=null && !table.equals(tb)) {
                    sub.getMeta().getTableName()[0]=table;
                    fs.addSubDataTable(sub);
                    sub=new DataTableEntity();
                }
                table=tb;
                sub.addFieldSetEntity(dt.getFieldSetEntity(i));
            }
            sub.getMeta().getTableName()[0]=table;
            fs.addSubDataTable(sub);
            return fs;
        }
        return null;
    }
}
src/main/java/com/product/mobile/core/service/ide/INavBarManagerService.java
@@ -54,5 +54,13 @@
     * @throws BaseException
     */
    List<Object> getNarBarTree() throws BaseException;
    /**
     * è®¾å¤‡ç®¡ç†
     * ç§»åŠ¨ç«¯èŽ·å–å¯¼èˆªæ ï¼ˆå±•ç¤ºè·³è½¬ï¼‰
     *
     * @return
     * @throws BaseException
     */
    List<Object> getDeviceNarBarTree() throws BaseException;
}
src/main/java/com/product/mobile/device/controller/DeviceManagerController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,232 @@
package com.product.mobile.device.controller;
import com.alibaba.druid.util.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.device.config.DeviceCode;
import com.product.device.service.DeviceMainenanceService;
import com.product.device.service.DeviceManagerService;
import com.product.device.service.ide.IDeviceMainenanceService;
import com.product.mobile.core.config.MobileCoreCode;
import com.product.mobile.core.config.MobileCoreConst;
import com.product.module.sys.entity.SystemUser;
import com.product.module.sys.version.ApiVersion;
import com.product.task.device.service.DeviceManagerTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
/**
 * @Author cheng
 * @Date 2022/2/22 15:59
 * @Desc å¯¼èˆªæ ç®¡ç†
 */
@RestController
@RequestMapping("/api/mobile/device")
public class DeviceManagerController extends AbstractBaseController {
    @Autowired
    DeviceManagerTaskService deviceManagerTaskService;
    @Autowired
    DeviceManagerService  deviceManagerService;
    @Autowired
    DeviceMainenanceService deviceMainenanceService;
    /**
     * ä»»åŠ¡åˆ—è¡¨
     *
     * @param request
     * @return
     */
    @PostMapping("/list-new-task/{version}")
    @ApiVersion(1)
    public String listConfig(HttpServletRequest request) {
        try {
             SystemUser curUser = SpringMVCContextHolder.getCurrentUser();
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(), MobileCoreCode.SYSTEM_FORM_NODATA.getText());
                return this.error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(), MobileCoreCode.SYSTEM_FORM_NODATA.getText());
            }
            // åˆ¤æ–­åˆ†é¡µå‚数是否正常
            if (StringUtils.isEmpty(fse.getString(MobileCoreConst.PAGESIZE))
                    || StringUtils.isEmpty(fse.getString(MobileCoreConst.CPAGE))) {
                SpringMVCContextHolder.getSystemLogger().error(MobileCoreCode.SYSTEM_FORM_COUNT.getValue(), MobileCoreCode.SYSTEM_FORM_COUNT.getText());
                return this.error(MobileCoreCode.SYSTEM_FORM_COUNT.getValue(), MobileCoreCode.SYSTEM_FORM_COUNT.getText());
            }
            String result=OK_List(deviceManagerTaskService.getsPersionNewTask(curUser));
            System.out.println(result);
            return result;
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(MobileCoreCode.GET_NAV_BAR_CONFIG_LIST_FAIL);
        }
    }
    /**
     * è®¾å¤‡ä¿¡æ¯
     *
     * @param request
     * @return
     */
    @PostMapping("/find-device/{version}")
    @ApiVersion(1)
    public String findDevice(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(MobileCoreCode.SYSTEM_FORM_NODATA.getValue(), MobileCoreCode.SYSTEM_FORM_NODATA.getText());
                return this.error(MobileCoreCode.SYSTEM_FORM_NODATA);
            }
            if (StringUtils.isEmpty(fse.getString("uuid")) && StringUtils.isEmpty(fse.getString("asset_code"))  ) {
                SpringMVCContextHolder.getSystemLogger().error(MobileCoreCode.SYSTEM_ACQUIRE_PARAM_FAIL.getValue(), MobileCoreCode.SYSTEM_ACQUIRE_PARAM_FAIL.getText());
                return this.error(MobileCoreCode.SYSTEM_ACQUIRE_PARAM_FAIL);
            }
            String result=OK_List(deviceManagerService.findDeviceAndSub(fse.getString("uuid"),fse.getString("asset_code")));
            System.out.println(result);
            return result;
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(MobileCoreCode.GET_NAV_BAR_CONFIG_LIST_FAIL);
        }
    }
    /**
     * åˆ›å»ºè®¾å¤‡æ•…障申报
     * @param content
     * @param servletResponse
     * @throws IOException
     */
    @RequestMapping(value = "/failure/create/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String createFailure(HttpServletRequest request) throws IOException {
         try {
             FieldSetEntity fse = null;
             Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
             if (bean != null) {
                 RequestParameterEntity reqp = (RequestParameterEntity) bean;
                 fse = reqp.getFormData();
             }
             if (bean == null || fse == null) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             if (StringUtils.isEmpty(fse.getString("uuid")) && StringUtils.isEmpty(fse.getString("asset_code"))  ) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             IDeviceMainenanceService service = (IDeviceMainenanceService) getProxyInstance(deviceMainenanceService);
             String uuid=service.saveDeviceFailure(fse);
             System.out.println(uuid);
             return !StringUtils.isEmpty(uuid)? this.OK_Add(uuid):this.error(new BaseException(DeviceCode.DEVICE_CREATE_FAILURE_ERROR));
         } catch (BaseException e) {
             e.printStackTrace();
             return error(e);
         } catch (Exception e) {
             e.printStackTrace();
             return error(DeviceCode.DEVICE_CREATE_INSPECTION_ERROR);
         }
    }
    /**
     * è®¾å¤‡çš„相关人员信息
     * @param content
     * @param servletResponse
     * @throws IOException
     */
    @RequestMapping(value = "/persion/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String devicePersion(HttpServletRequest request) throws IOException {
         try {
             FieldSetEntity fse = null;
             Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
             if (bean != null) {
                 RequestParameterEntity reqp = (RequestParameterEntity) bean;
                 fse = reqp.getFormData();
             }
             if (bean == null || fse == null) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             if (StringUtils.isEmpty(fse.getString("asset_code"))  ) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             DataTableEntity dt=deviceManagerService.findDevicePersion(fse.getString("asset_code"));
             return this.OK_List( dt );
         } catch (BaseException e) {
             e.printStackTrace();
             return error(e);
         } catch (Exception e) {
             e.printStackTrace();
             return error(DeviceCode.DEVICE_CREATE_INSPECTION_ERROR);
         }
    }
    /**
     * è®¾å¤‡çš„相关人员信息
     * @param content
     * @param servletResponse
     * @throws IOException
     */
    @RequestMapping(value = "/create/maintain/task/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String deviceMainTainTaskPersion(HttpServletRequest request) throws IOException {
         try {
             FieldSetEntity fse = null;
             Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
             if (bean != null) {
                 RequestParameterEntity reqp = (RequestParameterEntity) bean;
                 fse = reqp.getFormData();
             }
             if (bean == null || fse == null) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             if (StringUtils.isEmpty(fse.getString("asset_code"))  ) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             if (StringUtils.isEmpty(fse.getString("uuid"))  ) {
                 SpringMVCContextHolder.getSystemLogger().error(DeviceCode.SYSTEM_FORM_NODATA);
                 return this.error(DeviceCode.SYSTEM_FORM_NODATA);
             }
             deviceMainenanceService.createMaintainTask(fse);
             return this.OK();
         } catch (BaseException e) {
             e.printStackTrace();
             return error(e);
         } catch (Exception e) {
             e.printStackTrace();
             return error(DeviceCode.DEVICE_CREATE_INSPECTION_ERROR);
         }
    }
}