|
|
@@ -3,20 +3,31 @@ package com.uas.eis.service.Impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.uas.eis.core.support.TokenProperties;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.dao.SqlRowList;
|
|
|
import com.uas.eis.entity.*;
|
|
|
+import com.uas.eis.entity.fanwei.AccountRegisterDetail1;
|
|
|
+import com.uas.eis.entity.fanwei.AccountRegisterDetail2;
|
|
|
+import com.uas.eis.entity.fanwei.AccountRegisterMain;
|
|
|
+import com.uas.eis.entity.fanwei.AccountRegisterReq;
|
|
|
import com.uas.eis.sdk.entity.ApiResult;
|
|
|
import com.uas.eis.sdk.resp.ApiResponse;
|
|
|
import com.uas.eis.service.ERPService;
|
|
|
-import com.uas.eis.utils.*;
|
|
|
+import com.uas.eis.utils.BaseUtil;
|
|
|
+import com.uas.eis.utils.MD5Util;
|
|
|
+import com.uas.eis.utils.PSHttpUtils;
|
|
|
+import com.uas.eis.utils.StringUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -33,6 +44,361 @@ public class ERPServiceImpl implements ERPService {
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDao baseDao;
|
|
|
+ @Autowired
|
|
|
+ private ObjectMapper objectMapper;
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public ApiResult<String> syncProductStock(String data) {
|
|
|
+// logger.info("sendProd-Begin:master {} ids {}");
|
|
|
+// try {
|
|
|
+// SqlRowList docMsg = baseDao.queryForRowSet(" select pr_id,to_char(sysdate,'yyyy-mm-dd') ba_date,ba_remain,tspr_eightcode,pr_code,tspr_ninecode,tspr_description,ba_code from product left join batch on pr_code=ba_prodcode left join transsionproduct on pr_code=tspr_uasprcode " +
|
|
|
+// " where tspr_enable=-1 and pr_statuscode='AUDITED' and ba_whcode='BSD056' and ba_remain>0");
|
|
|
+// if(!docMsg.hasNext()){
|
|
|
+// return ApiResponse.failRsp("102","没有需要同步的商品库存");
|
|
|
+// }
|
|
|
+// List<Map<String, Object>> docMsgResultList = docMsg.getResultList();
|
|
|
+// StringBuffer errMsg = new StringBuffer();
|
|
|
+// List<Object> docCodes = new ArrayList<>();
|
|
|
+// List<SaleMaterialStockVO> list = new ArrayList<>();
|
|
|
+// Map<String,Object> reqMap = new HashMap<>();
|
|
|
+// String prCodes = "";
|
|
|
+// for (Map<String, Object> map : docMsgResultList) {
|
|
|
+// docCodes.add(map.get("pr_code"));
|
|
|
+// logger.info("sendProd-test: id {} code {}",map.get("pr_id"),map.get("pr_code"));
|
|
|
+// // 创建SaleMaterialStockVO对象
|
|
|
+// SaleMaterialStockVO saleMaterialStockVO = new SaleMaterialStockVO.Builder()
|
|
|
+// .location("BSD056")
|
|
|
+// .qdate(StringUtil.nvl(map.get("ba_date")," "))
|
|
|
+// .quanity(StringUtil.nvl(map.get("ba_remain")," "))
|
|
|
+// .materialNumber(StringUtil.nvl(map.get("tspr_eightcode")," "))
|
|
|
+// .supplierMaterialNumber(StringUtil.nvl(map.get("pr_code")," "))
|
|
|
+// .mpn(StringUtil.nvl(map.get("tspr_ninecode")," "))
|
|
|
+// .status(1)
|
|
|
+// .materialDescription(StringUtil.nvl(map.get("tspr_description")," "))
|
|
|
+// .batchNo(StringUtil.nvl(map.get("ba_code")," "))
|
|
|
+// .build();
|
|
|
+// list.add(saleMaterialStockVO);
|
|
|
+// }
|
|
|
+// reqMap.put("list",list);
|
|
|
+// logger.info("sendProd-End:master {} ids {}");
|
|
|
+// if(errMsg.length()>0){
|
|
|
+// return ApiResponse.failRsp("101",errMsg.toString());
|
|
|
+// }
|
|
|
+// String json = null;
|
|
|
+// try{
|
|
|
+// json = objectMapper.writeValueAsString(reqMap);
|
|
|
+// logger.info("Request JSON: {}", json);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// catch (JsonProcessingException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// logger.info("sendProd-Error:JSON转换失败 codes {} ",prCodes);
|
|
|
+// return ApiResponse.failRsp("106","JSON转换失败");
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// //eMsg = StringUtil.nvl(e.getMessage(),"无");
|
|
|
+// //baseDao.execute("update product set pr_sendwmsstatus='同步失败' ,pr_sendwmserr='操作:同步' where pr_code in ("+prCodes+")");
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// //接口入参,接口平台会直接将当前账号信息传入接口
|
|
|
+// //String json ="{\"elsAccount\":\"864385\"}";
|
|
|
+// //接口提供方企业应用账号
|
|
|
+// String elsAccount = "864385";
|
|
|
+// //接口标识
|
|
|
+// String interfaceCode = "SRM009";
|
|
|
+// //接口参数组装
|
|
|
+// EntryForPOST post = EntryForPOST.builder().elsAccount(elsAccount)
|
|
|
+// .businessType(interfaceCode)
|
|
|
+// .reuestData(json)
|
|
|
+// .specialSign(interfaceCode)
|
|
|
+// .build();
|
|
|
+//
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// JSONObject result = null;
|
|
|
+// try {
|
|
|
+// //接口调用
|
|
|
+// result = OpenApiUtil.doPost(post);
|
|
|
+// } catch (Exception e) {
|
|
|
+// jsonObject.put("message", e.getMessage());
|
|
|
+// System.out.println("error1"+e.getMessage());
|
|
|
+// }
|
|
|
+// //接口返回结果
|
|
|
+// jsonObject.put("message", result.toJSONString());
|
|
|
+// System.out.println(jsonObject.get("message"));
|
|
|
+// return ApiResponse.successRsp("0","同步库存成功");
|
|
|
+// } catch (Exception e) {
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("message", e.getMessage());
|
|
|
+// System.out.println("error1"+e.getMessage());
|
|
|
+// return ApiResponse.failRsp("101",jsonObject.getString("message"));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public ApiResult<String> syncOriFactoryDelivery(String data) {
|
|
|
+// logger.info("sendOriFactoryDelivery-Begin:master {} ids {}");
|
|
|
+// try {
|
|
|
+// SqlRowList docMsg = baseDao.queryForRowSet(" select nvl(pd_qty-nvl(pd_acceptqty,0),0) wrkQty,tspr_uasprcode,tspr_eightcode,tspr_ninecode,to_char(pu_date,'yyyy-mm-dd') pu_date,pu_code,pd_detno, " +
|
|
|
+// " to_char(pd_delivery,'yyyy-mm-dd') pd_delivery,pd_qty,pd_qty pd_qtyreply,to_char(pd_delivery,'yyyy-mm-dd') pd_deliveryreply,'' pd_remark " +
|
|
|
+// " from purchasedetail left join purchase on pd_puid=pu_id left join transsionproduct on pd_prodcode=tspr_uasprcode " +
|
|
|
+// " where pu_statuscode = 'AUDITED' and nvl(pd_mrpstatuscode,' ')<>'FINISH' and pd_qty-nvl(pd_acceptqty,0)>0 and upper(pd_custname) in ('传音','上海传音') and nvl(tspr_uasprcode,' ') <> 'STK35F62' " +
|
|
|
+// " and nvl(TSPR_EIGHTCODE,' ')<>' ' and nvl(tspr_ENABLE,0) = -1 order by pd_prodcode,pd_puid,pd_detno");
|
|
|
+// if(!docMsg.hasNext()){
|
|
|
+// return ApiResponse.failRsp("102","没有需要同步的商品库存");
|
|
|
+// }
|
|
|
+// List<Map<String, Object>> docMsgResultList = docMsg.getResultList();
|
|
|
+// StringBuffer errMsg = new StringBuffer();
|
|
|
+// List<Object> docCodes = new ArrayList<>();
|
|
|
+// List<SupplierSecondMaterialStockVO> list = new ArrayList<>();
|
|
|
+// Map<String,Object> reqMap = new HashMap<>();
|
|
|
+// String prCodes = "";
|
|
|
+// for (Map<String, Object> map : docMsgResultList) {
|
|
|
+// docCodes.add(map.get("pr_code"));
|
|
|
+// logger.info("sendProd-test: id {} code {}",map.get("pr_id"),map.get("pr_code"));
|
|
|
+// // 创建SaleMaterialStockVO对象
|
|
|
+// SupplierSecondMaterialStockVO supplierSecondMaterialStockVO = new SupplierSecondMaterialStockVO.Builder()
|
|
|
+// .materialOem(StringUtil.nvl(map.get("tspr_uasprcode")," "))
|
|
|
+// .matOrderDate(StringUtil.nvl(map.get("pu_date")," "))
|
|
|
+// .orderNumber(StringUtil.nvl(map.get("pu_code")," "))
|
|
|
+// .orderItemNumber(StringUtil.nvl(map.get("pd_detno")," "))
|
|
|
+// .orderReqDate(StringUtil.nvl(map.get("pd_delivery")," "))
|
|
|
+// .orderQty(StringUtil.nvl(map.get("pd_qty")," "))
|
|
|
+// .orderCondate(StringUtil.nvl(map.get("pd_deliveryreply")," "))
|
|
|
+// .orderConQty(StringUtil.nvl(map.get("pd_qtyreply")," "))
|
|
|
+// .supplierRemark(StringUtil.nvl(map.get("pd_remark")," "))
|
|
|
+// .build();
|
|
|
+// list.add(supplierSecondMaterialStockVO);
|
|
|
+// }
|
|
|
+// reqMap.put("list",list);
|
|
|
+// logger.info("sendOriFactoryDelivery-End:master {} ids {}");
|
|
|
+// if(errMsg.length()>0){
|
|
|
+// return ApiResponse.failRsp("101",errMsg.toString());
|
|
|
+// }
|
|
|
+// String json = null;
|
|
|
+// try{
|
|
|
+// json = objectMapper.writeValueAsString(reqMap);
|
|
|
+// logger.info("Request JSON: {}", json);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// catch (JsonProcessingException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// logger.info("sendOriFactoryDelivery-Error:JSON转换失败 codes {} ",prCodes);
|
|
|
+// return ApiResponse.failRsp("106","JSON转换失败");
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// //eMsg = StringUtil.nvl(e.getMessage(),"无");
|
|
|
+// //baseDao.execute("update product set pr_sendwmsstatus='同步失败' ,pr_sendwmserr='操作:同步' where pr_code in ("+prCodes+")");
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// //接口入参,接口平台会直接将当前账号信息传入接口
|
|
|
+// //String json ="{\"elsAccount\":\"864385\"}";
|
|
|
+// //接口提供方企业应用账号
|
|
|
+// String elsAccount = "864385";
|
|
|
+// //接口标识
|
|
|
+// String interfaceCode = "SRM013";
|
|
|
+// //接口参数组装
|
|
|
+// EntryForPOST post = EntryForPOST.builder().elsAccount(elsAccount)
|
|
|
+// .businessType(interfaceCode)
|
|
|
+// .reuestData(json)
|
|
|
+// .specialSign(interfaceCode)
|
|
|
+// .build();
|
|
|
+//
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// JSONObject result = null;
|
|
|
+// try {
|
|
|
+// //接口调用
|
|
|
+// result = OpenApiUtil.doPost(post);
|
|
|
+// } catch (Exception e) {
|
|
|
+// jsonObject.put("message", e.getMessage());
|
|
|
+// System.out.println("error1"+e.getMessage());
|
|
|
+// }
|
|
|
+// //接口返回结果
|
|
|
+// jsonObject.put("message", result.toJSONString());
|
|
|
+// System.out.println(jsonObject.get("message"));
|
|
|
+// return ApiResponse.successRsp("0","同步库存成功");
|
|
|
+// } catch (Exception e) {
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("message", e.getMessage());
|
|
|
+// System.out.println("error1"+e.getMessage());
|
|
|
+// return ApiResponse.failRsp("101",jsonObject.getString("message"));
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void saveAccountRegister(AccountRegisterReq accountRegisterReq) {
|
|
|
+ String caller="AccountRegister!Bank";
|
|
|
+ AccountRegisterMain accountRegisterMain = accountRegisterReq.getAccountRegisterMain();
|
|
|
+ int ar_id = baseDao.getSeqId("ACCOUNTREGISTER_SEQ");
|
|
|
+ String code = baseDao.sGetMaxNumber("AccountRegister", 2);
|
|
|
+ List<String> sqls = new ArrayList<>();
|
|
|
+
|
|
|
+ // 应收票据收款、应付票据付款 必须有来源,不允许手工新增
|
|
|
+ String type = accountRegisterMain.getType();
|
|
|
+ //Employee employee = SystemSession.getUser();
|
|
|
+ if ("应收票据收款".equals(type) || "应付票据付款".equals(type))
|
|
|
+ BaseUtil.showError(type + " 必须有来源,不允许手工新增");
|
|
|
+ List<AccountRegisterDetail1> accountRegisterDetail1s = accountRegisterReq.getListDetail1();
|
|
|
+
|
|
|
+ String err_out = "";
|
|
|
+ int count = accountRegisterDetail1s.size();
|
|
|
+
|
|
|
+ for (AccountRegisterDetail1 map : accountRegisterDetail1s) {
|
|
|
+ String cate_code = map.getCatecode(); // 科目编码
|
|
|
+ BigDecimal detno = map.getDetno();
|
|
|
+ if (!cate_code.trim().equals("")) {
|
|
|
+ Object o = baseDao.getFieldDataByCondition("CATEGORY", "ca_isleaf", "ca_code='" + cate_code + "'");
|
|
|
+ String isleaf = o == null ? "0" : o.toString();
|
|
|
+ if (isleaf.equals("0")) {
|
|
|
+ // 科目不是子节点 报错
|
|
|
+ err_out = err_out + String.valueOf(detno);
|
|
|
+ if (accountRegisterDetail1s.indexOf(map) == count - 1) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ err_out = err_out + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!err_out.equals("")) {
|
|
|
+ BaseUtil.showError("第" + err_out + "条明细行科目不是末级科目,不能保存明细行!");
|
|
|
+ }
|
|
|
+ Object date = (Object) accountRegisterMain.getDate();
|
|
|
+ baseDao.checkCloseMonth("MONTH-B", date);
|
|
|
+
|
|
|
+ String Sql="insert into AccountRegister(ar_id,ar_code,ar_date,ar_type,ar_currencytype,ar_accountcode,ar_accountname,ar_accountcurrency,ar_accountrate" +
|
|
|
+ ",ar_payment,ar_departmentcode,ar_departmentname,ar_cateid,ar_emid,ar_recordman,ar_status,ar_statuscode,ar_poststatus,ar_poststatuscode)" +
|
|
|
+ "values("+ar_id+",'"+code+"',to_date('"+accountRegisterMain.getDate()+"','yyyy-mm-dd'),'"+accountRegisterMain.getType()+"','"+accountRegisterMain.getCurrencytype()+"','"+accountRegisterMain.getAccountcode()+"'," +
|
|
|
+ "'"+accountRegisterMain.getAccountname()+"','"+accountRegisterMain.getAccountcurrency()+"','"+accountRegisterMain.getAccountrate()+"'," +
|
|
|
+ accountRegisterMain.getPayment()+",'"+accountRegisterMain.getDepartmentcode()+"','"+accountRegisterMain.getDepartmentname()+"',"+accountRegisterMain.getCateid()+"," +
|
|
|
+ "1033922,'管理员','在录入','ENTERING','未过账','UNPOST')";
|
|
|
+
|
|
|
+ sqls.add(Sql);
|
|
|
+
|
|
|
+
|
|
|
+ List<AccountRegisterDetail2> accountRegisterDetail2s = accountRegisterReq.getListDetail2();
|
|
|
+ for (AccountRegisterDetail1 accountRegisterDetail1: accountRegisterDetail1s) {
|
|
|
+ int ard_id = baseDao.getSeqId("ACCOUNTREGISTERDETAIL_SEQ");
|
|
|
+ Sql="insert into AccountRegisterDetail(ard_id,ard_arid,ard_detno,ard_explanation,ard_catecode,ard_catedesc,ard_currency,ard_rate,ard_doubledebit,ard_debit)" +
|
|
|
+ "values("+ard_id+","+ar_id+","+accountRegisterDetail1.getDetno()+",'"+accountRegisterDetail1.getExplanation()+"','"+accountRegisterDetail1.getCatecode()+"','"+
|
|
|
+ accountRegisterDetail1.getCatedesc()+"','"+accountRegisterDetail1.getCurrency()+"',"+accountRegisterDetail1.getRate()+","+accountRegisterDetail1.getDoubledebit()+","+accountRegisterDetail1.getDebit()+")";
|
|
|
+ sqls.add(Sql);
|
|
|
+
|
|
|
+ for (AccountRegisterDetail2 accountRegisterDetail2: accountRegisterDetail2s) {
|
|
|
+ if (accountRegisterDetail2.getDetailFkId().doubleValue() == accountRegisterDetail1.getDetailId().doubleValue()){
|
|
|
+ Sql="insert into ACCOUNTREGISTERDETAILASS(ARS_ID, ARS_ARDID, ARS_DETNO, ARS_ASSTYPE, ARS_ASSCODE, ARS_ASSNAME, ARS_TYPE)" +
|
|
|
+ "values(ACCOUNTREGISTERDETAILASS_seq.nextval,"+ard_id+","+accountRegisterDetail2.getDetno()+",'"+accountRegisterDetail2.getAsstype()+"','"+accountRegisterDetail2.getAsscode()+"','"+
|
|
|
+ accountRegisterDetail2.getAssname()+"','AccountRegister!Bank')";
|
|
|
+ sqls.add(Sql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ String defaultCurr = baseDao.getDBSetting(caller, "fyCurr");
|
|
|
+ if(defaultCurr != null){
|
|
|
+ baseDao.execute("update accountregisterdetail set ard_currency='"+defaultCurr+"' WHERE ard_arid in (select ar_id from accountregister where ar_id=" + ar_id +" and nvl(ar_currencytype,0)<>0 and ar_type='费用') and nvl(ard_currency,' ')=' '");
|
|
|
+ }
|
|
|
+ baseDao.execute("update accountregisterdetail set ard_rate=(select cm_crrate from CurrencysMonth,accountregister where ard_arid=ar_id and cm_crname=ard_currency "
|
|
|
+ + " and CM_YEARMONTH=to_char(ar_date,'yyyymm')) where ard_arid=" + ar_id + " and nvl(ard_currency,' ')<>' '");
|
|
|
+ baseDao.execute("update accountregisterdetail set ard_debit=round(ard_rate*ard_doubledebit,2) where nvl(ard_doubledebit,0)<>0 and nvl(ard_rate,0)<>0 and ard_arid="
|
|
|
+ + ar_id);
|
|
|
+ baseDao.execute("update accountregisterdetail set ard_credit=round(ard_rate*ard_doublecredit,2) where nvl(ard_doublecredit,0)<>0 and nvl(ard_rate,0)<>0 and ard_arid="
|
|
|
+ + ar_id);
|
|
|
+ baseDao.execute("update accountregisterdetail set ard_doubledebit=round(ard_debit/ard_rate,2) where nvl(ard_doubledebit,0)=0 and nvl(ard_rate,0)<>0 and ard_arid="
|
|
|
+ + ar_id);
|
|
|
+ baseDao.execute("update accountregisterdetail set ard_doublecredit=round(ard_credit/ard_rate,2) where nvl(ard_doublecredit,0)=0 and nvl(ard_rate,0)<>0 and ard_arid="
|
|
|
+ + ar_id);
|
|
|
+ String insertAssDetSql = "insert into accountregisterdetailass(ars_id,ars_ardid,ars_detno,ars_asstype,ars_asscode,ars_assname,ars_type) values (?,?,?,?,?,?,'AccountRegister!Bank')";
|
|
|
+ SqlRowList rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select * from accountregister left join accountregisterdetail on ard_arid=ar_id where ard_arid=? and nvl(ard_catecode,' ')<>' '",
|
|
|
+ ar_id);
|
|
|
+ while (rs.next()) {
|
|
|
+ Object catecode = rs.getObject("ard_catecode");
|
|
|
+ int ardid = rs.getInt("ard_id");
|
|
|
+ SqlRowList ass = baseDao.queryForRowSet("select ca_assname from category where ca_code=? and nvl(ca_assname,' ')<>' '",
|
|
|
+ catecode);
|
|
|
+ if (ass.next()) {
|
|
|
+ String assStr = ass.getString("ca_assname");
|
|
|
+ String[] codes = assStr.split("#");
|
|
|
+ for (String assname : codes) {
|
|
|
+ int i = baseDao.getCount("select count(1) from accountregisterdetailass where ars_ardid=" + ardid
|
|
|
+ + " and ARS_ASSTYPE='" + assname + "'");
|
|
|
+ if (i == 0) {
|
|
|
+ Object maxno = baseDao.getFieldDataByCondition("accountregisterdetailass", "max(nvl(ars_detno,0))", "ars_ardid="
|
|
|
+ + ardid);
|
|
|
+ maxno = maxno == null ? 0 : maxno;
|
|
|
+ int detno = Integer.parseInt(maxno.toString()) + 1;
|
|
|
+ int arsid = baseDao.getSeqId("ACCOUNTREGISTERDETAILASS_SEQ");
|
|
|
+ baseDao.execute(insertAssDetSql, new Object[] { arsid, ardid, detno, assname, null, null });
|
|
|
+ }
|
|
|
+ int arsid = baseDao.getFieldValue("accountregisterdetailass", "ars_id", "ars_ardid=" + ardid + " and ARS_ASSTYPE='"
|
|
|
+ + assname + "'", Integer.class);
|
|
|
+ if ("部门".equals(assname) && StringUtil.hasText(rs.getObject("ar_departmentcode"))) {
|
|
|
+ baseDao.execute("update accountregisterdetailass set ars_asscode='" + rs.getObject("ar_departmentcode")
|
|
|
+ + "', ars_assname='" + rs.getObject("ar_departmentname") + "' where ars_id=" + arsid
|
|
|
+ + " and nvl(ars_asscode,' ')=' '");
|
|
|
+ }
|
|
|
+ if ("项目".equals(assname) && StringUtil.hasText(rs.getObject("ar_prjcode"))) {
|
|
|
+ baseDao.execute("update accountregisterdetailass set ars_asscode='" + rs.getObject("ar_prjcode")
|
|
|
+ + "', ars_assname='" + rs.getObject("ar_prjname") + "' where ars_id=" + arsid
|
|
|
+ + " and nvl(ars_asscode,' ')=' '");
|
|
|
+ }
|
|
|
+ if ("客户往来".equals(assname) && StringUtil.hasText(rs.getObject("ar_custcode"))) {
|
|
|
+ baseDao.execute("update accountregisterdetailass set ars_asscode='" + rs.getObject("ar_custcode")
|
|
|
+ + "', ars_assname='" + rs.getObject("ar_custname") + "' where ars_id=" + arsid
|
|
|
+ + " and nvl(ars_asscode,' ')=' '" + " and nvl(ars_asscode,' ')=' '");
|
|
|
+ }
|
|
|
+ if ("供应商往来".equals(assname) && StringUtil.hasText(rs.getObject("ar_vendcode"))) {
|
|
|
+ baseDao.execute("update accountregisterdetailass set ars_asscode='" + rs.getObject("ar_vendcode")
|
|
|
+ + "', ars_assname='" + rs.getObject("ar_vendname") + "' where ars_id=" + arsid
|
|
|
+ + " and nvl(ars_asscode,' ')=' '" + " and nvl(ars_asscode,' ')=' '");
|
|
|
+ }
|
|
|
+ if ("员工".equals(assname) && StringUtil.hasText(rs.getObject("ar_emcode"))) {
|
|
|
+ baseDao.execute("update accountregisterdetailass set ars_asscode='" + rs.getObject("ar_emcode")
|
|
|
+ + "', ars_assname='" + rs.getObject("ar_emname") + "' where ars_id=" + arsid
|
|
|
+ + " and nvl(ars_asscode,' ')=' '" + " and nvl(ars_asscode,' ')=' '");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateErrorString(ar_id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void updateErrorString(int id) {
|
|
|
+ // 多辅助核算项的核算明细按照科目编号中辅助核算名称顺序重排
|
|
|
+ SqlRowList detailList = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select ard_id,ca_assname from accountregisterdetail left join category on ard_catecode=ca_code where ard_arid=? and ca_assname is not null and instr(ca_assname,'#')>0",
|
|
|
+ id);
|
|
|
+ while (detailList.next()) {
|
|
|
+ String[] assNames = detailList.getString("ca_assname").split("#");
|
|
|
+ int index = 1;
|
|
|
+ for (String assName : assNames) {
|
|
|
+ baseDao.execute("update accountregisterdetailass set ars_detno=? where ars_ardid=? and ars_asstype=? and ars_detno<>?",
|
|
|
+ index, detailList.getObject("ard_id"), assName, index);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 单据类型为 费用 或者其它收款 或者其它付款
|
|
|
+ baseDao.updateByCondition("AccountRegister", "ar_errstring = null", "ar_id=" + id);
|
|
|
+ SqlRowList rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "SELECT abs((ROUND(AR_DEPOSIT*AR_ACCOUNTRATE,2)+SUM_DEBIT)-(ROUND(AR_PAYMENT*AR_ACCOUNTRATE,2)+SUM_CREDIT)) amount, round((AR_DEPOSIT+AR_PAYMENT)*AR_ACCOUNTRATE,2) bbamount "
|
|
|
+ + "FROM (SELECT NVL(AR_ACCOUNTRATE,1) AR_ACCOUNTRATE,NVL(AR_PAYMENT,0) AR_PAYMENT,NVL(AR_DEPOSIT,0) AR_DEPOSIT,round(NVL(ARDDEBIT,0),2) SUM_DEBIT,round(NVL(ARDCREDIT,0),2) sum_credit "
|
|
|
+ + "FROM ACCOUNTREGISTER LEFT JOIN (SELECT SUM(NVL(ARD_DEBIT,0)) ARDDEBIT,SUM(NVL(ARD_CREDIT,0)) ARDCREDIT,ARD_ARID FROM ACCOUNTREGISTERDETAIL GROUP BY ARD_ARID) on ar_id=ard_arid "
|
|
|
+ + "where ar_id=? and ar_type in ('费用','其它收款','其它付款'))", id);
|
|
|
+ if (rs.next()) {
|
|
|
+ if (rs.getGeneralDouble("amount") >= 0.01) {
|
|
|
+ baseDao.updateByCondition("AccountRegister",
|
|
|
+ "ar_errstring = '不平衡(" + rs.getGeneralDouble("amount") + "),本币(" + rs.getGeneralDouble("bbamount") + ")'", "ar_id="
|
|
|
+ + id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public ApiResult<String> syncProduct(String data) {
|