|
@@ -1,5 +1,6 @@
|
|
|
package org.jeecg.modules.oa.service.impl;
|
|
|
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
@@ -7,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.oa.entity.IncidentTicket;
|
|
|
import org.jeecg.modules.oa.entity.IncidentTicketChildren;
|
|
|
import org.jeecg.modules.oa.entity.IncidentTicketMsg;
|
|
@@ -20,6 +22,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.Serializable;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -44,34 +47,294 @@ public class IncidentTicketServiceImpl extends ServiceImpl<IncidentTicketMapper,
|
|
|
private IIncidentTicketMsgService iIncidentTicketMsgService;
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Result<?> propelling(IncidentTicket incidentTicket){
|
|
|
+ /**
|
|
|
+ * 获取流水号最大值去除单号中的前缀0
|
|
|
+ * @param testStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String maxNumber(String testStr){
|
|
|
+ String[] strs = testStr.split("[^0-9]");//根据不是数字的字符拆分字符串
|
|
|
+ String numStr = strs[strs.length - 1];//取出最后一组数字
|
|
|
+ if (numStr != null && numStr.length() > 0) {//如果最后一组没有数字(也就是不以数字结尾),抛NumberFormatException异常
|
|
|
+ int i = Integer.valueOf(testStr);
|
|
|
+ return String.valueOf(i);
|
|
|
+ }else {
|
|
|
+ throw new NumberFormatException();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(!incidentTicket.getState().equals("3")){//1未处理 2已通知 3通知已反馈 4已推送 5已完结
|
|
|
- return Result.error("此单据状态下无法推送");
|
|
|
+ public static String addOne(String testStr) {
|
|
|
+ String[] strs = testStr.split("[^0-9]");//根据不是数字的字符拆分字符串
|
|
|
+ String numStr = strs[strs.length - 1];//取出最后一组数字
|
|
|
+ if (numStr != null && numStr.length() > 0) {//如果最后一组没有数字(也就是不以数字结尾),抛NumberFormatException异常
|
|
|
+ int n = numStr.length();//取出字符串的长度
|
|
|
+ BigDecimal num=new BigDecimal(numStr).add(new BigDecimal(1));//将该数字加一
|
|
|
+ String added = String.valueOf(num);
|
|
|
+ n = Math.min(n, added.length());
|
|
|
+ //拼接字符串
|
|
|
+ return testStr.subSequence(0, testStr.length() - n) + added;
|
|
|
+ } else {
|
|
|
+ throw new NumberFormatException();
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String cCode=addOne("123");
|
|
|
+ System.out.println(cCode);
|
|
|
+ }
|
|
|
|
|
|
+ @DS("master3")
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Map<String,Object> propellingThree(IncidentTicket incidentTicket,IncidentTicketChildren children) {
|
|
|
+ Map<String,Object> resMap = new HashMap<>();
|
|
|
+ resMap.put("res","false");
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String businessType = incidentTicket.getBusinessType();//业务类型
|
|
|
+ String moneyType = incidentTicket.getMoneyType();//币种
|
|
|
+ String accidentData = incidentTicket.getAccidentData();//日期
|
|
|
+ String factory = incidentTicket.getFactory();//工厂
|
|
|
+ String responsibilityCompany = incidentTicket.getResponsibilityCompany();//责任单位
|
|
|
+
|
|
|
+ String exchangeRate = children.getExchangeRate();//子表汇率
|
|
|
+ String planNumber = children.getPlanNumber();//计划单号
|
|
|
+ String practicalSum = children.getPracticalSum();//实际事故金额
|
|
|
+ String zhanghaoId = children.getZhanghaoId();//账套
|
|
|
+
|
|
|
+ Map<String,Object> factoryMap = incidentTicketMapper.getVendor(factory);
|
|
|
+ Map<String,Object> responsibilityCompanyMap = incidentTicketMapper.getVendor(responsibilityCompany);
|
|
|
+
|
|
|
+ if(factoryMap == null){
|
|
|
+ resMap.put("msg",zhanghaoId+"账套不存在工厂 "+factory);
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
+ if(responsibilityCompanyMap == null){
|
|
|
+ resMap.put("msg",zhanghaoId+"账套不存在责任单位 "+responsibilityCompany);
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
//推送正文
|
|
|
+ /**
|
|
|
+ * 主表
|
|
|
+ */
|
|
|
+ map.put("cPBVBillType","03");//发票类型 03
|
|
|
+ String cCode = "test";
|
|
|
+// String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cpbvcode"));
|
|
|
+// incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
|
|
|
+
|
|
|
+ map.put("cPBVCode",cCode);//采购发票号 生成
|
|
|
+ if(StringUtils.isNotBlank(businessType) && businessType.equals("委外加工")){
|
|
|
+ map.put("cPTCode","02");//采购类型编码 01普通采购 02委外加工
|
|
|
+ }else{
|
|
|
+ map.put("cPTCode","01");//采购类型编码 01普通采购 02委外加工
|
|
|
+ }
|
|
|
+ map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));//开票日期 当前日期
|
|
|
+ String cVenCode = factoryMap.get("cVenCode").toString();
|
|
|
+ map.put("cVenCode", cVenCode);//供应商编码 对接质量事故单责任单位(U8显示简称即可)
|
|
|
+ String cUnitCode = responsibilityCompanyMap.get("cVenCode").toString();
|
|
|
+ map.put("cUnitCode", cUnitCode);//代垫单位编码 供应商
|
|
|
+ map.put("cexch_name", moneyType);//人民币、美元
|
|
|
+// map.put("cExchRate", exchangeRate);//汇率 子表汇率
|
|
|
+ map.put("cExchRate", 12);//汇率 子表汇率
|
|
|
+ map.put("iPBVTaxRate", 0.0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
|
|
|
+ if(StringUtils.isNotBlank(businessType)){
|
|
|
+ map.put("cBusType", businessType);//业务类型 普通采购/委外加工
|
|
|
+ }else{
|
|
|
+ map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
|
|
|
+ }
|
|
|
|
|
|
- String businessType = incidentTicket.getBusinessType();//业务类型
|
|
|
- List<IncidentTicketChildren> childrenList = incidentTicketChildrenMapper.selectByMainId(incidentTicket.getId());
|
|
|
+ map.put("cPBVMaker", sysUser.getRealname());//创建人 推送人姓名
|
|
|
+ map.put("bNegative", 0);//负发票标志 0
|
|
|
+ map.put("bOriginal", 0);//采购期初标志 0
|
|
|
+ map.put("bFirst", 0);//应付期初标志 0
|
|
|
+ map.put("iNetLock", 0);//现无用 0
|
|
|
+ map.put("cDefine2", planNumber);//计划单号 计划单号
|
|
|
+ map.put("dVouDate", accidentData);//单据日期 日期
|
|
|
+ map.put("iVTid", 8167);//单据模版号 8167
|
|
|
+// map.put("ufts", DateUtils.getTimestamp());//时间戳
|
|
|
+// map.put("cSource", businessType);//单据来源 采购、委外
|
|
|
+ map.put("cSource", "采购");//单据来源 采购、委外
|
|
|
+ map.put("cDefine12", factory);//江苏康弘纺织品有限公司
|
|
|
+ map.put("cDefine13", responsibilityCompany);//江苏康弘纺织品有限公司
|
|
|
+ map.put("iDiscountTaxType",0);//扣税类别(0应税外加,1应税内含) 0
|
|
|
+ map.put("bCredit",0);//是否为立账依据0
|
|
|
+ String cVenAccount = "";
|
|
|
+ String cVenBank = "";
|
|
|
+ if(factoryMap.get("cVenAccount") != null){
|
|
|
+ cVenAccount = factoryMap.get("cVenAccount").toString();
|
|
|
+ }
|
|
|
+ if(factoryMap.get("cVenBank") != null){
|
|
|
+ cVenBank = factoryMap.get("cVenBank").toString();
|
|
|
+ }
|
|
|
+ map.put("cVenAccount",cVenAccount);//供方银行账号
|
|
|
+ map.put("cVenBank",cVenBank);//供方银行名称
|
|
|
+ map.put("iPrintCount",0);//打印次数 0
|
|
|
+ String cVenContactCode = "";
|
|
|
+ String cVenPerson = "";
|
|
|
+ if(factoryMap.get("cVenContactCode") != null){
|
|
|
+ cVenContactCode = factoryMap.get("cVenContactCode").toString();
|
|
|
+ }
|
|
|
+ if(factoryMap.get("cVenPerson") != null){
|
|
|
+ cVenPerson = factoryMap.get("cVenPerson").toString();
|
|
|
+ }
|
|
|
+ map.put("cContactCode",cVenContactCode);//供方联系人编码
|
|
|
+ map.put("cVenPerson",cVenPerson);//供方联系人
|
|
|
+ map.put("IsWfControlled",0);//是否工作流控制 0
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("||puzl|");
|
|
|
+ sb.append(cCode);
|
|
|
+ map.put("csysbarcode",sb.toString());//单据条码 ||puzl|0000001185
|
|
|
+ map.put("cmaketime",DateUtils.now());//制单时间
|
|
|
|
|
|
- for (IncidentTicketChildren children:childrenList){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 子表
|
|
|
+ */
|
|
|
+ Map<String,Object> map2 = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
+ map2.put("cInvCode","N3000002424");//存货编码
|
|
|
+ map2.put("bExBill",1);//是否为费用 1
|
|
|
+// map2.put("iPBVQuantity","1");//数量
|
|
|
+ //税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
|
|
|
+ if(StringUtils.isNotBlank(practicalSum)){
|
|
|
|
|
|
+ }else{
|
|
|
+ map2.put("iOriMoney",0);//原币金额 -- 原币无税金额=原币金额/(1+税率)
|
|
|
}
|
|
|
|
|
|
+ map2.put("iOriSum",practicalSum);//原币价税合计 --实际事故金额
|
|
|
+ map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
|
|
|
+ map2.put("iMoney",practicalSum);//本币金额 (本币无税金额) 本币金额/(1+税率)
|
|
|
+ map2.put("iSum",practicalSum);//本币价税合计 原币金额*汇率
|
|
|
+ map2.put("iTaxPrice",practicalSum);//本币税额 本币金额-本币无税金额
|
|
|
+ map2.put("iTaxRate",0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
|
|
|
+ map2.put("ivouchrowno",1);//行号
|
|
|
+ map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
|
|
|
+ map2.put("bgift",0);//是否赠品 0
|
|
|
+
|
|
|
+// int chId = incidentTicketMapper.getMaxCode2();
|
|
|
+// map.put("pbvid",chId+1);//主表主键
|
|
|
+// incidentTicketMapper.insertPurBillVouch(map);
|
|
|
+//
|
|
|
+// int chIds = incidentTicketMapper.getMaxCode3();
|
|
|
+// map2.put("pbvid",chId+1);//主表主键
|
|
|
+// map2.put("id",chIds+1);//主键
|
|
|
+// incidentTicketMapper.insertPurBillVouchs(map2);
|
|
|
+
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS("master3")
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Result<?> propelling(IncidentTicket incidentTicket){
|
|
|
|
|
|
+ if(!incidentTicket.getState().equals("3")){//1未处理 2已通知 3通知已反馈 4已推送 5已完结
|
|
|
+ return Result.error("此单据状态下无法推送");
|
|
|
+ }
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
|
|
|
|
+ String businessType = incidentTicket.getBusinessType();//业务类型
|
|
|
+ String moneyType = incidentTicket.getMoneyType();//币种
|
|
|
+ String accidentData = incidentTicket.getAccidentData();//日期
|
|
|
+ String factory = incidentTicket.getFactory();//工厂
|
|
|
+ String responsibilityCompany = incidentTicket.getResponsibilityCompany();//责任单位
|
|
|
+ List<IncidentTicketChildren> childrenList = incidentTicketChildrenMapper.selectByMainId(incidentTicket.getId());
|
|
|
|
|
|
+ for (IncidentTicketChildren children:childrenList){
|
|
|
|
|
|
+ String exchangeRate = children.getExchangeRate();//子表汇率
|
|
|
+ String planNumber = children.getPlanNumber();//计划单号
|
|
|
+ String practicalSum = children.getPracticalSum();//实际事故金额
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ //推送正文
|
|
|
+ /**
|
|
|
+ * 主表
|
|
|
+ */
|
|
|
+ map.put("cPBVBillType","03");//发票类型 03
|
|
|
+
|
|
|
+ String cCode=this.addOne(incidentTicketMapper.getMaxCode("cPBVCode","PurBillVouch","cmaketime"));
|
|
|
+ incidentTicketMapper.updateVoucherHistoryCNumber(this.maxNumber(cCode),"2502");
|
|
|
+
|
|
|
+ map.put("PBVID","2"+cCode);//采购发票主表标识
|
|
|
+ map.put("cPBVCode",cCode);//采购发票号 生成
|
|
|
+ if(businessType.equals("普通采购")){
|
|
|
+ map.put("cPTCode","01");//采购类型编码 01普通采购 02委外加工
|
|
|
+ }else{
|
|
|
+ map.put("cPTCode","02");//采购类型编码 01普通采购 02委外加工
|
|
|
+ }
|
|
|
+ map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));//开票日期 当前日期
|
|
|
+ map.put("cVenCode", "0001");//供应商编码 对接质量事故单责任单位(U8显示简称即可)
|
|
|
+ map.put("cUnitCode", "0001");//代垫单位编码 供应商
|
|
|
+ map.put("cexch_name", moneyType);//人民币、美元
|
|
|
+// map.put("cExchRate", exchangeRate);//汇率 子表汇率
|
|
|
+ map.put("cExchRate", 12.0);//汇率 子表汇率
|
|
|
+ map.put("iPBVTaxRate", 0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
|
|
|
+ if(StringUtils.isNotBlank(businessType)){
|
|
|
+ map.put("cBusType", businessType);//业务类型 普通采购/委外加工
|
|
|
+ }else{
|
|
|
+ map.put("cBusType", "普通采购");//业务类型 普通采购/委外加工
|
|
|
+ }
|
|
|
|
|
|
+ map.put("cPBVMaker", sysUser.getRealname());//创建人 推送人姓名
|
|
|
+ map.put("bNegative", 0);//负发票标志 0
|
|
|
+ map.put("bOriginal", 0);//采购期初标志 0
|
|
|
+ map.put("bFirst", 0);//应付期初标志 0
|
|
|
+ map.put("iNetLock", 0);//现无用 0
|
|
|
+ map.put("cDefine2", planNumber);//计划单号 计划单号
|
|
|
+ map.put("dVouDate", accidentData);//单据日期 日期
|
|
|
+ map.put("iVTid", "8167");//单据模版号 8167
|
|
|
+// map.put("ufts", DateUtils.getTimestamp());//时间戳
|
|
|
+ map.put("cSource", businessType);//单据来源 采购、委外
|
|
|
+ map.put("cDefine12", factory);//江苏康弘纺织品有限公司
|
|
|
+ map.put("cDefine13", responsibilityCompany);//江苏康弘纺织品有限公司
|
|
|
+ map.put("iDiscountTaxType",0);//扣税类别(0应税外加,1应税内含) 0
|
|
|
+ map.put("bCredit",0);//是否为立账依据0
|
|
|
+ map.put("cVenAccount","1112333333333");//供方银行账号
|
|
|
+ map.put("cVenBank","中国银行");//供方银行名称
|
|
|
+ map.put("iPrintCount",0);//打印次数 0
|
|
|
+ map.put("cContactCode","0001");//供方联系人编码
|
|
|
+ map.put("cVenPerson","同步");//供方联系人
|
|
|
+ map.put("IsWfControlled",0);//是否工作流控制 0
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("||puzl|");
|
|
|
+ sb.append(cCode);
|
|
|
+ map.put("csysbarcode",sb.toString());//单据条码 ||puzl|0000001185
|
|
|
+ map.put("cmaketime",DateUtils.now());//制单时间
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 子表
|
|
|
+ */
|
|
|
+ Map<String,Object> map2 = new HashMap<>();
|
|
|
+
|
|
|
+ map2.put("pbvid",map.get("PBVID"));//主表主键
|
|
|
+ map2.put("cInvCode","N3000002424");//存货编码
|
|
|
+ map2.put("bExBill",1);//是否为费用 1
|
|
|
+// map2.put("iPBVQuantity","1");//数量
|
|
|
+ //税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
|
|
|
+ map2.put("iOriMoney",practicalSum);//原币金额 -- 原币无税金额=原币金额/(1+税率)
|
|
|
+ map2.put("iOriSum",practicalSum);//原币价税合计 --实际事故金额
|
|
|
+ map2.put("iOriTaxPrice",0);//原币税额 原币金额-原币无税金额
|
|
|
+ map2.put("iMoney",practicalSum);//本币金额 (本币无税金额) 本币金额/(1+税率)
|
|
|
+ map2.put("iSum",practicalSum);//本币价税合计 原币金额*汇率
|
|
|
+ map2.put("iTaxPrice",practicalSum);//本币税额 本币金额-本币无税金额
|
|
|
+ map2.put("iTaxRate",0);//税率(101默认为0,102/103默认为13,可取U8该字段设置的默认值)
|
|
|
+ map2.put("ivouchrowno",1);//行号
|
|
|
+ map2.put("cbsysbarcode",sb.toString()+"|1");//行条码 ||puzl|0000001185|1
|
|
|
+ map2.put("bgift",0);//是否赠品 0
|
|
|
+
|
|
|
+ incidentTicketMapper.insertPurBillVouch(map);
|
|
|
+ incidentTicketMapper.insertPurBillVouchs(map2);
|
|
|
+
|
|
|
+ children.setU8Invoice(cCode);
|
|
|
+ incidentTicketChildrenMapper.updateById(children);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
incidentTicket.setState("4");
|