y пре 2 година
родитељ
комит
6f04474288

+ 290 - 0
src/main/java/com/ydtech/modules/inv/controller/InvChannelsExternalBillsDetailsController.java

@@ -0,0 +1,290 @@
+package com.ydtech.modules.inv.controller;
+
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.constants.enums.dict.finance.CheckingStatusEnum;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.base.model.dto.PageDto;
+import com.ydtech.modules.base.model.vo.PageVo;
+import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
+import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetailsHistory;
+import com.ydtech.modules.inv.model.InvInsExternalBillsDetails;
+import com.ydtech.modules.inv.model.dto.InvInsCompanyDto;
+import com.ydtech.modules.inv.service.InvChannelsExternalBillsDetailsHistoryService;
+import com.ydtech.modules.inv.service.InvChannelsExternalBillsDetailsService;
+import com.ydtech.modules.inv.service.InvInsExternalBillsDetailsService;
+import com.ydtech.utils.StringUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.function.Function;
+
+/**
+ * 财务 - 渠道 - 外部票据控制层 详情
+ *
+ * @author: lig
+ * @date: 2023-05-31
+ */
+@Api(tags = "财务 - 渠道 - 外部票据 详情 控制层")
+@RestController
+@RequestMapping("api/inv/channelsExternalBillsDetails")
+@Slf4j
+public class InvChannelsExternalBillsDetailsController extends BaseController {
+
+    //渠道
+    @Resource
+    private InvChannelsExternalBillsDetailsService icebdService;
+
+    //渠道 历史
+    @Resource
+    private InvChannelsExternalBillsDetailsHistoryService icebdhService;
+
+    //保险公司
+    @Resource
+    private InvInsExternalBillsDetailsService InvInsExternalBillsDetailsService;
+
+
+    /**
+     * 分页查询
+     *
+     * @param pageDto
+     * @return
+     */
+    @ApiOperation(value = "分页查询")
+    @PostMapping(value = "/queryPage")
+    public HttpResult<PageResult<InvChannelsExternalBillsDetails>> queryPage(@RequestBody PageDto<InvInsCompanyDto> pageDto) {
+//    public HttpResult<PageResult<InvChannelsExternalBillsDetails>> queryPage(@RequestBody InvInsExternalBillsDetailsReqVO reqVo) {
+
+
+        LambdaQueryWrapper<InvChannelsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        if(null != pageDto.getDto()){
+            lqw.in(null != pageDto.getDto().getInsCompanyIds() && pageDto.getDto().getInsCompanyIds().size() > 0, InvChannelsExternalBillsDetails::getInsCompanyId, pageDto.getDto().getInsCompanyIds());
+            lqw.eq(null != pageDto.getDto().getPayDate(),InvChannelsExternalBillsDetails::getPayDate,pageDto.getDto().getPayDate());
+            lqw.eq(StringUtils.isNotEmpty(pageDto.getDto().getPlateNum()), InvChannelsExternalBillsDetails::getPlateNum, pageDto.getDto().getPlateNum());
+            lqw.eq(StringUtils.isNotEmpty(pageDto.getDto().getOutChannel()), InvChannelsExternalBillsDetails::getOutChannel, pageDto.getDto().getOutChannel());
+            lqw.eq(StringUtils.isNotEmpty(pageDto.getDto().getChannel()), InvChannelsExternalBillsDetails::getChannel, pageDto.getDto().getChannel());
+            lqw.eq(StringUtils.isNotEmpty(pageDto.getDto().getStatus()), InvChannelsExternalBillsDetails::getStatus, pageDto.getDto().getStatus());
+        }
+
+        Page p = PageVo.buildPageRequest(pageDto);
+        IPage<InvChannelsExternalBillsDetails> pResult = icebdService.page(p, lqw);
+        //传入查询条件
+        PageResult pageResult = PageResult.buildPageResult(pResult);
+        return HttpResult.ok(pageResult);
+    }
+
+
+    @GetMapping("/detailsById")
+    @ApiOperation(value = "详情")
+    public HttpResult detailsById(String id) {
+        return HttpResult.ok(icebdService.getById(id));
+
+    }
+
+
+    @ApiOperation(value = "修改")
+    @PostMapping(value = "/edit")
+    @Transactional
+    public HttpResult edit(@RequestBody InvChannelsExternalBillsDetails icebd) {
+
+
+        List<InvChannelsExternalBillsDetailsHistory> list = icebdhService.gainListByEditId(icebd.getId());
+
+        List<InvChannelsExternalBillsDetailsHistory> icebdhList = new ArrayList<>();
+        InvChannelsExternalBillsDetails icebdOld = icebdService.getById(icebd.getId());
+        if (null == list || list.size() < 1) {
+            //初始历史数据
+            InvChannelsExternalBillsDetailsHistory icebdh = new InvChannelsExternalBillsDetailsHistory();
+//            BeanUtils.copyProperties(icebdOld, icebdh,"id");
+            BeanUtil.copyProperties(icebdOld, icebdh, CopyOptions.create(null, true, "id"));
+            icebdh.setEditId(icebd.getId());
+            icebdhList.add(icebdh);
+        }
+
+
+        InvChannelsExternalBillsDetailsHistory icebdh = new InvChannelsExternalBillsDetailsHistory();
+
+        //构造更新数据
+        BeanUtil.copyProperties(icebd, icebdOld, CopyOptions.create(null, true));
+
+        //构造历史数据
+        BeanUtil.copyProperties(icebdOld, icebdh, CopyOptions.create(null, true, "id"));
+
+//        //构造更新数据
+//        BeanUtils.copyProperties(icebdOld , icebd);
+//        //构造历史数据
+//        BeanUtils.copyProperties(icebd, icebdh,"id");
+        icebdh.setEditId(icebdOld.getId());
+        icebdh.setEditTime(new Date());
+        icebdh.setEditBy(StpUtil.getLoginId().toString());
+        icebdhList.add(icebdh);
+
+
+//            icebdhService.saveBatch(icebdhList);
+
+        icebdService.updateById(icebdOld);
+
+
+        return HttpResult.ok(icebdhService.saveBatch(icebdhList));
+    }
+
+
+    @PostMapping(value = "/batchReceive")
+    @ApiOperation(value = "批量领取")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", value = "渠道ID数组", dataType = "String", paramType = "body", allowMultiple = true, required = true)
+    })
+    public HttpResult batchReceive(@RequestBody List<String> ids) {
+        LambdaQueryWrapper<InvChannelsExternalBillsDetails> lqw = new LambdaQueryWrapper<>();
+        lqw.select(InvChannelsExternalBillsDetails::getPlateNum);
+        lqw.in(InvChannelsExternalBillsDetails::getId,ids);
+        //车牌号
+        List<String> plateNums = icebdService.listObjs(lqw, new Function<Object, String>() {
+            @Override
+            public String apply(Object id) {
+                return id.toString();
+            }
+        });
+
+        //保险公司 更新状态
+        LambdaUpdateWrapper<InvInsExternalBillsDetails> insLuw = new LambdaUpdateWrapper<>();
+        insLuw.set(InvInsExternalBillsDetails::getStatus,CheckingStatusEnum.AS1.getCode());
+        insLuw.in(InvInsExternalBillsDetails::getPlateNum,plateNums);
+        insLuw.eq(InvInsExternalBillsDetails::getStatus,CheckingStatusEnum.AS0.getCode());
+        InvInsExternalBillsDetailsService.update(insLuw);
+
+
+        //渠道 更新批次号状态
+        LambdaUpdateWrapper<InvChannelsExternalBillsDetails> luw = new LambdaUpdateWrapper<>();
+        luw.set(InvChannelsExternalBillsDetails::getStatus, CheckingStatusEnum.AS1.getCode());
+        luw.in(InvChannelsExternalBillsDetails::getId,ids);
+        icebdService.update(luw);
+
+        return HttpResult.ok("领取成功");
+    }
+
+
+//    @GetMapping(value = "/receive/{batchNum}")
+//    @ApiOperation(value = "确认领取")
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name = "batchNum", value = "批次号", required = true, dataType = "String")
+//    })
+//    @Transactional
+//    public HttpResult receive(@PathVariable String batchNum) {
+//
+//        LambdaQueryWrapper<InvChannelsExternalBillsDetails> lqw = new LambdaQueryWrapper<>();
+//        lqw.select(InvChannelsExternalBillsDetails::getPlateNum);
+//        lqw.eq(InvChannelsExternalBillsDetails::getBatchNum,batchNum);
+////        List<InvChannelsExternalBillsDetails> iebdList = icebdService.list(lqw);
+//        //车牌号
+//        List<String> plateNums = icebdService.listObjs(lqw, new Function<Object, String>() {
+//            @Override
+//            public String apply(Object id) {
+//                return id.toString();
+//            }
+//        });
+//
+//        //保险公司 更新状态
+//        LambdaUpdateWrapper<InvInsExternalBillsDetails> insLuw = new LambdaUpdateWrapper<>();
+//        insLuw.set(InvInsExternalBillsDetails::getStatus,"1");
+//        insLuw.in(InvInsExternalBillsDetails::getPlateNum,plateNums);
+//        InvInsExternalBillsDetailsService.update(insLuw);
+//
+//
+//
+//
+//        //渠道 更新批次号状态
+//        LambdaUpdateWrapper<InvChannelsExternalBillsDetails> luw = new LambdaUpdateWrapper<>();
+//        luw.set(InvChannelsExternalBillsDetails::getStatus,"1");
+//        luw.eq(InvChannelsExternalBillsDetails::getBatchNum,batchNum);
+//        icebdService.update(luw);
+//
+//        return HttpResult.ok("领取成功");
+//    }
+
+
+    @PostMapping(value = "/batchPay")
+    @ApiOperation(value = "批量支付")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", value = "渠道数据ID数组", dataType = "String", paramType = "body", allowMultiple = true, required = true)
+    })
+    public HttpResult pay(@RequestBody List<String> ids) {
+        SysUser user = getUser();
+        icebdService.pay(ids,user);
+
+        return HttpResult.ok("支付成功");
+    }
+
+
+    @PostMapping(value = "/pay/{id}")
+    @ApiOperation(value = "支付")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "渠道数据ID", dataType = "String", paramType = "path", required = true)
+    })
+    public HttpResult pay(@PathVariable String id) {
+        SysUser user = getUser();
+        List<String> ids = new ArrayList<>();
+        ids.add(id);
+
+        icebdService.pay(ids,user);
+
+        return HttpResult.ok("支付成功");
+    }
+
+
+
+    @PostMapping("/importData")
+    @ApiOperation(value = "渠道数据导入(excel)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
+    })
+    public HttpResult importData(@RequestPart MultipartFile file) {
+
+        icebdService.importData(file);
+
+        return HttpResult.ok("导入成功");
+
+    }
+
+    @PostMapping(value = "/findEditHistory")
+    @ApiOperation(value = "获取渠道修改历史")
+    public HttpResult<PageResult<InvChannelsExternalBillsDetailsHistory>> findEditHistory(@RequestBody PageDto<InvInsCompanyDto> pageDto) {
+
+        LambdaQueryWrapper<InvChannelsExternalBillsDetailsHistory> lqw = new LambdaQueryWrapper<>();
+        if(null != pageDto.getDto()){
+            lqw.eq(StringUtils.isNotEmpty(pageDto.getDto().getPlateNum()),InvChannelsExternalBillsDetailsHistory::getPlateNum,pageDto.getDto().getPlateNum());
+        }
+        lqw.orderByAsc(InvChannelsExternalBillsDetailsHistory::getPlateNum,InvChannelsExternalBillsDetailsHistory::getEditTime);
+
+
+        Page p = PageVo.buildPageRequest(pageDto);
+        IPage<InvChannelsExternalBillsDetailsHistory> pResult = icebdhService.page(p,lqw);
+        //传入查询条件
+        PageResult pageResult = PageResult.buildPageResult(pResult);
+
+
+        return HttpResult.ok(pageResult);
+//        return HttpResult.ok(sysUserService.gainUserPage(pageDto));
+    }
+
+
+
+}

+ 94 - 0
src/main/java/com/ydtech/modules/inv/controller/InvCompanyController.java

@@ -0,0 +1,94 @@
+package com.ydtech.modules.inv.controller;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.inv.model.InvCompany;
+import com.ydtech.modules.inv.model.vo.req.InvCompanyReqVO;
+import com.ydtech.modules.inv.model.vo.res.InvCompanyResVO;
+import com.ydtech.modules.inv.service.InvCompanyService;
+import com.ydtech.utils.DateUtil;
+import com.ydtech.utils.StringUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 发票公司控制层
+ *
+ * @author: lig
+ * @date: 2023年05月11日 0011
+ */
+@Api(tags = "发票公司控制层")
+@RestController
+@RequestMapping("api/inv/company")
+@Slf4j
+public class InvCompanyController extends BaseController {
+
+    @Autowired
+    private InvCompanyService invCompanyService;
+
+
+    @ApiOperation(value = "保存")
+    @ApiResponses({
+            @ApiResponse(code = 500, message = "出现异常"),
+            @ApiResponse(code = 200, message = "请求成功")
+    })
+    @PostMapping(value = "/save")
+//    @ApiOperationSupport(ignoreParameters = {"id"})
+    public HttpResult save(@RequestBody InvCompany invCompany, HttpServletRequest request) {
+
+        if(StringUtils.isNotEmpty(invCompany.getId())){
+            //更新
+            invCompany.setUpdateBy(getUserId());
+            invCompany.setUpdateTime(new Date());
+
+        }else{
+            //新增
+            invCompany.setDelFlag(0);
+            invCompany.setCreateBy(getUserId());
+            invCompany.setCreateTime(new Date());
+        }
+
+        return HttpResult.ok(invCompanyService.saveOrUpdate(invCompany));
+    }
+
+    @ApiOperation(value = "开票公司查询分页(展示额度)",notes = "默认当前一年")
+    @PostMapping(value = "/findPage")
+    public HttpResult<PageResult<InvCompanyResVO>> findPage(@RequestBody InvCompanyReqVO InvCompanyReqVO) {
+
+        if(StringUtils.isNullOrEmpty(InvCompanyReqVO.getStartInvoiceDate())){
+            String sectionStart = DateUtil.gainDateMonthFirstDay(DateUtil.gainFrontOneYear());
+            InvCompanyReqVO.setStartInvoiceDate(sectionStart);
+        }
+        if(StringUtils.isNullOrEmpty(InvCompanyReqVO.getEndInvoiceDate())){
+            String sectionEnd = DateUtil.gainDateMonthFirstDay(null);
+            InvCompanyReqVO.setEndInvoiceDate(sectionEnd);
+        }
+        return HttpResult.ok(invCompanyService.gainPage(InvCompanyReqVO));
+
+    }
+
+
+    @ApiOperation(value = "开票公司查询")
+    @PostMapping(value = "/findList")
+    public HttpResult<List<InvCompany>> findList() {
+        return HttpResult.ok(invCompanyService.list());
+    }
+
+
+
+
+
+}

+ 217 - 0
src/main/java/com/ydtech/modules/inv/controller/InvExternalBillsController.java

@@ -0,0 +1,217 @@
+package com.ydtech.modules.inv.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageRequest;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.base.model.dto.PageDto;
+import com.ydtech.modules.base.model.vo.PageVo;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
+import com.ydtech.modules.inv.model.InvExternalBills;
+import com.ydtech.modules.inv.model.InvInsExternalBillsDetails;
+import com.ydtech.modules.inv.model.dto.InvInsCompanyDto;
+import com.ydtech.modules.inv.model.dto.InvInsImportDto;
+import com.ydtech.modules.inv.model.vo.InvInsCompanyExportVo;
+import com.ydtech.modules.inv.model.vo.InvInsCompanyVo;
+import com.ydtech.modules.inv.model.vo.req.InvChannelExternalBillsDetailsReqVO;
+import com.ydtech.modules.inv.model.vo.req.InvInsExternalBillsReqVO;
+import com.ydtech.modules.inv.model.vo.res.InvBaseChannelMatchInsResVO;
+import com.ydtech.modules.inv.service.InvChannelsExternalBillsDetailsService;
+import com.ydtech.modules.inv.service.InvExternalBillsService;
+import com.ydtech.modules.inv.service.InvInsExternalBillsDetailsService;
+import com.ydtech.utils.StringUtils;
+import com.ydtech.utils.excel.ExcelEasypoiUtils;
+import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 外部单据控制层
+ *
+ * @author: lig
+ * @date: 2023-05-31
+ */
+@Api(tags = "财务 - 外部票据控制层")
+@RestController
+@RequestMapping("api/inv/insExternalBills")
+public class InvExternalBillsController extends BaseController {
+
+    @Autowired
+    private InvExternalBillsService invExternalBillsService;
+
+    @Autowired
+    private InvInsExternalBillsDetailsService invInsExternalBillsDetailsService;
+    @Autowired
+    private InvChannelsExternalBillsDetailsService invChannelsExternalBillsDetailsService;
+    @Autowired
+    private EsmInsCompanyService esmInsCompanyService;
+
+
+    /**
+     * 分页查询
+     *
+     * @param reqVo
+     * @return
+     */
+    @ApiOperation(value = "分页查询")
+    @PostMapping(value = "/queryPage")
+    public HttpResult<PageResult<InvExternalBills>> queryPage(@RequestBody InvInsExternalBillsReqVO reqVo) {
+
+        LambdaQueryWrapper<InvExternalBills> lqw = new LambdaQueryWrapper();
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getImportStatus()), InvExternalBills::getImportStatus, reqVo.getImportStatus());
+        lqw.between(StringUtils.isNotEmpty(reqVo.getImportStartTime()) && StringUtils.isNotEmpty(reqVo.getImportEndTime()), InvExternalBills::getCreateTime, reqVo.getImportStartTime(), reqVo.getImportEndTime());
+        lqw.eq(InvExternalBills::getFlag, reqVo.getFlag());
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getInsCompanyId()), InvExternalBills::getInsCompanyId, reqVo.getInsCompanyId());
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getId()), InvExternalBills::getId, reqVo.getId());
+
+        Page p = PageRequest.buildPageRequestByVo(reqVo);
+        IPage<InvExternalBills> pResult = invExternalBillsService.page(p, lqw);
+        //传入查询条件
+        PageResult<InvExternalBills> pageResult = PageResult.buildPageResult(pResult);
+        return HttpResult.ok(pageResult);
+    }
+
+
+    @PostMapping("/importData")
+    @ApiOperation(value = "excel导入数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
+    })
+//    public HttpResult importData( InvInsImportDto importDto) {
+    public HttpResult importData(@RequestPart MultipartFile file, InvInsImportDto importDto) {
+//    public HttpResult importData(@RequestBody InvInsImportDto importDto) {
+
+        if (importDto.getFlag().equals("1") && StringUtils.isEmpty(importDto.getInsCompanyId()))
+            return HttpResult.error("保险公司导入模式下,保险公司ID为必填。");
+
+        InvExternalBills iieb = null;
+        if (StringUtils.isNotEmpty(importDto.getBatchNum())) {
+            iieb = invExternalBillsService.getById(importDto.getBatchNum());
+            //删除详细数据
+            invInsExternalBillsDetailsService.deleteByBatchNum(iieb.getId());
+        } else {
+            iieb = new InvExternalBills();
+            iieb.setCreateTime(new Date());
+            iieb.setCreateBy(getUserId());
+            iieb.setImportStatus("1");
+            iieb.setFlag(importDto.getFlag());
+
+//            //渠道
+//            iieb.setBusinessChannels(importDto.getBusinessChannels());
+            invExternalBillsService.save(iieb);
+        }
+        //数据导入
+        invExternalBillsService.importData(importDto, iieb, file);
+
+        return HttpResult.ok("导入成功");
+
+    }
+
+
+    @ApiOperation(value = "修改")
+    @ApiResponses({
+            @ApiResponse(code = 500, message = "出现异常"),
+            @ApiResponse(code = 200, message = "请求成功")
+    })
+    @PostMapping(value = "/edit")
+    public HttpResult edit(@RequestBody InvExternalBills invExternalBills, HttpServletRequest request) {
+
+        return HttpResult.ok(invExternalBillsService.updateById(invExternalBills));
+    }
+
+    @ApiOperation(value = "单条删除通过批次号")
+    @ApiResponses({
+            @ApiResponse(code = 500, message = "出现异常"),
+            @ApiResponse(code = 200, message = "请求成功")
+    })
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "batchNum", value = "批次号", required = true)
+            , @ApiImplicitParam(name = "flag", value = "标识(1 保险公司模板导入   2 渠道模板导入)", required = true)})
+    @DeleteMapping(value = "/deleteByBatchNum")
+    public HttpResult deleteByBatchNum(String batchNum, String flag) {
+
+        if (flag.equals("1")) {
+            invInsExternalBillsDetailsService.deleteByBatchNum(batchNum);
+        }
+        if (flag.equals("2")) {
+            invChannelsExternalBillsDetailsService.deleteByBatchNum(batchNum);
+        }
+
+        return HttpResult.ok(invExternalBillsService.removeById(batchNum));
+    }
+
+    @PostMapping("/channelMatchingIns")
+    @ApiOperation(value = "渠道匹配保险公司数据(分页)")
+    public HttpResult<PageVo<InvBaseChannelMatchInsResVO>> channelMatchIns(@RequestBody PageDto<InvChannelExternalBillsDetailsReqVO> pageDto) {
+        return HttpResult.ok(invChannelsExternalBillsDetailsService.gainChannelMatchIns(pageDto));
+    }
+//    @PostMapping("/channelMatchingIns")
+//    @ApiOperation(value = "渠道匹配保险公司数据(分页)")
+//    public HttpResult<PageResult<InvBaseChannelMatchInsResVO>> channelMatchIns(@RequestBody InvChannelExternalBillsDetailsReqVO reqVo) {
+//
+//        return HttpResult.ok(invChannelsExternalBillsDetailsService.gainChannelMatchIns(reqVo));
+//
+//    }
+
+    @GetMapping(value = "/export/{batchNum}")
+    @ApiOperation(value = "保司数据导出(包含费用)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "batchNum", value = "批次号", required = true, dataType = "String")
+    })
+    public HttpResult export(@PathVariable String batchNum, HttpServletRequest request, HttpServletResponse response) {
+
+
+        LambdaQueryWrapper<InvInsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        lqw.eq(InvInsExternalBillsDetails::getBatchNum, batchNum);
+        List<InvInsExternalBillsDetails> list = invInsExternalBillsDetailsService.list(lqw);
+
+        List<InvInsCompanyExportVo> listVo = new ArrayList<>();
+        list.stream().forEach(a -> {
+            InvInsCompanyExportVo vo = new InvInsCompanyExportVo();
+            vo.setMliftaPolicyNum(a.getMliftaPolicyNum());
+            vo.setCipPolicyNum(a.getCipPolicyNum());
+            vo.setApplicant(a.getApplicant());
+            vo.setPlateNum(a.getPlateNum());
+            vo.setPayDate(a.getPayDate());
+            vo.setMlifta(a.getMlifta());
+            vo.setVavt(a.getVavt());
+            vo.setCip(a.getCip());
+            vo.setOther(a.getOther());
+            vo.setMliftaCost(a.getMliftaCost());
+            vo.setVavtCost(a.getVavtCost());
+            vo.setCipCost(a.getCipCost());
+            vo.setInsCompany(a.getInsCompany());
+
+            listVo.add(vo);
+        });
+        String fileName = batchNum + "-保司数据导出";
+        try {
+            ExcelEasypoiUtils.exportExcel(listVo, InvInsCompanyExportVo.class, fileName, response);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return HttpResult.ok();
+    }
+
+
+    @PostMapping(value = "/synthesize")
+    @ApiOperation(value = "综合查询")
+    public HttpResult<PageVo<InvInsCompanyVo>> synthesize(@RequestBody PageDto<InvInsCompanyDto> pageDto) {
+        return HttpResult.ok(invExternalBillsService.gainSynthesizePage(pageDto));
+
+    }
+
+
+}

+ 79 - 0
src/main/java/com/ydtech/modules/inv/controller/InvInsExternalBillsDetailsController.java

@@ -0,0 +1,79 @@
+package com.ydtech.modules.inv.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageRequest;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
+import com.ydtech.modules.inv.model.InvInsExternalBillsDetails;
+import com.ydtech.modules.inv.model.vo.req.InvInsExternalBillsDetailsReqVO;
+import com.ydtech.modules.inv.service.InvExternalBillsService;
+import com.ydtech.modules.inv.service.InvInsExternalBillsDetailsService;
+import com.ydtech.utils.StringUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * 财务 - 保险公司 - 外部票据控制层 详情
+ *
+ * @author: lig
+ * @date: 2023-05-31
+ */
+@Api(tags = "财务 - 保险公司 - 外部票据 详情 控制层")
+@RestController
+@RequestMapping("api/inv/insExternalBillsDetails")
+public class InvInsExternalBillsDetailsController extends BaseController {
+
+    @Resource
+    private InvExternalBillsService insExternalBillsService;
+    @Resource
+    private InvInsExternalBillsDetailsService invInsExternalBillsDetailsService;
+    @Resource
+    private EsmInsCompanyService esmInsCompanyService;
+
+
+
+
+    /**
+     * 分页查询
+     *
+     * @param reqVo
+     * @return
+     */
+    @ApiOperation(value = "分页查询")
+    @PostMapping(value = "/queryPage")
+    public HttpResult<PageResult<InvInsExternalBillsDetails>> queryPage(@RequestBody InvInsExternalBillsDetailsReqVO reqVo){
+
+        LambdaQueryWrapper<InvInsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getBatchNum()),InvInsExternalBillsDetails::getBatchNum,reqVo.getBatchNum());
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getStatus()),InvInsExternalBillsDetails::getStatus,reqVo.getStatus());
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getInsCompanyId()),InvInsExternalBillsDetails::getInsCompanyId,reqVo.getInsCompanyId());
+
+        Page p = PageRequest.buildPageRequestByVo(reqVo);
+        IPage<InvInsExternalBillsDetails> pResult = invInsExternalBillsDetailsService.page(p, lqw);
+        //传入查询条件
+        PageResult<InvInsExternalBillsDetails> pageResult = PageResult.buildPageResult(pResult);
+        return HttpResult.ok(pageResult);
+    }
+
+
+
+
+    @GetMapping("/detailsById")
+    @ApiOperation(value = "详情")
+    public HttpResult<InvInsExternalBillsDetails> detailsById(String id) {
+        return HttpResult.ok(invInsExternalBillsDetailsService.getById(id));
+
+    }
+
+
+
+
+
+}

+ 178 - 0
src/main/java/com/ydtech/modules/inv/controller/InvInvoiceInfoController.java

@@ -0,0 +1,178 @@
+package com.ydtech.modules.inv.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.aop.exception.DescribeException;
+import com.ydtech.constants.enums.dict.ApprovalStatusEnum;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageRequest;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.inv.model.InvInvoiceInfo;
+import com.ydtech.modules.inv.model.InvInvoiceInfoInOut;
+import com.ydtech.modules.inv.model.dto.InvInvoiceInfoDto;
+import com.ydtech.modules.inv.model.vo.req.InvInvoiceInfoReqVO;
+import com.ydtech.modules.inv.service.InvInvoiceInfoInOutService;
+import com.ydtech.modules.inv.service.InvInvoiceInfoService;
+import com.ydtech.utils.StringUtils;
+import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 发票信息管理
+ *
+ * @author: lig
+ * @date: 2023-05-15
+ */
+@Api(tags = "发票信息管理")
+@RestController
+@RequestMapping("api/inv/invoiceInfo")
+public class InvInvoiceInfoController extends BaseController {
+
+    @Autowired
+    private InvInvoiceInfoService invInvoiceInfoService;
+
+    @Autowired
+    private InvInvoiceInfoInOutService invInvoiceInfoInOutService;
+
+
+    @ApiOperation(value = "保存(外部合同开票)")
+    @PostMapping(value = "/saveTypeOne")
+    public HttpResult saveTypeOne(@RequestBody InvInvoiceInfoDto dto) {
+        dto.getInvoiceInfo().setType(1);
+        return HttpResult.ok(invInvoiceInfoService.saveInvoice(dto));
+
+
+    }
+    @ApiOperation(value = "保存(手续费开票)")
+    @PostMapping(value = "/saveTypeTwo")
+    public HttpResult saveTypeTwo(@RequestBody InvInvoiceInfoDto dto) {
+        dto.getInvoiceInfo().setType(2);
+        return HttpResult.ok(invInvoiceInfoService.saveInvoice(dto));
+    }
+    @ApiOperation(value = "保存")
+    @PostMapping(value = "/save")
+    public HttpResult save(@RequestBody InvInvoiceInfoDto dto) {
+        return HttpResult.ok(invInvoiceInfoService.saveInvoice(dto));
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param reqVo
+     * @return
+     */
+    @ApiOperation(value = "分页查询")
+    @PostMapping(value = "/queryPage")
+    public HttpResult queryPage(@RequestBody InvInvoiceInfoReqVO reqVo){
+
+        LambdaQueryWrapper<InvInvoiceInfo> lqw = new LambdaQueryWrapper();
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getApprovalStatus()),InvInvoiceInfo::getApprovalStatus,reqVo.getApprovalStatus());
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getInvoiceClerk()),InvInvoiceInfo::getInvoiceClerk,reqVo.getInvoiceClerk());
+        lqw.eq(StringUtils.isNotEmpty(reqVo.getInvCompanyId()),InvInvoiceInfo::getInvCompanyId,reqVo.getInvCompanyId());
+
+        Page p = PageRequest.buildPageRequestByVo(reqVo);
+        IPage<InvInvoiceInfo> pResult = invInvoiceInfoService.page(p, lqw);
+        //传入查询条件
+        PageResult pageResult = PageResult.buildPageResult(pResult);
+        return HttpResult.ok(pageResult);
+    }
+
+
+    /**
+     * 审批通过
+     *
+     * @param
+     * @return
+     */
+//    @PreAuthorize("hasAuthority('inv:invoice:info:approval:pass')")
+    @ApiOperation(value = "审批通过")
+    @PostMapping(value = "/approvalPass")
+    public HttpResult approvalPass(@RequestParam("ids") List<String> ids){
+
+        return HttpResult.ok(invInvoiceInfoService.approval(ApprovalStatusEnum.AS1,ids));
+    }
+
+    /**
+     * 审批退回
+     *
+     * @param
+     * @return
+     */
+//    @PreAuthorize("hasAuthority('inv:invoice:info:approval:back')")
+    @ApiOperation(value = "审批退回")
+    @PostMapping(value = "/approvalBack")
+    public HttpResult approvalBack(@RequestParam("ids") List<String> ids){
+
+        return HttpResult.ok(invInvoiceInfoService.approval(ApprovalStatusEnum.AS3,ids));
+    }
+
+
+//    /**
+//     * 批量删除
+//     *
+//     * @param
+//     * @return
+//     */
+//    @ApiOperation(value = "批量删除")
+//    @PostMapping(value = "/batchDelete")
+//    public HttpResult batchDelete(List<String> ids){
+//
+//        return HttpResult.ok(invInvoiceInfoService.removeBatchByIds(ids));
+//    }
+
+
+
+    @PostMapping("/import")
+    @ApiOperation(value = "excel导入数据")
+    public HttpResult importData(@ApiParam(name = "file", value = "excel文件") MultipartFile file, HttpServletRequest request) {
+        HttpResult result = null;
+
+        return invInvoiceInfoService.importData(file);
+
+    }
+//    @PostMapping("/export")
+    @GetMapping("/export")
+    @ApiOperation(value = "excel导出数据")
+    public void exportData(@RequestParam("ids") List<String> ids, HttpServletRequest request, HttpServletResponse response) {
+
+        try {
+            invInvoiceInfoService.exportData(ids,request,response);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new DescribeException("信息导出失败!" + e.getMessage());
+        }
+
+    }
+
+
+
+    @GetMapping(value = "/details/{id}")
+    @ApiOperation(value = "获取发票详情(包含进出帐)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "String")
+    })
+    public HttpResult<InvInvoiceInfoDto> details(@PathVariable String id) {
+
+        InvInvoiceInfo invInfo = invInvoiceInfoService.getById(id);
+
+        LambdaQueryWrapper<InvInvoiceInfoInOut> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(InvInvoiceInfoInOut::getId,invInfo.getId());
+        List<InvInvoiceInfoInOut> inOutList = invInvoiceInfoInOutService.list(lqw);
+
+        InvInvoiceInfoDto iiiDto = new InvInvoiceInfoDto();
+        iiiDto.setInvoiceInfo(invInfo);
+        iiiDto.setInvoiceInfoInOutList(inOutList);
+
+        return HttpResult.ok(iiiDto);
+    }
+
+
+}

+ 28 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvChannelsExternalBillsDetailsHistoryServiceImpl.java

@@ -0,0 +1,28 @@
+package com.ydtech.modules.inv.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.inv.dao.InvChannelsExternalBillsDetailsHistoryMapper;
+import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetailsHistory;
+import com.ydtech.modules.inv.service.InvChannelsExternalBillsDetailsHistoryService;
+import com.ydtech.utils.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class InvChannelsExternalBillsDetailsHistoryServiceImpl extends ServiceImpl<InvChannelsExternalBillsDetailsHistoryMapper, InvChannelsExternalBillsDetailsHistory>
+    implements InvChannelsExternalBillsDetailsHistoryService {
+
+
+    @Override
+    public List<InvChannelsExternalBillsDetailsHistory> gainListByEditId(String editId) {
+        LambdaQueryWrapper<InvChannelsExternalBillsDetailsHistory> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(StringUtils.isNotEmpty(editId),InvChannelsExternalBillsDetailsHistory::getEditId,editId);
+        return list(lqw);
+    }
+}
+
+
+
+

+ 274 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvChannelsExternalBillsDetailsServiceImpl.java

@@ -0,0 +1,274 @@
+package com.ydtech.modules.inv.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.constants.enums.dict.finance.CheckingStatusEnum;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.base.model.dto.PageDto;
+import com.ydtech.modules.base.model.vo.PageVo;
+import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
+import com.ydtech.modules.inv.dao.InvChannelsExternalBillsDetailsMapper;
+import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
+import com.ydtech.modules.inv.model.dto.InvChannelExcelDto;
+import com.ydtech.modules.inv.model.vo.res.InvBaseChannelMatchInsResVO;
+import com.ydtech.modules.inv.service.InvChannelsExternalBillsDetailsService;
+import com.ydtech.modules.inv.service.InvExternalBillsService;
+import com.ydtech.utils.excel.ExcelEasypoiUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Service
+public class InvChannelsExternalBillsDetailsServiceImpl extends ServiceImpl<InvChannelsExternalBillsDetailsMapper, InvChannelsExternalBillsDetails>
+        implements InvChannelsExternalBillsDetailsService {
+
+    @Resource
+    InvExternalBillsService invExternalBillsService;
+    @Resource
+    private EsmInsCompanyService esmInsCompanyService;
+
+    @Override
+    public PageVo<InvBaseChannelMatchInsResVO> gainChannelMatchIns(PageDto pageDto) {
+        PageVo<InvBaseChannelMatchInsResVO> pageVo = new PageVo();
+        //获取总数量
+        int total = super.baseMapper.gainChannelMatchInsCount(pageDto);
+
+        pageVo.setTotalSize(total);
+        PageVo.buildPageInfo(pageDto, pageVo);
+
+        pageVo.setContent(super.baseMapper.gainChannelMatchIns(pageDto));
+
+        return pageVo;
+
+
+    }
+//    @Override
+//    public PageResult<InvBaseChannelMatchInsResVO> gainChannelMatchIns(InvChannelExternalBillsDetailsReqVO reqVo) {
+//        //获取总数量
+//        int total = super.baseMapper.gainChannelMatchInsCount(reqVo);
+////        //计算mysql分页起索引
+////        int firstIndex = reqVo.getPageNum()==1?0:(reqVo.getPageNum()-1) * reqVo.getPageSize() +1;
+////        //计算mysql分页总页数
+////        int totalPages = total % reqVo.getPageSize() == 0?total / reqVo.getPageSize():total / reqVo.getPageSize() +1;
+//
+////        PageResult pr = new PageResult();
+////        pr.setPageNum(reqVo.getPageNum());
+////        pr.setPageSize(reqVo.getPageSize());
+////        pr.setTotalSize(total);
+////        pr.setTotalPages(totalPages);
+//
+//
+//        //请求替换分页开始索引
+//        reqVo.setPageNum(PageResult.buildPageLimitStart(reqVo));
+//
+//        List<InvBaseChannelMatchInsResVO> resVOList = super.baseMapper.gainChannelMatchIns(reqVo);
+//
+//
+//        return PageResult.buildPageResult(reqVo, total, resVOList);
+//
+//    }
+
+    @Override
+    public boolean deleteByBatchNum(String batchNum) {
+        LambdaQueryWrapper<InvChannelsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        lqw.eq(InvChannelsExternalBillsDetails::getBatchNum, batchNum);
+        return remove(lqw);
+    }
+
+//    @Override
+//    public InvExternalBills importData(MultipartFile file, InvExternalBills iieb) {
+//
+//        String errorMsg = "";
+//        List<InvChannelsExternalBillsDetails> list = null;
+//        try {
+//            List<InvInsChannelExcelDto> dtoList =  ExcelEasypoiUtils.importExcel(file, InvInsChannelExcelDto.class, 0, 1, 1);
+//
+//            dtoList = dtoList.stream().filter(l -> l.getPlateNum() != null).collect(Collectors.toList());
+//            if(null == dtoList || dtoList.size() < 1){
+//                errorMsg = "导入失败!匹配数据 0 条";
+//
+//            }
+//
+//
+//            Map<String, InvChannelsExternalBillsDetails> m = new HashMap();
+//            dtoList.stream().forEach(a ->{
+//                InvChannelsExternalBillsDetails icebd = new InvChannelsExternalBillsDetails();
+//                if (m.containsKey(a.getPlateNum())) {
+//                    icebd = m.get(a.getPlateNum());
+//
+//                } else {
+//                    BeanUtil.copyProperties(a, icebd);
+//                    //对应保险公司
+//                    EsmInsCompany insCompany = esmInsCompanyService.findInsCompanyByName(a.getInsCompany());
+//                    if(null == insCompany)throw new SystemException("保险公司:" + a.getInsCompany() + "不匹配");
+//                    icebd.setInsCompanyId(insCompany.getId());
+//                    icebd.setInsCompany(insCompany.getName());
+//
+//                    icebd.setMliftaCost(a.getMliftaCost());
+//
+//                    icebd.setPayDate(a.getPayDate());
+//                    icebd.setInsCoverage(a.getInsCoverage());
+//
+//
+//                    icebd.setStatus("1");
+//
+//                }
+//                m.put(a.getPlateNum(), icebd);
+//            });
+//
+//            //获取车牌号list
+//            List<String> listKey = m.keySet().stream().collect(Collectors.toList());
+//            //获取车牌号重复的list  渠道
+//            List<String> longs = gainPlateNumRepetitionList(listKey);
+//
+//
+//            if(longs.size() > 0){
+//                errorMsg = "车牌号已经存在:"+longs;
+////                throw new SystemException("车牌号已经存在:"+longs);
+//            }else{
+//                list = new ArrayList<>(m.values());
+//            }
+//
+//
+//
+//
+//        } catch (IOException e) {
+//            errorMsg = "导入失败!" + e.getMessage();
+//        }
+//
+//
+//        if (StringUtils.isNotEmpty(errorMsg)) {
+//            iieb.setImportStatus("0");
+//            iieb.setErrorMsg(errorMsg);
+//
+//
+//        } else {
+//
+//            iieb = InvExternalBills.buildImportInvExternalBills(iieb, list);
+//            boolean boo = saveBatch(list);
+//        }
+//        return iieb;
+//
+//
+//    }
+
+    @Override
+    public void pay(List<String> ids, SysUser user) {
+        //更新批次号状态
+        LambdaUpdateWrapper<InvChannelsExternalBillsDetails> luw = new LambdaUpdateWrapper<>();
+        luw.set(InvChannelsExternalBillsDetails::getStatus, "2");
+        luw.set(InvChannelsExternalBillsDetails::getPayOperatorId, user.getId());
+        luw.set(InvChannelsExternalBillsDetails::getPayOperator, user.getName());
+        luw.in(InvChannelsExternalBillsDetails::getId, ids);
+        update(luw);
+    }
+
+
+    /**
+     * 获取车牌号重复的list  渠道
+     *
+     * @author: lig
+     * @date: 2023年07月07日 0007
+     */
+    private List<String> gainPlateNumRepetitionList(List<String> listKey) {
+        LambdaQueryWrapper<InvChannelsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        lqw.select(InvChannelsExternalBillsDetails::getPlateNum);
+        lqw.eq(InvChannelsExternalBillsDetails::getStatus, CheckingStatusEnum.AS0.getCode());
+        lqw.in(InvChannelsExternalBillsDetails::getPlateNum, listKey);
+
+        //查询获取对象具体字段的集合
+        List<String> longs = listObjs(lqw, new Function<Object, String>() {
+            @Override
+            public String apply(Object id) {
+                return id.toString();
+            }
+        });
+        return longs;
+
+    }
+
+
+    @Override
+    public void importData(MultipartFile file) {
+
+        String errorMsg = "";
+        List<InvChannelsExternalBillsDetails> list = null;
+        try {
+            List<InvChannelExcelDto> dtoList = ExcelEasypoiUtils.importExcel(file, InvChannelExcelDto.class, 0, 1, 1);
+
+            dtoList = dtoList.stream().filter(l -> l.getPlateNum() != null).collect(Collectors.toList());
+            if (null == dtoList || dtoList.size() < 1) {
+//                errorMsg = "导入失败!匹配数据 0 条";
+                throw new SystemException("导入失败!匹配数据 0 条");
+
+            }
+
+
+            Map<String, InvChannelsExternalBillsDetails> m = new HashMap();
+            dtoList.stream().forEach(a -> {
+                InvChannelsExternalBillsDetails icebd = new InvChannelsExternalBillsDetails();
+                if (m.containsKey(a.getPlateNum())) {
+                    icebd = m.get(a.getPlateNum());
+                    if (!a.getChannel().equals(icebd.getChannel())) {
+                        throw new SystemException("导入重复数据,车牌号:" + a.getPlateNum());
+                    }
+
+                } else {
+                    BeanUtil.copyProperties(a, icebd);
+                    //对应保险公司
+                    EsmInsCompany insCompany = esmInsCompanyService.findInsCompanyByName(a.getInsCompany());
+                    if (null == insCompany) throw new SystemException("保险公司:" + a.getInsCompany() + "不匹配");
+                    icebd.setInsCompanyId(insCompany.getId());
+                    icebd.setInsCompany(insCompany.getName());
+
+                    icebd.setMliftaCost(a.getMliftaCost());
+
+                    icebd.setPayDate(a.getPayDate());
+                    icebd.setInsCoverage(a.getInsCoverage());
+
+                    icebd.setStatus("0");
+
+                }
+                m.put(a.getPlateNum(), icebd);
+            });
+
+            //获取车牌号list
+            List<String> listKey = m.keySet().stream().collect(Collectors.toList());
+            //获取车牌号重复的list  渠道
+            List<String> longs = gainPlateNumRepetitionList(listKey);
+
+            if (longs.size() > 0) {
+                throw new SystemException(String.format("车牌号已经存在:%s", longs));
+//                errorMsg = "车牌号已经存在:"+longs;
+//                throw new SystemException("车牌号已经存在:"+longs);
+            } else {
+                list = new ArrayList<>(m.values());
+                saveBatch(list);
+            }
+
+        } catch (IOException e) {
+            throw new SystemException("导入失败!");
+//            errorMsg = "导入失败!" + e.getMessage();
+        }
+
+
+    }
+
+
+}
+
+
+
+

+ 63 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvCompanyServiceImpl.java

@@ -0,0 +1,63 @@
+package com.ydtech.modules.inv.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.inv.dao.InvCompanyMapper;
+import com.ydtech.modules.inv.model.InvCompany;
+import com.ydtech.modules.inv.model.vo.req.InvCompanyReqVO;
+import com.ydtech.modules.inv.model.vo.res.InvCompanyResVO;
+import com.ydtech.modules.inv.service.InvCompanyService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ * @description 针对表【inv_company(开票公司)】的数据库操作Service实现
+ * @createDate 2023-05-15 11:03:06
+ */
+@Service
+public class InvCompanyServiceImpl extends ServiceImpl<InvCompanyMapper, InvCompany>
+        implements InvCompanyService {
+
+
+
+    @Override
+    public PageResult gainPage(InvCompanyReqVO invCompanyReqVO) {
+        //获取总数量
+        int total = super.baseMapper.gainCount(invCompanyReqVO);
+        //计算mysql分页起索引
+        int firstIndex = invCompanyReqVO.getPageNum()==1?0:(invCompanyReqVO.getPageNum()-1) * invCompanyReqVO.getPageSize() +1;
+        //计算mysql分页总页数
+        int totalPages = total % invCompanyReqVO.getPageSize() == 0?total / invCompanyReqVO.getPageSize():total / invCompanyReqVO.getPageSize() +1;
+
+        PageResult pr = new PageResult();
+        pr.setPageNum(invCompanyReqVO.getPageNum());
+        pr.setPageSize(invCompanyReqVO.getPageSize());
+        pr.setTotalSize(total);
+        pr.setTotalPages(totalPages);
+
+        //请求替换分页开始索引
+        invCompanyReqVO.setPageNum(firstIndex);
+
+        List<InvCompanyResVO> resVOList =  super.baseMapper.gainPage(invCompanyReqVO);
+
+
+        pr.setContent(resVOList);
+
+
+        return pr;
+    }
+
+    @Override
+    public InvCompany gainIdByEnterpriseName(String enterpriseName) {
+        LambdaQueryWrapper<InvCompany> lqw = new LambdaQueryWrapper();
+        lqw.eq(InvCompany::getEnterpriseName,enterpriseName);
+        return getOne(lqw);
+    }
+}
+
+
+
+

+ 153 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvExternalBillsServiceImpl.java

@@ -0,0 +1,153 @@
+package com.ydtech.modules.inv.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.base.model.dto.PageDto;
+import com.ydtech.modules.base.model.vo.PageVo;
+import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
+import com.ydtech.modules.inv.dao.InvExternalBillsMapper;
+import com.ydtech.modules.inv.model.InvExternalBills;
+import com.ydtech.modules.inv.model.dto.InvInsImportDto;
+import com.ydtech.modules.inv.model.vo.InvInsCompanyVo;
+import com.ydtech.modules.inv.service.InvChannelsExternalBillsDetailsService;
+import com.ydtech.modules.inv.service.InvExternalBillsService;
+import com.ydtech.modules.inv.service.InvInsExternalBillsDetailsService;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+
+
+@Service
+public class InvExternalBillsServiceImpl extends ServiceImpl<InvExternalBillsMapper, InvExternalBills>
+        implements InvExternalBillsService {
+
+    @Resource
+    private InvInsExternalBillsDetailsService invInsExternalBillsDetailsService;
+    @Resource
+    private InvChannelsExternalBillsDetailsService invChannelsExternalBillsDetailsService;
+    @Resource
+    private EsmInsCompanyService esmInsCompanyService;
+
+
+//    @Override
+//    public void importDataInsOper(String batchNum, MultipartFile file, InvExternalBills ieb) {
+//        //删除详细数据
+//        invInsExternalBillsDetailsService.deleteByBatchNum(batchNum);
+//        try {
+//            //导入《保司》详细数据
+//            invInsExternalBillsDetailsService.importData(file, ieb);
+//        }catch (Exception e){
+//            ieb.setImportStatus("0");
+//            updateById(ieb);
+//        }
+//
+//    }
+//
+//    @Override
+//    public void importDataChannelsOper(String batchNum, MultipartFile file, InvExternalBills ieb) {
+//
+//        //删除详细数据
+//        invChannelsExternalBillsDetailsService.deleteByBatchNum(batchNum);
+//        try {
+//            //导入《渠道》详细数据
+//            invChannelsExternalBillsDetailsService.importData(file, ieb);
+//        }catch (Exception e){
+//            ieb.setImportStatus("0");
+//            updateById(ieb);
+//        }
+//
+//    }
+
+
+    @Override
+    public void importData(InvInsImportDto importDto, InvExternalBills iieb,MultipartFile file) {
+        try {
+            /**
+             *  保险公司模板导入
+             */
+            if (importDto.getFlag().equals("1")) {
+
+                EsmInsCompany eic = esmInsCompanyService.getById(importDto.getInsCompanyId());
+                if (null == eic) throw new SystemException("未找到匹配的保险公司信息");
+                iieb.setInsCompanyId(eic.getId());
+                iieb.setInsCompanyName(eic.getName());
+                //导入保险公司详细数据
+                invInsExternalBillsDetailsService.importData(importDto,file, iieb);
+            }
+//            else
+//                /**
+//                 *  渠道模板导入
+//                 */
+//                if (importDto.getFlag().equals("2")) {
+//                //导入渠道详细数据
+//                invChannelsExternalBillsDetailsService.importData(file, iieb);
+//            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("导入数据失败:" + e.getMessage());
+            iieb.setImportStatus("0");
+            iieb.setErrorMsg(e.getMessage());
+        }
+
+        updateById(iieb);
+    }
+
+    @Override
+    public PageVo<InvInsCompanyVo> gainSynthesizePage(PageDto pageDto) {
+        PageVo<InvInsCompanyVo> pageVo = new PageVo();
+
+        //获取分页数量
+        int total = super.baseMapper.gainSynthesizeCount(pageDto);
+        pageVo.setTotalSize(total);
+
+        PageVo.buildPageInfo(pageDto,pageVo);
+
+        pageVo.setContent(super.baseMapper.gainSynthesize(pageDto));
+
+
+        return pageVo;
+    }
+
+
+//    @Override
+//    public void importData(String flag, String insCompanyId, String businessChannels, InvExternalBills iieb, MultipartFile file) {
+//
+//
+//    }
+
+//    @Override
+//    public void importDataAnew(String flag, String batchNum, MultipartFile file, InvExternalBills ieb) {
+//
+//        if (flag.equals("1")) {
+//
+//            try {
+//                //删除详细数据
+//                invInsExternalBillsDetailsService.deleteByBatchNum(batchNum);
+//                //导入《保司》详细数据
+//                invInsExternalBillsDetailsService.importData(file, ieb);
+//            } catch (Exception e) {
+//                ieb.setImportStatus("0");
+//                updateById(ieb);
+//            }
+//        } else if (flag.equals("2")) {
+//
+//            try {
+//                //删除详细数据
+//                invChannelsExternalBillsDetailsService.deleteByBatchNum(batchNum);
+//                //导入《渠道》详细数据
+//                invChannelsExternalBillsDetailsService.importData(file, ieb);
+//            } catch (Exception e) {
+//                ieb.setImportStatus("0");
+//                updateById(ieb);
+//            }
+//        }
+//
+//
+//    }
+}
+
+
+
+

+ 306 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvInsExternalBillsDetailsServiceImpl.java

@@ -0,0 +1,306 @@
+package com.ydtech.modules.inv.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.constants.enums.dict.finance.CheckingStatusEnum;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.inv.dao.InvInsExternalBillsDetailsMapper;
+import com.ydtech.modules.inv.model.InvExternalBills;
+import com.ydtech.modules.inv.model.InvInsExternalBillsDetails;
+import com.ydtech.modules.inv.model.dto.InvInsChinaCoalExcelDto;
+import com.ydtech.modules.inv.model.dto.InvInsExcelDto;
+import com.ydtech.modules.inv.model.dto.InvInsImportDto;
+import com.ydtech.modules.inv.model.dto.InvInsSimpleSysExcelDto;
+import com.ydtech.modules.inv.service.InvExternalBillsService;
+import com.ydtech.modules.inv.service.InvInsExternalBillsDetailsService;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementProductCosts;
+import com.ydtech.modules.protocol.service.PtlAgreementProductCostsService;
+import com.ydtech.utils.StringUtils;
+import com.ydtech.utils.excel.ExcelEasypoiUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * @author Administrator
+ * @description 针对表【inv_ins_external_bills_details(财务 - 保险公司 - 外部票据 - 详情)】的数据库操作Service实现
+ * @createDate 2023-06-06 11:08:53
+ */
+@Service
+public class InvInsExternalBillsDetailsServiceImpl extends ServiceImpl<InvInsExternalBillsDetailsMapper, InvInsExternalBillsDetails>
+        implements InvInsExternalBillsDetailsService {
+
+    @Resource
+    InvExternalBillsService invExternalBillsService;
+    @Resource
+    PtlAgreementProductCostsService ptlAgreementProductCostsService;
+
+    @Override
+    public boolean deleteByBatchNum(String batchNum) {
+        LambdaQueryWrapper<InvInsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        lqw.eq(InvInsExternalBillsDetails::getBatchNum, batchNum);
+        return remove(lqw);
+    }
+
+
+    @Override
+    public InvExternalBills importData(InvInsImportDto importDto, MultipartFile file, InvExternalBills iieb) throws Exception {
+
+
+        List<InvInsExternalBillsDetails> list = buildImportExcel(importDto, file, iieb);
+
+        iieb = InvExternalBills.buildImportInvExternalBills(iieb, list);
+
+        boolean boo = saveBatch(list);
+
+        if (!boo) {
+            iieb.setImportStatus("0");
+            iieb.setErrorMsg("保存数据出错");
+
+        }
+
+
+        return iieb;
+
+
+    }
+
+
+    /**
+     * 构造导入excel数据
+     *
+     * @author: lig
+     * @date: 2023年07月06日 0006
+     */
+    private List<InvInsExternalBillsDetails> buildImportExcel(InvInsImportDto importDto, MultipartFile file, InvExternalBills iieb) throws Exception {
+
+
+        List<InvInsExternalBillsDetails> list;
+        Map<String, InvInsExternalBillsDetails> m = new HashMap();
+
+
+        List<InvInsExcelDto> standardList = ExcelEasypoiUtils.importExcel(file, InvInsExcelDto.class, 0, 1, 1);
+        standardList.stream().forEach(a -> {
+
+
+            List<String> filedList = new ArrayList<>();
+            filedList.add(a.getInsCompanyUser());
+            //费用map
+            Map<String,String> costMap = new HashMap();
+            try {
+                //获取费用
+                List<PtlAgreementProductCosts> costList = ptlAgreementProductCostsService.selectByCompanyId(iieb.getInsCompanyId(),filedList);
+
+                costList.stream().forEach(cost ->{
+//                    costMap.put(cost.getProductName(),cost.getCostsProportion());
+                });
+            }catch (Exception e){
+                log.error("保司导入,获取费用失败!");
+            }
+
+            InvInsExternalBillsDetails iiebd = new InvInsExternalBillsDetails();
+            if (m.containsKey(a.getPlateNum())) {
+                iiebd = m.get(a.getPlateNum());
+
+            } else {
+                BeanUtil.copyProperties(a, iiebd);
+                iiebd.setInsCompanyId(iieb.getInsCompanyId());
+                iiebd.setInsCompany(iieb.getInsCompanyName());
+            }
+
+
+            //产品匹配   添加费用
+            if(costMap.containsKey(a.getProductName())){
+                if(a.getProductName().equals("单交")){
+                    iiebd.setMliftaCost(new BigDecimal(costMap.get(a.getProductName())));
+                }
+            }
+
+            buildStandardDtoParam(a, iiebd);
+            m.put(a.getPlateNum(), iiebd);
+        });
+
+
+//        //标准模板
+//        if (importDto.isStandard()) {
+//            List<InvInsStandardExcelDto> standardList = ExcelUtils2.importExcel(file, InvInsStandardExcelDto.class, 0, 1, 1);
+//            standardList.stream().forEach(a -> {
+//
+//
+//                List<String> filedList = new ArrayList<>();
+//                filedList.add(a.getInsuranceCompanyUser());
+//                //获取费用
+//                List<PtlAgreementProductCosts> costList = ptlAgreementProductCostsService.selectByCompanyId(iieb.getInsCompanyId(),filedList);
+//                Map<String,String> costMap = new HashMap();
+//                costList.stream().forEach(cost ->{
+//                    costMap.put(cost.getProductName(),cost.getCostsProportion());
+//                });
+//
+//                InvInsExternalBillsDetails iiebd = new InvInsExternalBillsDetails();
+//                if (m.containsKey(a.getPlateNum())) {
+//                    iiebd = m.get(a.getPlateNum());
+//
+//                } else {
+//                    BeanUtil.copyProperties(a, iiebd);
+//                }
+//
+//
+//                //产品匹配   添加费用
+//                if(costMap.containsKey(a.getProductName())){
+//                    if(a.getProductName().equals("单交")){
+//                        iiebd.setMliftaCost(new BigDecimal(costMap.get(a.getProductName())));
+//                    }
+//
+//                }
+//
+//                buildStandardDtoParam(a, iiebd);
+//                m.put(a.getPlateNum(), iiebd);
+//            });
+//
+//        } else if (iieb.getInsCompanyId().equals("000019")) {
+//            //中煤
+//            List<InvInsChinaCoalExcelDto> zmlist = ExcelUtils2.importExcel(file, InvInsChinaCoalExcelDto.class, 0, 1, 1);
+//            zmlist.stream().forEach(a -> {
+//
+//                InvInsExternalBillsDetails iiebd = new InvInsExternalBillsDetails();
+//                if (m.containsKey(a.getPlateNum())) {
+//                    iiebd = m.get(a.getPlateNum());
+//
+//                } else {
+//                    BeanUtil.copyProperties(a, iiebd);
+//                }
+//                buildChinaCoalDtoParam(a, iiebd);
+//                m.put(a.getPlateNum(), iiebd);
+//            });
+//
+//        } else {
+//            //万家模板
+//            List<InvInsSimpleSysExcelDto> wjlist = ExcelUtils2.importExcel(file, InvInsSimpleSysExcelDto.class, 0, 1, 1);
+//            wjlist.stream().forEach(b -> {
+//
+//                InvInsExternalBillsDetails iiebd = new InvInsExternalBillsDetails();
+//                if (m.containsKey(b.getPlateNum())) {
+//                    iiebd = m.get(b.getPlateNum());
+//
+//                } else {
+//                    BeanUtil.copyProperties(b, iiebd);
+//                }
+//
+//                buildSimpleSysDtoParam(b, iiebd);
+//
+//
+//                m.put(b.getPlateNum(), iiebd);
+//
+//
+//            });
+//        }
+
+
+        //判断车牌号是否存在  保司
+
+        List<String> listKey = m.keySet().stream().collect(Collectors.toList());
+        LambdaQueryWrapper<InvInsExternalBillsDetails> lqw = new LambdaQueryWrapper();
+        lqw.select(InvInsExternalBillsDetails::getPlateNum);
+        lqw.in(InvInsExternalBillsDetails::getPlateNum, listKey);
+        lqw.eq(InvInsExternalBillsDetails::getStatus, CheckingStatusEnum.AS0.getCode());
+
+        //查询获取对象具体字段的集合
+        List<String> longs = listObjs(lqw, new Function<Object, String>() {
+            @Override
+            public String apply(Object id) {
+                return id.toString();
+            }
+        });
+
+        List<InvInsExternalBillsDetails> plateNumRepetitionList = list(lqw);
+
+        if (plateNumRepetitionList.size() > 0 && plateNumRepetitionList.size() < 5) {
+            throw new SystemException("车牌号已经存在:" + longs);
+        } else if (plateNumRepetitionList.size() > 5) {
+            throw new SystemException("大量车牌号已经存在");
+        }
+
+
+        list = new ArrayList<>(m.values());
+
+
+        return list;
+
+
+    }
+
+
+    /**
+     * 构造 中煤 dto参数
+     *
+     * @author: lig
+     * @date: 2023年07月10日 0010
+     */
+    void buildChinaCoalDtoParam(InvInsChinaCoalExcelDto dto, InvInsExternalBillsDetails iiebd) {
+
+        iiebd.setStatus("0");
+        if (dto.getInsKindName().equals("机动车交通事故责任强制保险")) {
+            iiebd.setMlifta(dto.getPremium());
+            iiebd.setVavt(dto.getVavt());
+        } else {
+            //商业保费
+            iiebd.setCip(dto.getPremium());
+            //三者保额
+            iiebd.setTpi(dto.getTpi());
+//            //三者保费
+//            iiebd.setTpiCost(dto.getTpiPremium());
+        }
+    }
+
+
+    /**
+     * 构造 简易系统(万家) dto参数
+     *
+     * @author: lig
+     * @date: 2023年07月10日 0010
+     */
+    void buildSimpleSysDtoParam(InvInsSimpleSysExcelDto simpleSysDto, InvInsExternalBillsDetails iiebd) {
+
+        iiebd.setStatus("0");
+        if (StringUtils.isNotEmpty(simpleSysDto.getInsKindName()) && simpleSysDto.getInsKindName().equals("交强险")) {
+            iiebd.setMlifta(simpleSysDto.getPremium());
+            iiebd.setVavt(simpleSysDto.getVavt());
+        } else {
+            //商业保费
+            iiebd.setCip(simpleSysDto.getPremium());
+//            //三者保额
+//            iiebd.setTpi(simpleSysDto.getTpi());
+//            //三者保费
+//            iiebd.setTpiCost(simpleSysDto.getTpiPremium());
+        }
+    }
+
+    /**
+     * 构造 标准模板 dto参数
+     *
+     * @author: lig
+     * @date: 2023-07-10
+     */
+    void buildStandardDtoParam(InvInsExcelDto simpleSysDto, InvInsExternalBillsDetails iiebd) {
+
+        iiebd.setInsHabit(simpleSysDto.getProductName());
+        iiebd.setStatus("0");
+
+
+    }
+
+
+}
+
+
+
+

+ 21 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvInvoiceInfoInOutServiceImpl.java

@@ -0,0 +1,21 @@
+package com.ydtech.modules.inv.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.inv.dao.InvInvoiceInfoInOutMapper;
+import com.ydtech.modules.inv.model.InvInvoiceInfoInOut;
+import com.ydtech.modules.inv.service.InvInvoiceInfoInOutService;
+import org.springframework.stereotype.Service;
+
+/**
+ */
+@Service
+public class InvInvoiceInfoInOutServiceImpl extends ServiceImpl<InvInvoiceInfoInOutMapper, InvInvoiceInfoInOut>
+        implements InvInvoiceInfoInOutService {
+
+
+
+}
+
+
+
+

+ 174 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvInvoiceInfoServiceImpl.java

@@ -0,0 +1,174 @@
+package com.ydtech.modules.inv.service.impl;
+
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.constants.enums.dict.ApprovalStatusEnum;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.SysDict;
+import com.ydtech.modules.admin.service.SysDictService;
+import com.ydtech.modules.ins.utils.ExcelStyleUtil;
+import com.ydtech.modules.inv.dao.InvInvoiceInfoMapper;
+import com.ydtech.modules.inv.model.InvCompany;
+import com.ydtech.modules.inv.model.InvInvoiceInfo;
+import com.ydtech.modules.inv.model.InvInvoiceInfoInOut;
+import com.ydtech.modules.inv.model.dto.InvInvoiceInfoDto;
+import com.ydtech.modules.inv.service.InvCompanyService;
+import com.ydtech.modules.inv.service.InvInvoiceInfoInOutService;
+import com.ydtech.modules.inv.service.InvInvoiceInfoService;
+import com.ydtech.utils.StringUtils;
+import com.ydtech.utils.excel.ExcelEasypoiUtils;
+import com.ydtech.utils.excel.ExcelUtils2;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author Administrator
+ * @description 针对表【inv_invoice_info(发票表- 信息)】的数据库操作Service实现
+ * @createDate 2023-05-15 14:22:55
+ */
+@Service
+public class InvInvoiceInfoServiceImpl extends ServiceImpl<InvInvoiceInfoMapper, InvInvoiceInfo>
+        implements InvInvoiceInfoService {
+
+    @Resource
+    private InvCompanyService invCompanyService;
+    @Resource
+    private SysDictService sysDictService;
+    @Resource
+    private InvInvoiceInfoInOutService invInvoiceInfoInOutService;
+
+    @Override
+    public boolean approval(ApprovalStatusEnum approvalStatusEnum, List<String> ids) {
+        LambdaUpdateWrapper<InvInvoiceInfo> luw = new LambdaUpdateWrapper();
+        luw.set(InvInvoiceInfo::getApprovalStatus, approvalStatusEnum.getCode());
+        luw.in(InvInvoiceInfo::getId, ids);
+        return update(luw);
+    }
+
+    @Override
+    public HttpResult importData(MultipartFile file) {
+
+        List<InvInvoiceInfo> list = null;
+        try {
+            list = ExcelEasypoiUtils.importExcel(file, InvInvoiceInfo.class, null, null, null);
+        } catch (IOException e) {
+            return HttpResult.error("导入失败!" + e.getMessage());
+        }
+
+        list.remove(null);
+
+
+        List<InvCompany> iCompanyList = invCompanyService.list();
+        List<SysDict> subjectsList = sysDictService.findByLable("subjects");
+
+
+        List<InvInvoiceInfo> finalList = new ArrayList<>();
+        list.stream().forEach(a -> {
+            if (StringUtils.isNullOrEmpty(a.getInvCompanyName())) return;
+
+            a.setApprovalStatus(ApprovalStatusEnum.AS0.getCode());
+
+            //获取ID
+            if (StringUtils.isNotEmpty(a.getInvCompanyName())) {
+
+//                iCompanyList.stream().filter(ic -> ic.getEnterpriseName().equals(a.getInvCompanyName())).collect(Collectors.toList());
+
+                String eNameId = iCompanyList
+                        .stream()
+                        .filter(ic -> ic.getEnterpriseName().equals(a.getInvCompanyName()))
+//                        .sorted(Comparator.comparing(B::getSorted))
+                        .map(b -> b.getId())
+                        .collect(Collectors.joining(StrUtil.CRLF));
+
+
+//                InvCompany ic = invCompanyService.gainIdByEnterpriseName(a.getInvCompanyName());
+                if (StringUtils.isNotEmpty(eNameId)) {
+                    a.setInvCompanyId(eNameId);
+                } else {
+                    return;
+                }
+            }
+
+            if (null != a && StringUtils.isNotEmpty(a.getSubjects())) {
+
+                String subjectsId = subjectsList
+                        .stream()
+                        .filter(sub -> sub.getLabel().equals(a.getSubjects()))
+//                        .sorted(Comparator.comparing(B::getSorted))
+                        .map(b -> b.getValue())
+                        .collect(Collectors.joining(StrUtil.CRLF));
+
+
+//                List<SysDict> subjectsList = sysDictService.findByLable("subjects");
+                if (StringUtils.isNotEmpty(subjectsId)) {
+                    a.setSubjectsId(subjectsId);
+                } else {
+                    return;
+                }
+            }
+            finalList.add(a);
+        });
+
+        if (finalList.size() > 0) {
+            saveBatch(finalList);
+            return HttpResult.ok("导入匹配[开票公司]的数据条数:" + finalList.size());
+        } else {
+            return HttpResult.error("导入匹配[开票公司]的数据条数:0");
+        }
+
+
+    }
+
+    @Override
+    public HttpResult exportData(List<String> ids, HttpServletRequest request, HttpServletResponse response) {
+        List<InvInvoiceInfo> iiiList = listByIds(ids);
+
+        // 导出
+        ExportParams exportParams = new ExportParams(null, "Sheet1", ExcelType.HSSF);
+//        ExportParams exportParams = new ExportParams();
+        // 设置
+        exportParams.setStyle(ExcelStyleUtil.class);
+        try {
+            String fileName = URLEncoder.encode("发票信息表", "UTF-8");
+            ExcelUtils2.exportExcel(iiiList, InvInvoiceInfo.class, fileName, exportParams, request, response);
+//            ExcelUtils2.exportExcel(iiiList, InvInvoiceInfo.class, "发票信息表", exportParams, request, response);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return HttpResult.ok("导出成功");
+    }
+
+    @Override
+    public boolean saveInvoice(InvInvoiceInfoDto dto) {
+        InvInvoiceInfo invInvoiceInfo = dto.getInvoiceInfo();
+        invInvoiceInfo.setApprovalStatus(ApprovalStatusEnum.AS1.getCode());
+        if(StringUtils.isNotEmpty(invInvoiceInfo.getId())){
+            List<InvInvoiceInfoInOut> invoiceInfoInOutList = dto.getInvoiceInfoInOutList();
+            if(null !=invoiceInfoInOutList && invoiceInfoInOutList.size()>0){
+                invInvoiceInfoInOutService.removeById(invInvoiceInfo.getId());
+
+            }
+            invInvoiceInfoInOutService.saveBatch(invoiceInfoInOutList);
+        }
+        return saveOrUpdate(invInvoiceInfo);
+    }
+
+
+}
+
+
+
+

+ 44 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvPayableStatementServiceImpl.java

@@ -0,0 +1,44 @@
+package com.ydtech.modules.inv.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.inv.dao.InvPayableStatementMapper;
+import com.ydtech.modules.inv.model.InvPayableStatement;
+import com.ydtech.modules.inv.service.InvPayableStatementService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author Administrator
+ * @description 针对表【inv_payable_statement(应付明细表)】的数据库操作Service实现
+ * @createDate 2022-09-14 17:43:32
+ */
+@Service
+public class InvPayableStatementServiceImpl extends ServiceImpl<InvPayableStatementMapper, InvPayableStatement>
+        implements InvPayableStatementService {
+
+    @Autowired
+    private InvPayableStatementMapper invPayableStatementMapper;
+
+    @Override
+    @Transactional
+    public boolean insertBatch(List<InvPayableStatement> itemList) {
+
+        List<InvPayableStatement> invPayableStatements = invPayableStatementMapper.selectBySigningDateAndNumberPlate(itemList);
+        if (invPayableStatements.size() > 0) {
+            throw new SystemException("重复车牌:" + invPayableStatements.stream().parallel().map(InvPayableStatement::getNumberPlate).collect(Collectors.joining(",")));
+        }
+
+        try {
+            invPayableStatementMapper.insertBatch(itemList);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+
+    }
+}

+ 105 - 0
src/main/java/com/ydtech/modules/inv/service/impl/InvoiceServiceImpl.java

@@ -0,0 +1,105 @@
+package com.ydtech.modules.inv.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.service.SysDeptService;
+import com.ydtech.modules.ins.dao.InsSettleMapper;
+import com.ydtech.modules.ins.model.InsSettle;
+import com.ydtech.modules.inv.dao.InvoiceMapper;
+import com.ydtech.modules.inv.model.vo.req.InvoiceReq;
+import com.ydtech.modules.inv.model.vo.res.InvoiceRes;
+import com.ydtech.modules.inv.service.InvoiceService;
+import com.ydtech.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class InvoiceServiceImpl implements InvoiceService {
+    @Autowired
+    private InvoiceMapper invoiceMapper;
+    @Autowired
+    private InsSettleMapper insSettleMapper;
+
+    @Autowired
+    private SysDeptService sysDeptService;
+
+    @Override
+    public HttpResult save(InvoiceReq req, HttpServletRequest request) {
+        String msg = "保存成功";
+        if (StringUtils.isNullOrEmpty(req.getFphm())) {
+            return HttpResult.error("发票号不可为空!");
+        }
+        if (StringUtils.isNullOrEmpty(req.getSettleno())) {
+            return HttpResult.error("结算单号不可为空!");
+        }
+        if (StringUtils.isNullOrEmpty(req.getFileid())) {
+            return HttpResult.error("文件id不可为空!");
+        }
+        InsSettle insSettle = insSettleMapper.selectByPrimaryKey(req.getSettleno());
+        req.setComcode(insSettle.getComcode());
+        req.setCreatedate(new Date());
+        String usercode = "";
+//        String usercode = JwtTokenUtils.getUsernameFromRequest(request);
+        req.setCreatecode(usercode);
+        req.setUpdatedate(new Date());
+        req.setUpdatecode(usercode);
+
+        invoiceMapper.save(req);
+        return HttpResult.ok(msg);
+    }
+
+    @Transactional
+    @Override
+    public HttpResult saveList(List<InvoiceReq> reqList, HttpServletRequest request) {
+        String msg = "保存成功";
+        if (CollectionUtils.isEmpty(reqList)) {
+            return HttpResult.error("请求参数为空!");
+        }
+
+        for (InvoiceReq req : reqList) {
+            if (StringUtils.isNullOrEmpty(req.getFphm())) {
+                return HttpResult.error("发票号码不可为空!");
+            }
+            if (StringUtils.isNullOrEmpty(req.getSettleno())) {
+                return HttpResult.error("结算单号不可为空!");
+            }
+            if (StringUtils.isNullOrEmpty(req.getFileid())) {
+                return HttpResult.error("文件id不可为空!");
+            }
+
+            InsSettle insSettle = insSettleMapper.selectByPrimaryKey(req.getSettleno());
+            req.setComcode(insSettle.getComcode());
+            req.setCreatedate(new Date());
+            String usercode = "";
+//            String usercode = JwtTokenUtils.getUsernameFromRequest(request);
+            req.setCreatecode(usercode);
+            req.setUpdatedate(new Date());
+            req.setUpdatecode(usercode);
+        }
+        int a = invoiceMapper.deleteBatch(reqList);
+        int i = invoiceMapper.insertBatch(reqList);
+        return HttpResult.ok(msg);
+    }
+
+    @Override
+    public HttpResult select(InvoiceReq req) {
+        String msg = "查询成功!";
+        PageHelper.startPage(req.getPageNum(), req.getPageSize());
+        List<InvoiceRes> list = invoiceMapper.select(req);
+        for (InvoiceRes invoiceVo : list) {
+            SysDept sysDept = sysDeptService.getById(invoiceVo.getComcode());
+            invoiceVo.setComname(sysDept.getName());
+        }
+        return HttpResult.ok(msg, new PageResult<>(list));
+    }
+
+
+}