|
|
@@ -0,0 +1,207 @@
|
|
|
+package com.huyi.service.bill.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.huyi.service.base.entity.ZcBillInf;
|
|
|
+import com.huyi.service.base.entity.ZcInvoiceInf;
|
|
|
+import com.huyi.service.base.service.IZcBillInfService;
|
|
|
+import com.huyi.service.base.service.IZcInvoiceInfService;
|
|
|
+import com.huyi.service.bill.service.IOwnBillService;
|
|
|
+import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
|
|
|
+import com.tianhu.common.core.constant.SalaryConstants;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.core.utils.SecurityUtils;
|
|
|
+import com.tianhu.common.core.utils.ServletUtils;
|
|
|
+import com.tianhu.common.core.web.controller.BaseController;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.RemoteFileService;
|
|
|
+import com.tianhu.system.api.domain.PubFileInf;
|
|
|
+import com.tianhu.system.api.domain.SysUser;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 往来账款管理
|
|
|
+ *
|
|
|
+ * @author dudm@minpay.cc
|
|
|
+ * @date 2021-08-17
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("ownBill")
|
|
|
+public class OwnBillController extends BaseController {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证状态 0未验证1成功2失败
|
|
|
+ */
|
|
|
+ private static String CHECK_SUCCESS = "1";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnBillService iOwnBillService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IZcBillInfService iZcBillInfService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IZcInvoiceInfService iZcInvoiceInfService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RemoteFileService remoteFileService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 往来账款列表
|
|
|
+ *
|
|
|
+ * @param zbiName 账款名称
|
|
|
+ * @param zbiContractNo 合同编号
|
|
|
+ * @param payerName 应付方
|
|
|
+ * @param payeeName 应收方
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/billList")
|
|
|
+ public R list(
|
|
|
+ @RequestParam(required=false) String zbiName,
|
|
|
+ @RequestParam(required=false) String zbiContractNo,
|
|
|
+ @RequestParam(required=false) String payerName,
|
|
|
+ @RequestParam(required=false) String payeeName,
|
|
|
+ QueryRequest request) {
|
|
|
+ //查询当前操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = user.getCompanyId();
|
|
|
+ Map map = new HashMap();
|
|
|
+ if (!SalaryConstants.OPEX.equals(companyId)) {
|
|
|
+ map.put("companyId", companyId);
|
|
|
+ }
|
|
|
+ //账款名称
|
|
|
+ map.put("zbiName", zbiName);
|
|
|
+ //合同编号
|
|
|
+ map.put("zbiContractNo", zbiContractNo);
|
|
|
+ //应付方
|
|
|
+ map.put("payerName", payerName);
|
|
|
+ //应收方
|
|
|
+ map.put("payeeName", payeeName);
|
|
|
+ IPage<Map> list = iOwnBillService.selectBillInfList(map,request);
|
|
|
+ return R.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增账款信息
|
|
|
+ *
|
|
|
+ * @param map 账款信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ public R add(Map map) throws ParseException {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //账款名称
|
|
|
+ String zbiName = CommonUtil.objToString(map.get("zbiName"));
|
|
|
+ //应付方
|
|
|
+ String zbiPayerId = CommonUtil.objToString(map.get("zbiPayerId"));
|
|
|
+ //应收方
|
|
|
+ String zbiPayeeId = CommonUtil.objToString(map.get("zbiPayeeId"));
|
|
|
+ //时间格式化
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //贸易日期
|
|
|
+ String zbiDate = CommonUtil.objToString(map.get("zbiDate"));
|
|
|
+ Date date = sdf.parse(zbiDate);
|
|
|
+ //预计收付款日期
|
|
|
+ String zbiPayDate = CommonUtil.objToString(map.get("zbiPayDate"));
|
|
|
+ Date payDate = sdf.parse(zbiPayDate);
|
|
|
+ //贸易金额
|
|
|
+ String zbiAmount = CommonUtil.objToString(map.get("zbiAmount"));
|
|
|
+ //合同编号
|
|
|
+ String zbiContractNo = CommonUtil.objToString(map.get("zbiContractNo"));
|
|
|
+ //账款服务
|
|
|
+ String zbiService = CommonUtil.objToString(map.get("zbiService"));
|
|
|
+ //配送订单
|
|
|
+ String zbiOrderNo = CommonUtil.objToString(map.get("zbiOrderNo"));
|
|
|
+ //配送企业
|
|
|
+ String zbiDistributor = CommonUtil.objToString(map.get("zbiDistributor"));
|
|
|
+ //备注
|
|
|
+ String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));
|
|
|
+ ZcBillInf zcBillInf = new ZcBillInf();
|
|
|
+ iZcBillInfService.createZcBillInf(zcBillInf);
|
|
|
+ //TODO
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发票识别
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/getInvoiceText")
|
|
|
+ public ZcInvoiceInf getInvoiceText(MultipartFile file) {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ //获取发票信息
|
|
|
+ ZcInvoiceInf zcInvoiceInf = iOwnBillService.getInvoice(file);
|
|
|
+ LambdaQueryWrapper<ZcInvoiceInf> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //发票代码
|
|
|
+ queryWrapper.eq(ZcInvoiceInf::getZiiNo,zcInvoiceInf.getZiiNo());
|
|
|
+ //发票号码
|
|
|
+ queryWrapper.eq(ZcInvoiceInf::getZiiNumber,zcInvoiceInf.getZiiNumber());
|
|
|
+ List<ZcInvoiceInf> list = iZcInvoiceInfService.findZcInvoiceInfs(queryWrapper);
|
|
|
+ //不重复则储存发票并上传
|
|
|
+ if(list.size() == 0){
|
|
|
+ iZcInvoiceInfService.createZcInvoiceInf(zcInvoiceInf);
|
|
|
+ //TODO 只验真部分发票
|
|
|
+ //验真发票
|
|
|
+ zcInvoiceInf = iOwnBillService.invoiceVerification(zcInvoiceInf);
|
|
|
+ zcInvoiceInf.setCreateBy(user.getUserid().toString());
|
|
|
+ zcInvoiceInf.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //验真通过发票上传到文件服务器
|
|
|
+ if(CHECK_SUCCESS.equals(zcInvoiceInf.getZiiCheckStt())){
|
|
|
+ //获取上传文件token
|
|
|
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
|
|
|
+ //文件传输
|
|
|
+ R<PubFileInf> fileResult = remoteFileService.uploadFile(file,"01","04","00", companyId, token);
|
|
|
+ zcInvoiceInf.setZiiFile(fileResult.getData().getPfiFileId());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ zcInvoiceInf.setZiiId(list.get(0).getZiiId());
|
|
|
+ }
|
|
|
+ //返回发票信息
|
|
|
+ return zcInvoiceInf;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新验真
|
|
|
+ *
|
|
|
+ * @param zcInvoiceInf 发票信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/invoiceVerification")
|
|
|
+ public ZcInvoiceInf invoiceVerification(ZcInvoiceInf zcInvoiceInf) {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ if(CommonUtil.isEmpty(zcInvoiceInf.getZiiId())){
|
|
|
+ return zcInvoiceInf;
|
|
|
+ }
|
|
|
+ //验真发票
|
|
|
+ zcInvoiceInf = iOwnBillService.invoiceVerification(zcInvoiceInf);
|
|
|
+ zcInvoiceInf.setUpdateBy(user.getUserid().toString());
|
|
|
+ zcInvoiceInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //修改发票信息
|
|
|
+ iZcInvoiceInfService.updateZcInvoiceInf(zcInvoiceInf);
|
|
|
+ return zcInvoiceInf;
|
|
|
+ }
|
|
|
+}
|