jiangping
2024-01-22 ac1c48e5ae523ec6f62366542478bc5d451326a0
开发业务接口
已添加1个文件
已修改12个文件
315 ■■■■ 文件已修改
server/platform/src/main/java/com/doumee/api/business/InsuranceApplyController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/business/WorktypeController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/core/utils/Constants.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/dto/WorktypeImport.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/ApplyChange.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/dao/business/model/Worktype.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/ApplyChangeService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/WorktypeService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java 111 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/WorktypeServiceImpl.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/business/InsuranceApplyController.java
@@ -122,7 +122,7 @@
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:insuranceapply:query")
    public ApiResponse findById(@PathVariable Integer id) {
        return ApiResponse.success(insuranceApplyService.findById(id));
    public ApiResponse<InsuranceApply> findById(@PathVariable Integer id) {
        return ApiResponse.success(insuranceApplyService.findDetail(id));
    }
}
server/platform/src/main/java/com/doumee/api/business/WorktypeController.java
@@ -8,13 +8,15 @@
import com.doumee.core.model.PageData;
import com.doumee.dao.business.model.Worktype;
import com.doumee.service.business.WorktypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;    
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -81,6 +83,18 @@
        ExcelExporter.build(Worktype.class).export(worktypeService.findPage(pageWrap).getRecords(), "工种信息表", response);
    }
    @ApiOperation("导入模板")
    @PostMapping("/importExcel/{id}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "file", value = "file", required = true, paramType = "query", dataType = "file", dataTypeClass = File.class),
    })
    @RequiresPermissions("business:worktype:create")
    public ApiResponse<List<String>> importExcel (@ApiParam(value = "file") MultipartFile file,@PathVariable Integer id) {
        return ApiResponse.success(worktypeService .importBatch(file,id));
    }
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:worktype:query")
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -70,6 +70,8 @@
    public static final String COMPANY_FILE ="COMPANY_FILE" ;
    public static final String SMS_COMNAME = "SMS_COMNAME";
    public static final String TAXES_FILE = "TAXES_FILE";
    public static final String APPLY_FILE ="APPLY_FILE" ;
    public static final String SETTLE_FILE ="SETTLE_FILE" ;
    /**
     * ä¼ä¸šæ•°æ®æ¥æº 0平台注册 1后台导入
@@ -772,6 +774,8 @@
        RETURN_APPLY(3, "发起退回申请"),
        PLATFORM_AGREE(4, "平台同意(已退回)"),
        CLOSE(5, "已关闭"),
        PALTFORM_CHECK_PASS(6, "审核不通过"),
        PALTFORM_CHECK_PASS_NO(7, "审核通过"),
        ;
        // æˆå‘˜å˜é‡
        private String name;
server/service/src/main/java/com/doumee/dao/business/dto/WorktypeImport.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
package com.doumee.dao.business.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.doumee.core.annotation.excel.ExcelColumn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
 * å·¥ç§ä¿¡æ¯è¡¨
 * @author æ±Ÿè¹„蹄
 * @date 2024/01/16 10:03
 */
@Data
@ApiModel("工种信息表导入")
public class WorktypeImport {
    @ExcelColumn(name="序号",value = "id")
    private Integer id;
    @ExcelColumn(name="工种名称",value = "name")
    private String name;
}
server/service/src/main/java/com/doumee/dao/business/model/ApplyChange.java
@@ -37,6 +37,19 @@
    @ExcelColumn(name="创建时间")
    private Date createDate;
    @ApiModelProperty(value = "最近操作时间")
    @ExcelColumn(name="最近操作时间")
    private Date checkDate;
    @ApiModelProperty(value = "最近操作备注")
    @ExcelColumn(name="最近操作备注")
    private String checkInfo;
    @ApiModelProperty(value = "最近操作人编码(关联system_user)", example = "1")
    @ExcelColumn(name="最近操作人编码(关联system_user)")
    private Integer checkUserId;
    @ApiModelProperty(value = "更新人编码", example = "1")
    @ExcelColumn(name="更新人编码")
    private Integer editor;
@@ -87,6 +100,9 @@
    @ExcelColumn(name="操作类型 0加减保 1换厂")
    private Integer type;
    @ApiModelProperty(value = "变更金额")
    @ExcelColumn(name="变更金额")
    private BigDecimal fee;
    @ApiModelProperty(value = "保单号")
    @TableField(exist = false)
    private String applyCode;
server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java
@@ -35,6 +35,18 @@
        this.beforeContent=before;
        this.afterContent=after;
    }
    public ApplyLog(ApplyChange apply,String title,String content,Integer objId,Integer objType, String before,String after){
        this.title =title;
        this.content=content;
        this.applyId = apply.getId();
        this.createDate =apply.getEditDate();
        this.editor =apply.getEditor();
        this.status = apply.getStatus();
        this.objId=objId;
        this.objType = objType;
        this.beforeContent=before;
        this.afterContent=after;
    }
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键", example = "1")
server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java
@@ -139,6 +139,9 @@
    @ApiModelProperty(value = "投保单对象")
    @TableField(exist = false)
    private Multifile toubaodanFile;
    @ApiModelProperty(value = "投保单(已签署)对象")
    @TableField(exist = false)
    private Multifile toubaodanSignedFile;
    @ApiModelProperty(value = "保险单对象")
    @TableField(exist = false)
    private Multifile baoxiandanFile;
server/service/src/main/java/com/doumee/dao/business/model/Worktype.java
@@ -31,7 +31,6 @@
    @ApiModelProperty(value = "创建时间")
    @ExcelColumn(name="创建时间")
    private Date createDate;
    @ApiModelProperty(value = "更新人编码", example = "1")
server/service/src/main/java/com/doumee/service/business/ApplyChangeService.java
@@ -20,7 +20,7 @@
     * @return Integer
     */
    Integer create(ApplyChange applyChange);
    Integer back(ApplyChange param);
    /**
     * ä¸»é”®åˆ é™¤
     *
server/service/src/main/java/com/doumee/service/business/WorktypeService.java
@@ -4,6 +4,8 @@
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.dto.WorkTypeQueryDTO;
import com.doumee.dao.business.model.Worktype;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
@@ -104,4 +106,6 @@
     * @return long
     */
    long count(Worktype worktype);
    List<String> importBatch(MultipartFile file,Integer id);
}
server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
import com.alibaba.fastjson.JSONObject;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -71,6 +72,45 @@
    @Autowired
    private SolutionsMapper solutionsMapper;
    /**
     * å¹³å°é€€å›žç”³è¯·
     * @param insuranceApply
     * @return
     */
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer back(ApplyChange param) {
        if(param.getId() == null ||StringUtils.isBlank(param.getCheckInfo())){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        ApplyChange model = applyChangeMapper.selectById(param.getId());
        if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        ApplyChange update = new ApplyChange();
        update.setEditDate(new Date());
        update.setEditor(user.getId());
        update.setStatus(Constants.ApplyChangeStatus.PALTFORM_CHECK_PASS_NO.getKey());
        update.setCheckDate(update.getEditDate());
        update.setCheckInfo(param.getCheckInfo());
        update.setCheckUserId(user.getId());
        update.setId(model.getId());
        applyChangeMapper.updateById(update);
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.PLATFORM_RETURN;
        String info =applyLogType.getInfo();
        info = info.replace("${param}", update.getCheckInfo());
        ApplyLog log = new ApplyLog(update,applyLogType.getName(),info,update.getId(),applyLogType.getKey(), JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  1;
    }
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
@@ -399,57 +439,25 @@
    @Override
    public PageData<ApplyChange> findPage(PageWrap<ApplyChange> pageWrap) {
        IPage<ApplyChange> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        QueryWrapper<ApplyChange> queryWrapper = new QueryWrapper<>();
        MPJLambdaWrapper<ApplyChange> queryWrapper = new MPJLambdaWrapper<>();
        Utils.MP.blankToNull(pageWrap.getModel());
        if (pageWrap.getModel().getId() != null) {
            queryWrapper.lambda().eq(ApplyChange::getId, pageWrap.getModel().getId());
        }
        if (pageWrap.getModel().getCreator() != null) {
            queryWrapper.lambda().eq(ApplyChange::getCreator, pageWrap.getModel().getCreator());
        }
        if (pageWrap.getModel().getCreateDate() != null) {
            queryWrapper.lambda().ge(ApplyChange::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()));
            queryWrapper.lambda().le(ApplyChange::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()));
        }
        if (pageWrap.getModel().getEditor() != null) {
            queryWrapper.lambda().eq(ApplyChange::getEditor, pageWrap.getModel().getEditor());
        }
        if (pageWrap.getModel().getEditDate() != null) {
            queryWrapper.lambda().ge(ApplyChange::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()));
            queryWrapper.lambda().le(ApplyChange::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()));
        }
        if (pageWrap.getModel().getIsdeleted() != null) {
            queryWrapper.lambda().eq(ApplyChange::getIsdeleted, pageWrap.getModel().getIsdeleted());
        }
        if (pageWrap.getModel().getRemark() != null) {
            queryWrapper.lambda().eq(ApplyChange::getRemark, pageWrap.getModel().getRemark());
        }
        if (pageWrap.getModel().getSortnum() != null) {
            queryWrapper.lambda().eq(ApplyChange::getSortnum, pageWrap.getModel().getSortnum());
        }
        if (pageWrap.getModel().getApplyId() != null) {
            queryWrapper.lambda().eq(ApplyChange::getApplyId, pageWrap.getModel().getApplyId());
        }
        if (pageWrap.getModel().getCode() != null) {
            queryWrapper.lambda().eq(ApplyChange::getCode, pageWrap.getModel().getCode());
        }
        if (pageWrap.getModel().getApplyStartTime() != null) {
            queryWrapper.lambda().ge(ApplyChange::getApplyStartTime, Utils.Date.getStart(pageWrap.getModel().getApplyStartTime()));
            queryWrapper.lambda().le(ApplyChange::getApplyStartTime, Utils.Date.getEnd(pageWrap.getModel().getApplyStartTime()));
        }
        if (pageWrap.getModel().getStatus() != null) {
            queryWrapper.lambda().eq(ApplyChange::getStatus, pageWrap.getModel().getStatus());
        }
        if (pageWrap.getModel().getValidTime() != null) {
            queryWrapper.lambda().ge(ApplyChange::getValidTime, Utils.Date.getStart(pageWrap.getModel().getValidTime()));
            queryWrapper.lambda().le(ApplyChange::getValidTime, Utils.Date.getEnd(pageWrap.getModel().getValidTime()));
        }
        if (pageWrap.getModel().getValidCode() != null) {
            queryWrapper.lambda().eq(ApplyChange::getValidCode, pageWrap.getModel().getValidCode());
        }
        if (pageWrap.getModel().getType() != null) {
            queryWrapper.lambda().eq(ApplyChange::getType, pageWrap.getModel().getType());
        }
        ApplyChange model = pageWrap.getModel() ;
        queryWrapper
                .selectAll(ApplyChange.class)
                .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0  )",ApplyChange::getAddNum)
                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1  )",ApplyChange::getDelNum)
                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2  )",ApplyChange::getChangeNum)
                .select("( select ifnull(sum(ad.FEE),0) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID  )",ApplyChange::getChangeMoney)
                .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .eq(!Objects.isNull(model.getType()),ApplyChange::getType,model.getType())
                .eq(!Objects.isNull(model.getStatus()),ApplyChange::getStatus,model.getStatus())
                .eq(!Objects.isNull(model.getCompanyId()),InsuranceApply::getCompanyId,model.getCompanyId())
                .eq(!Objects.isNull(model.getSolutionsId()),ApplyChange::getSolutionsId,model.getSolutionsId())
                .ge(StringUtils.isNotBlank(model.getCreateDateS()),ApplyChange::getCreateDate, model.getCreateDateS()+" 00:00:00" )
                .le(StringUtils.isNotBlank(model.getCreateDateE()),ApplyChange::getCreateDate, model.getCreateDateE()+" 23:59:59" );
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
@@ -457,7 +465,8 @@
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        return PageData.from(applyChangeMapper.selectPage(page, queryWrapper));
        PageData<ApplyChange> pageData = PageData.from(applyChangeJoinMapper.selectJoinPage(page,ApplyChange.class, queryWrapper));
        return pageData;
    }
    @Override
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -1,6 +1,7 @@
package com.doumee.service.business.impl;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -12,6 +13,7 @@
import com.doumee.dao.business.*;
import com.doumee.dao.business.dto.InsuranceApplyOptDTO;
import com.doumee.dao.business.dto.InsuranceApplyQueryDTO;
import com.doumee.dao.business.join.ApplyDetailJoinMapper;
import com.doumee.dao.business.join.ApplyLogJoinMapper;
import com.doumee.dao.business.join.InsuranceApplyJoinMapper;
import com.doumee.dao.business.model.*;
@@ -46,10 +48,14 @@
    private InsuranceApplyMapper insuranceApplyMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private InsuranceApplyJoinMapper insuranceApplyJoinMapper;
    @Autowired
    private ApplyDetailMapper applyDetailMapper;
    @Autowired
    private ApplyDetailJoinMapper applyDetailJoinMapper;
    @Autowired
    private ApplyLogMapper applyLogMapper;
@@ -536,7 +542,17 @@
    @Override
    public InsuranceApply findDetail(Integer id) {
        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(id);
        MPJLambdaWrapper wrapper=  new MPJLambdaWrapper<InsuranceApply>()
                .selectAll(InsuranceApply.class)
                .selectAs(Solutions::getName,InsuranceApply::getSolutionsName)
                .selectAs(Company::getName,ApplyLog::getCompanyName)
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                .eq(InsuranceApply::getId,id)
                .last("limit 1");
        InsuranceApply insuranceApply = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,wrapper);
        if(Objects.isNull(insuranceApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
@@ -556,7 +572,8 @@
            }
        }
        //查询附件数据
        initImgData(insuranceApply);
        //查询操作记录
        List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
@@ -571,6 +588,34 @@
        );
        insuranceApply.setApplyLogList(applyLogList);
        return insuranceApply;
    }
    private void initImgData(InsuranceApply model) {
        List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
                .eq(Multifile::getObjId,model.getId())
                .in(Multifile::getObjType,Arrays.asList(new Integer[]{Constants.MultiFile.BD_APPLY_PDF.getKey()
                        ,Constants.MultiFile.BD_SIGNED_PDF.getKey()
                        ,Constants.MultiFile.BD_DONE_PDF.getKey()}))
                .eq(Multifile::getIsdeleted,Constants.ZERO));
        if(multifiles!=null){
            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                    +systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
            for(Multifile f : multifiles){
                if(StringUtils.isBlank(f.getFileurl())){
                    continue;
                }
                f.setFileurlFull(path+f.getFileurl());
                if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.BD_APPLY_PDF.getKey())){
                    //签署前的投保单
                    model.setBaoxiandanFile(f);
                }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.BD_SIGNED_PDF.getKey())){
                    //签署后的投保单
                    model.setToubaodanSignedFile(f);
                }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.BD_DONE_PDF.getKey())){
                    //最終保险单
                    model.setBaoxiandanFile(f);
                }
            }
        }
    }
    @Override
    public  InsuranceApply  findDetailForExport(InsuranceApply model){
@@ -587,10 +632,16 @@
        if(Objects.isNull(insuranceApply)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        //查询明细
        List<ApplyDetail> detailList =applyDetailMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId())
                .eq(ApplyDetail::getIsdeleted,Constants.ZERO));
        MPJLambdaWrapper wrapper1=  new MPJLambdaWrapper<ApplyDetail>()
                .selectAll(ApplyDetail.class)
                .selectAs(Worktype::getName,ApplyDetail::getWorkTypeName)
                .selectAs(DispatchUnit::getName,ApplyDetail::getDuName)
                .leftJoin(Worktype.class,Worktype::getId,ApplyDetail::getWorktypeId)
                .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId)
                .eq(InsuranceApply::getId,model.getId());
        //查询明细
        List<ApplyDetail> detailList =applyDetailJoinMapper.selectJoinList(ApplyDetail.class,wrapper1);
        if(detailList!=null){
            insuranceApply.setInsureNum(detailList.size());
            insuranceApply.setApplyDetailList(detailList);
server/service/src/main/java/com/doumee/service/business/impl/WorktypeServiceImpl.java
@@ -1,21 +1,29 @@
package com.doumee.service.business.impl;
import com.doumee.core.annotation.excel.ExcelImporter;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.InsuranceMapper;
import com.doumee.dao.business.WorktypeMapper;
import com.doumee.dao.business.dto.WorkTypeQueryDTO;
import com.doumee.dao.business.dto.WorktypeImport;
import com.doumee.dao.business.model.Worktype;
import com.doumee.service.business.WorktypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -29,6 +37,8 @@
    @Autowired
    private WorktypeMapper worktypeMapper;
    @Autowired
    private InsuranceMapper insuranceMapper;
    @Override
    public Integer create(Worktype worktype) {
@@ -164,4 +174,44 @@
        QueryWrapper<Worktype> wrapper = new QueryWrapper<>(worktype);
        return worktypeMapper.selectCount(wrapper);
    }
    @Override
    public List<String> importBatch(MultipartFile file,Integer id){
        List<Worktype> list = new ArrayList<>();
        if(id!=null){
            Worktype param = new Worktype();
            param.setIsdeleted(Constants.ZERO);
            param.setDataType(Constants.ZERO);
            param.setInsuranceId(id);
            list = findList(param);
        }
        ExcelImporter ie = null;
        List<WorktypeImport> dataList =null;
        try {
            ie = new ExcelImporter(file,0,0);
            dataList = ie.getDataList(WorktypeImport.class,null);
        }  catch (Exception e) {
            e.printStackTrace();
        }
        if(dataList == null || dataList.size() ==0){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!");
        }
         List<String> result = new ArrayList<>();
        for(WorktypeImport model : dataList){
            if(StringUtils.isNotBlank(model.getName()) && !isNewWorkTypeByName(model.getName(),list)){
                result.add(model.getName());
            }
        }
        return result;
    }
    private boolean isNewWorkTypeByName(String name, List<Worktype> list) {
        if(  list!=null && list.size()>0){
            for(Worktype m : list){
                if(StringUtils.equals(name,m.getName())){
                    return true;
                }
            }
        }
        return  false;
    }
}