|
|
@@ -0,0 +1,255 @@
|
|
|
+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.BaseController;
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.core.page.PageRequest;
|
|
|
+import com.ydtech.core.page.PageResult;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.esm.model.EsmInsCompany;
|
|
|
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
|
|
|
+import com.ydtech.modules.inv.model.InvExternalBills;
|
|
|
+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.model.vo.res.InvCompanyResVO;
|
|
|
+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 io.swagger.annotations.*;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+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());
|
|
|
+
|
|
|
+ Page p = PageRequest.buildPageRequestByVo(reqVo);
|
|
|
+ IPage<InvExternalBills> pResult = invExternalBillsService.page(p, lqw);
|
|
|
+ //传入查询条件
|
|
|
+ PageResult<InvExternalBills> pageResult = PageResult.buildPageResult(pResult);
|
|
|
+ return HttpResult.ok(pageResult);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/importDataAdd")
|
|
|
+ @ApiOperation(value = "excel导入数据(新增)")
|
|
|
+ public HttpResult importDataAdd(@ApiParam(name = "file", value = "excel文件", required = true) @RequestPart MultipartFile file
|
|
|
+ , HttpServletRequest request
|
|
|
+ , @ApiParam(name = "insCompanyId", value = "保险公司ID") String insCompanyId
|
|
|
+ , @ApiParam(name = "businessChannels", value = "业务渠道") String businessChannels
|
|
|
+ , @ApiParam(name = "flag", value = "标识(1 保险公司模板导入 2 渠道模板导入)", required = true) @RequestParam String flag
|
|
|
+ ) {
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) {
|
|
|
+ throw new SystemException("上传文件大小为空");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ HttpResult result = null;
|
|
|
+
|
|
|
+ InvExternalBills iieb = new InvExternalBills();
|
|
|
+ iieb.setCreateTime(new Date());
|
|
|
+ iieb.setCreateBy(getUserId(request));
|
|
|
+ iieb.setImportStatus("1");
|
|
|
+ iieb.setFlag(flag);
|
|
|
+
|
|
|
+ if (flag.equals("1")) {
|
|
|
+ if (StringUtils.isNullOrEmpty(insCompanyId)) return HttpResult.error("保险公司ID不存在");
|
|
|
+ EsmInsCompany eic = esmInsCompanyService.getById(insCompanyId);
|
|
|
+ if (null == eic) return HttpResult.error("保险公司不存在");
|
|
|
+ iieb.setInsCompanyId(eic.getId());
|
|
|
+ iieb.setInsCompanyName(eic.getName());
|
|
|
+
|
|
|
+ invExternalBillsService.save(iieb);
|
|
|
+ //导入保险公司详细数据
|
|
|
+ invInsExternalBillsDetailsService.importData(file, iieb);
|
|
|
+
|
|
|
+
|
|
|
+ } else if (flag.equals("2")) {
|
|
|
+ iieb.setBusinessChannels(businessChannels);
|
|
|
+ invExternalBillsService.save(iieb);
|
|
|
+ invChannelsExternalBillsDetailsService.importData(file, iieb);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return HttpResult.ok("导入成功");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/importDataEdit")
|
|
|
+ @ApiOperation(value = "excel导入数据(修改)")
|
|
|
+ public HttpResult importDataEdit(@ApiParam(name = "file", value = "excel文件", required = true) @RequestPart MultipartFile file
|
|
|
+ , @ApiParam(name = "batchNum", value = "批次号", required = true) @RequestParam String batchNum
|
|
|
+ , HttpServletRequest request
|
|
|
+ ) {
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) {
|
|
|
+ throw new SystemException("上传文件大小为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ InvExternalBills ieb = invExternalBillsService.getById(batchNum);
|
|
|
+
|
|
|
+
|
|
|
+ ieb.setCreateTime(new Date());
|
|
|
+ ieb.setCreateBy(getUserId(request));
|
|
|
+ ieb.setImportStatus("1");
|
|
|
+ invExternalBillsService.updateById(ieb);
|
|
|
+
|
|
|
+
|
|
|
+ if (ieb.getFlag().equals("1")) {
|
|
|
+
|
|
|
+ invExternalBillsService.importDataInsOper( batchNum, file, ieb);
|
|
|
+
|
|
|
+ } else if (ieb.getFlag().equals("2")) {
|
|
|
+
|
|
|
+ invExternalBillsService.importDataChannelsOper( batchNum, file, ieb);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return HttpResult.ok("重新导入成功");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// @PostMapping("/import")
|
|
|
+// @ApiOperation(value = "excel导入数据")
|
|
|
+// public HttpResult importData(@ApiParam(name = "file", value = "excel文件") MultipartFile file, HttpServletRequest request
|
|
|
+// , String insCompanyId, String id ) {
|
|
|
+// HttpResult result = null;
|
|
|
+//
|
|
|
+//
|
|
|
+// InvInsExternalBills iieb = null;
|
|
|
+// if (StringUtils.isNotEmpty(id)) {
|
|
|
+// iieb = insExternalBillsService.getById(id);
|
|
|
+// invInsExternalBillsDetailsService.deleteByBatchNum(id);
|
|
|
+// } else {
|
|
|
+// if (StringUtils.isNotEmpty(insCompanyId)) {
|
|
|
+// EsmInsCompany eic = esmInsCompanyService.getById(insCompanyId);
|
|
|
+// if (null != eic) {
|
|
|
+// iieb = new InvInsExternalBills();
|
|
|
+// iieb.setInsCompanyId(eic.getId());
|
|
|
+// iieb.setInsCompanyName(eic.getName());
|
|
|
+//
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// return HttpResult.error("保险公司不存在");
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// return HttpResult.error("保险公司ID空");
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// iieb.setCreateTime(new Date());
|
|
|
+// iieb.setCreateBy(getUserId(request));
|
|
|
+//
|
|
|
+// iieb.setImportStatus("1");
|
|
|
+//
|
|
|
+// insExternalBillsService.saveOrUpdate(iieb);
|
|
|
+//
|
|
|
+// //导入详细数据
|
|
|
+// insExternalBillsService.importData(file, iieb);
|
|
|
+//
|
|
|
+//
|
|
|
+//// return insExternalBillsService.importData(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<PageResult<InvBaseChannelMatchInsResVO>> channelMatchIns(@RequestBody InvChannelExternalBillsDetailsReqVO reqVo) {
|
|
|
+
|
|
|
+ return HttpResult.ok(invChannelsExternalBillsDetailsService.gainChannelMatchIns(reqVo));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|