对接吉客云代码

This commit is contained in:
yuqh 2025-05-27 09:52:41 +08:00
parent 31f9aa0f3d
commit f7abab248c
18 changed files with 311 additions and 71 deletions

View File

@ -195,8 +195,9 @@
<select id="entity_list_base_all" resultMap="get-entity-result" parameterType="com.hzya.frame.Jackyun.goodsdocin.entity.GoodsdocInEntity">
select
top 100
*
from jeck_goodsdocin where state is null
from jeck_goodsdocin where state is null and inouttype = '105'

View File

@ -22,6 +22,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -198,6 +199,10 @@ public class GoodsdocInServiceImpl extends BaseService<GoodsdocInEntity,String>
JSONObject jsonObject = bdingParm(goodsdocInEntity,goodsdocInDetailEntityList);
//调用U8接口生成退货单
U8ResultEntity u8ResultEntity = deliveryOrderService.addDeliveryT(jsonObject);
// U8ResultEntity u8ResultEntity = new U8ResultEntity();
// if(1==1){
// return;
// }
String state = "";
if(!u8ResultEntity.issuccess()){
goodsdocInEntity.setState("N");
@ -228,31 +233,35 @@ public class GoodsdocInServiceImpl extends BaseService<GoodsdocInEntity,String>
private JSONObject bdingParmOut(GoodsdocInEntity goodsdocInEntity, List<GoodsdocInDetailEntity> goodsdocInDetailEntityList) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("AccId", "201");
jsonObject.put("AccId", "005");
jsonObject.put("billid", "123");
JSONObject head = new JSONObject();
head.put("cbuscode", goodsdocInEntity.getU8BillCode());//发货单号
head.put("cdepcode", "00702");//todo 部门编码
head.put("cmaker", "吉客云入库单自动生成");//创建人
head.put("cbustype", "普通销售");//创建人
head.put("crdcode", "203");//入库类别编码
head.put("cwhcode", "01001");//仓库编码 todo 正式需要切换为04009
head.put("ddate", "2024-12-31");//销售类型
// head.put("ccuscode", "99999994");//todo 正式需要切换未这个客户
head.put("ccuscode", "01010918");//客户
head.put("cwhcode", "04009");//仓库编码 todo 正式需要切换为04009
head.put("ddate", DateUtil.format(new Date(),"yyyy-MM-dd"));//销售类型
head.put("ccuscode", "99999994");//todo 正式需要切换未这个客户
head.put("cDefine1", "多组织-红字采购入库");//
// head.put("ccuscode", "01010918");//客户
head.put("csource","发货单");
jsonObject.put("head",head);
JSONArray body = new JSONArray();
int i = 0;
if(CollectionUtils.isNotEmpty(goodsdocInDetailEntityList)){
for(GoodsdocInDetailEntity item : goodsdocInDetailEntityList){
i++;
if("501010323".equals(item.getGoodsNo())){
continue;
}
// if("501010323".equals(item.getGoodsNo())){
// continue;
// }
JSONObject details = new JSONObject();
details.put("cbdlcode",goodsdocInEntity.getU8BillCode());//发货单号
details.put("cdblrowno", i);//行号
details.put("cinvcode", item.getGoodsNo());//存货编码
details.put("iquantity", item.getQuantity());//数量
details.put("iquantity",new BigDecimal(item.getQuantity()).subtract(new BigDecimal(item.getQuantity()).add(new BigDecimal(item.getQuantity()))));
// details.put("iquantity", item.getQuantity());//数量
body.add(details);
}
}
@ -262,7 +271,7 @@ public class GoodsdocInServiceImpl extends BaseService<GoodsdocInEntity,String>
private JSONObject bdingParm(GoodsdocInEntity goodsdocInEntity, List<GoodsdocInDetailEntity> goodsdocInDetailEntityList) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("AccId", "201");
jsonObject.put("AccId", "005");
jsonObject.put("billid", "123");
JSONObject head = new JSONObject();
head.put("brdflag", "1");//发货0退货1
@ -270,16 +279,17 @@ public class GoodsdocInServiceImpl extends BaseService<GoodsdocInEntity,String>
head.put("cbustype", "普通销售");//
head.put("cdepcode", "00702");//销售部门
head.put("cmaker", "吉客云入库单自动生成");//创建人
// head.put("ccuscode", "99999994");//todo 正式需要切换未这个客户
head.put("ccuscode", "01010918");//客户
head.put("cDefine1", "多组织-红字采购入库");//
head.put("ccuscode", "99999994");//todo 正式需要切换未这个客户
// head.put("ccuscode", "01010918");//客户
head.put("cstcode", "11");//销售类型
head.put("ddate", "2024-12-31");//销售类型
head.put("ddate", DateUtil.format(new Date(),"yyyy-MM-dd"));//创建时间
jsonObject.put("head",head);
JSONArray body = new JSONArray();
if(CollectionUtils.isNotEmpty(goodsdocInDetailEntityList)){
goodsdocInDetailEntityList.forEach(item -> {
JSONObject details = new JSONObject();
details.put("cwhcode","01001");//todo 正式需要切换为04009
details.put("cwhcode","04009");//todo 正式需要切换为04009
details.put("cinvcode",item.getGoodsNo());
//计量单位编码需要按照名称去U8查询
String unitName = item.getUnitName();
@ -288,7 +298,7 @@ public class GoodsdocInServiceImpl extends BaseService<GoodsdocInEntity,String>
}
//todo idiscount原币折扣金额没有 看看是否需要调整代码
details.put("isum",item.getTransHasTaxAmount());
details.put("iquantity",item.getQuantity());
details.put("iquantity",new BigDecimal(item.getQuantity()).subtract(new BigDecimal(item.getQuantity()).add(new BigDecimal(item.getQuantity()))));
details.put("itaxrate",item.getTaxRate());
body.add(details);
});

View File

@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/**
@ -505,12 +506,12 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
*
*/
@Override
public U8ResultEntity addDeliveryT(JSONObject parm) {
public U8ResultEntity addDeliveryT(JSONObject jsonObject) {
String billCode = "";
String dlId = "";
String AccId = "";
try {
JSONObject jsonObject = parm.getJSONObject("jsonStr");
// JSONObject jsonObject = parm.getJSONObject("jsonStr");
logger.info("接收到的参数"+jsonObject.toString());
StringBuffer resultStr = new StringBuffer();//回传json
String billid = jsonObject.getString("billid");
@ -519,8 +520,10 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
}
AccId = jsonObject.getString("AccId");
String cmemo = jsonObject.getString("cmemo");
if(cmemo.length()>255){
jsonObject.put("cmemo", cmemo.substring(0,254));
if(StrUtil.isNotEmpty(cmemo)){
if(cmemo.length()>255){
jsonObject.put("cmemo", cmemo.substring(0,254));
}
}
if(StrUtil.isEmpty(AccId)){
return BaseU8Result.getFailureMessageEntity("请传入正确的账套号");
@ -623,7 +626,9 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
//todo 发货单表体
JSONArray body = new JSONArray();
JSONArray jBody = jsonObject.getJSONArray("body");
int t=0;
for (int i = 0; i < jBody.size(); i++) {
System.out.println("错误的位置"+t++);
JSONObject jBodyObj = jBody.getJSONObject(i);
//验证数据如果为空则返回报错信息
String[] MustInputCodes = new String[] { "iquantity", "cinvcode","inum" };
@ -635,13 +640,18 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
}
}
//获取计量单位组信息
String sqlUnit = "select b.cInvCName,a.* from "+AccCode+".dbo.Inventory a left join "+AccCode+".dbo.InventoryClass b on b.cInvCCode = a.cInvCCode " +
"where cInvCode='"+jBodyObj.getString("cinvcode")+"'";
String sqlUnit = "select b.cInvCName,c.ichangrate,a.* " +
"from "+AccCode+".dbo.Inventory a " +
"left join "+AccCode+".dbo.InventoryClass b on b.cInvCCode = a.cInvCCode " +
"left join " +AccCode+".dbo.tc_unit c on a.cSAComUnitCode = c.unit_id "+
" where cInvCode='"+jBodyObj.getString("cinvcode")+"'";
SaleInvEntity U8Body = new SaleInvEntity();
U8Body.setDataSourceCode("YONYOUU8NEW");
List<HashMap<String, Object>> U8BodyHashMaps = saleInvDao.getU8BillData(sqlUnit,U8Body);
if(CollectionUtils.isEmpty(U8BodyHashMaps)){
resultStr.append("存货编码不存在[" + jBodyObj.getString("cinvcode")+ "],行:"+i + 1+"" );
if(CollectionUtils.isEmpty(U8BodyHashMaps) && U8BodyHashMaps.size()==0){
continue;
// todo 匹配不上的自行跳过等待对照表
// resultStr.append("存货编码不存在[" + jBodyObj.getString("cinvcode")+ "],行:"+i + 1+"" );
}
//存货信息
HashMap<String, Object> inv= U8BodyHashMaps.get(0);
@ -649,8 +659,13 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
jBodyObj.put("cgroupcode",inv.get("cGroupCode"));
jBodyObj.put("igrouptype",inv.get("iGroupType"));
jBodyObj.put("ccomunitcode",inv.get("cComUnitCode"));
jBodyObj.put("cunitid",inv.get("cComUnitCode"));//计量单位默认
//默认项 在第三方调用不传输数据情况下 则默认以下数据
System.out.println("当前换算率"+inv.get("ichangrate"));
if(null != inv.get("ichangrate")){
//辅助计量数量
jBodyObj.put("inum",jBodyObj.getBigDecimal("iquantity").divide(new BigDecimal(String.valueOf(inv.get("ichangrate"))),6, RoundingMode.HALF_UP));
}
// 买赠类型
String cdefine22 = jBodyObj.getString("cdefine22");
if(StrUtil.isEmpty(cdefine22)){
@ -706,23 +721,25 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
//原币折扣金额
BigDecimal idiscount = StrUtil.isNotEmpty(jBodyObj.getString("idiscount")) ? jBodyObj.getBigDecimal("idiscount") : new BigDecimal(0);
BigDecimal iquantity = jBodyObj.getBigDecimal("iquantity");//数量
BigDecimal isum = jBodyObj.getBigDecimal("isum");//价税合计
// BigDecimal isum = jBodyObj.getBigDecimal("isum");//价税合计
BigDecimal isum = new BigDecimal(0);//价税合计
BigDecimal itaxrate_b = jBodyObj.getBigDecimal("itaxrate");//税率
BigDecimal nflat = jHead.getBigDecimal("iexchrate");//汇率
BigDecimal iTaxUnitPrice = isum.divide(iquantity,6); //原币含税单价
// BigDecimal iTaxUnitPrice = isum.divide(iquantity,6); //原币含税单价
BigDecimal iTaxUnitPrice = new BigDecimal(0); //原币含税单价
JSONObject ae = new JSONObject();
//工具类编写金额信息进行计算
U8Util.CalculationSum(isum, iquantity, nflat, itaxrate_b, 6);
jBodyObj.put("iquotedprice",ae.getString("TaxPrice")) ;
jBodyObj.put("itaxunitprice",ae.getString("TaxPrice")) ;//原币含税单价
jBodyObj.put("isum",ae.getString("Sum"));//价税合计
jBodyObj.put("iunitprice",ae.getString("UnitPrice")) ;//原币不含税单价
jBodyObj.put("imoney",ae.getString("Money"));//原货不含税金额
jBodyObj.put("itax",ae.getString("Tax"));//原币税额
jBodyObj.put("inatunitprice",ae.getString("NatUnitPrice"));//本币含税单价
jBodyObj.put("inatmoney",ae.getString("NatMoney"));//本币含税金额
jBodyObj.put("inattax",ae.getString("NatTax"));//本币税额
jBodyObj.put("inatsum",ae.getString("NatSum"));//本币含税金额
// U8Util.CalculationSum(isum, iquantity, nflat, itaxrate_b, 6);
jBodyObj.put("iquotedprice",0) ;
jBodyObj.put("itaxunitprice",0) ;//原币含税单价
jBodyObj.put("isum",0);//价税合计
jBodyObj.put("iunitprice",0) ;//原币不含税单价
jBodyObj.put("imoney",0);//原货不含税金额
jBodyObj.put("itax",0);//原币税额
jBodyObj.put("inatunitprice",0);//本币含税单价
jBodyObj.put("inatmoney",0);//本币含税金额
jBodyObj.put("inattax",0);//本币税额
jBodyObj.put("inatsum",0);//本币含税金额
String kl = jBodyObj.getString("kl");
String kl2 = jBodyObj.getString("kl2");
if(StrUtil.isEmpty(kl)){
@ -739,11 +756,15 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
main.put("AccId",AccId);
main.put("head",jHead);
main.put("body",body);
main.put("domPosition",new ArrayList<>());
//如果有错误信息则返回错误信息
if(StrUtil.isNotEmpty(resultStr.toString())){
return BaseU8Result.getSuccessMessageEntity(resultStr.toString());
}
// if(1==1){
// return null;
// }
logger.info("发货单新增推送U8"+main.toString());
String result = U8Util.sengBillToU8(main.toString(), "8000110015");
logger.info("发货单新增推送U8结果"+result);
@ -797,8 +818,10 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
delete.put("billid", UUID.randomUUID());
delete.put("AccId", AccId);
delete.put("cVoucherId", dlId);
//删除
String resultDelete = U8Util.sengBillToU8(delete.toString(), "8000110017");
if(StrUtil.isNotEmpty(dlId)){
//删除
String resultDelete = U8Util.sengBillToU8(delete.toString(), "8000110017");
}
//删除之后直接返回失败信息
logger.info("新增失败:"+e.getMessage());
return BaseU8Result.getFailureMessageEntity("新增失败请联系U8管理员");
@ -1222,7 +1245,7 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
return json;
}
/**
/**
*
* @content 获取删除JSON
* @className: Administrator
@ -1242,8 +1265,8 @@ public class DeliveryOrderServiceImpl extends BaseService<DeliveryOrderEntity,St
return json;
}
/**
*
/**
*
* @content 发货单部分作废-红字发货单-新增
* @className: Administrator
* @author laborer

View File

@ -34,4 +34,8 @@ public interface IOtherReceiptDao extends IBaseDao<OtherReceiptEntity,String> {
*/
int updateState(OtherReceiptEntity entity);
int updateModify(OtherReceiptEntity entity);
int insertLog(OtherReceiptEntity entity);
}

View File

@ -24,4 +24,8 @@ public interface IOtherReceiptDetailDao extends IBaseDao<OtherReceiptDetailEntit
*/
List<OtherReceiptDetailEntity> getU8OtherReceipt(OtherReceiptDetailEntity line);
List<OtherReceiptDetailEntity> getU8OtherReceiptElse(OtherReceiptDetailEntity line);
int insertU8Log(OtherReceiptDetailEntity entity);
}

View File

@ -29,4 +29,16 @@ public class OtherReceiptDaoImpl extends MybatisGenericDao<OtherReceiptEntity,St
public int updateState(OtherReceiptEntity entity) {
return super.update("com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDaoImpl.entity_update", entity);
}
@DS("#entity.dataSourceCode")
@Override
public int updateModify(OtherReceiptEntity entity) {
return super.update("com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDaoImpl.entity_modify", entity);
}
@DS("#entity.dataSourceCode")
@Override
public int insertLog(OtherReceiptEntity entity) {
return super.insert("com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDaoImpl.entity_insert_log", entity);
}
}

View File

@ -23,4 +23,16 @@ public class OtherReceiptDetailDaoImpl extends MybatisGenericDao<OtherReceiptDet
public List<OtherReceiptDetailEntity> getU8OtherReceipt(OtherReceiptDetailEntity entity) {
return (List<OtherReceiptDetailEntity>) super.selectList("com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDetailDaoImpl.entity_list_base",entity);
}
@DS("#entity.dataSourceCode")
@Override
public List<OtherReceiptDetailEntity> getU8OtherReceiptElse(OtherReceiptDetailEntity entity) {
return (List<OtherReceiptDetailEntity>) super.selectList("com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDetailDaoImpl.entity_list_else",entity);
}
@DS("#entity.dataSourceCode")
@Override
public int insertU8Log(OtherReceiptDetailEntity entity) {
return super.insert("com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDetailDaoImpl.entity_insert_log", entity);
}
}

View File

@ -20,6 +20,7 @@ public class OtherReceiptDetailEntity extends BaseEntity {
private String inum;//
private String iAmount_f;//
private String cLink;//
private Integer logId;
public String getAccId() {
return AccId;
@ -92,4 +93,12 @@ public class OtherReceiptDetailEntity extends BaseEntity {
public void setcLink(String cLink) {
this.cLink = cLink;
}
public Integer getLogId() {
return logId;
}
public void setLogId(Integer logId) {
this.logId = logId;
}
}

View File

@ -20,8 +20,18 @@
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.otherreceipt.entity.OtherReceiptDetailEntity">
select * from kjs_external.dbo.v_hzya_other_receipt_details
where cLink = #{cLink} and AccId = #{AccId}
</select>
<select id="entity_list_else" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.otherreceipt.entity.OtherReceiptDetailEntity">
select * from kjs_external.dbo.v_hzya_other_receipt_details_update
where id = #{logId}
</select>
<insert id="entity_insert_log" parameterType="com.hzya.frame.u8.otherreceipt.entity.OtherReceiptDetailEntity" >
insert into kjs_external.dbo.other_receipt_details_log(
[id],[AccId],[AccCode],[cinvcode],[cinvname],[iquantity],[cdlcode],[inum],[iAmount_f],[cLink])
values(
#{logId},#{AccId},#{AccCode},#{cinvcode},#{cinvname},#{iquantity},#{cdlcode},#{inum},#{iAmount_f},#{cLink})
</insert>
</mapper>

View File

@ -23,6 +23,7 @@ public class OtherReceiptEntity extends BaseEntity {
private String cLink;
private String state;
private String cDigest;
private String orderType;
public String getcDigest() {
return cDigest;
@ -96,6 +97,14 @@ public class OtherReceiptEntity extends BaseEntity {
this.syncFlag = syncFlag;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
private List<OtherReceiptDetailEntity>OtherReceiptDetailEntity;
public List<com.hzya.frame.u8.otherreceipt.entity.OtherReceiptDetailEntity> getOtherReceiptDetailEntity() {

View File

@ -2,6 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.otherreceipt.dao.impl.OtherReceiptDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.otherreceipt.entity.OtherReceiptEntity">
<result property="id" column="id" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="cvouchid" column="cvouchid" />
@ -10,6 +11,7 @@
<result property="syncFlag" column="sync_flag" />
<result property="cLink" column="cLink" />
<result property="cDigest" column="cDigest" />
<result property="orderType" column="orderType" />
</resultMap>
<sql id="OtherReceiptEntity_Base_Column_List">
@ -28,4 +30,15 @@
where cLink = #{cLink}
</update>
<update id="entity_modify" parameterType="com.hzya.frame.u8.otherreceipt.entity.OtherReceiptEntity">
update ${AccCode}.dbo.Ap_Vouch set modify_flag_time = getdate()
where cLink = #{cLink}
</update>
<insert id="entity_insert_log" parameterType="com.hzya.frame.u8.otherreceipt.entity.OtherReceiptEntity" useGeneratedKeys="true" keyProperty="id">
insert into kjs_external.dbo.other_receipt_log(
[AccId],[AccCode],[ids],[cLink],[cvouchid],[cCusCode],[sync_flag],[cDigest],[orderType])
values (#{AccId},#{AccCode},#{ids},#{cLink},#{cvouchid},#{cCusCode},#{syncFlag},#{cDigest},#{orderType})
</insert>
</mapper>

View File

@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -78,9 +79,17 @@ public class OtherReceiptServiceImpl extends BaseService<OtherReceiptEntity,Stri
logger.info("其他应收单对象{}",JSONObject.toJSONString(sale));
line.setcLink(id);
line.setAccId(sale.getAccId());
if (sale.getId() != null) {
line.setLogId(Integer.parseInt(sale.getId()));
}
line.setDataSourceCode(requestJson.getString("db_code"));
logger.info("其他应收单明细查询{}",JSONObject.toJSONString(line));
List<OtherReceiptDetailEntity> lineList = otherReceiptDetailDao.getU8OtherReceipt(line);
List<OtherReceiptDetailEntity> lineList = new ArrayList<>();
if (sale.getOrderType() == null || sale.getOrderType().equals("正常")){
lineList = otherReceiptDetailDao.getU8OtherReceipt(line);
}else{
lineList = otherReceiptDetailDao.getU8OtherReceiptElse(line);
}
logger.info("其他应收单明细查询数据{}",JSONObject.toJSONString(lineList));
sale.setOtherReceiptDetailEntity(lineList);
logger.info("组装数据");
@ -115,6 +124,28 @@ public class OtherReceiptServiceImpl extends BaseService<OtherReceiptEntity,Stri
e.printStackTrace();
}
otherReceiptDao.updateState(sale);
//当推送成功将数据存入u8库中
try{
if (sale.getState().equals("Y")){
if (sale.getOrderType().equals("修改")){
otherReceiptDao.updateModify(sale);
}
otherReceiptDao.insertLog(sale);
sale.getOtherReceiptDetailEntity().forEach(saleDetail -> {
try {
saleDetail.setDataSourceCode(requestJson.getString("db_code"));
saleDetail.setLogId(Integer.parseInt(sale.getId()));
otherReceiptDetailDao.insertU8Log(saleDetail);
} catch (Exception e) {
logger.error("保存写入u8明细日志失败" + e.getMessage());
e.printStackTrace();
}
});
}
}catch (Exception e){
logger.error("保存写入u8日志失败"+e.getMessage());
e.printStackTrace();
}
}
} catch (Exception e) {
logger.error("其他应收单执行失败"+e.getMessage());

View File

@ -1,6 +1,7 @@
package com.hzya.frame.u8.receipt.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.otherreceipt.entity.OtherReceiptEntity;
import com.hzya.frame.u8.receipt.entity.ReceiptEntity;
import java.util.List;
@ -34,4 +35,8 @@ public interface IReceiptDao extends IBaseDao<ReceiptEntity,String> {
*/
int updateState(ReceiptEntity sale);
int modifyState(ReceiptEntity sale);
int insertLog(ReceiptEntity entity);
}

View File

@ -2,6 +2,7 @@ package com.hzya.frame.u8.receipt.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.otherreceipt.entity.OtherReceiptEntity;
import com.hzya.frame.u8.receipt.dao.IReceiptDao;
import com.hzya.frame.u8.receipt.entity.ReceiptEntity;
import org.springframework.stereotype.Repository;
@ -28,4 +29,16 @@ public class ReceiptDaoImpl extends MybatisGenericDao<ReceiptEntity,String> impl
public int updateState(ReceiptEntity entity) {
return super.update("com.hzya.frame.u8.receipt.dao.impl.ReceiptDaoImpl.entity_update",entity);
}
@DS("#entity.dataSourceCode")
@Override
public int modifyState(ReceiptEntity entity) {
return super.update("com.hzya.frame.u8.receipt.dao.impl.ReceiptDaoImpl.entity_modify",entity);
}
@DS("#entity.dataSourceCode")
@Override
public int insertLog(ReceiptEntity entity) {
return super.insert("com.hzya.frame.u8.receipt.dao.impl.ReceiptDaoImpl.entity_insert_log", entity);
}
}

View File

@ -25,6 +25,8 @@ public class ReceiptEntity extends BaseEntity {
private String state;//状态
private String AccCode;//账套编码
private String ids;//
private String cDigest;
private String orderType;
public String getIds() {
return ids;
@ -123,4 +125,20 @@ public class ReceiptEntity extends BaseEntity {
public void setState(String state) {
this.state = state;
}
public String getcDigest() {
return cDigest;
}
public void setcDigest(String cDigest) {
this.cDigest = cDigest;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
}

View File

@ -14,6 +14,8 @@
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="ids" column="ids" />
<result property="cDigest" column="cDigest" />
<result property="orderType" column="orderType" />
</resultMap>
<sql id="ReceiptEntity_Base_Column_List">
@ -32,4 +34,18 @@
update ${AccCode}.dbo.Ap_CloseBill set sync_flag = #{state}
where iID = #{iID}
</update>
<!--通过主键修改方法-->
<update id="entity_modify" parameterType="com.hzya.frame.u8.receipt.entity.ReceiptEntity">
update ${AccCode}.dbo.Ap_CloseBill set modify_flag_time = getdate()
where iID = #{iID}
</update>
<insert id="entity_insert_log" parameterType="com.hzya.frame.u8.receipt.entity.ReceiptEntity" useGeneratedKeys="true" keyProperty="id">
insert into kjs_external.dbo.receipt_log(
[AccId],[AccCode],[iID],[ids],[cvouchid],[dvouchdate],[ccuscode],[ccusname],[iamount_f]
,[csscode],[sync_flag],[cDigest],[orderType])
values (#{AccId},#{AccCode},#{iID},#{ids},#{cvouchid},#{dvouchdate},#{ccuscode},#{ccusname},#{iamount_f},
#{csscode},#{syncFlag},#{cDigest},#{orderType})
</insert>
</mapper>

View File

@ -101,6 +101,18 @@ public class ReceiptServiceImpl extends BaseService<ReceiptEntity,String> implem
sale.setState("N");
}
sale.setDataSourceCode(requestJson.getString("db_code"));
// 日志写入u8扩展库
try{
if (sale.getState().equals("Y")) {
if (sale.getOrderType().equals("修改")){
saleOutDao.modifyState(sale);
}
saleOutDao.insertLog(sale);
}
}catch (Exception e){
logger.error("保存写入u8日志失败"+e.getMessage());
e.printStackTrace();
}
try{
saveLog(interId, logDetails, flag);
}catch (Exception e){
@ -169,6 +181,7 @@ public class ReceiptServiceImpl extends BaseService<ReceiptEntity,String> implem
head.put("iamount_f",sale.getIamount_f());
head.put("csscode",sale.getCsscode());
head.put("syncFlag",sale.getSyncFlag());
head.put("cDigest",sale.getcDigest());
main.put("head",head);
return main;
}

View File

@ -309,7 +309,7 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
//发货退货单主表@
//发货退货单主表
String sqlSelDisList = "select DLID as 'dlid',DLID as 'cdlcode' ,cDLCode as 'cbuscode' ,cDepCode as 'cdepcode' ,cPersonCode as 'cpersoncode' ,cCusCode as 'ccuscode'," +
"cCusCode as 'cinvoicecompany',cSTCode as 'cstcode ,'32' as 'cvouchtype' ,'普通销售' as 'cbustype' ,'发货单' as 'csource' ,GETDATE() as 'ddate' ,'form WMS' as 'cmemo'," +
"cCusCode as 'cinvoicecompany',cSTCode as 'cstcode' ,'32' as 'cvouchtype' ,'普通销售' as 'cbustype' ,'发货单' as 'csource' ,GETDATE() as 'ddate' ,'form WMS' as 'cmemo'," +
"case when bReturnFlag = 1 then '多组织-红字采购入库' else '多组织-采购订单' end as 'cdefine1' " +
"from "+AccCode+".dbo.DispatchList " +
"where cDLCode = '"+jHead.getString("cbuscode")+"'";
@ -514,11 +514,11 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
}
@Override
public U8ResultEntity addSaleOutT(JSONObject parm) {
public U8ResultEntity addSaleOutT(JSONObject jsonObject) {
String billCode = "";
String dlId = "";
String AccId = "";
JSONObject jsonObject = parm.getJSONObject("jsonStr");
// JSONObject jsonObject = parm.getJSONObject("jsonStr");
logger.info("接收到的参数"+jsonObject.toString());
StringBuffer resultStr = new StringBuffer();//回传json
try {
@ -566,21 +566,38 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
if(StrUtil.isEmpty(AccCode)){
return BaseU8Result.getFailureMessageEntity("获取账套号有误,请联系管理员");
}
String ccodeSql = "SELECT ISNULL(max(CONVERT(DECIMAL(20, 0), ccode))+1, CONVERT (VARCHAR (20),ddate,112) + '0001') as ccode " +
"FROM "+AccCode+".dbo.RdRecord32 " +
"WHERE cCode LIKE CONVERT (VARCHAR (20),'"+DateUtil.format(jHead.getDate("ddate"),"yyyyMMdd")+"',112) + '%'" +
"AND len(cCode) = 12 GROUP BY ddate";
//查询账套中的发货单信息
// SaleInvEntity U8Obj = new SaleInvEntity();
// U8Obj.setDataSourceCode("YONYOUU8NEW");
List<HashMap<String, Object>> ccodeHashMaps = saleInvDao.getU8BillData(ccodeSql,U8Obj);
if(CollectionUtils.isNotEmpty(ccodeHashMaps)){
HashMap<String, Object> ccodeObj= ccodeHashMaps.get(0);
jHead.put("ccode",ccodeObj.get("ccode"));
}else{
jHead.put("ccode",DateUtil.format(jHead.getDate("ddate"),"yyyyMMdd")+"0001");
}
jHead.put("csource","发货单");
//验证单号唯一
String cdefine5 = jsonObject.getString("cdefine5");
if(StrUtil.isNotEmpty(cdefine5)){
String cdefine5Sql = "select cdefine5 from "+AccCode+".dbo.rdrecord32 where cdefine5 = '"+cdefine5+"'";
List<HashMap<String, Object>> cdefine5Map = saleInvDao.getU8BillData(cdefine5Sql,U8Obj);
if(CollectionUtils.isNotEmpty(cdefine5Map) ){
return BaseU8Result.getFailureMessageEntity("单号重复,请检查:"+cdefine5);
}
}
// String cdefine5 = jsonObject.getString("cdefine5");
// if(StrUtil.isNotEmpty(cdefine5)){
// String cdefine5Sql = "select cdefine5 from "+AccCode+".dbo.rdrecord32 where cdefine5 = '"+cdefine5+"'";
// List<HashMap<String, Object>> cdefine5Map = saleInvDao.getU8BillData(cdefine5Sql,U8Obj);
// if(CollectionUtils.isNotEmpty(cdefine5Map) ){
// return BaseU8Result.getFailureMessageEntity("单号重复,请检查:"+cdefine5);
// }
// }
//发货退货单主表@
//发货退货单主表
String sqlSelDisList = "select DLID as 'dlid',DLID as 'cdlcode' ,cDLCode as 'cbuscode' ,cDepCode as 'cdepcode' ,cPersonCode as 'cpersoncode' ,cCusCode as 'ccuscode'," +
"cCusCode as 'cinvoicecompany',cSTCode as 'cstcode ,'32' as 'cvouchtype' ,'普通销售' as 'cbustype' ,'发货单' as 'csource' ,GETDATE() as 'ddate' ,'form WMS' as 'cmemo'," +
"cCusCode as 'cinvoicecompany',cSTCode as 'cstcode' ,'32' as 'cvouchtype' ,'普通销售' as 'cbustype' ,'发货单' as 'csource' ,GETDATE() as 'ddate' ,'form WMS' as 'cmemo'," +
"case when bReturnFlag = 1 then '多组织-红字采购入库' else '多组织-采购订单' end as 'cdefine1' " +
"from "+AccCode+".dbo.DispatchList " +
"where cDLCode = '"+jHead.getString("cbuscode")+"'";
@ -635,7 +652,10 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
//表体
JSONArray body = new JSONArray();
JSONArray jBody = jsonObject.getJSONArray("body");
int k = 1;
for (int i = 0; i < jBody.size(); i++) {
System.out.println("错误的行"+k);
k++;
JSONObject jBodyObj = jBody.getJSONObject(i);
if(StrUtil.isEmpty(jBodyObj.getString("cinvcode"))){
resultStr.append("材料编码不能为空 行:"+i+1) ;
@ -659,22 +679,24 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
}
}
//发货退货单子表@
String sqlSelDisLists = " select idlsid from "+AccCode+".dbo.DispatchList dl left join "+AccCode+".dbo.DispatchLists dls on dls.DLID = dl.DLID " +
String sqlSelDisLists = " select idlsid,irowno from "+AccCode+".dbo.DispatchList dl left join "+AccCode+".dbo.DispatchLists dls on dls.DLID = dl.DLID " +
"where cDLCode = '"+jBodyObj.getString("cbdlcode")+"" +
"' and cInvCode = '"+jBodyObj.getString("cinvcode")+"" +
"' and irowno = '"+jBodyObj.getString("cdblrowno")+"'";
"' and cInvCode = '"+jBodyObj.getString("cinvcode")+"'" ;
// "' and irowno = '"+jBodyObj.getString("cdblrowno")+"'";
List<HashMap<String, Object>> selDisDetailsListMap = saleInvDao.getU8BillData(sqlSelDisLists,U8Obj);
if(CollectionUtils.isEmpty(selDisDetailsListMap) ){
return BaseU8Result.getFailureMessageEntity("发货单子表查询失败"+jHead.getString("cbuscode")+"发货单表体存货"+jBodyObj.getString("cinvcode")+"行号"+jBodyObj.getString("cdblrowno")+"不存在");
if(CollectionUtils.isEmpty(selDisDetailsListMap)&& selDisDetailsListMap.size()==0){
continue;
// return BaseU8Result.getFailureMessageEntity("发货单子表查询失败"+jHead.getString("cbuscode")+"发货单表体存货"+jBodyObj.getString("cinvcode")+"行号"+jBodyObj.getString("cdblrowno")+"不存在");
}
HashMap<String, Object> selDisDetails= hashMaps.get(0);
HashMap<String, Object> selDisDetails= selDisDetailsListMap.get(0);
if(StrUtil.isEmpty(jBodyObj.getString("idlsid"))){
jBodyObj.put("idlsid",selDisDetails.get("idlsid"));
jBodyObj.put("irowno",selDisDetails.get("irowno"));
}
//获取辅计量单位
String dtInvSql = "select cInvCode,cInvName,cInvStd,Inv.cComUnitCode,cInvCCode,iChangRate, cPUComUnitCode,cSAComUnitCode,cProductUnit,cSTComUnitCode " +
String dtInvSql = "select inv.bInvBatch,cInvCode,cInvName,cInvStd,Inv.cComUnitCode,cInvCCode,iChangRate, cPUComUnitCode,cSAComUnitCode,cProductUnit,cSTComUnitCode " +
"from "+AccCode+".dbo.Inventory Inv " +
"left join "+AccCode+".dbo.ComputationUnit Com On Inv.cComUnitCode = Com.cComUnitCode " +
"where cInvCode='" + jBodyObj.getString("cinvcode") +"'";
@ -689,15 +711,19 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
String sqlCassUnit = "select * from "+AccCode+".dbo.ComputationUnit where cComUnitCode='" +dtInvObj.get("cSTComUnitCode")+"'";
List<HashMap<String, Object>> dtUnit = saleInvDao.getU8BillData(sqlCassUnit,U8Obj);
if(CollectionUtils.isEmpty(dtUnit) ){
return BaseU8Result.getFailureMessageEntity("查询单位失败,请检查,行号:"+i+1);
// return BaseU8Result.getFailureMessageEntity("查询单位失败,请检查,行号:"+i+1);
jBodyObj.put("iinvexchrate",0);
}else {
HashMap<String, Object> dtUnitObj= dtUnit.get(0);
jBodyObj.put("iinvexchrate",dtUnitObj.get("iChangRate"));
jBodyObj.put("inum",jBodyObj.getBigDecimal("iquantity").divide(jBodyObj.getBigDecimal("iinvexchrate"),6, RoundingMode.HALF_UP));
}
HashMap<String, Object> dtUnitObj= dtUnit.get(0);
jBodyObj.put("iinvexchrate",dtUnitObj.get("iChangRate"));
jBodyObj.put("inum",jBodyObj.getBigDecimal("iquantity").divide(new BigDecimal(String.valueOf(dtUnitObj.get("iChangRate"))),6, RoundingMode.HALF_UP));
}
jBodyObj.put("irowno",i+1);
//默认字段
//是否需要开票
if(StrUtil.isEmpty(jBodyObj.getString("bneedbill"))){
@ -728,6 +754,15 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
// }
// }
// }
jBodyObj.put("cProBatch",0);
// jBodyObj.put("csource","发货单");
// jBodyObj.put("cbustype","普通销售");
jBodyObj.put("cProBatch",0);
String bInvBatch = String.valueOf(dtInvObj.get("bInvBatch"));
if("true".equals(bInvBatch)){
jBodyObj.put("cbatch",0);
}
body.add(jBodyObj);
}
JSONObject main = new JSONObject();
@ -777,8 +812,10 @@ public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implem
delete.put("billid", UUID.randomUUID());
delete.put("AccId", AccId);
delete.put("cVoucherId", billCode);
if(StrUtil.isNotEmpty(billCode)){
String resultDelete = U8Util.sengBillToU8(delete.toString(), "8000110023");
}
//删除
String resultDelete = U8Util.sengBillToU8(delete.toString(), "8000110023");
logger.info("新增失败:"+e.getMessage());
return BaseU8Result.getFailureMessageEntity("新增失败请联系U8管理员");
}