|
@@ -3,6 +3,7 @@ package com.huyi.service.bill.controller;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.huyi.service.base.entity.*;
|
|
@@ -160,19 +161,199 @@ public class OwnBillController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 初始化账款信息
|
|
|
+ * 新增账款信息
|
|
|
*
|
|
|
* @param map 账款信息
|
|
|
* @return
|
|
|
*/
|
|
|
- @Log(title = "初始化往来账款信息", businessType = BusinessType.UPDATE)
|
|
|
+ @Log(title = "新增往来账款信息", businessType = BusinessType.INSERT)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@PostMapping("/add")
|
|
|
public R add(@RequestBody Map map) throws ParseException {
|
|
|
//获取登录用户
|
|
|
LoginUser user = tokenService.getLoginUser();
|
|
|
+ //企业id
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
ZcBillInf zcBillInf = new ZcBillInf();
|
|
|
+ //主键
|
|
|
+ String zbiId = IdUtils.fastSimpleUUID();
|
|
|
+ zcBillInf.setZbiId(zbiId);
|
|
|
//账款名称
|
|
|
+ String zbiName = CommonUtil.objToString(map.get("zbiName"));
|
|
|
+ zcBillInf.setZbiName(zbiName);
|
|
|
+ //应付方
|
|
|
+ String zbiPayerId = CommonUtil.objToString(map.get("zbiPayerId"));
|
|
|
+ zcBillInf.setZbiPayerId(zbiPayerId);
|
|
|
+ //应收方
|
|
|
+ String zbiPayeeId = CommonUtil.objToString(map.get("zbiPayeeId"));
|
|
|
+ zcBillInf.setZbiPayeeId(zbiPayeeId);
|
|
|
+ //时间格式化
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //贸易日期
|
|
|
+ String zbiDate = CommonUtil.objToString(map.get("zbiDate"));
|
|
|
+ Date date = sdf.parse(zbiDate);
|
|
|
+ zcBillInf.setZbiDate(date);
|
|
|
+ //预计收付款日期
|
|
|
+ String zbiPayDate = CommonUtil.objToString(map.get("zbiPayDate"));
|
|
|
+ Date payDate = sdf.parse(zbiPayDate);
|
|
|
+ zcBillInf.setZbiPayDate(payDate);
|
|
|
+ //贸易金额
|
|
|
+ String zbiAmount = CommonUtil.objToString(map.get("zbiAmount"));
|
|
|
+ zcBillInf.setZbiAmount(zbiAmount);
|
|
|
+ //合同编号
|
|
|
+ String zbiContractNo = CommonUtil.objToString(map.get("zbiContractNo"));
|
|
|
+ zcBillInf.setZbiContractNo(zbiContractNo);
|
|
|
+ //账款服务
|
|
|
+ String zbiService = CommonUtil.objToString(map.get("zbiService"));
|
|
|
+ zcBillInf.setZbiService(zbiService);
|
|
|
+ //配送订单
|
|
|
+ String zbiOrderNo = CommonUtil.objToString(map.get("zbiOrderNo"));
|
|
|
+ zcBillInf.setZbiOrderNo(zbiOrderNo);
|
|
|
+ //配送企业
|
|
|
+ String zbiDistributor = CommonUtil.objToString(map.get("zbiDistributor"));
|
|
|
+ zcBillInf.setZbiDistributor(zbiDistributor);
|
|
|
+ //备注
|
|
|
+ String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));
|
|
|
+ zcBillInf.setZbiRemark(zbiRemark);
|
|
|
+ //编号
|
|
|
+ String number = "ASSET1121" + System.currentTimeMillis();
|
|
|
+ zcBillInf.setZbiNumber(number);
|
|
|
+ //创建人
|
|
|
+ zcBillInf.setCreateBy(user.getUserid().toString());
|
|
|
+ //创建时间
|
|
|
+ zcBillInf.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //发票列表
|
|
|
+ List<Map<String,String>> fileList = (List<Map<String, String>>) map.get("fileList");
|
|
|
+ for (Map<String,String> file : fileList) {
|
|
|
+ //发票代码
|
|
|
+ String ziiNo = CommonUtil.objToString(file.get("ziiNo"));
|
|
|
+ //发票号码
|
|
|
+ String ziiNumber = CommonUtil.objToString(file.get("ziiNumber"));
|
|
|
+ //校验码
|
|
|
+ String ziiCheckCode = CommonUtil.objToString(file.get("ziiCheckCode"));
|
|
|
+ //开票日期
|
|
|
+ String ziiDate = CommonUtil.objToString(file.get("ziiDate"));
|
|
|
+ Date ziiDateParse = sdf.parse(ziiDate);
|
|
|
+ //开票金额(价税合计)
|
|
|
+ String ziiAmount = CommonUtil.objToString(file.get("ziiAmount"));
|
|
|
+ //不含税金额
|
|
|
+ String ziiExcludedAmount = CommonUtil.objToString(file.get("ziiExcludedAmount"));
|
|
|
+ //开票类型
|
|
|
+ String ziiType = CommonUtil.objToString(file.get("ziiType"));
|
|
|
+ //购方名称
|
|
|
+ String ziiPurchaserName = CommonUtil.objToString(file.get("ziiPurchaserName"));
|
|
|
+ //购方识别号
|
|
|
+ String ziiPurchaserNo = CommonUtil.objToString(file.get("ziiPurchaserNo"));
|
|
|
+ //销方名称
|
|
|
+ String ziiSellerName = CommonUtil.objToString(file.get("ziiSellerName"));
|
|
|
+ //销方识别号
|
|
|
+ String ziiSellerNo = CommonUtil.objToString(file.get("ziiSellerNo"));
|
|
|
+ //合计金额
|
|
|
+ String ziiTotalAmount = CommonUtil.objToString(file.get("ziiTotalAmount"));
|
|
|
+ //校验结果
|
|
|
+ String ziiCheckStt = CommonUtil.objToString(file.get("ziiCheckStt"));
|
|
|
+ //附件
|
|
|
+ String ziiFile = CommonUtil.objToString(file.get("ziiFile"));
|
|
|
+ if (!"1".equals(ziiCheckStt)) {
|
|
|
+// return R.fail(500,"存在未验真或验真未通过发票,不可进行账款关联");
|
|
|
+ }
|
|
|
+ //贸易日期前一个月
|
|
|
+ Calendar startDate = Calendar.getInstance();
|
|
|
+ startDate.setTime(date);
|
|
|
+ startDate.add(Calendar.MONTH,-1);
|
|
|
+ Date start = startDate.getTime();
|
|
|
+ //付款日期后两个月
|
|
|
+ Calendar endDate = Calendar.getInstance();
|
|
|
+ endDate.setTime(payDate);
|
|
|
+ endDate.add(Calendar.MONTH,2);
|
|
|
+ Date end = endDate.getTime();
|
|
|
+ if(start.compareTo(ziiDateParse) > 0 || end.compareTo(ziiDateParse) < 0){
|
|
|
+ return R.fail(500,"存在不符合账款期限内发票,不可进行账款关联");
|
|
|
+ }
|
|
|
+ ZcInvoiceInf zcInvoiceInf = new ZcInvoiceInf();
|
|
|
+ String id = IdUtils.fastSimpleUUID();
|
|
|
+ zcInvoiceInf.setZiiId(id);
|
|
|
+ zcInvoiceInf.setZiiCompanyId(companyId);
|
|
|
+ zcInvoiceInf.setZiiNo(ziiNo);
|
|
|
+ zcInvoiceInf.setZiiNumber(ziiNumber);
|
|
|
+ zcInvoiceInf.setZiiCheckCode(ziiCheckCode);
|
|
|
+ zcInvoiceInf.setZiiDate(ziiDateParse);
|
|
|
+ zcInvoiceInf.setZiiAmount(ziiAmount);
|
|
|
+ zcInvoiceInf.setZiiExcludedAmount(ziiExcludedAmount);
|
|
|
+ zcInvoiceInf.setZiiType(ziiType);
|
|
|
+ zcInvoiceInf.setZiiPurchaserName(ziiPurchaserName);
|
|
|
+ zcInvoiceInf.setZiiPurchaserNo(ziiPurchaserNo);
|
|
|
+ zcInvoiceInf.setZiiSellerName(ziiSellerName);
|
|
|
+ zcInvoiceInf.setZiiSellerNo(ziiSellerNo);
|
|
|
+ zcInvoiceInf.setZiiTotalAmount(ziiTotalAmount);
|
|
|
+ zcInvoiceInf.setZiiCheckStt(ziiCheckStt);
|
|
|
+ zcInvoiceInf.setZiiFile(ziiFile);
|
|
|
+ //创建发票
|
|
|
+ iZcInvoiceInfService.createZcInvoiceInf(zcInvoiceInf);
|
|
|
+ //创建账款发票关联
|
|
|
+ ZcBillInvoiceRel zcBillInvoiceRel = new ZcBillInvoiceRel();
|
|
|
+ zcBillInvoiceRel.setZbirBillId(zbiId);
|
|
|
+ zcBillInvoiceRel.setZbirInvoiceId(id);
|
|
|
+ iZcBillInvoiceRelService.createZcBillInvoiceRel(zcBillInvoiceRel);
|
|
|
+ }
|
|
|
+ //合同附件
|
|
|
+ List<Map<String,String>> contractList = (List<Map<String, String>>) map.get("contractList");
|
|
|
+ for (Map<String,String> contractMap : contractList) {
|
|
|
+ //销方名称
|
|
|
+ String id = CommonUtil.objToString(contractMap.get("id"));
|
|
|
+ //创建账款附件关联
|
|
|
+ ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
+ zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
+ zcBillFileRel.setZbfrFileId(id);
|
|
|
+ zcBillFileRel.setZbfrType("0");
|
|
|
+ iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
+ }
|
|
|
+ //物流附件
|
|
|
+ List<Map<String,String>> logisticsList = (List<Map<String, String>>) map.get("logisticsList");
|
|
|
+ for (Map<String,String> logisticsMap : logisticsList) {
|
|
|
+ //销方名称
|
|
|
+ String id = CommonUtil.objToString(logisticsMap.get("id"));
|
|
|
+ //创建账款附件关联
|
|
|
+ ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
+ zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
+ zcBillFileRel.setZbfrFileId(id);
|
|
|
+ zcBillFileRel.setZbfrType("1");
|
|
|
+ iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
+ }
|
|
|
+ //其他附件
|
|
|
+ List<Map<String,String>> otherList = (List<Map<String, String>>) map.get("otherList");
|
|
|
+ for (Map<String,String> otherMap : otherList) {
|
|
|
+ //销方名称
|
|
|
+ String id = CommonUtil.objToString(otherMap.get("id"));
|
|
|
+ //创建账款附件关联
|
|
|
+ ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
+ zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
+ zcBillFileRel.setZbfrFileId(id);
|
|
|
+ zcBillFileRel.setZbfrType("2");
|
|
|
+ iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
+ }
|
|
|
+ zcBillInf.setZbiStatus("00");
|
|
|
+ iZcBillInfService.createZcBillInf(zcBillInf);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改账款信息
|
|
|
+ *
|
|
|
+ * @param map 账款信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/commitBill")
|
|
|
+ @Log(title = "修改往来账款信息", businessType = BusinessType.UPDATE)
|
|
|
+ public R commitBill(@RequestBody Map map) throws ParseException {
|
|
|
+ //获取登录用户
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //企业id
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ ZcBillInf zcBillInf = new ZcBillInf();
|
|
|
+ //主键
|
|
|
String zbiId = CommonUtil.objToString(map.get("zbiId"));
|
|
|
+ zcBillInf.setZbiId(zbiId);
|
|
|
//账款名称
|
|
|
String zbiName = CommonUtil.objToString(map.get("zbiName"));
|
|
|
zcBillInf.setZbiName(zbiName);
|
|
@@ -210,30 +391,143 @@ public class OwnBillController extends BaseController {
|
|
|
//备注
|
|
|
String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));
|
|
|
zcBillInf.setZbiRemark(zbiRemark);
|
|
|
- if(CommonUtil.isEmpty(zbiId)){
|
|
|
- //主键
|
|
|
- zbiId = IdUtils.fastSimpleUUID();
|
|
|
- zcBillInf.setZbiId(zbiId);
|
|
|
- //编号
|
|
|
- String number = "ASSET1121" + System.currentTimeMillis();
|
|
|
- zcBillInf.setZbiNumber(number);
|
|
|
- //创建人
|
|
|
- zcBillInf.setCreateBy(user.getUserid().toString());
|
|
|
- //创建时间
|
|
|
- zcBillInf.setCreateTime(DateUtils.getNowDate());
|
|
|
- iZcBillInfService.createZcBillInf(zcBillInf);
|
|
|
- }else{
|
|
|
- zcBillInf.setZbiId(zbiId);
|
|
|
- //修改人
|
|
|
- zcBillInf.setUpdateBy(user.getUserid().toString());
|
|
|
- //修改时间
|
|
|
- zcBillInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
- iZcBillInfService.updateZcBillInf(zcBillInf);
|
|
|
+ //编号
|
|
|
+ String number = "ASSET1121" + System.currentTimeMillis();
|
|
|
+ zcBillInf.setZbiNumber(number);
|
|
|
+ //创建人
|
|
|
+ zcBillInf.setCreateBy(user.getUserid().toString());
|
|
|
+ //创建时间
|
|
|
+ zcBillInf.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //发票列表
|
|
|
+ List<Map<String,String>> fileList = (List<Map<String, String>>) map.get("fileList");
|
|
|
+ for (Map<String,String> file : fileList) {
|
|
|
+ //发票id
|
|
|
+ String ziiId = CommonUtil.objToString(file.get("ziiId"));
|
|
|
+ //发票代码
|
|
|
+ String ziiNo = CommonUtil.objToString(file.get("ziiNo"));
|
|
|
+ //发票号码
|
|
|
+ String ziiNumber = CommonUtil.objToString(file.get("ziiNumber"));
|
|
|
+ //校验码
|
|
|
+ String ziiCheckCode = CommonUtil.objToString(file.get("ziiCheckCode"));
|
|
|
+ //开票日期
|
|
|
+ String ziiDate = CommonUtil.objToString(file.get("ziiDate"));
|
|
|
+ Date ziiDateParse = sdf.parse(ziiDate);
|
|
|
+ //开票金额(价税合计)
|
|
|
+ String ziiAmount = CommonUtil.objToString(file.get("ziiAmount"));
|
|
|
+ //不含税金额
|
|
|
+ String ziiExcludedAmount = CommonUtil.objToString(file.get("ziiExcludedAmount"));
|
|
|
+ //开票类型
|
|
|
+ String ziiType = CommonUtil.objToString(file.get("ziiType"));
|
|
|
+ //购方名称
|
|
|
+ String ziiPurchaserName = CommonUtil.objToString(file.get("ziiPurchaserName"));
|
|
|
+ //购方识别号
|
|
|
+ String ziiPurchaserNo = CommonUtil.objToString(file.get("ziiPurchaserNo"));
|
|
|
+ //销方名称
|
|
|
+ String ziiSellerName = CommonUtil.objToString(file.get("ziiSellerName"));
|
|
|
+ //销方识别号
|
|
|
+ String ziiSellerNo = CommonUtil.objToString(file.get("ziiSellerNo"));
|
|
|
+ //合计金额
|
|
|
+ String ziiTotalAmount = CommonUtil.objToString(file.get("ziiTotalAmount"));
|
|
|
+ //校验结果
|
|
|
+ String ziiCheckStt = CommonUtil.objToString(file.get("ziiCheckStt"));
|
|
|
+ //附件
|
|
|
+ String ziiFile = CommonUtil.objToString(file.get("ziiFile"));
|
|
|
+ if (!"1".equals(ziiCheckStt)) {
|
|
|
+// return R.fail(500,"存在未验真或验真未通过发票,不可进行账款关联");
|
|
|
+ }
|
|
|
+ //贸易日期前一个月
|
|
|
+ Calendar startDate = Calendar.getInstance();
|
|
|
+ startDate.setTime(date);
|
|
|
+ startDate.add(Calendar.MONTH,-1);
|
|
|
+ Date start = startDate.getTime();
|
|
|
+ //付款日期后两个月
|
|
|
+ Calendar endDate = Calendar.getInstance();
|
|
|
+ endDate.setTime(payDate);
|
|
|
+ endDate.add(Calendar.MONTH,2);
|
|
|
+ Date end = endDate.getTime();
|
|
|
+ if(start.compareTo(ziiDateParse) > 0 || end.compareTo(ziiDateParse) < 0){
|
|
|
+ return R.fail(500,"存在不符合账款期限内发票,不可进行账款关联");
|
|
|
+ }
|
|
|
+ ZcInvoiceInf zcInvoiceInf = new ZcInvoiceInf();
|
|
|
+ zcInvoiceInf.setZiiNo(ziiNo);
|
|
|
+ zcInvoiceInf.setZiiNumber(ziiNumber);
|
|
|
+ zcInvoiceInf.setZiiCheckCode(ziiCheckCode);
|
|
|
+ zcInvoiceInf.setZiiDate(ziiDateParse);
|
|
|
+ zcInvoiceInf.setZiiAmount(ziiAmount);
|
|
|
+ zcInvoiceInf.setZiiExcludedAmount(ziiExcludedAmount);
|
|
|
+ zcInvoiceInf.setZiiType(ziiType);
|
|
|
+ zcInvoiceInf.setZiiPurchaserName(ziiPurchaserName);
|
|
|
+ zcInvoiceInf.setZiiPurchaserNo(ziiPurchaserNo);
|
|
|
+ zcInvoiceInf.setZiiSellerName(ziiSellerName);
|
|
|
+ zcInvoiceInf.setZiiSellerNo(ziiSellerNo);
|
|
|
+ zcInvoiceInf.setZiiTotalAmount(ziiTotalAmount);
|
|
|
+ zcInvoiceInf.setZiiCheckStt(ziiCheckStt);
|
|
|
+ zcInvoiceInf.setZiiFile(ziiFile);
|
|
|
+ if(CommonUtil.isEmpty(ziiId)){
|
|
|
+ String id = IdUtils.fastSimpleUUID();
|
|
|
+ zcInvoiceInf.setZiiId(id);
|
|
|
+ zcInvoiceInf.setZiiCompanyId(companyId);
|
|
|
+ zcInvoiceInf.setCreateBy(user.getUserid().toString());
|
|
|
+ zcInvoiceInf.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //创建发票
|
|
|
+ iZcInvoiceInfService.createZcInvoiceInf(zcInvoiceInf);
|
|
|
+ //创建账款发票关联
|
|
|
+ ZcBillInvoiceRel zcBillInvoiceRel = new ZcBillInvoiceRel();
|
|
|
+ zcBillInvoiceRel.setZbirBillId(zbiId);
|
|
|
+ zcBillInvoiceRel.setZbirInvoiceId(id);
|
|
|
+ iZcBillInvoiceRelService.createZcBillInvoiceRel(zcBillInvoiceRel);
|
|
|
+ }else{
|
|
|
+ zcInvoiceInf.setZiiId(ziiId);
|
|
|
+ zcInvoiceInf.setUpdateBy(user.getUserid().toString());
|
|
|
+ zcInvoiceInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //创建发票
|
|
|
+ iZcInvoiceInfService.updateZcInvoiceInf(zcInvoiceInf);
|
|
|
+ }
|
|
|
}
|
|
|
- Map res = new HashMap();
|
|
|
- //返回账款id
|
|
|
- res.put("zbiId", zbiId);
|
|
|
- return R.ok(res);
|
|
|
+ //查询关联往来账款的附件
|
|
|
+ LambdaQueryWrapper<ZcBillFileRel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //往来账款id
|
|
|
+ lambdaQueryWrapper.eq(ZcBillFileRel::getZbfrBillId,zbiId);
|
|
|
+ //删除旧关联
|
|
|
+ iZcBillFileRelService.deleteZcBillFileRel(lambdaQueryWrapper);
|
|
|
+ //合同附件
|
|
|
+ List<Map<String,String>> contractList = (List<Map<String, String>>) map.get("contractList");
|
|
|
+ for (Map<String,String> contractMap : contractList) {
|
|
|
+ //销方名称
|
|
|
+ String id = CommonUtil.objToString(contractMap.get("id"));
|
|
|
+ //创建账款附件关联
|
|
|
+ ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
+ zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
+ zcBillFileRel.setZbfrFileId(id);
|
|
|
+ zcBillFileRel.setZbfrType("0");
|
|
|
+ iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
+ }
|
|
|
+ //物流附件
|
|
|
+ List<Map<String,String>> logisticsList = (List<Map<String, String>>) map.get("logisticsList");
|
|
|
+ for (Map<String,String> logisticsMap : logisticsList) {
|
|
|
+ //销方名称
|
|
|
+ String id = CommonUtil.objToString(logisticsMap.get("id"));
|
|
|
+ //创建账款附件关联
|
|
|
+ ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
+ zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
+ zcBillFileRel.setZbfrFileId(id);
|
|
|
+ zcBillFileRel.setZbfrType("1");
|
|
|
+ iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
+ }
|
|
|
+ //其他附件
|
|
|
+ List<Map<String,String>> otherList = (List<Map<String, String>>) map.get("otherList");
|
|
|
+ for (Map<String,String> otherMap : otherList) {
|
|
|
+ //销方名称
|
|
|
+ String id = CommonUtil.objToString(otherMap.get("id"));
|
|
|
+ //创建账款附件关联
|
|
|
+ ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
+ zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
+ zcBillFileRel.setZbfrFileId(id);
|
|
|
+ zcBillFileRel.setZbfrType("2");
|
|
|
+ iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
+ }
|
|
|
+ iZcBillInfService.updateZcBillInf(zcBillInf);
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -303,6 +597,8 @@ public class OwnBillController extends BaseController {
|
|
|
map.put("name",pubFileInf.getPfiFileName());
|
|
|
//文件url
|
|
|
map.put("url",pubFileInf.getPfiUrl());
|
|
|
+ //文件id
|
|
|
+ map.put("id",pubFileInf.getPfiFileId());
|
|
|
//时间格式化
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String date = sdf.format(map.get("ziiDate"));
|
|
@@ -323,9 +619,6 @@ public class OwnBillController extends BaseController {
|
|
|
@Log(title = "上传往来账款发票", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/getInvoiceText")
|
|
|
public R getInvoiceText(@RequestParam("file")MultipartFile file, @RequestParam("zbiId") String zbiId) {
|
|
|
- if(CommonUtil.isEmpty(zbiId)){
|
|
|
- return R.fail(500,"未获取到要上传发票的账款");
|
|
|
- }
|
|
|
long size = file.getSize();
|
|
|
if(size > 2097152L){
|
|
|
return R.fail(500,"上传文件大小不能超过2mb");
|
|
@@ -346,8 +639,6 @@ public class OwnBillController extends BaseController {
|
|
|
//发票状态
|
|
|
queryWrapper.eq(ZcInvoiceInf::getZiiStatus,"00");
|
|
|
List<ZcInvoiceInf> list = iZcInvoiceInfService.findZcInvoiceInfs(queryWrapper);
|
|
|
- String id = IdUtils.fastSimpleUUID();
|
|
|
- zcInvoiceInf.setZiiId(id);
|
|
|
zcInvoiceInf.setZiiCompanyId(companyId);
|
|
|
zcInvoiceInf.setCreateBy(user.getUserid().toString());
|
|
|
zcInvoiceInf.setCreateTime(DateUtils.getNowDate());
|
|
@@ -362,14 +653,8 @@ public class OwnBillController extends BaseController {
|
|
|
//文件传输
|
|
|
R<PubFileInf> fileResult = remoteFileService.uploadFile(file,"01","04","00", companyId, token);
|
|
|
zcInvoiceInf.setZiiFile(fileResult.getData().getPfiFileId());
|
|
|
- //创建发票
|
|
|
- iZcInvoiceInfService.createZcInvoiceInf(zcInvoiceInf);
|
|
|
- //创建账款发票关联
|
|
|
- ZcBillInvoiceRel zcBillInvoiceRel = new ZcBillInvoiceRel();
|
|
|
- zcBillInvoiceRel.setZbirBillId(zbiId);
|
|
|
- zcBillInvoiceRel.setZbirInvoiceId(id);
|
|
|
- iZcBillInvoiceRelService.createZcBillInvoiceRel(zcBillInvoiceRel);
|
|
|
Map map = new HashMap();
|
|
|
+ map.put("id",fileResult.getData().getPfiFileId());
|
|
|
map.put("name",fileResult.getData().getPfiFileName());
|
|
|
map.put("url",fileResult.getData().getPfiUrl());
|
|
|
//将发票对象转换成Map集合重新组合
|
|
@@ -427,32 +712,22 @@ public class OwnBillController extends BaseController {
|
|
|
//批量验真
|
|
|
for (int i = 0; i < jsonArray.size(); i++){
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
- ZcInvoiceInf zcInvoiceInf = iZcInvoiceInfService.getById(jsonObject.getString("ziiId"));
|
|
|
-
|
|
|
+ Map<String, String> params = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, String>>(){});
|
|
|
LambdaQueryWrapper<ZcInvoiceInf> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- //时间格式化
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
//发票代码
|
|
|
String ziiNo = jsonObject.getString("ziiNo");
|
|
|
//发票号码
|
|
|
String ziiNumber = jsonObject.getString("ziiNumber");
|
|
|
- //发票日期
|
|
|
- String ziiDate = jsonObject.getString("ziiDate");
|
|
|
- //购方纳税人识别号
|
|
|
- String ziiPurchaserNo = jsonObject.getString("ziiPurchaserNo");
|
|
|
- //销方纳税人识别号
|
|
|
- String ziiSellerNo = jsonObject.getString("ziiSellerNo");
|
|
|
- //发票金额
|
|
|
- String ziiAmount = jsonObject.getString("ziiAmount");
|
|
|
- //价税合计
|
|
|
- String ziiTotalAmount = jsonObject.getString("ziiTotalAmount");
|
|
|
//校验状态
|
|
|
String ziiCheckStt = jsonObject.getString("ziiCheckStt");
|
|
|
+ //发票id
|
|
|
+ String ziiId = jsonObject.getString("ziiId");
|
|
|
+ if(!CommonUtil.isEmpty(ziiId)){
|
|
|
+ queryWrapper.ne(ZcInvoiceInf::getZiiId,ziiId);
|
|
|
+ }
|
|
|
queryWrapper.eq(ZcInvoiceInf::getZiiNo,ziiNo);
|
|
|
//发票号码
|
|
|
queryWrapper.eq(ZcInvoiceInf::getZiiNumber,ziiNumber);
|
|
|
- //发票主键
|
|
|
- queryWrapper.ne(ZcInvoiceInf::getZiiId,jsonObject.getString("ziiId"));
|
|
|
//发票状态
|
|
|
queryWrapper.eq(ZcInvoiceInf::getZiiStatus,"00");
|
|
|
List<ZcInvoiceInf> list = iZcInvoiceInfService.findZcInvoiceInfs(queryWrapper);
|
|
@@ -460,36 +735,19 @@ public class OwnBillController extends BaseController {
|
|
|
if(list.size() == 0){
|
|
|
if(i != 0 && i != (jsonArray.size() - 1) && i != checkNum){
|
|
|
//没有验真的默认成功
|
|
|
- zcInvoiceInf.setZiiCheckStt("1");
|
|
|
+ params.put("ziiCheckStt","1");
|
|
|
}else{
|
|
|
//验真发票
|
|
|
- zcInvoiceInf = iOwnBillService.invoiceVerification(zcInvoiceInf);
|
|
|
+// params = iOwnBillService.invoiceVerification(params);
|
|
|
}
|
|
|
}else{
|
|
|
if(!CHECK_SUCCESS.equals(ziiCheckStt)){
|
|
|
- zcInvoiceInf.setZiiCheckStt("3");
|
|
|
+ params.put("ziiCheckStt","3");
|
|
|
}
|
|
|
}
|
|
|
- zcInvoiceInf.setZiiNo(ziiNo);
|
|
|
- zcInvoiceInf.setZiiNumber(ziiNumber);
|
|
|
- zcInvoiceInf.setZiiDate(sdf.parse(ziiDate));
|
|
|
- zcInvoiceInf.setZiiPurchaserNo(ziiPurchaserNo);
|
|
|
- zcInvoiceInf.setZiiSellerNo(ziiSellerNo);
|
|
|
- zcInvoiceInf.setZiiAmount(ziiAmount);
|
|
|
- zcInvoiceInf.setZiiExcludedAmount(ziiAmount);
|
|
|
- zcInvoiceInf.setZiiTotalAmount(ziiTotalAmount);
|
|
|
- zcInvoiceInf.setUpdateBy(user.getUserid().toString());
|
|
|
- zcInvoiceInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
- //修改发票信息
|
|
|
- iZcInvoiceInfService.updateZcInvoiceInf(zcInvoiceInf);
|
|
|
- Map map = new HashMap();
|
|
|
//将发票对象转换成Map集合重新组合
|
|
|
- if (zcInvoiceInf != null) {
|
|
|
- BeanMap beanMap = BeanMap.create(zcInvoiceInf);
|
|
|
- for (Object key : beanMap.keySet()) {
|
|
|
- map.put(key+"", beanMap.get(key));
|
|
|
- }
|
|
|
- if("3".equals(map.get("ziiCheckStt"))){
|
|
|
+ if (params != null) {
|
|
|
+ if("3".equals(params.get("ziiCheckStt"))){
|
|
|
//如果是重复状态查询关联往来账款
|
|
|
LambdaQueryWrapper<ZcBillInvoiceRel> relQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
//发票代码
|
|
@@ -497,12 +755,12 @@ public class OwnBillController extends BaseController {
|
|
|
List<ZcBillInvoiceRel> relList = iZcBillInvoiceRelService.findZcBillInvoiceRels(relQueryWrapper);
|
|
|
//查询往来账款名称返回前台展示
|
|
|
ZcBillInf zcBillInf = iZcBillInfService.getById(relList.get(0).getZbirBillId());
|
|
|
- map.put("zbiName",zcBillInf.getZbiName());
|
|
|
+ params.put("zbiName",zcBillInf.getZbiName());
|
|
|
}else {
|
|
|
- map.put("zbiName",null);
|
|
|
+ params.put("zbiName",null);
|
|
|
}
|
|
|
}
|
|
|
- zcInvoiceInfs.add(map);
|
|
|
+ zcInvoiceInfs.add(params);
|
|
|
}
|
|
|
return zcInvoiceInfs;
|
|
|
}
|
|
@@ -549,9 +807,6 @@ public class OwnBillController extends BaseController {
|
|
|
@Log(title = "上传往来账款附件", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/uploadBillFile")
|
|
|
public R uploadBillFile(@RequestParam("file")MultipartFile file, @RequestParam("zbiId") String zbiId, @RequestParam("type") String type) {
|
|
|
- if(CommonUtil.isEmpty(zbiId)){
|
|
|
- R.fail(500,"未获取到要上传发票的账款");
|
|
|
- }
|
|
|
//获取登录用户
|
|
|
LoginUser user = tokenService.getLoginUser();
|
|
|
String companyId = user.getSysUser().getCompanyId();
|
|
@@ -559,12 +814,6 @@ public class OwnBillController extends BaseController {
|
|
|
String token = SecurityUtils.getToken(ServletUtils.getRequest());
|
|
|
//文件传输
|
|
|
R<PubFileInf> fileResult = remoteFileService.uploadFile(file,"01","04","00", companyId, token);
|
|
|
- //创建账款附件关联
|
|
|
- ZcBillFileRel zcBillFileRel = new ZcBillFileRel();
|
|
|
- zcBillFileRel.setZbfrBillId(zbiId);
|
|
|
- zcBillFileRel.setZbfrFileId(fileResult.getData().getPfiFileId());
|
|
|
- zcBillFileRel.setZbfrType(type);
|
|
|
- iZcBillFileRelService.createZcBillFileRel(zcBillFileRel);
|
|
|
Map map = new HashMap();
|
|
|
map.put("id",fileResult.getData().getPfiFileId());
|
|
|
map.put("name",fileResult.getData().getPfiFileName());
|
|
@@ -622,11 +871,28 @@ public class OwnBillController extends BaseController {
|
|
|
//获取上传文件token
|
|
|
String token = SecurityUtils.getToken(ServletUtils.getRequest());
|
|
|
for (String id : ids) {
|
|
|
- LambdaQueryWrapper<ZcBillFileRel> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- //附件id
|
|
|
- queryWrapper.eq(ZcBillFileRel::getZbfrFileId, id);
|
|
|
- //删除附件关联
|
|
|
- iZcBillFileRelService.deleteZcBillFileRel(queryWrapper);
|
|
|
+ //查询关联往来账款的发票
|
|
|
+ LambdaQueryWrapper<ZcInvoiceInf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //往来账款id
|
|
|
+ lambdaQueryWrapper.eq(ZcInvoiceInf::getZiiFile,id);
|
|
|
+ lambdaQueryWrapper.eq(ZcInvoiceInf::getZiiStatus,"00");
|
|
|
+ List<ZcInvoiceInf> list = iZcInvoiceInfService.findZcInvoiceInfs(lambdaQueryWrapper);
|
|
|
+ for (ZcInvoiceInf zcInvoiceInf : list) {
|
|
|
+ //修改发票信息为删除状态
|
|
|
+ zcInvoiceInf.setZiiStatus("99");
|
|
|
+ iZcInvoiceInfService.updateZcInvoiceInf(zcInvoiceInf);
|
|
|
+ //查询关联往来账款的附件
|
|
|
+ LambdaQueryWrapper<ZcBillInvoiceRel> lambdaQueryWrapperRel = new LambdaQueryWrapper<>();
|
|
|
+ //往来账款id
|
|
|
+ lambdaQueryWrapperRel.eq(ZcBillInvoiceRel::getZbirInvoiceId,zcInvoiceInf.getZiiId());
|
|
|
+ //删除账款发票关联表
|
|
|
+ iZcBillInvoiceRelService.deleteZcBillInvoiceRel(lambdaQueryWrapperRel);
|
|
|
+ }
|
|
|
+ //查询关联往来账款的附件
|
|
|
+ LambdaQueryWrapper<ZcBillFileRel> lambdaQueryWrapperRel = new LambdaQueryWrapper<>();
|
|
|
+ //往来账款id
|
|
|
+ lambdaQueryWrapperRel.eq(ZcBillFileRel::getZbfrFileId,id);
|
|
|
+ iZcBillFileRelService.deleteZcBillFileRel(lambdaQueryWrapperRel);
|
|
|
//删除附件
|
|
|
remoteFileService.delete(id, companyId, token);
|
|
|
}
|
|
@@ -634,29 +900,6 @@ public class OwnBillController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 提交账款信息
|
|
|
- *
|
|
|
- * @param zbiId 账款id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @PostMapping("/commitBill/{zbiId}")
|
|
|
- @Log(title = "提交往来账款信息", businessType = BusinessType.UPDATE)
|
|
|
- public R commitBill(@PathVariable("zbiId") String zbiId) throws ParseException {
|
|
|
- //获取登录用户
|
|
|
- LoginUser user = tokenService.getLoginUser();
|
|
|
- ZcBillInf zcBillInf = new ZcBillInf();
|
|
|
- zcBillInf.setZbiId(zbiId);
|
|
|
- //创建人
|
|
|
- zcBillInf.setUpdateBy(user.getUserid().toString());
|
|
|
- //创建时间
|
|
|
- zcBillInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
- //修改为正常状态
|
|
|
- zcBillInf.setZbiStatus("00");
|
|
|
- iZcBillInfService.updateZcBillInf(zcBillInf);
|
|
|
- return R.ok();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 删除往来账款信息
|
|
|
*
|
|
|
* @param zbiIds 往来账款id集合
|