|
|
@@ -1730,6 +1730,8 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
public String auditSaveBranch(WorkInvoice workInvoice,List<User> auditUsers) {
|
|
|
+ //用于判定是否是生产环境,是否开启oms开具发票功能
|
|
|
+ boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
|
|
|
//所属部门
|
|
|
Office office = officeService.get(workInvoice.getOffice().getId());
|
|
|
String userName = UserUtils.get(workInvoice.getCreateBy().getId()).getName();
|
|
|
@@ -1857,8 +1859,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
notifyRole = "审批通过";
|
|
|
workActivityProcess.setIsApproval("1");
|
|
|
|
|
|
- //用于判定是否是生产环境,是否开启oms开具发票功能
|
|
|
- boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
|
|
|
if(OMS_ENABLED){
|
|
|
//需要判定,此处 如果开票金额为正数,则表示是开蓝票,如果是负数,则表示是开红票
|
|
|
if(workInvoice.getMoney()>0){
|
|
|
@@ -1867,12 +1867,26 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
}else{
|
|
|
//先获取对应红冲发票的数电票 票号
|
|
|
//查询关联红冲发票的开票号
|
|
|
- if(1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
|
|
|
- String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
|
|
|
- workInvoice.setInvoiceNumberStr(invoiceNumberStr);
|
|
|
+ if(1 == workInvoice.getRedInvoiceFlag()){
|
|
|
+ if(StringUtils.isBlank(workInvoice.getInvoiceNumberStr())){
|
|
|
+ if(StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
|
|
|
+ String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
|
|
|
+ workInvoice.setInvoiceNumberStr(invoiceNumberStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String invoiceNumber = workInvoice.getInvoiceNumberStr();
|
|
|
+ //判断 如果发票小于10位,则表示为老发票红冲,需要按照老方法进行处理
|
|
|
+ if (invoiceNumber == null || invoiceNumber.isEmpty() || invoiceNumber.length() < 10) {
|
|
|
+ OMS_ENABLED = false;
|
|
|
+ }
|
|
|
+ if(OMS_ENABLED && StringUtils.isBlank(invoiceNumber)){
|
|
|
+ return "红冲发票号不存在,无法进行红冲!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(OMS_ENABLED){
|
|
|
+ //还需要获取被红冲发票的对应invoice信息
|
|
|
+ new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(), "21").start();
|
|
|
}
|
|
|
- //还需要获取被红冲发票的对应invoice信息
|
|
|
- new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(), "21").start();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1933,7 +1947,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
if (!state) {
|
|
|
|
|
|
//用于判定是否是生产环境,是否开启oms开具发票功能
|
|
|
- boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
|
|
|
if(OMS_ENABLED){
|
|
|
//将数据流程接点重新归属到审批状态不变,等发票开启之后 进行变更为审核通过,若失败,则变更为暂存状态并发送通知
|
|
|
users.add(workInvoice.getCreateBy());
|
|
|
@@ -2509,6 +2522,8 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
public String saveWorkInvoiceNotProjectAudit(WorkInvoice workInvoice,List<User> auditUsers) {
|
|
|
+ //用于判定是否是生产环境,是否开启oms开具发票功能
|
|
|
+ boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
|
|
|
//所属部门
|
|
|
Office office = officeService.get(workInvoice.getOffice().getId());
|
|
|
String userName = UserUtils.get(workInvoice.getCreateBy().getId()).getName();
|
|
|
@@ -2644,8 +2659,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
notifyRole = "审批通过";
|
|
|
workActivityProcess.setIsApproval("1");
|
|
|
|
|
|
- //用于判定是否是生产环境,是否开启oms开具发票功能
|
|
|
- boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
|
|
|
if(OMS_ENABLED){
|
|
|
//需要判定,此处 如果开票金额为正数,则表示是开蓝票,如果是负数,则表示是开红票
|
|
|
if(workInvoice.getMoney()>0){
|
|
|
@@ -2654,12 +2667,26 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
}else{
|
|
|
//先获取对应红冲发票的数电票 票号
|
|
|
//查询关联红冲发票的开票号
|
|
|
- if(1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
|
|
|
- String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
|
|
|
- workInvoice.setInvoiceNumberStr(invoiceNumberStr);
|
|
|
+ if(1 == workInvoice.getRedInvoiceFlag()){
|
|
|
+ if(StringUtils.isBlank(workInvoice.getInvoiceNumberStr())){
|
|
|
+ if(StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
|
|
|
+ String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
|
|
|
+ workInvoice.setInvoiceNumberStr(invoiceNumberStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String invoiceNumber = workInvoice.getInvoiceNumberStr();
|
|
|
+ //判断 如果发票小于10位,则表示为老发票红冲,需要按照老方法进行处理
|
|
|
+ if (invoiceNumber == null || invoiceNumber.isEmpty() || invoiceNumber.length() < 10) {
|
|
|
+ OMS_ENABLED = false;
|
|
|
+ }
|
|
|
+ if(OMS_ENABLED && StringUtils.isBlank(invoiceNumber)){
|
|
|
+ return "红冲发票号不存在,无法进行红冲!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(OMS_ENABLED){
|
|
|
+ //还需要获取被红冲发票的对应invoice信息
|
|
|
+ new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(),"213").start();
|
|
|
}
|
|
|
- //还需要获取被红冲发票的对应invoice信息
|
|
|
- new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(),"213").start();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2716,7 +2743,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
if (!state) {
|
|
|
|
|
|
//用于判定是否是生产环境,是否开启oms开具发票功能
|
|
|
- boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
|
|
|
if(OMS_ENABLED){
|
|
|
//将数据流程接点重新归属到审批状态不变,等发票开启之后 进行变更为审核通过,若失败,则变更为暂存状态并发送通知
|
|
|
users.add(workInvoice.getCreateBy());
|
|
|
@@ -4612,4 +4638,115 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
|
|
|
|
|
|
return isSuccess;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询同项目名称、价格、材料名称的数量是否只有一个
|
|
|
+ */
|
|
|
+ public Map<String, List<WorkInvoiceReceiptInfo>> distinctProjectMaterialStorage(
|
|
|
+ List<WorkInvoiceReceiptInfo> workInvoiceReceiptInfo) {
|
|
|
+
|
|
|
+ HashMap<String, List<WorkInvoiceReceiptInfo>> map = new HashMap<>();
|
|
|
+
|
|
|
+ // 第一步:对本次导入数据进行去重(自身重复)
|
|
|
+ Set<String> seen = new HashSet<>();
|
|
|
+ List<WorkInvoiceReceiptInfo> uniqueList = new ArrayList<>(); // 本次去重后的有效值
|
|
|
+ List<WorkInvoiceReceiptInfo> duplicateList = new ArrayList<>(); // 本次自身重复值
|
|
|
+
|
|
|
+ for (WorkInvoiceReceiptInfo item : workInvoiceReceiptInfo) {
|
|
|
+ String distinctStr = item.getDistinctStr();
|
|
|
+
|
|
|
+ // 处理null值(视为重复)
|
|
|
+ if (distinctStr == null) {
|
|
|
+ duplicateList.add(item);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!seen.contains(distinctStr)) {
|
|
|
+ seen.add(distinctStr);
|
|
|
+ uniqueList.add(item);
|
|
|
+ } else {
|
|
|
+ duplicateList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //对有效值进行发票查询操作,如果已经存在记录 则表示 给该数据存在问题(重复上传)
|
|
|
+ List<String> invoiceNumberList = Lists.newArrayList();
|
|
|
+ for (WorkInvoiceReceiptInfo invoiceReceiptInfo : uniqueList) {
|
|
|
+ invoiceNumberList.add(invoiceReceiptInfo.getInvoiceNumber());
|
|
|
+ }
|
|
|
+ //根据 invoiceNumberList 去进行查询已经存在的数据信息
|
|
|
+ List<WorkInvoiceReceipt> alreadyExistReceiptList = workInvoiceReceiptDao.getByInvoiceNumber(invoiceNumberList);
|
|
|
+
|
|
|
+ //遍历有效值和查出来的已经存在的收款信息进行对比,若存在同一发票号的信息,金额进行累加,若金额大于应收金额,则表示该条数据存在问题,所小于则表示部分收款,若等于 则表示完全收款,改成已收款
|
|
|
+ for (WorkInvoiceReceipt workInvoiceReceipt : alreadyExistReceiptList) {
|
|
|
+ for (WorkInvoiceReceiptInfo invoiceReceiptInfo : uniqueList) {
|
|
|
+ if(workInvoiceReceipt.getInvoiceNumber().equals(invoiceReceiptInfo.getInvoiceNumber())){
|
|
|
+
|
|
|
+ }
|
|
|
+ invoiceNumberList.add(invoiceReceiptInfo.getInvoiceNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 第二步:获取历史数据并处理其distinctStr
|
|
|
+ /*List<WorkInvoiceReceiptInfo> historyInfoList = dao.getByProjectId(projectId);
|
|
|
+ for (WorkInvoiceReceiptInfo info : historyInfoList) {
|
|
|
+ // 组合历史数据的distinctStr(材料名称+规格+含税价格)
|
|
|
+ // 处理可能的null值,转为空字符串
|
|
|
+ String invoiceName = (info.getInvoiceNumber() != null) ? info.getInvoiceNumber() : "";
|
|
|
+ String buyerName = (info.getBuyerName() != null) ? info.getBuyerName() : "";
|
|
|
+ String money = (info.getMoney() != null) ? info.getMoney().toString() : "";
|
|
|
+ // 以逗号分隔组合
|
|
|
+ String resultStr = invoiceName + "," + buyerName + "," + money;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第三步:筛选历史数据中的distinctStr,用于比对
|
|
|
+ Set<String> historyDistinctSet = new HashSet<>();
|
|
|
+ for (WorkInvoiceReceiptInfo historyItem : historyInfoList) {
|
|
|
+ String historyDistinctStr = historyItem.getDistinctStr();
|
|
|
+ if (historyDistinctStr != null) {
|
|
|
+ historyDistinctSet.add(historyDistinctStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第四步:从uniqueList中移除与历史数据重复的项,并加入重复列表
|
|
|
+ // 使用迭代器支持边遍历边删除
|
|
|
+ Iterator<WorkInvoiceReceiptInfo> iterator = uniqueList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ WorkInvoiceReceiptInfo currentItem = iterator.next();
|
|
|
+ String currentDistinctStr = currentItem.getDistinctStr();
|
|
|
+
|
|
|
+ // 处理null值(从uniqueList移除并加入重复列表)
|
|
|
+ if (currentDistinctStr == null) {
|
|
|
+ iterator.remove();
|
|
|
+ duplicateList.add(currentItem);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 与历史数据重复:从uniqueList移除并加入重复列表
|
|
|
+ if (historyDistinctSet.contains(currentDistinctStr)) {
|
|
|
+ iterator.remove();
|
|
|
+ duplicateList.add(currentItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. 提取duplicateList中所有数据的唯一标识(distinctStr)
|
|
|
+ Set<String> duplicateDistinctSet = new HashSet<>();
|
|
|
+ for (WorkInvoiceReceiptInfo item : duplicateList) {
|
|
|
+ String distinctStr = item.getDistinctStr();
|
|
|
+ if (distinctStr != null) {
|
|
|
+ duplicateDistinctSet.add(distinctStr);
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ // 最终返回处理后的列表
|
|
|
+ map.put("uniqueList", uniqueList); // 仅包含本次新增且不与历史重复的数据
|
|
|
+ map.put("duplicateList", duplicateList); // 包含自身重复和与历史重复的数据
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|