Browse Source

整合easypoi

suqinyi 1 year ago
parent
commit
e3bbecb0e8

+ 8 - 7
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSubItemDO.java

@ -1,5 +1,6 @@
package com.yihu.jw.entity.base.servicePackage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
@ -18,8 +19,8 @@ public class ServicePackageSubItemDO extends UuidIdentityEntity implements java.
    @Column(name = "name")
    private String name;//名称
    @Column(name = "item_id")
    private String itemId;//项目的id
    @Column(name = "dict_item_id")
    private String dictItemId;//字典配置的服务项的id
    @Column(name = "introduce")
    private String introduce;//说明
@ -49,7 +50,6 @@ public class ServicePackageSubItemDO extends UuidIdentityEntity implements java.
    private Date createTime;
    public String getName() {
        return name;
    }
@ -58,12 +58,12 @@ public class ServicePackageSubItemDO extends UuidIdentityEntity implements java.
        this.name = name;
    }
    public String getItemId() {
        return itemId;
    public String getDictItemId() {
        return dictItemId;
    }
    public void setItemId(String itemId) {
        this.itemId = itemId;
    public void setDictItemId(String dictItemId) {
        this.dictItemId = dictItemId;
    }
    public String getIntroduce() {
@ -130,6 +130,7 @@ public class ServicePackageSubItemDO extends UuidIdentityEntity implements java.
        this.photo = photo;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/qvo/ParamQvo.java

@ -20,12 +20,22 @@ public class ParamQvo {
    private String parentId;//父id
    private String dictItemId;//字典服务项id
    private String configureIf;//是否是配置
    private String pageIf;//是否分页
    private int page = 1;//是否分页
    private int pageSize = 20;//数量
    public String getDictItemId() {
        return dictItemId;
    }
    public void setDictItemId(String dictItemId) {
        this.dictItemId = dictItemId;
    }
    public String getItemName() {
        return itemName;
    }

+ 48 - 34
svr/svr-base/pom.xml

@ -16,6 +16,43 @@
    <version>${project.parent.version}</version>
    <dependencies>
        <!--这边用2.2.6适配这个系统原本的有的poi3.17版本-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>2.2.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>
        <!-- xlsx  依赖这个包 -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
        </dependency>
        <!--   poi xml导入导出工具 start-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.yihu.ehr</groupId>
                    <artifactId>commons-util</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-collections4</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--   poi xml导入导出工具 end -->
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
@ -49,10 +86,10 @@
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.springframework.cloud</groupId>-->
<!--            <artifactId>spring-cloud-starter-sleuth</artifactId>-->
<!--        </dependency>-->
        <!--        <dependency>-->
        <!--            <groupId>org.springframework.cloud</groupId>-->
        <!--            <artifactId>spring-cloud-starter-sleuth</artifactId>-->
        <!--        </dependency>-->
        <!--注释掉就不会读取git的配置,只会读取yml中的配置-->
        <dependency>
@ -67,11 +104,11 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>com.yihu.jw</groupId>-->
<!--            <artifactId>minio-starter</artifactId>-->
<!--            <version>2.4.0</version>-->
<!--        </dependency>-->
        <!--        <dependency>-->
        <!--            <groupId>com.yihu.jw</groupId>-->
        <!--            <artifactId>minio-starter</artifactId>-->
        <!--            <version>2.4.0</version>-->
        <!--        </dependency>-->
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>im-service</artifactId>
@ -165,30 +202,7 @@
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <!--   poi xml导入导出工具 start-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.yihu.ehr</groupId>
                    <artifactId>commons-util</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-collections4</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>
        <!-- xlsx  依赖这个包 -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
@ -214,7 +228,7 @@
            <version>${version.wlyy-common}</version>
            <scope>compile</scope>
        </dependency>
        <!--   poi xml导入导出工具 end -->
        <!--oracle驱动-->
        <dependency>
            <groupId>com.oracle</groupId>

+ 4 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java

@ -49,6 +49,7 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.ServicePackage.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<Map<String, Object>> page(
            @ApiParam(name = "id", value = "主键") @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "leasedCode", value = "租户code") @RequestParam(value = "leasedCode", required = false) String leasedCode,
            @ApiParam(name = "orgCode", value = "机构code") @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "pageName", value = "服务包名称") @RequestParam(value = "pageName", required = false) String pageName,
@ -56,7 +57,7 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size
    ) throws Exception {
        HashMap<String, Object> resultMap = servicePackageService.findList(leasedCode, orgCode, pageName, status, page, size);
        HashMap<String, Object> resultMap = servicePackageService.findList(id,leasedCode, orgCode, pageName, status, page, size);
        Integer count = (Integer) resultMap.get("count");
        List<Map<String, Object>> list = (List<Map<String, Object>>) resultMap.get("list");
        return success(list, count, page, size);
@ -68,6 +69,7 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
    public Envelop create(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        jsonData = URLDecoder.decode(jsonData, "UTF-8");
        ServicePackageDO servicePackageDO = toEntity(jsonData, ServicePackageDO.class);
        servicePackageService.create(servicePackageDO);
        return success("操作成功");
@ -91,6 +93,7 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
    public Envelop changeState(
            @ApiParam(name = "jsonStr", value = "Json数据", required = false) @RequestParam String jsonStr
    ) throws Exception {
        jsonStr = URLDecoder.decode(jsonStr, "UTF-8");
        ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
        servicePackageService.changeState(qvo);
        return success("删除成功");

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageItemEndpoint.java

@ -78,6 +78,7 @@ public class ServicePackageItemEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "改变状态")
    public ObjEnvelop changeState(
            @ApiParam(name = "jsonStr", value = "jsonStr", required = true) @RequestParam String jsonStr) throws Exception {
        jsonStr = URLDecoder.decode(jsonStr, "UTF-8");
        ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
        if (org.apache.commons.lang3.StringUtils.isBlank(qvo.getId())) {
            return failed("ID不能为空", ObjEnvelop.class);

+ 80 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageSubItemEndpoint.java

@ -1,10 +1,14 @@
package com.yihu.jw.base.endpoint.servicePackage;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.servicePackage.ServicePackageSubItemService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.vo.excel.SubItemExcelVo;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSubItemDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.restmodel.qvo.ParamQvo;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -17,7 +21,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
@ -39,6 +49,7 @@ public class ServicePackageSubItemEndpoint extends EnvelopRestEndpoint {
    public PageEnvelop<Map<String, Object>> getSubItemList(
            @ApiParam(name = "jsonStr", value = "Json数据", required = true) @RequestParam String jsonStr
    ) throws Exception {
        jsonStr = URLDecoder.decode(jsonStr, "UTF-8");
        ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
        Map<String, Object> map = subItemService.getSubItemList(qvo);
        List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("list");
@ -51,6 +62,7 @@ public class ServicePackageSubItemEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "创建服务子项")
    public Envelop createSubItem(
            @ApiParam(name = "jsonStr", value = "Json数据", required = true) @RequestParam String jsonStr) throws Exception {
        jsonStr = URLDecoder.decode(jsonStr, "UTF-8");
        ServicePackageSubItemDO subItemDO = toEntity(jsonStr, ServicePackageSubItemDO.class);
        JSONObject result = subItemService.createSubItem(subItemDO);
        if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL, result.getString("response"))) {
@ -68,6 +80,7 @@ public class ServicePackageSubItemEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop changeState(
            @ApiParam(name = "jsonStr", value = "jsonStr", required = true) @RequestParam String jsonStr) throws Exception {
        try {
            jsonStr = URLDecoder.decode(jsonStr, "UTF-8");
            ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
            if (org.apache.commons.lang3.StringUtils.isBlank(qvo.getId())) {
                return failed("ID不能为空", ObjEnvelop.class);
@ -91,4 +104,71 @@ public class ServicePackageSubItemEndpoint extends EnvelopRestEndpoint {
    }
    /**
     * 导入数据
     */
    @PostMapping(value = "/importSubItemExcel")
    public void importSubItemExcel(
            @ApiParam(value = "文件", required = true)
            @RequestParam(value = "file", required = true) MultipartFile file) {
        try {
            //获取文件的输入流
            InputStream inputStream = file.getInputStream();
            List<SubItemExcelVo> list = EasyExcel.read(inputStream)
                    .head(SubItemExcelVo.class)
                    .sheet(0)
                    .headRowNumber(1)
                    .doReadSync();
            subItemService.importSubItemExcel(list);
        } catch (Exception exception) {
            throw new RuntimeException(exception);
        }
    }
    /**
     * 导出数据
     */
    @GetMapping("/exportSubItemExcel")
    public void exportSubItemExcel(
            HttpServletResponse response,
            @ApiParam(name = "jsonStr", value = "jsonStr", required = false) @RequestParam(value = "jsonStr") String jsonStr
    ) throws Exception {
        OutputStream outputStream = response.getOutputStream();
        try {
            jsonStr = URLDecoder.decode(jsonStr, "UTF-8");
            System.out.println("入参:" + JSON.toJSONString(jsonStr));
            ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
            this.setExcelResponseProp(response, "服务子项");
            List<SubItemExcelVo> resultList = subItemService.getSubItemVoList(qvo);
            EasyExcel.write(outputStream, SubItemExcelVo.class)
                    .excelType(ExcelTypeEnum.XLSX)
                    .sheet("服务子项")
                    .doWrite(resultList);
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            outputStream.flush();
            outputStream.close();
        }
    }
    /**
     * 设置响应结果
     */
    private void setExcelResponseProp(HttpServletResponse response, String rawFileName) throws Exception {
        //设置内容类型
        response.setContentType("application/vnd.vnd.ms-excel");
        //设置编码格式
        response.setCharacterEncoding("utf-8");
        //设置导出文件名称(避免乱码)
        String fileName = URLEncoder.encode(rawFileName.concat(".xlsx"), "UTF-8");
        // 设置响应头
        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
    }
}

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseTableDictService.java

@ -6,6 +6,7 @@ import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.dict.BaseTableDict;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.qvo.ParamQvo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -27,7 +28,10 @@ public class BaseTableDictService extends BaseJpaService<BaseDrugUseDictDO, Base
    }
    public List<Map<String, Object>> findDictByName(ParamQvo qvo) {
        String sql = " select * from base_table_dict where dict_name='" + qvo.getName() + "'";
        String sql = " select * from base_table_dict where 1=1 ";
        if (StringUtils.isNotBlank(qvo.getName())) {
            sql += " and  dict_name='" + qvo.getName() + "'";
        }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java

@ -82,6 +82,9 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
        if (StringUtils.isNotBlank(qvo.getId())) {
            sql += " AND a.id ='" + qvo.getId() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getParentId())) {
            sql += " AND a.service_package_id ='" + qvo.getParentId() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getLeasedCode())) {
            sql += " AND a.leased_code ='" + qvo.getLeasedCode() + "'";
        }

+ 10 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java

@ -72,6 +72,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        List<ServicePackageItemDO> saveItemList = new ArrayList<>();
        for (ServicePackageItemDO item : itemList) {
            item.setCreateTime(dateFormat.format(new Date()));
            item.setServicePackageId(packageVo.getId());
            saveItemList.add(item);
        }
        servicePackageItemDao.saveAll(saveItemList);
@ -81,13 +82,16 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    }
    public HashMap<String, Object> findList(String leasedCode, String orgCode, String pageName, String status, int page, int size) {
    public HashMap<String, Object> findList(String id, String leasedCode, String orgCode, String pageName, String status, int page, int size) {
        String detailSql = "SELECT\n" +
                "	(SELECT GROUP_CONCAT(b.`name`) FROM  base_service_package_item b WHERE b.service_package_id=a.id) 'pageItemName',\n" +
                "	a.* \n";
        String countSql = "SELECT count(1)  ";
        String sql = " FROM 	base_service_package a  WHERE 1 =1 ";
        if (StringUtils.isNotBlank(id)) {
            sql += " AND a.id='" + id + "'";
        }
        if (StringUtils.isNotBlank(status)) {
            sql += " AND a.del='" + status + "'";
        }
@ -122,14 +126,16 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        //删除服务项
        String sql02 = " DELETE FROM base_service_package_item WHERE service_package_id='" + qvo.getId() + "'";
        //删除关联关系
        String sql03 = " DELETE FROM base_service_package_item_relational WHERE item_id IN " + collect;
        jdbcTemplate.execute(sql03);
        if (!list.isEmpty()) {
            String sql03 = " DELETE FROM base_service_package_item_relational WHERE item_id IN " + collect;
            jdbcTemplate.execute(sql03);
        }
        jdbcTemplate.execute(sql02);
        jdbcTemplate.execute(sql01);
    }
    public void changeState(ParamQvo qvo) {
        String sql = " UPDATE  base_service_package SET del='" + qvo.getStatus() + "'' WHERE id='" + qvo.getId() + "'";
        String sql = " UPDATE  base_service_package SET del='" + qvo.getStatus() + "' WHERE id='" + qvo.getId() + "'";
        jdbcTemplate.execute(sql);
    }
}

+ 105 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageSubItemService.java

@ -1,12 +1,15 @@
package com.yihu.jw.base.service.servicePackage;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.servicePackage.ServicePackageSubItemDao;
import com.yihu.jw.base.vo.excel.SubItemExcelVo;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSubItemDO;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.qvo.ParamQvo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import java.util.*;
@ -26,26 +29,35 @@ public class ServicePackageSubItemService extends BaseJpaService<ServicePackageS
        String detailSql = "select * ";
        String countSql = " select count(1) ";
        String pageSql = "";
        String sql = " FROM base_service_package_sub_item WHERE 1=1  ";
        String sql = " FROM base_service_package_sub_item a   ";
        if (StringUtils.isNotBlank(qvo.getParentId())) {
            sql += " INNER JOIN base_service_package_item_relational b ON a.id = b.sub_item_id  ";
        }
        sql += " WHERE 1=1 ";
        if (StringUtils.isNotBlank(qvo.getId())) {
            sql += "AND id = '" + qvo.getId() + "'";
            sql += "AND a.id = '" + qvo.getId() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getLeasedCode())) {
            sql += "AND leased_code = '" + qvo.getLeasedCode() + "'";
            sql += "AND a.leased_code = '" + qvo.getLeasedCode() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getOrgCode())) {
            sql += "AND org_code = '" + qvo.getOrgCode() + "'";
            sql += "AND a.org_code = '" + qvo.getOrgCode() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getStatus())) {
            sql += "AND `status` = '" + qvo.getStatus() + "'";
            sql += "AND a.`status` = '" + qvo.getStatus() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getName())) {
            sql += "AND `name` like '%" + qvo.getName() + "%'";
            sql += "AND a.`name` like '%" + qvo.getName() + "%'";
        }
        if (StringUtils.isNotBlank(qvo.getParentId())) {
            sql += "AND `item_id` = '" + qvo.getParentId() + "'";
            //创建的服务项的id
            sql += "AND b.`item_id` = '" + qvo.getParentId() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getDictItemId())) {
            sql += " and  a.dict_item_id='" + qvo.getDictItemId() + "'";
        }
        //分页
        if (StringUtils.isNotBlank(qvo.getPageIf())) {
            pageSql += " limit " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize();
@ -60,6 +72,42 @@ public class ServicePackageSubItemService extends BaseJpaService<ServicePackageS
        return map;
    }
    /**
     * 用实体返回
     */
    public List<SubItemExcelVo> getSubItemVoList(ParamQvo qvo) {
        String detailSql = "SELECT\n" +
                " c.`name`'itemName',a.`name` 'subItemName' ,a.*\n" +
                "FROM\n" +
                " base_service_package_sub_item a\n" +
                " INNER JOIN base_service_package_item_relational b ON a.id = b.sub_item_id \n" +
                " INNER JOIN base_service_package_item c ON b.item_id=c.id\n" +
                "WHERE\n" +
                " 1 = 1;";
        if (StringUtils.isNotBlank(qvo.getId())) {
            detailSql += "AND a.id = '" + qvo.getId() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getLeasedCode())) {
            detailSql += "AND a.leased_code = '" + qvo.getLeasedCode() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getOrgCode())) {
            detailSql += "AND a.org_code = '" + qvo.getOrgCode() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getStatus())) {
            detailSql += "AND a.`status` = '" + qvo.getStatus() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getName())) {
            detailSql += "AND a.`name` like '%" + qvo.getName() + "%'";
        }
        if (StringUtils.isNotBlank(qvo.getParentId())) {
            detailSql += "AND a.`item_id` = '" + qvo.getParentId() + "'";
        }
        List<SubItemExcelVo> list = jdbcTemplate.query(detailSql, new BeanPropertyRowMapper<>(SubItemExcelVo.class));
        return list;
    }
    public JSONObject createSubItem(ServicePackageSubItemDO subItemDO) {
        subItemDO.setCreateTime(new Date());
        ServicePackageSubItemDO entity = subItemDao.save(subItemDO);
@ -87,4 +135,54 @@ public class ServicePackageSubItemService extends BaseJpaService<ServicePackageS
        delSql += collect;
        jdbcTemplate.execute(delSql);
    }
    public void importSubItemExcel(List<SubItemExcelVo> list) {
        //查询出所有租户和机构
        String sql01 = " SELECT id,`name` FROM base_saas WHERE `status`='1' ";
        String sql02 = " SELECT id,`code`,`name` FROM\tbase_org WHERE del='1' ";
        String sql03 = " SELECT id,name FROM `base`.`wlyy_rehabilitation_service_item`  ";
        List<Map<String, Object>> leasedList = jdbcTemplate.queryForList(sql01);
        List<Map<String, Object>> orgList = jdbcTemplate.queryForList(sql02);
        List<Map<String, Object>> itemList = jdbcTemplate.queryForList(sql03);
        ArrayList<ServicePackageSubItemDO> resultList = new ArrayList<>();
        for (SubItemExcelVo vo : list) {
            ServicePackageSubItemDO entity = new ServicePackageSubItemDO();
            entity.setCreateTime(new Date());
            entity.setName(vo.getItemName());
            entity.setIntroduce(vo.getIntroduce());
            entity.setSort(vo.getSort());
            if (StringUtils.isNotBlank(vo.getStatus())) {
                if (vo.getStatus().equals("生效")) {
                    entity.setStatus("1");
                } else {
                    entity.setStatus("0");
                }
            }
            for (Map<String, Object> map : leasedList) {
                if (vo.getLeasedName().equals(map.get("name"))) {
                    entity.setLeasedCode(map.get("id").toString());
                    entity.setLeasedName(map.get("name").toString());
                    break;
                }
            }
            for (Map<String, Object> map : orgList) {
                if (vo.getOrgName().equals(map.get("name"))) {
                    entity.setOrgCode(map.get("id").toString());
                    entity.setOrgName(map.get("name").toString());
                    break;
                }
            }
            for (Map<String, Object> map : itemList) {
                if (vo.getItemName().equals(map.get("name"))) {
                    entity.setDictItemId(map.get("id").toString());
                    break;
                }
            }
            resultList.add(entity);
            System.out.println(JSON.toJSONString(entity));
        }
        subItemDao.saveAll(resultList);
    }
}

+ 29 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/vo/excel/SubItemExcelVo.java

@ -0,0 +1,29 @@
package com.yihu.jw.base.vo.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
 * @author suqinyi
 * @Date 2023/9/26
 */
@Data
public class SubItemExcelVo {
    @ExcelProperty("归属项目名称")
    private String itemName;
    @ExcelProperty("项目名称")
    private String subItemName;
    @ExcelProperty("租户")
    private String leasedName;
    @ExcelProperty("机构")
    private String orgName;
    @ExcelProperty("状态")
    private String status;
    @ExcelProperty("排序")
    private String sort;
    @ExcelProperty("说明")
    private String introduce;
}