You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
4.5 KiB
129 lines
4.5 KiB
2 years ago
|
package com.dxhy.erp.controller;
|
||
|
|
||
|
import com.dxhy.common.aspect.SysLog;
|
||
|
import com.dxhy.common.constant.CommonConstants;
|
||
|
import com.dxhy.common.controller.AbstractController;
|
||
|
import com.dxhy.common.enums.FplxEnum;
|
||
|
import com.dxhy.common.util.InvoiceUtil;
|
||
|
import com.dxhy.common.util.UserInfoUtil;
|
||
|
import com.dxhy.common.utils.R;
|
||
|
import com.dxhy.erp.service.InvoiceQueryService;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
import org.apache.commons.lang3.StringUtils;
|
||
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
import org.springframework.http.ResponseEntity;
|
||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
||
|
import javax.annotation.Resource;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/**
|
||
|
* 山东能源查验主流程控制器
|
||
|
*
|
||
|
* @author ariesy
|
||
|
* @date 2023-03-15
|
||
|
*/
|
||
|
@SuppressWarnings({"AlibabaUndefineMagicConstant", "AlibabaMethodTooLong"})
|
||
|
@RestController
|
||
|
@Slf4j
|
||
|
public class SDNYMainProcessController extends AbstractController {
|
||
|
@Resource
|
||
|
private InvoiceQueryService invoiceQueryService;
|
||
|
|
||
|
@Value("${ftp.connection.size}")
|
||
|
private String size;
|
||
|
/**
|
||
|
* 上传时本地文件暂存路径
|
||
|
*/
|
||
|
@Value("${ftp.connection.tempPath}")
|
||
|
private String tempPath;
|
||
|
/**
|
||
|
* 上传时本地文件存放路径
|
||
|
*/
|
||
|
@Value("${ftp.connection.depositPath}")
|
||
|
private String depositPath;
|
||
|
|
||
|
/**
|
||
|
* 查验发票
|
||
|
*/
|
||
|
@PostMapping("/sn/singleInvoiceCheck")
|
||
|
@ResponseBody
|
||
|
@SysLog("发票查验")
|
||
|
public ResponseEntity<?> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) {
|
||
|
// 入参统一在入口处理
|
||
|
String userid = getLoginName();
|
||
|
pramsMap.put("userid", userid);
|
||
|
String dbName = getUserInfo().getDbName();
|
||
|
pramsMap.put("dbName", dbName);
|
||
|
pramsMap.put("saveHistory","Y");
|
||
|
|
||
|
pramsMap.put("company", getUserInfo().getCompany());
|
||
|
|
||
|
List<String> gfshAll = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
|
||
|
if (gfshAll.size() > 0) {
|
||
|
pramsMap.put("taxNo", gfshAll.get(0));
|
||
|
|
||
|
}
|
||
|
pramsMap.put("purchaserTaxNo", pramsMap.get("purchaserTaxNo"));
|
||
|
|
||
|
|
||
|
InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode"));
|
||
|
|
||
|
if (pramsMap.get("invoiceCode").isEmpty()) {
|
||
|
|
||
|
return ResponseEntity.ok(R.error("发票代码不能为空!"));
|
||
|
}
|
||
|
pramsMap.put("invoiceType", iu.getFplxdm());
|
||
|
|
||
|
|
||
|
if (pramsMap.get("invoiceNumber").isEmpty()) {
|
||
|
return ResponseEntity.ok(R.error("发票号码不能为空!"));
|
||
|
}
|
||
|
pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber"));
|
||
|
|
||
|
if (!pramsMap.get("billingDate").isEmpty()) {
|
||
|
iu.setKprq(pramsMap.get("billingDate"));
|
||
|
pramsMap.put("invoiceDate", pramsMap.get("invoiceNumber"));
|
||
|
if (!iu.kprqValid(null)) {
|
||
|
pramsMap.put("invoiceDate", "开票日期格式错误!");
|
||
|
}
|
||
|
} else {
|
||
|
return ResponseEntity.ok(R.error("开票日期不能为空!"));
|
||
|
}
|
||
|
|
||
|
if (FplxEnum.ZP.getFplxDm().equals(pramsMap.get("invoiceType"))
|
||
|
|| FplxEnum.JDC.getFplxDm().equals(pramsMap.get("invoiceType"))
|
||
|
|| FplxEnum.DZZP.getFplxDm().equals(pramsMap.get("invoiceType"))
|
||
|
|| FplxEnum.ESC.getFplxDm().equals(pramsMap.get("invoiceType"))
|
||
|
|| FplxEnum.QDZZP.getFplxDm().equals(pramsMap.get("invoiceType"))
|
||
|
|| FplxEnum.QDPP.getFplxDm().equals(pramsMap.get("invoiceType"))) {
|
||
|
if (pramsMap.get("totalAmount").isEmpty()) {
|
||
|
return ResponseEntity.ok(R.error("金额不能为空!"));
|
||
|
}
|
||
|
} else {
|
||
|
if (pramsMap.get("checkCode").isEmpty()) {
|
||
|
return ResponseEntity.ok(R.error("校验码不能为空!"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode"))?"":pramsMap.get("invoiceCode"))+ pramsMap.get("invoiceNo");
|
||
|
String notes = invoiceQueryService.checkingInvoiceInfo(dbName, uuid, getUserInfo());
|
||
|
if (notes != null) {
|
||
|
return ResponseEntity.ok(R.error(notes));
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
return ResponseEntity.ok(R.ok().put("data", invoiceQueryService.smQueryInvoice(pramsMap)));
|
||
|
} catch (Exception e) {
|
||
|
e.printStackTrace();
|
||
|
log.error("", e);
|
||
|
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|