|
@@ -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) {
|
|
|
+ int i = Integer.valueOf(testStr);
|
|
|
+ return String.valueOf(i);
|
|
|
+ }else {
|
|
|
+ throw new NumberFormatException();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(!incidentTicket.getState().equals("3")){
|
|
|
- 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) {
|
|
|
+ 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");
|
|
|
+ String cCode = "test";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ map.put("cPBVCode",cCode);
|
|
|
+ if(StringUtils.isNotBlank(businessType) && businessType.equals("委外加工")){
|
|
|
+ map.put("cPTCode","02");
|
|
|
+ }else{
|
|
|
+ map.put("cPTCode","01");
|
|
|
+ }
|
|
|
+ map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));
|
|
|
+ String cVenCode = factoryMap.get("cVenCode").toString();
|
|
|
+ map.put("cVenCode", cVenCode);
|
|
|
+ String cUnitCode = responsibilityCompanyMap.get("cVenCode").toString();
|
|
|
+ map.put("cUnitCode", cUnitCode);
|
|
|
+ map.put("cexch_name", moneyType);
|
|
|
+
|
|
|
+ map.put("cExchRate", 12);
|
|
|
+ map.put("iPBVTaxRate", 0.0);
|
|
|
+ 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);
|
|
|
+ map.put("bOriginal", 0);
|
|
|
+ map.put("bFirst", 0);
|
|
|
+ map.put("iNetLock", 0);
|
|
|
+ map.put("cDefine2", planNumber);
|
|
|
+ map.put("dVouDate", accidentData);
|
|
|
+ map.put("iVTid", 8167);
|
|
|
+
|
|
|
+
|
|
|
+ map.put("cSource", "采购");
|
|
|
+ map.put("cDefine12", factory);
|
|
|
+ map.put("cDefine13", responsibilityCompany);
|
|
|
+ map.put("iDiscountTaxType",0);
|
|
|
+ map.put("bCredit",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);
|
|
|
+ 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);
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("||puzl|");
|
|
|
+ sb.append(cCode);
|
|
|
+ map.put("csysbarcode",sb.toString());
|
|
|
+ map.put("cmaketime",DateUtils.now());
|
|
|
|
|
|
- for (IncidentTicketChildren children:childrenList){
|
|
|
+
|
|
|
+
|
|
|
+ * 子表
|
|
|
+ */
|
|
|
+ Map<String,Object> map2 = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
+ map2.put("cInvCode","N3000002424");
|
|
|
+ map2.put("bExBill",1);
|
|
|
+
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(practicalSum)){
|
|
|
|
|
|
+ }else{
|
|
|
+ map2.put("iOriMoney",0);
|
|
|
}
|
|
|
|
|
|
+ map2.put("iOriSum",practicalSum);
|
|
|
+ map2.put("iOriTaxPrice",0);
|
|
|
+ map2.put("iMoney",practicalSum);
|
|
|
+ map2.put("iSum",practicalSum);
|
|
|
+ map2.put("iTaxPrice",practicalSum);
|
|
|
+ map2.put("iTaxRate",0);
|
|
|
+ map2.put("ivouchrowno",1);
|
|
|
+ map2.put("cbsysbarcode",sb.toString()+"|1");
|
|
|
+ map2.put("bgift",0);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS("master3")
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Result<?> propelling(IncidentTicket incidentTicket){
|
|
|
|
|
|
+ if(!incidentTicket.getState().equals("3")){
|
|
|
+ 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");
|
|
|
+
|
|
|
+ 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");
|
|
|
+ }else{
|
|
|
+ map.put("cPTCode","02");
|
|
|
+ }
|
|
|
+ map.put("dPBVDate", DateUtils.getDate("yyyy-MM-dd"));
|
|
|
+ map.put("cVenCode", "0001");
|
|
|
+ map.put("cUnitCode", "0001");
|
|
|
+ map.put("cexch_name", moneyType);
|
|
|
+
|
|
|
+ map.put("cExchRate", 12.0);
|
|
|
+ map.put("iPBVTaxRate", 0);
|
|
|
+ if(StringUtils.isNotBlank(businessType)){
|
|
|
+ map.put("cBusType", businessType);
|
|
|
+ }else{
|
|
|
+ map.put("cBusType", "普通采购");
|
|
|
+ }
|
|
|
|
|
|
+ map.put("cPBVMaker", sysUser.getRealname());
|
|
|
+ map.put("bNegative", 0);
|
|
|
+ map.put("bOriginal", 0);
|
|
|
+ map.put("bFirst", 0);
|
|
|
+ map.put("iNetLock", 0);
|
|
|
+ map.put("cDefine2", planNumber);
|
|
|
+ map.put("dVouDate", accidentData);
|
|
|
+ map.put("iVTid", "8167");
|
|
|
+
|
|
|
+ map.put("cSource", businessType);
|
|
|
+ map.put("cDefine12", factory);
|
|
|
+ map.put("cDefine13", responsibilityCompany);
|
|
|
+ map.put("iDiscountTaxType",0);
|
|
|
+ map.put("bCredit",0);
|
|
|
+ map.put("cVenAccount","1112333333333");
|
|
|
+ map.put("cVenBank","中国银行");
|
|
|
+ map.put("iPrintCount",0);
|
|
|
+ map.put("cContactCode","0001");
|
|
|
+ map.put("cVenPerson","同步");
|
|
|
+ map.put("IsWfControlled",0);
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append("||puzl|");
|
|
|
+ sb.append(cCode);
|
|
|
+ map.put("csysbarcode",sb.toString());
|
|
|
+ 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);
|
|
|
+
|
|
|
+
|
|
|
+ map2.put("iOriMoney",practicalSum);
|
|
|
+ map2.put("iOriSum",practicalSum);
|
|
|
+ map2.put("iOriTaxPrice",0);
|
|
|
+ map2.put("iMoney",practicalSum);
|
|
|
+ map2.put("iSum",practicalSum);
|
|
|
+ map2.put("iTaxPrice",practicalSum);
|
|
|
+ map2.put("iTaxRate",0);
|
|
|
+ map2.put("ivouchrowno",1);
|
|
|
+ map2.put("cbsysbarcode",sb.toString()+"|1");
|
|
|
+ map2.put("bgift",0);
|
|
|
+
|
|
|
+ incidentTicketMapper.insertPurBillVouch(map);
|
|
|
+ incidentTicketMapper.insertPurBillVouchs(map2);
|
|
|
+
|
|
|
+ children.setU8Invoice(cCode);
|
|
|
+ incidentTicketChildrenMapper.updateById(children);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
incidentTicket.setState("4");
|