新增对接CRM插件

This commit is contained in:
yuqh 2024-11-05 14:29:29 +08:00
parent 87d554ba64
commit 2400d08a93
60 changed files with 3567 additions and 0 deletions

View File

@ -0,0 +1,37 @@
package com.hzya.frame.u8.otherin.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.otherin.entity.OtherInEntity;
import java.util.List;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherInDao extends IBaseDao<OtherInEntity,String> {
/**
*
* @content 获取U8C其他入库单数据
* @className: Administrator
* @author laborer
* @date 2024-10-18 14:52
*
*/
List<OtherInEntity> getU8otherIn(OtherInEntity entity);
/**
*
* @content 修改状态
* @className: Administrator
* @author laborer
* @date 2024-10-18 15:10
*
*/
int updateState(OtherInEntity sale);
}

View File

@ -0,0 +1,27 @@
package com.hzya.frame.u8.otherin.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.otherin.entity.OtherInDetailEntity;
import java.util.List;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherInDetailDao extends IBaseDao<OtherInDetailEntity,String> {
/**
*
* @content 获取其他入库单的明细数据
* @className: Administrator
* @author laborer
* @date 2024-10-18 15:02
*
*/
List<OtherInDetailEntity> getU8OtherInLine(OtherInDetailEntity line);
}

View File

@ -0,0 +1,31 @@
package com.hzya.frame.u8.otherin.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.otherin.dao.IOtherInDao;
import com.hzya.frame.u8.otherin.entity.OtherInEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "OtherInDaoImpl")
public class OtherInDaoImpl extends MybatisGenericDao<OtherInEntity,String> implements IOtherInDao {
@DS("#entity.dataSourceCode")
@Override
public List<OtherInEntity> getU8otherIn(OtherInEntity entity) {
return (List<OtherInEntity>) super.selectList("com.hzya.frame.u8.otherin.dao.impl.OtherInDaoImpl.entity_list_base",entity);
}
@Override
public int updateState(OtherInEntity entity) {
return super.update("com.hzya.frame.u8.otherin.dao.impl.OtherInDaoImpl.entity_update",entity);
}
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8.otherin.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.otherin.dao.IOtherInDetailDao;
import com.hzya.frame.u8.otherin.entity.OtherInDetailEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "OtherInDetailDaoImpl")
public class OtherInDetailDaoImpl extends MybatisGenericDao<OtherInDetailEntity,String> implements IOtherInDetailDao {
@DS("#entity.dataSourceCode")
@Override
public List<OtherInDetailEntity> getU8OtherInLine(OtherInDetailEntity entity) {
return (List<OtherInDetailEntity>) super.selectList("com.hzya.frame.u8.otherin.dao.impl.OtherInDetailDaoImpl.entity_list_base",entity);
}
}

View File

@ -0,0 +1,68 @@
package com.hzya.frame.u8.otherin.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class OtherInDetailEntity extends BaseEntity {
private String cinvcode;//存货编码
private String iquantity;//数量
private String itvrowno;//调拨单行号
private String irowno;//单据体行号
private String AccCode;//账套编码
private String AccId;//账套号
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
public String getCinvcode() {
return cinvcode;
}
public void setCinvcode(String cinvcode) {
this.cinvcode = cinvcode;
}
public String getIquantity() {
return iquantity;
}
public void setIquantity(String iquantity) {
this.iquantity = iquantity;
}
public String getItvrowno() {
return itvrowno;
}
public void setItvrowno(String itvrowno) {
this.itvrowno = itvrowno;
}
public String getIrowno() {
return irowno;
}
public void setIrowno(String irowno) {
this.irowno = irowno;
}
}

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.otherin.dao.impl.OtherInDetailDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.otherin.entity.OtherInDetailEntity">
<result property="cinvcode" column="cinvcode" />
<result property="iquantity" column="iquantity" />
<result property="itvrowno" column="itvrowno" />
<result property="irowno" column="irowno" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
</resultMap>
<sql id="OtherInDetailEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.otherin.entity.OtherInDetailEntity">
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
body.cinvcode,
body.iquantity,
TransVouchs.irowno as itvrowno,
body.irowno,
body.id as id
from UFDATA_001_2023.dbo.RdRecords08 body
left join UFDATA_001_2023.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
body.cinvcode,
body.iquantity,
TransVouchs.irowno as itvrowno,
body.irowno,
body.id as id
from UFDATA_002_2024.dbo.RdRecords08 body
left join UFDATA_002_2024.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
body.cinvcode,
body.iquantity,
TransVouchs.irowno as itvrowno,
body.irowno,
body.id as id
from UFDATA_004_2024.dbo.RdRecords08 body
left join UFDATA_004_2024.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
body.cinvcode,
body.iquantity,
TransVouchs.irowno as itvrowno,
body.irowno,
body.id as id
from UFDATA_005_2024.dbo.RdRecords08 body
left join UFDATA_005_2024.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
union all
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
body.cinvcode,
body.iquantity,
TransVouchs.irowno as itvrowno,
body.irowno,
body.id as id
from UFDATA_201_2023.dbo.RdRecords08 body
left join UFDATA_201_2023.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
)m1
where id = #{id} and AccId = #{AccId}
</select>
</mapper>

View File

@ -0,0 +1,120 @@
package com.hzya.frame.u8.otherin.entity;
import com.hzya.frame.web.entity.BaseEntity;
import java.util.List;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class OtherInEntity extends BaseEntity {
private String ccode;//入库单号
private String cbuscode;//调拨单号
private String crdcode;//入库类别编码
private String cwhcode;//仓库编码
private String cmaker;//制单人
private String AccId;//账套
private String id;//
private String state;//
private String AccCode;//
private String ids;//
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
private List<OtherInDetailEntity>otherInDetailEntityList;
public List<OtherInDetailEntity> getOtherInDetailEntityList() {
return otherInDetailEntityList;
}
public void setOtherInDetailEntityList(List<OtherInDetailEntity> otherInDetailEntityList) {
this.otherInDetailEntityList = otherInDetailEntityList;
}
public String getCcode() {
return ccode;
}
public void setCcode(String ccode) {
this.ccode = ccode;
}
public String getCbuscode() {
return cbuscode;
}
public void setCbuscode(String cbuscode) {
this.cbuscode = cbuscode;
}
public String getCrdcode() {
return crdcode;
}
public void setCrdcode(String crdcode) {
this.crdcode = crdcode;
}
public String getCwhcode() {
return cwhcode;
}
public void setCwhcode(String cwhcode) {
this.cwhcode = cwhcode;
}
public String getCmaker() {
return cmaker;
}
public void setCmaker(String cmaker) {
this.cmaker = cmaker;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.otherin.dao.impl.OtherInDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.otherin.entity.OtherInEntity">
<result property="ccode" column="ccode" />
<result property="cbuscode" column="cbuscode" />
<result property="crdcode" column="crdcode" />
<result property="cwhcode" column="cwhcode" />
<result property="cmaker" column="cmaker" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="id" column="id" />
<result property="ids" column="ids" />
</resultMap>
<sql id="OtherInEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.otherin.entity.OtherInEntity">
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
id,
'1001'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
ccuscode,
cHandler
from UFDATA_001_2023.dbo.RdRecord08
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
id,
'1002'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
ccuscode,
cHandler
from UFDATA_002_2024.dbo.RdRecord08
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
id,
'1004'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
ccuscode,
cHandler
from UFDATA_004_2024.dbo.RdRecord08
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
id,
'1005'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
ccuscode,
cHandler
from UFDATA_005_2024.dbo.RdRecord08
union all
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
id,
'1201'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
ccuscode,
cHandler
from UFDATA_201_2023.dbo.RdRecord08
)m1 where cHandler is not null
<if test="ids != null and ids != ''">and ids = #{ids} </if>
</select>
<!--通过主键修改方法-->
<update id="entity_update" parameterType="com.hzya.frame.u8.otherin.entity.OtherInEntity">
update #{AccCode}.dbo.RdRecord08 set sync_flag = #{state}
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,15 @@
package com.hzya.frame.u8.otherin.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.otherin.entity.OtherInDetailEntity;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherInDetaiService extends IBaseService<OtherInDetailEntity,String> {
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8.otherin.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.otherin.entity.OtherInEntity;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherInService extends IBaseService<OtherInEntity,String> {
/**
*
* @content 获取U8其他入库单数据推送CRM
* @className: Administrator
* @author laborer
* @date 2024-10-18 13:45
*
*/
void getU8OtherInToCrm(JSONObject requestJson);
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.u8.otherin.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.u8.otherin.entity.OtherInDetailEntity;
import com.hzya.frame.u8.otherin.service.IOtherInDetaiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "OtherInDetaiServiceImpl")
public class OtherInDetaiServiceImpl extends BaseService<OtherInDetailEntity,String> implements IOtherInDetaiService {
Logger logger = LogManager.getLogger(getClass());
}

View File

@ -0,0 +1,201 @@
package com.hzya.frame.u8.otherin.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.crm.util.CrmUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.u8.otherin.dao.IOtherInDao;
import com.hzya.frame.u8.otherin.dao.IOtherInDetailDao;
import com.hzya.frame.u8.otherin.entity.OtherInDetailEntity;
import com.hzya.frame.u8.otherin.entity.OtherInEntity;
import com.hzya.frame.u8.otherin.service.IOtherInService;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
*
* @content 其他入库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "OtherInServiceImpl")
public class OtherInServiceImpl extends BaseService<OtherInEntity,String> implements IOtherInService {
Logger logger = LogManager.getLogger(getClass());
@Autowired
private IOtherInDao otherInDao;
@Autowired
private IOtherInDetailDao otherInDetailDao;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
/**
*
* @content 获取U8其他入库单数据推送CRM
* @className: Administrator
* @author laborer
* @date 2024-10-18 13:46
*
*/
@Override
public void getU8OtherInToCrm(JSONObject requestJson) {
//获取重推信息id并记录日志
JSONObject requestJsonObj = JSON.parseObject(requestJson.toString(),JSONObject.class);
String interId = requestJsonObj.getString("integration_task_living_details_id");
logger.info("U8其他入库单重推解析后"+requestJsonObj.toString());
logger.info("U8其他入库单推送CRM重新执行的任务主键"+interId);
//更换数据源
JsonResultEntity resultEntity = new JsonResultEntity();
OtherInEntity entity = new OtherInEntity();
requestJson.put("db_code","YONYOUU8");
entity.setDataSourceCode(requestJson.getString("db_code"));
//根据重推信息id查询该条重推记录信息
IntegrationTaskLivingDetailsEntity oldMsg = new IntegrationTaskLivingDetailsEntity();
if(StrUtil.isNotEmpty(interId)){
oldMsg = taskLivingDetailsService.get(interId);
}
String rootAppPk = oldMsg.getRootAppPk();
entity.setIds(rootAppPk);
StrUtil.isEmpty(rootAppPk);//entity.setQueryState("查询");
//如果是重推是否通过entity传入的id只能查到一条数据
//entity.setId("-8845102890648320822");
List<OtherInEntity> soleList = otherInDao.getU8otherIn(entity);
logger.info("销售出库查询数据{}",JSONObject.toJSONString(soleList));
if(CollectionUtils.isNotEmpty(soleList)){
soleList.forEach(sale -> {
try{
//获取明细数据进行拼接
String id = sale.getId();
if(!StrUtil.isEmpty(id)){
OtherInDetailEntity line = new OtherInDetailEntity();
line.setId(id);
line.setAccId(sale.getAccId());
line.setDataSourceCode(requestJson.getString("db_code"));
List<OtherInDetailEntity> lineList = otherInDetailDao.getU8OtherInLine(line);
logger.info("其他入库单明细查询数据{}",JSONObject.toJSONString(lineList));
sale.setOtherInDetailEntityList(lineList);
logger.info("组装数据");
JSONObject main = bindingAdd(sale);
logger.info("销售出库推送数据:"+main.toString());
String result = CrmUtil.sendU8TOCrmEsb(main.toString(), "8000340003");
logger.info("销售出库推送结果:"+result);
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(sale.getIds());
logDetails.setRootAppBill(sale.getCcode());
logDetails.setNewTransmitInfo(result);
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(JSON.toJSONString(sale));
logDetails.setPluginId("SaleConPlugin");
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.getString("code").equals("0");
if(flag){
// 推送成功更新状态
sale.setState("Y");
logDetails.setNewTransmitInfo("推送成功");
}else{
// 推送失败
sale.setState("N");
}
sale.setDataSourceCode(requestJson.getString("db_code"));
try{
saveLog(interId, logDetails, flag);
}catch (Exception e){
logger.error("保存日志失败"+e.getMessage());
otherInDao.updateState(sale);
e.printStackTrace();
}
otherInDao.updateState(sale);
}
} catch (Exception e) {
logger.error("销售出库执行失败"+e.getMessage());
e.printStackTrace();
}
});
}
}
/**
*
* @content 保存日志信息
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:27
*
*/
private void saveLog(String interId, IntegrationTaskLivingDetailsEntity logDetails, boolean flag) throws Exception {
if(StrUtil.isEmpty(interId)){
if(flag){
//首推成功
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else{
//首推失败
taskLivingDetailsService.saveLogToFail(logDetails);
}
}else{
logDetails.setId(interId);
if(flag){
//重推成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else{
//重推失败把失败信息更新到重推表中
taskLivingDetailsService.updateLogFailToSuccess(logDetails);
}
}
}
/**
*
* @content 组装推送参数
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:13
*
*/
private JSONObject bindingAdd(OtherInEntity sale) {
JSONObject main = new JSONObject();
main.put("AccId",sale.getAccId());
main.put("billid",sale.getId());
main.put("LoginDate", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
JSONObject head = new JSONObject();
head.put("ccode",sale.getCcode());
head.put("cbuscode",sale.getCbuscode());
head.put("crdcode",sale.getCrdcode());
head.put("cwhcode",sale.getCwhcode());
head.put("cmaker",sale.getCmaker());
JSONArray body = new JSONArray();
List<OtherInDetailEntity> lineList = sale.getOtherInDetailEntityList();
if(CollectionUtils.isNotEmpty(lineList)){
lineList.forEach(line -> {
JSONObject lineObj = new JSONObject();
lineObj.put("cinvcode",line.getCinvcode());
lineObj.put("iquantity",line.getIquantity());
lineObj.put("itvrowno",line.getItvrowno());
lineObj.put("irowno",line.getIrowno());
body.add(lineObj);
});
}
main.put("head",head);
main.put("body",body);
return main;
}
}

View File

@ -0,0 +1,37 @@
package com.hzya.frame.u8.otherout.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.otherout.entity.OtherOutEntity;
import java.util.List;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherOutDao extends IBaseDao<OtherOutEntity,String> {
/**
*
* @content 获取销售出库单数据
* @className: Administrator
* @author laborer
* @date 2024-10-18 15:18
*
*/
List<OtherOutEntity> getU8SaleOut(OtherOutEntity entity);
/**
*
* @content 修改推送状态
* @className: Administrator
* @author laborer
* @date 2024-10-18 15:22
*
*/
int updateState(OtherOutEntity sale);
}

View File

@ -0,0 +1,28 @@
package com.hzya.frame.u8.otherout.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity;
import java.util.List;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherOutDetailDao extends IBaseDao<OtherOutDetailEntity,String> {
/**
*
* @content 获取U8其他出库单行数据
* @param line
* @className: Administrator
* @author laborer
* @date 2024-10-18 15:20
*
*/
List<OtherOutDetailEntity> getU8otherOutLine(OtherOutDetailEntity line);
}

View File

@ -0,0 +1,31 @@
package com.hzya.frame.u8.otherout.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.otherout.dao.IOtherOutDao;
import com.hzya.frame.u8.otherout.entity.OtherOutEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "OtherOutDaoImpl")
public class OtherOutDaoImpl extends MybatisGenericDao<OtherOutEntity,String> implements IOtherOutDao {
@DS("#entity.dataSourceCode")
@Override
public List<OtherOutEntity> getU8SaleOut(OtherOutEntity entity) {
return (List<OtherOutEntity>) super.selectList("com.hzya.frame.u8.otherout.dao.impl.OtherOutDaoImpl.entity_list_base",entity);
}
@DS("#entity.dataSourceCode")
@Override
public int updateState(OtherOutEntity entity) {
return super.update("com.hzya.frame.u8.otherout.dao.impl.OtherOutDaoImpl.entity_update",entity);
}
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8.otherout.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.otherout.dao.IOtherOutDetailDao;
import com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "OtherOutDetailDaoImpl")
public class OtherOutDetailDaoImpl extends MybatisGenericDao<OtherOutDetailEntity,String> implements IOtherOutDetailDao {
@DS("#entity.dataSourceCode")
@Override
public List<OtherOutDetailEntity> getU8otherOutLine(OtherOutDetailEntity entity) {
return (List<OtherOutDetailEntity>) selectList("com.hzya.frame.u8.otherout.dao.impl.OtherOutDetailDaoImpl.entity_list_base",entity);
}
}

View File

@ -0,0 +1,49 @@
package com.hzya.frame.u8.otherout.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class OtherOutDetailEntity extends BaseEntity {
private String cinvcode;//存货编码
private String iquantity;//数量
private String AccCode;//账套编码
private String AccId;//账套号
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
public String getCinvcode() {
return cinvcode;
}
public void setCinvcode(String cinvcode) {
this.cinvcode = cinvcode;
}
public String getIquantity() {
return iquantity;
}
public void setIquantity(String iquantity) {
this.iquantity = iquantity;
}
}

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.otherout.dao.impl.OtherOutDetailDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity">
<result property="cinvcode" column="cinvcode" />
<result property="iquantity" column="iquantity" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
</resultMap>
<sql id="OtherOutDetailEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity">
select * from (
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
body.cinvcode,
body.iquantity
from UFDATA_201_2023.dbo.RdRecords09 body
left join UFDATA_201_2023.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
UNION ALL
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
body.cinvcode,
body.iquantity
from UFDATA_002_2024.dbo.RdRecords09 body
left join UFDATA_002_2024.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
UNION ALL
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
body.cinvcode,
body.iquantity
from UFDATA_004_2024.dbo.RdRecords09 body
left join UFDATA_004_2024.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
UNION ALL
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
body.cinvcode,
body.iquantity
from UFDATA_005_2024.dbo.RdRecords09 body
left join UFDATA_005_2024.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
UNION ALL
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
body.cinvcode,
body.iquantity
from UFDATA_201_2023.dbo.RdRecords09 body
left join UFDATA_201_2023.dbo.TransVouchs on body.iTrIds = TransVouchs.autoID
)m1
where id = #{id} and AccId = #{AccId}
</mapper>

View File

@ -0,0 +1,119 @@
package com.hzya.frame.u8.otherout.entity;
import com.hzya.frame.web.entity.BaseEntity;
import java.util.List;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class OtherOutEntity extends BaseEntity {
private String ccode;//入库单号
private String cbuscode;//调拨单号
private String crdcode;//入库类别编码
private String cwhcode;//仓库编码
private String cmaker;//制单人
private String AccId;//账套
private String id;//
private String state;//
private List<OtherOutDetailEntity>otherOutDetailEntityList;
private String AccCode;//账套编码
private String ids;//
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getCcode() {
return ccode;
}
public void setCcode(String ccode) {
this.ccode = ccode;
}
public String getCbuscode() {
return cbuscode;
}
public void setCbuscode(String cbuscode) {
this.cbuscode = cbuscode;
}
public String getCrdcode() {
return crdcode;
}
public void setCrdcode(String crdcode) {
this.crdcode = crdcode;
}
public String getCwhcode() {
return cwhcode;
}
public void setCwhcode(String cwhcode) {
this.cwhcode = cwhcode;
}
public String getCmaker() {
return cmaker;
}
public void setCmaker(String cmaker) {
this.cmaker = cmaker;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public List<OtherOutDetailEntity> getOtherOutDetailEntityList() {
return otherOutDetailEntityList;
}
public void setOtherOutDetailEntityList(List<OtherOutDetailEntity> otherOutDetailEntityList) {
this.otherOutDetailEntityList = otherOutDetailEntityList;
}
}

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.otherout.dao.impl.OtherOutDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.otherout.entity.OtherOutEntity">
<result property="ccode" column="ccode" />
<result property="cbuscode" column="cbuscode" />
<result property="crdcode" column="crdcode" />
<result property="cwhcode" column="cwhcode" />
<result property="cmaker" column="cmaker" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="id" column="id" />
<result property="ids" column="ids" />
</resultMap>
<sql id="OtherOutEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.otherout.entity.OtherOutEntity">
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
id,
'1001'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
cCusCode,
cHandler
from UFDATA_001_2023.dbo.RdRecord09
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
id,
'1002'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
cCusCode,
cHandler
from UFDATA_002_2024.dbo.RdRecord09
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
id,
'1004'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
cCusCode,
cHandler
from UFDATA_004_2024.dbo.RdRecord09
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
id,
'1005'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
cCusCode,
cHandler
from UFDATA_005_2024.dbo.RdRecord09
union all
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
id,
'1201'+CAST( id AS VARCHAR(100)) as ids,
ccode,
cbuscode,
crdcode,
cwhcode,
cmaker,
cCusCode,
cHandler
from UFDATA_201_2023.dbo.RdRecord09
)m1 where cHandler is not null
<if test="ids != null and ids != ''">and ids = #{ids} </if>
</select>
<!--通过主键修改方法-->
<update id="entity_update" parameterType="com.hzya.frame.u8.otherout.entity.OtherOutEntity">
update RdRecord09 set sync_flag = #{state}
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,15 @@
package com.hzya.frame.u8.otherout.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherOutDetaiService extends IBaseService<OtherOutDetailEntity,String> {
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8.otherout.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.otherout.entity.OtherOutEntity;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IOtherOutService extends IBaseService<OtherOutEntity,String> {
/**
*
* @content 获取其他出库单信息推送到CRM
* @className: Administrator
* @author laborer
* @date 2024-10-18 13:46
*
*/
void getU8OtherOutToCrm(JSONObject requestJson);
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.u8.otherout.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity;
import com.hzya.frame.u8.otherout.service.IOtherOutDetaiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "OtherOutDetaiServiceImpl")
public class OtherOutDetaiServiceImpl extends BaseService<OtherOutDetailEntity,String> implements IOtherOutDetaiService {
Logger logger = LogManager.getLogger(getClass());
}

View File

@ -0,0 +1,190 @@
package com.hzya.frame.u8.otherout.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.crm.util.CrmUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.u8.otherout.dao.IOtherOutDao;
import com.hzya.frame.u8.otherout.dao.IOtherOutDetailDao;
import com.hzya.frame.u8.otherout.entity.OtherOutDetailEntity;
import com.hzya.frame.u8.otherout.entity.OtherOutEntity;
import com.hzya.frame.u8.otherout.service.IOtherOutService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
*
* @content 其他出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "OtherOutServiceImpl")
public class OtherOutServiceImpl extends BaseService<OtherOutEntity,String> implements IOtherOutService {
Logger logger = LogManager.getLogger(getClass());
@Autowired
private IOtherOutDao otherOutDao;
@Autowired
private IOtherOutDetailDao otherOutDetailDao;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void getU8OtherOutToCrm(JSONObject requestJson) {
//获取重推信息id并记录日志
JSONObject requestJsonObj = JSON.parseObject(requestJson.toString(),JSONObject.class);
String interId = requestJsonObj.getString("integration_task_living_details_id");
logger.info("U8销售出库单重推解析后"+requestJsonObj.toString());
logger.info("U8销售出库单推送CRM重新执行的任务主键"+interId);
//更换数据源
JsonResultEntity resultEntity = new JsonResultEntity();
OtherOutEntity entity = new OtherOutEntity();
requestJson.put("db_code","YONYOUU8");
entity.setDataSourceCode(requestJson.getString("db_code"));
//根据重推信息id查询该条重推记录信息
IntegrationTaskLivingDetailsEntity oldMsg = new IntegrationTaskLivingDetailsEntity();
if(StrUtil.isNotEmpty(interId)){
oldMsg = taskLivingDetailsService.get(interId);
}
String rootAppPk = oldMsg.getRootAppPk();
entity.setIds(rootAppPk);
StrUtil.isEmpty(rootAppPk);
//如果是重推是否通过entity传入的id只能查到一条数据
List<OtherOutEntity> soleList = otherOutDao.getU8SaleOut(entity);
logger.info("销售出库查询数据{}",JSONObject.toJSONString(soleList));
if(CollectionUtils.isNotEmpty(soleList)){
soleList.forEach(sale -> {
try{
//获取明细数据进行拼接
String id = sale.getId();
if(!StrUtil.isEmpty(id)){
OtherOutDetailEntity line = new OtherOutDetailEntity();
line.setId(id);
line.setAccId(id);
line.setDataSourceCode(requestJson.getString("db_code"));
List<OtherOutDetailEntity> lineList = otherOutDetailDao.getU8otherOutLine(line);
logger.info("销售出库单明细查询数据{}",JSONObject.toJSONString(lineList));
sale.setOtherOutDetailEntityList(lineList);
logger.info("组装数据");
JSONObject main = bindingAdd(sale);
logger.info("销售出库推送数据:"+main.toString());
String result = CrmUtil.sendU8TOCrmEsb(main.toString(), "8000340003");
logger.info("销售出库推送结果:"+result);
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(sale.getIds());
logDetails.setRootAppBill(sale.getCcode());
logDetails.setNewTransmitInfo(result);
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(JSON.toJSONString(sale));
logDetails.setPluginId("SaleConPlugin");
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.getString("code").equals("0");
if(flag){
logDetails.setNewTransmitInfo("推送成功");
// 推送成功更新状态
sale.setState("Y");
}else{
// 推送失败
sale.setState("N");
}
sale.setDataSourceCode(requestJson.getString("db_code"));
try{
saveLog(interId, logDetails, flag);
}catch (Exception e){
logger.error("保存日志失败"+e.getMessage());
otherOutDao.updateState(sale);
e.printStackTrace();
}
otherOutDao.updateState(sale);
}
} catch (Exception e) {
logger.error("销售出库执行失败"+e.getMessage());
e.printStackTrace();
}
});
}
}
/**
*
* @content 保存日志信息
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:27
*
*/
private void saveLog(String interId, IntegrationTaskLivingDetailsEntity logDetails, boolean flag) throws Exception {
if(StrUtil.isEmpty(interId)){
if(flag){
//首推成功
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else{
//首推失败
taskLivingDetailsService.saveLogToFail(logDetails);
}
}else{
logDetails.setId(interId);
if(flag){
//重推成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else{
//重推失败把失败信息更新到重推表中
taskLivingDetailsService.updateLogFailToSuccess(logDetails);
}
}
}
/**
*
* @content 组装推送参数
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:13
*
*/
private JSONObject bindingAdd(OtherOutEntity sale) {
JSONObject main = new JSONObject();
main.put("AccId",sale.getAccId());
main.put("billid",sale.getId());
main.put("LoginDate", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
JSONObject head = new JSONObject();
head.put("ccode",sale.getCcode());
head.put("cbuscode",sale.getCbuscode());
head.put("crdcode",sale.getCrdcode());
head.put("cwhcode",sale.getCwhcode());
head.put("cmaker",sale.getCmaker());
JSONArray body = new JSONArray();
List<OtherOutDetailEntity> lineList = sale.getOtherOutDetailEntityList();
if(CollectionUtils.isNotEmpty(lineList)){
lineList.forEach(line -> {
JSONObject lineObj = new JSONObject();
lineObj.put("cinvcode",line.getCinvcode());
lineObj.put("iquantity",line.getIquantity());
body.add(lineObj);
});
}
main.put("head",head);
main.put("body",body);
return main;
}
}

View File

@ -0,0 +1,37 @@
package com.hzya.frame.u8.receipt.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.receipt.entity.ReceiptEntity;
import java.util.List;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IReceiptDao extends IBaseDao<ReceiptEntity,String> {
/**
*
* @content 获取U8销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 13:53
*
*/
List<ReceiptEntity> getU8Receipt(ReceiptEntity entity);
/**
*
* @content 修改推送状态
* @className: Administrator
* @author laborer
* @date 2024-10-18 14:07
*
*/
int updateState(ReceiptEntity sale);
}

View File

@ -0,0 +1,15 @@
package com.hzya.frame.u8.receipt.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.receipt.entity.ReceiptDetailEntity;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IReceiptDetailDao extends IBaseDao<ReceiptDetailEntity,String> {
}

View File

@ -0,0 +1,31 @@
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.receipt.dao.IReceiptDao;
import com.hzya.frame.u8.receipt.entity.ReceiptEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "ReceiptDaoImpl")
public class ReceiptDaoImpl extends MybatisGenericDao<ReceiptEntity,String> implements IReceiptDao {
@DS("#entity.dataSourceCode")
@Override
public List<ReceiptEntity> getU8Receipt(ReceiptEntity entity) {
return (List<ReceiptEntity>) super.selectList("com.hzya.frame.u8.receipt.dao.impl.ReceiptDaoImpl.entity_list_base",entity);
}
@DS("#entity.dataSourceCode")
@Override
public int updateState(ReceiptEntity entity) {
return super.update("com.hzya.frame.u8.receipt.dao.impl.ReceiptDaoImpl.entity_update",entity);
}
}

View File

@ -0,0 +1,18 @@
package com.hzya.frame.u8.receipt.dao.impl;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.receipt.dao.IReceiptDetailDao;
import com.hzya.frame.u8.receipt.entity.ReceiptDetailEntity;
import org.springframework.stereotype.Repository;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "ReceiptDetailDaoImpl")
public class ReceiptDetailDaoImpl extends MybatisGenericDao<ReceiptDetailEntity,String> implements IReceiptDetailDao {
}

View File

@ -0,0 +1,32 @@
package com.hzya.frame.u8.receipt.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class ReceiptDetailEntity extends BaseEntity {
private String AccCode;//账套编码
private String AccId;//账套号
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.receipt.dao.impl.receiptDetailDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.receipt.entity.ReceiptDetailEntity">
<result property="dlid" column="dlid" />
</resultMap>
<sql id="ReceiptDetailEntity_Base_Column_List">
</sql>
</mapper>

View File

@ -0,0 +1,126 @@
package com.hzya.frame.u8.receipt.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class ReceiptEntity extends BaseEntity {
private String iID;//主键
private String cvouchid;//收款单号
private String dvouchdate;//单据日期
private String ccuscode;//客户编码
private String ccusname;//客户名称
private String iamount_f;//金额
private String csscode;//收款方式
private String syncFlag;//标识
private String AccId;//账套
private String state;//状态
private String AccCode;//账套编码
private String ids;//
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getiID() {
return iID;
}
public void setiID(String iID) {
this.iID = iID;
}
public String getCvouchid() {
return cvouchid;
}
public void setCvouchid(String cvouchid) {
this.cvouchid = cvouchid;
}
public String getDvouchdate() {
return dvouchdate;
}
public void setDvouchdate(String dvouchdate) {
this.dvouchdate = dvouchdate;
}
public String getCcuscode() {
return ccuscode;
}
public void setCcuscode(String ccuscode) {
this.ccuscode = ccuscode;
}
public String getCcusname() {
return ccusname;
}
public void setCcusname(String ccusname) {
this.ccusname = ccusname;
}
public String getIamount_f() {
return iamount_f;
}
public void setIamount_f(String iamount_f) {
this.iamount_f = iamount_f;
}
public String getCsscode() {
return csscode;
}
public void setCsscode(String csscode) {
this.csscode = csscode;
}
public String getSyncFlag() {
return syncFlag;
}
public void setSyncFlag(String syncFlag) {
this.syncFlag = syncFlag;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}

View File

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.receipt.dao.impl.ReceiptDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.receipt.entity.ReceiptEntity">
<result property="iID" column="iID" />
<result property="cvouchid" column="cvouchid" />
<result property="dvouchdate" column="dvouchdate" />
<result property="dvouchdate" column="dvouchdate" />
<result property="ccuscode" column="ccuscode" />
<result property="ccusname" column="ccusname" />
<result property="iamount_f" column="iamount_f" />
<result property="csscode" column="csscode" />
<result property="syncFlag" column="syncFlag" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="ids" column="ids" />
</resultMap>
<sql id="ReceiptEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.receipt.entity.ReceiptEntity">
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
head.iID,
'1001'+CAST( head.iID AS VARCHAR(100)) as ids,
head.cvouchid,
head.dvouchdate,
customer.ccuscode,
customer.ccusname,
head.iamount_f,
head.csscode,
'Y' as syncFlag,
cCheckMan
from UFDATA_001_2023.dbo.Ap_CloseBill head
left join UFDATA_001_2023.dbo.customer customer on cDwCode = customer.ccuscode
UNION ALL
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
head.iID,
'1002'+CAST( head.iID AS VARCHAR(100)) as ids,
head.cvouchid,
head.dvouchdate,
customer.ccuscode,
customer.ccusname,
head.iamount_f,
head.csscode,
'Y' as syncFlag,
cCheckMan
from UFDATA_002_2024.dbo.Ap_CloseBill head
left join UFDATA_002_2024.dbo.customer customer on cDwCode = customer.ccuscode
UNION ALL
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
head.iID,
'1004'+CAST( head.iID AS VARCHAR(100)) as ids,
head.cvouchid,
head.dvouchdate,
customer.ccuscode,
customer.ccusname,
head.iamount_f,
head.csscode,
'Y' as syncFlag,
cCheckMan
from UFDATA_004_2024.dbo.Ap_CloseBill head
left join UFDATA_004_2024.dbo.customer customer on cDwCode = customer.ccuscode
UNION ALL
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
head.iID,
'1005'+CAST( head.iID AS VARCHAR(100)) as ids,
head.cvouchid,
head.dvouchdate,
customer.ccuscode,
customer.ccusname,
head.iamount_f,
head.csscode,
'Y' as syncFlag,
cCheckMan
from UFDATA_005_2024.dbo.Ap_CloseBill head
left join UFDATA_005_2024.dbo.customer customer on cDwCode = customer.ccuscode
UNION ALL
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
head.iID,
'1201'+CAST( head.iID AS VARCHAR(100)) as ids,
head.cvouchid,
head.dvouchdate,
customer.ccuscode,
customer.ccusname,
head.iamount_f,
head.csscode,
'Y' as syncFlag,
cCheckMan
from UFDATA_201_2023.dbo.Ap_CloseBill head
left join UFDATA_201_2023.dbo.customer customer on cDwCode = customer.ccuscode
)m1 where cCusCode not in ('001','002','004','005') and cCheckMan is not null
<if test="ids != null and ids != ''">and ids = #{ids} </if>
</select>
<!--通过主键修改方法-->
<update id="entity_update" parameterType="com.hzya.frame.u8.receipt.entity.ReceiptEntity">
update #{AccCode}.dbo.Ap_CloseBill set sync_flag = #{state}
where iID = #{iID}
</update>
</mapper>

View File

@ -0,0 +1,15 @@
package com.hzya.frame.u8.receipt.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.receipt.entity.ReceiptDetailEntity;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IReceiptDetaiService extends IBaseService<ReceiptDetailEntity,String> {
}

View File

@ -0,0 +1,27 @@
package com.hzya.frame.u8.receipt.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.receipt.entity.ReceiptEntity;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface IReceiptService extends IBaseService<ReceiptEntity,String> {
/**
*
* @content 获取U8收款单推送CRM
* @param requestJson
* @className: Administrator
* @author laborer
* @date 2024-10-18 13:47
*
*/
void getU8ReceiptCrm(JSONObject requestJson);
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.u8.receipt.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.u8.receipt.entity.ReceiptDetailEntity;
import com.hzya.frame.u8.receipt.service.IReceiptDetaiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "ReceiptDetaiServiceImpl")
public class ReceiptDetaiServiceImpl extends BaseService<ReceiptDetailEntity,String> implements IReceiptDetaiService {
Logger logger = LogManager.getLogger(getClass());
}

View File

@ -0,0 +1,168 @@
package com.hzya.frame.u8.receipt.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.crm.util.CrmUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.u8.receipt.dao.IReceiptDao;
import com.hzya.frame.u8.receipt.entity.ReceiptEntity;
import com.hzya.frame.u8.receipt.service.IReceiptService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
*
* @content 销售收款单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "ReceiptServiceImpl")
public class ReceiptServiceImpl extends BaseService<ReceiptEntity,String> implements IReceiptService {
Logger logger = LogManager.getLogger(getClass());
@Autowired
private IReceiptDao saleOutDao;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void getU8ReceiptCrm(JSONObject requestJson) {
//获取重推信息id并记录日志
JSONObject requestJsonObj = JSON.parseObject(requestJson.toString(),JSONObject.class);
String interId = requestJsonObj.getString("integration_task_living_details_id");
logger.info("U8销售收款单重推解析后"+requestJsonObj.toString());
logger.info("U8销售收款单推送CRM重新执行的任务主键"+interId);
//更换数据源
JsonResultEntity resultEntity = new JsonResultEntity();
ReceiptEntity entity = new ReceiptEntity();
requestJson.put("db_code","YONYOUU8");
entity.setDataSourceCode(requestJson.getString("db_code"));
//根据重推信息id查询该条重推记录信息
IntegrationTaskLivingDetailsEntity oldMsg = new IntegrationTaskLivingDetailsEntity();
if(StrUtil.isNotEmpty(interId)){
oldMsg = taskLivingDetailsService.get(interId);
}
String rootAppPk = oldMsg.getRootAppPk();
entity.setIds(rootAppPk);
StrUtil.isEmpty(rootAppPk);//entity.setQueryState("查询");
//如果是重推是否通过entity传入的id只能查到一条数据
//entity.setId("-8845102890648320822");
List<ReceiptEntity> soleList = saleOutDao.getU8Receipt(entity);
logger.info("销售出库查询数据{}",JSONObject.toJSONString(soleList));
if(CollectionUtils.isNotEmpty(soleList)){
soleList.forEach(sale -> {
try{
//获取明细数据进行拼接
String id = sale.getiID();
if(!StrUtil.isEmpty(id)){
logger.info("组装数据");
JSONObject main = bindingAdd(sale);
logger.info("销售出库推送数据:"+main.toString());
String result = CrmUtil.sendU8TOCrmEsb(main.toString(), "8000340003");
logger.info("销售出库推送结果:"+result);
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(sale.getIds());
logDetails.setRootAppBill(sale.getCvouchid());
logDetails.setNewTransmitInfo(result);
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(JSON.toJSONString(sale));
logDetails.setPluginId("SaleConPlugin");
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.getString("code").equals("0");
if(flag){
logDetails.setNewTransmitInfo("推送成功");
// 推送成功更新状态
sale.setState("Y");
}else{
// 推送失败
sale.setState("N");
}
sale.setDataSourceCode(requestJson.getString("db_code"));
try{
saveLog(interId, logDetails, flag);
}catch (Exception e){
logger.error("保存日志失败"+e.getMessage());
saleOutDao.updateState(sale);
e.printStackTrace();
}
saleOutDao.updateState(sale);
}
} catch (Exception e) {
logger.error("销售出库执行失败"+e.getMessage());
e.printStackTrace();
}
});
}
}
/**
*
* @content 保存日志信息
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:27
*
*/
private void saveLog(String interId, IntegrationTaskLivingDetailsEntity logDetails, boolean flag) throws Exception {
if(StrUtil.isEmpty(interId)){
if(flag){
//首推成功
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else{
//首推失败
taskLivingDetailsService.saveLogToFail(logDetails);
}
}else{
logDetails.setId(interId);
if(flag){
//重推成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else{
//重推失败把失败信息更新到重推表中
taskLivingDetailsService.updateLogFailToSuccess(logDetails);
}
}
}
/**
*
* @content 组装推送参数
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:13
*
*/
private JSONObject bindingAdd(ReceiptEntity sale) {
JSONObject main = new JSONObject();
main.put("AccId",sale.getAccId());
main.put("billid",sale.getiID());
main.put("LoginDate", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
JSONObject head = new JSONObject();
head.put("cvouchid",sale.getCvouchid());
head.put("dvouchdate",sale.getDvouchdate());
head.put("ccuscode",sale.getCcuscode());
head.put("iamount",sale.getCcusname());
head.put("csscode",sale.getCsscode());
head.put("syncFlag",sale.getSyncFlag());
main.put("head",head);
return main;
}
}

View File

@ -0,0 +1,37 @@
package com.hzya.frame.u8.saleinv.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.saleinv.entity.SaleInvEntity;
import java.util.List;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface ISaleInvDao extends IBaseDao<SaleInvEntity,String> {
/**
*
* @content 获取U8销售发票信息
* @className: Administrator
* @author laborer
* @date 2024-10-18 14:22
*
*/
List<SaleInvEntity> getU8SaleInv(SaleInvEntity entity);
/**
*
* @content 修改推送状态
* @className: Administrator
* @author laborer
* @date 2024-10-18 14:43
*
*/
int updateState(SaleInvEntity entity);
}

View File

@ -0,0 +1,27 @@
package com.hzya.frame.u8.saleinv.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity;
import java.util.List;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface ISaleInvDetailDao extends IBaseDao<SaleInvDetailEntity,String> {
/**
*
* @content 获取U8销售发票明细数据
* @className: Administrator
* @author laborer
* @date 2024-10-18 14:37
*
*/
List<SaleInvDetailEntity> getU8InvDetail(SaleInvDetailEntity line);
}

View File

@ -0,0 +1,32 @@
package com.hzya.frame.u8.saleinv.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.saleinv.dao.ISaleInvDao;
import com.hzya.frame.u8.saleinv.entity.SaleInvEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "SaleInvDaoImpl")
public class SaleInvDaoImpl extends MybatisGenericDao<SaleInvEntity,String> implements ISaleInvDao {
@DS("#entity.dataSourceCode")
@Override
public List<SaleInvEntity> getU8SaleInv(SaleInvEntity entity) {
return (List<SaleInvEntity>) super.selectList("com.hzya.frame.u8.saleinv.dao.impl.SaleInvDaoImpl.entity_list_base",entity);
}
@Override
public int updateState(SaleInvEntity entity) {
return super.update("com.hzya.frame.u8.saleinv.dao.impl.SaleInvDaoImpl.entity_update", entity);
}
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8.saleinv.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.saleinv.dao.ISaleInvDetailDao;
import com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Repository(value = "SaleInvDetailDaoImpl")
public class SaleInvDetailDaoImpl extends MybatisGenericDao<SaleInvDetailEntity,String> implements ISaleInvDetailDao {
@DS("#entity.dataSourceCode")
@Override
public List<SaleInvDetailEntity> getU8InvDetail(SaleInvDetailEntity entity) {
return (List<SaleInvDetailEntity>) super.selectList("com.hzya.frame.u8.saleinv.dao.impl.SaleInvDetailDaoImpl.entity_list_base",entity);
}
}

View File

@ -0,0 +1,67 @@
package com.hzya.frame.u8.saleinv.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class SaleInvDetailEntity extends BaseEntity {
private String cdlcode;//发货单号
private String idlsum;//发货单金额
private String idlrowno;//发货单行号
private String SBVID;//主表主键
private String AccCode;//账套编码
private String AccId;//账套号
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
public String getCdlcode() {
return cdlcode;
}
public void setCdlcode(String cdlcode) {
this.cdlcode = cdlcode;
}
public String getIdlsum() {
return idlsum;
}
public void setIdlsum(String idlsum) {
this.idlsum = idlsum;
}
public String getIdlrowno() {
return idlrowno;
}
public void setIdlrowno(String idlrowno) {
this.idlrowno = idlrowno;
}
public String getSBVID() {
return SBVID;
}
public void setSBVID(String SBVID) {
this.SBVID = SBVID;
}
}

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.saleinv.dao.impl.SaleInvDetailDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity">
<result property="cbdlcode" column="cbdlcode" />
<result property="iexchsum" column="iexchsum" />
<result property="idlrowno" column="idlrowno" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
</resultMap>
<sql id="SaleInvDetailEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity">
-- 销售发票子表
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
cbdlcode ,
DispatchLists.iexchsum,
DispatchLists.irowno as idlrowno
from UFDATA_001_2023.dbo.SaleBillVouchs Vouchs
left join UFDATA_001_2023.dbo.DispatchLists on Vouchs.iDLsID = DispatchLists.AutoID
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
cbdlcode ,
DispatchLists.iexchsum,
DispatchLists.irowno as idlrowno
from UFDATA_002_2024.dbo.SaleBillVouchs Vouchs
left join UFDATA_002_2024.dbo.DispatchLists on Vouchs.iDLsID = DispatchLists.AutoID
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
cbdlcode ,
DispatchLists.iexchsum,
DispatchLists.irowno as idlrowno
from UFDATA_004_2024.dbo.SaleBillVouchs Vouchs
left join UFDATA_004_2024.dbo.DispatchLists on Vouchs.iDLsID = DispatchLists.AutoID
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
cbdlcode ,
DispatchLists.iexchsum,
DispatchLists.irowno as idlrowno
from UFDATA_005_2024.dbo.SaleBillVouchs Vouchs
left join UFDATA_005_2024.dbo.DispatchLists on Vouchs.iDLsID = DispatchLists.AutoID
union all
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
cbdlcode ,
DispatchLists.iexchsum,
DispatchLists.irowno as idlrowno
from UFDATA_201_2023.dbo.SaleBillVouchs Vouchs
left join UFDATA_201_2023.dbo.DispatchLists on Vouchs.iDLsID = DispatchLists.AutoID
)m1
where SBVID = #{SBVID} and AccId = #{AccId}
</select>
</mapper>

View File

@ -0,0 +1,107 @@
package com.hzya.frame.u8.saleinv.entity;
import com.hzya.frame.web.entity.BaseEntity;
import java.util.List;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class SaleInvEntity extends BaseEntity {
private String csbvcode;//销售发票号
private String ddate;//销售发票日期
private String isum;//发票金额
private String SBVID;//发票主键
private String AccId;//账套
private String state;//
private String syncFlag;//
private String ids;//
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
private List<SaleInvDetailEntity> saleInvDetailEntityList;
private String AccCode;//账套编码
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public List<SaleInvDetailEntity> getSaleInvDetailEntityList() {
return saleInvDetailEntityList;
}
public void setSaleInvDetailEntityList(List<SaleInvDetailEntity> saleInvDetailEntityList) {
this.saleInvDetailEntityList = saleInvDetailEntityList;
}
public String getCsbvcode() {
return csbvcode;
}
public void setCsbvcode(String csbvcode) {
this.csbvcode = csbvcode;
}
public String getDdate() {
return ddate;
}
public void setDdate(String ddate) {
this.ddate = ddate;
}
public String getIsum() {
return isum;
}
public void setIsum(String isum) {
this.isum = isum;
}
public String getSBVID() {
return SBVID;
}
public void setSBVID(String SBVID) {
this.SBVID = SBVID;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getSyncFlag() {
return syncFlag;
}
public void setSyncFlag(String syncFlag) {
this.syncFlag = syncFlag;
}
}

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.saleinv.dao.impl.SaleInvDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.saleinv.entity.SaleInvEntity">
<result property="csbvcode" column="csbvcode" />
<result property="ddate" column="ddate" />
<result property="isum" column="isum" />
<result property="SBVID" column="SBVID" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="ids" column="ids" />
</resultMap>
<sql id="SaleInvEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.saleinv.entity.SaleInvEntity">
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
main.SBVID,
'1001'+CAST(main.SBVID AS VARCHAR(100)) as ids,
main.csbvcode,
main.ddate,
sum(line.isum) as isum,
cCusCode,
cVerifier
from UFDATA_001_2023.dbo.SaleBillVouch main
left join UFDATA_001_2023.dbo.SaleBillVouchs line on main.SBVID = line.SBVID
GROUP BY main.csbvcode,main.ddate,main.SBVID,cCusCode,
cVerifier
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
main.SBVID,
'1002'+CAST(main.SBVID AS VARCHAR(100)) as ids,
main.csbvcode,
main.ddate,
sum(line.isum) as isum,
cCusCode,
cVerifier
from UFDATA_002_2024.dbo.SaleBillVouch main
left join UFDATA_002_2024.dbo.SaleBillVouchs line on main.SBVID = line.SBVID
GROUP BY main.csbvcode,main.ddate,main.SBVID,cCusCode,
cVerifier
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
main.SBVID,
'1004'+CAST(main.SBVID AS VARCHAR(100)) as ids,
main.csbvcode,
main.ddate,
sum(line.isum) as isum,
cCusCode,
cVerifier
from UFDATA_004_2024.dbo.SaleBillVouch main
left join UFDATA_004_2024.dbo.SaleBillVouchs line on main.SBVID = line.SBVID
GROUP BY main.csbvcode,main.ddate,main.SBVID,cCusCode,
cVerifier
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
main.SBVID,
'1005'+CAST(main.SBVID AS VARCHAR(100)) as ids,
main.csbvcode,
main.ddate,
sum(line.isum) as isum,
cCusCode,
cVerifier
from UFDATA_005_2024.dbo.SaleBillVouch main
left join UFDATA_005_2024.dbo.SaleBillVouchs line on main.SBVID = line.SBVID
GROUP BY main.csbvcode,main.ddate,main.SBVID,cCusCode,
cVerifier
union all
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
main.SBVID,
'1201'+CAST(main.SBVID AS VARCHAR(100)) as ids,
main.csbvcode,
main.ddate,
sum(line.isum) as isum,
cCusCode,
cVerifier
from UFDATA_201_2023.dbo.SaleBillVouch main
left join UFDATA_201_2023.dbo.SaleBillVouchs line on main.SBVID = line.SBVID
GROUP BY main.csbvcode,main.ddate,main.SBVID,cCusCode,
cVerifier
)m1 where cCusCode not in ('001','002','004','005') and cVerifier is not null
<if test="ids != null and ids != ''">and ids = #{ids} </if>
</select>
<!--通过主键修改方法-->
<update id="entity_update" parameterType="com.hzya.frame.u8.saleinv.entity.SaleInvEntity">
update #{AccCode}.dbo.SaleBillVouch set sync_flag = #{state}
where SBVID = #{SBVID}
</update>
</mapper>

View File

@ -0,0 +1,15 @@
package com.hzya.frame.u8.saleinv.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface ISaleInvDetaiService extends IBaseService<SaleInvDetailEntity,String> {
}

View File

@ -0,0 +1,27 @@
package com.hzya.frame.u8.saleinv.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.saleinv.entity.SaleInvEntity;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface ISaleInvService extends IBaseService<SaleInvEntity,String> {
/**
*
* @content 获取U8销售发票数据并推送到CRM
* @param requestJson
* @className: Administrator
* @author laborer
* @date 2024-10-18 13:48
*
*/
void getU8SaleInvToCrm(JSONObject requestJson);
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.u8.saleinv.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity;
import com.hzya.frame.u8.saleinv.service.ISaleInvDetaiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "SaleInvDetaiServiceImpl")
public class SaleInvDetaiServiceImpl extends BaseService<SaleInvDetailEntity,String> implements ISaleInvDetaiService {
Logger logger = LogManager.getLogger(getClass());
}

View File

@ -0,0 +1,191 @@
package com.hzya.frame.u8.saleinv.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.crm.util.CrmUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.u8.saleinv.dao.ISaleInvDao;
import com.hzya.frame.u8.saleinv.dao.ISaleInvDetailDao;
import com.hzya.frame.u8.saleinv.entity.SaleInvDetailEntity;
import com.hzya.frame.u8.saleinv.entity.SaleInvEntity;
import com.hzya.frame.u8.saleinv.service.ISaleInvService;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
*
* @content 销售发票
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "SaleInvServiceImpl")
public class SaleInvServiceImpl extends BaseService<SaleInvEntity,String> implements ISaleInvService {
Logger logger = LogManager.getLogger(getClass());
@Autowired
private ISaleInvDao saleInvDao;
@Autowired
private ISaleInvDetailDao saleInvDetailDao;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void getU8SaleInvToCrm(JSONObject requestJson) {
//获取重推信息id并记录日志
JSONObject requestJsonObj = JSON.parseObject(requestJson.toString(),JSONObject.class);
String interId = requestJsonObj.getString("integration_task_living_details_id");
logger.info("U8销售发票单重推解析后"+requestJsonObj.toString());
logger.info("U8销售发票单推送CRM重新执行的任务主键"+interId);
//更换数据源
JsonResultEntity resultEntity = new JsonResultEntity();
SaleInvEntity entity = new SaleInvEntity();
requestJson.put("db_code","YONYOUU8");
entity.setDataSourceCode(requestJson.getString("db_code"));
//根据重推信息id查询该条重推记录信息
IntegrationTaskLivingDetailsEntity oldMsg = new IntegrationTaskLivingDetailsEntity();
if(StrUtil.isNotEmpty(interId)){
oldMsg = taskLivingDetailsService.get(interId);
}
String rootAppPk = oldMsg.getRootAppPk();
entity.setIds(rootAppPk);
StrUtil.isEmpty(rootAppPk);//entity.setQueryState("查询");
//如果是重推是否通过entity传入的id只能查到一条数据
//entity.setId("-8845102890648320822");
List<SaleInvEntity> soleList = saleInvDao.getU8SaleInv(entity);
logger.info("销售发票查询数据{}",JSONObject.toJSONString(soleList));
if(CollectionUtils.isNotEmpty(soleList)){
soleList.forEach(sale -> {
try{
//获取明细数据进行拼接
String id = sale.getSBVID();
if(!StrUtil.isEmpty(id)){
SaleInvDetailEntity line = new SaleInvDetailEntity();
line.setSBVID(id);
line.setAccId(id);
line.setDataSourceCode(requestJson.getString("db_code"));
List<SaleInvDetailEntity> lineList = saleInvDetailDao.getU8InvDetail(line);
logger.info("销售发票单明细查询数据{}",JSONObject.toJSONString(lineList));
sale.setSaleInvDetailEntityList(lineList);
logger.info("组装数据");
JSONObject main = bindingAdd(sale);
logger.info("销售发票推送数据:"+main.toString());
String result = CrmUtil.sendU8TOCrmEsb(main.toString(), "8000340003");
logger.info("销售发票推送结果:"+result);
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(sale.getIds());
logDetails.setRootAppBill(sale.getCsbvcode());
logDetails.setNewTransmitInfo(result);
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(JSON.toJSONString(sale));
logDetails.setPluginId("SaleConPlugin");
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.getString("code").equals("0");
if(flag){
logDetails.setNewTransmitInfo("推送成功");
// 推送成功更新状态
sale.setState("Y");
}else{
// 推送失败
sale.setState("N");
}
sale.setDataSourceCode(requestJson.getString("db_code"));
try{
saveLog(interId, logDetails, flag);
}catch (Exception e){
logger.error("保存日志失败"+e.getMessage());
saleInvDao.updateState(sale);
e.printStackTrace();
}
saleInvDao.updateState(sale);
}
} catch (Exception e) {
logger.error("销售发票执行失败"+e.getMessage());
e.printStackTrace();
}
});
}
}
/**
*
* @content 保存日志信息
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:27
*
*/
private void saveLog(String interId, IntegrationTaskLivingDetailsEntity logDetails, boolean flag) throws Exception {
if(StrUtil.isEmpty(interId)){
if(flag){
//首推成功
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else{
//首推失败
taskLivingDetailsService.saveLogToFail(logDetails);
}
}else{
logDetails.setId(interId);
if(flag){
//重推成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else{
//重推失败把失败信息更新到重推表中
taskLivingDetailsService.updateLogFailToSuccess(logDetails);
}
}
}
/**
*
* @content 组装推送参数
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:13
*
*/
private JSONObject bindingAdd(SaleInvEntity sale) {
JSONObject main = new JSONObject();
main.put("AccId",sale.getAccId());
main.put("billid",sale.getId());
main.put("LoginDate", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
JSONObject head = new JSONObject();
head.put("csbvcode",sale.getCsbvcode());
head.put("ddate",sale.getDdate());
head.put("syncFlag",sale.getSyncFlag());
head.put("isum",sale.getIsum());
JSONArray body = new JSONArray();
main.put("head",head);
List<SaleInvDetailEntity> lineList = sale.getSaleInvDetailEntityList();
if(CollectionUtils.isNotEmpty(lineList)){
lineList.forEach(line -> {
JSONObject lineObj = new JSONObject();
lineObj.put("cdlcode",line.getCdlcode());
lineObj.put("idlsum",line.getIdlsum());
lineObj.put("idlrowno",line.getIdlrowno());
body.add(lineObj);
});
}
main.put("body",body);
return main;
}
}

View File

@ -0,0 +1,32 @@
package com.hzya.frame.u8.saleout.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.saleout.entity.SaleOutEntity;
import java.util.List;
/**
* @Description U8发货单
* @Author xiangerlin
* @Date 2024/8/22 15:07
**/
public interface ISaleOutDao extends IBaseDao<SaleOutEntity,String> {
/**
* @content 获取U8销售出库单数据
* @className: Administrator
* @author laborer
* @date 2024-10-18 10:49
*/
List<SaleOutEntity> getU8SaleOut(SaleOutEntity entity);
/**
*
* @content 推送修改状态
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:23
*
*/
int updateState(SaleOutEntity sale);
}

View File

@ -0,0 +1,25 @@
package com.hzya.frame.u8.saleout.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
import java.util.List;
/**
* @Description u8发货单明细行
* @Author xiangerlin
* @Date 2024/8/22 16:22
**/
public interface ISaleOutDetailDao extends IBaseDao<SaleOutDetailEntity,String> {
/**
*
* @content 获取u8发货单明细行
* @return
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:04
*
*/
List<SaleOutDetailEntity> getU8SaleOutLine(SaleOutDetailEntity entity);
}

View File

@ -0,0 +1,28 @@
package com.hzya.frame.u8.saleout.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.saleout.dao.ISaleOutDao;
import com.hzya.frame.u8.saleout.entity.SaleOutEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description u8发货单
* @Author xiangerlin
* @Date 2024/8/22 15:09
**/
@Repository(value = "SaleOutDaoImpl")
public class SaleOutDaoImpl extends MybatisGenericDao<SaleOutEntity,String> implements ISaleOutDao {
@DS("#entity.dataSourceCode")
@Override
public List<SaleOutEntity> getU8SaleOut(SaleOutEntity entity) {
return (List<SaleOutEntity>) super.selectList("com.hzya.frame.u8.saleout.dao.impl.SaleOutDaoImpl.entity_list_base",entity);
}
@DS("#entity.dataSourceCode")
@Override
public int updateState(SaleOutEntity entity) {
return super.update("com.hzya.frame.u8.saleout.dao.impl.SaleOutDaoImpl.entity_list_base",entity);
}
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.u8.saleout.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.u8.saleout.dao.ISaleOutDetailDao;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description
* @Author xiangerlin
* @Date 2024/8/22 16:24
**/
@Repository(value = "SaleOutDetailDaoImpl")
public class SaleOutDetailDaoImpl extends MybatisGenericDao<SaleOutDetailEntity,String> implements ISaleOutDetailDao {
@DS("#entity.dataSourceCode")
@Override
public List<SaleOutDetailEntity> getU8SaleOutLine(SaleOutDetailEntity entity) {
return (List<SaleOutDetailEntity>) super.selectList("com.hzya.frame.u8.saleout.dao.impl.SaleOutDetailDaoImpl.entity_list_base",entity);
}
}

View File

@ -0,0 +1,76 @@
package com.hzya.frame.u8.saleout.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 销售出库单明细
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class SaleOutDetailEntity extends BaseEntity {
private String cinvcode;//存货编码
private String cinvname;//存货名称
private String iquantity;//数量
private String inum;//辅计量单位数量
private String idlrowno;//发货单行号
private String AccCode;//账套编码
private String AccId;//账套号
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
public String getCinvcode() {
return cinvcode;
}
public void setCinvcode(String cinvcode) {
this.cinvcode = cinvcode;
}
public String getCinvname() {
return cinvname;
}
public void setCinvname(String cinvname) {
this.cinvname = cinvname;
}
public String getIquantity() {
return iquantity;
}
public void setIquantity(String iquantity) {
this.iquantity = iquantity;
}
public String getInum() {
return inum;
}
public void setInum(String inum) {
this.inum = inum;
}
public String getIdlrowno() {
return idlrowno;
}
public void setIdlrowno(String idlrowno) {
this.idlrowno = idlrowno;
}
}

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.saleout.dao.impl.SaleOutDetailDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity">
<result property="dlid" column="dlid" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
</resultMap>
<sql id="SaleOutDetailEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity">
-- 销售出库单子表
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
inv.cinvcode,
inv.cinvname,
iquantity,
inum,
irowno as idlrowno
from UFDATA_001_2023.dbo.rdrecords32 main
left join UFDATA_001_2023.dbo.inventory inv on main.cinvcode = inv.cinvcode
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
inv.cinvcode,
inv.cinvname,
iquantity,
inum,
irowno as idlrowno
from UFDATA_002_2024.dbo.rdrecords32 main
left join UFDATA_002_2024.dbo.inventory inv on main.cinvcode = inv.cinvcode
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
inv.cinvcode,
inv.cinvname,
iquantity,
inum,
irowno as idlrowno
from UFDATA_004_2024.dbo.rdrecords32 main
left join UFDATA_004_2024.dbo.inventory inv on main.cinvcode = inv.cinvcode
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
inv.cinvcode,
inv.cinvname,
iquantity,
inum,
irowno as idlrowno
from UFDATA_005_2024.dbo.rdrecords32 main
left join UFDATA_005_2024.dbo.inventory inv on main.cinvcode = inv.cinvcode
union all
select
'201' as AccId,
'UFDATA_201_2023' as AccCode,
inv.cinvcode,
inv.cinvname,
iquantity,
inum,
irowno as idlrowno
from UFDATA_201_2023.dbo.rdrecords32 main
left join UFDATA_201_2023.dbo.inventory inv on main.cinvcode = inv.cinvcode
)m1
where id = #{id} and AccId = #{AccId}
</select>
</mapper>

View File

@ -0,0 +1,102 @@
package com.hzya.frame.u8.saleout.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hzya.frame.web.entity.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.List;
/**
*
* @content 销售出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public class SaleOutEntity extends BaseEntity {
private String cdlcode;//发货单号
private String outtype;//出库方式
private String ccode;//出库单号
private String ddate;//出库日期
private String AccId;//账套
private String state;//状态
private String AccCode;//账套编码
private String ids;//
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getAccCode() {
return AccCode;
}
public void setAccCode(String accCode) {
AccCode = accCode;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getAccId() {
return AccId;
}
public void setAccId(String accId) {
AccId = accId;
}
private List<SaleOutDetailEntity>saleOutDetailEntityList;
public List<SaleOutDetailEntity> getSaleOutDetailEntityList() {
return saleOutDetailEntityList;
}
public void setSaleOutDetailEntityList(List<SaleOutDetailEntity> saleOutDetailEntityList) {
this.saleOutDetailEntityList = saleOutDetailEntityList;
}
public String getCdlcode() {
return cdlcode;
}
public void setCdlcode(String cdlcode) {
this.cdlcode = cdlcode;
}
public String getOuttype() {
return outtype;
}
public void setOuttype(String outtype) {
this.outtype = outtype;
}
public String getCcode() {
return ccode;
}
public void setCcode(String ccode) {
this.ccode = ccode;
}
public String getDdate() {
return ddate;
}
public void setDdate(String ddate) {
this.ddate = ddate;
}
}

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.u8.saleout.dao.impl.SaleOutDaoImpl">
<resultMap id="get-entity-result" type="com.hzya.frame.u8.saleout.entity.SaleOutEntity">
<result property="id" column="id" />
<result property="cdlcode" column="cdlcode" />
<result property="couttype" column="couttype" />
<result property="ccode" column="ccode" />
<result property="ddate" column="ddate" />
<result property="AccId" column="AccId" />
<result property="AccCode" column="AccCode" />
<result property="ids" column="ids" />
</resultMap>
<sql id="SaleOutEntity_Base_Column_List">
</sql>
<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.u8.saleout.entity.SaleOutEntity">
-- 销售单主表
select * from (
select
'001' as AccId,
'UFDATA_001_2023' as AccCode,
'1001'+CAST(id AS VARCHAR(100)) as ids,
id,
cdlcode,
'' as couttype,
ccode,
ddate,
cCusCode,
cHandler
from UFDATA_001_2023.dbo.rdrecord32
union all
select
'002' as AccId,
'UFDATA_002_2024' as AccCode,
'1002'+CAST(id AS VARCHAR(100)) as ids,
id,
cdlcode,
'' as couttype,
ccode,
ddate,
cCusCode,
cHandler
from UFDATA_002_2024.dbo.rdrecord32
union all
select
'004' as AccId,
'UFDATA_004_2024' as AccCode,
'1004'+CAST(id AS VARCHAR(100)) as ids,
id,
cdlcode,
'' as couttype,
ccode,
ddate,
cCusCode,
cHandler
from UFDATA_004_2024.dbo.rdrecord32
union all
select
'005' as AccId,
'UFDATA_005_2024' as AccCode,
'1005'+CAST(id AS VARCHAR(100)) as ids,
id,
cdlcode,
'' as couttype,
ccode,
ddate,
cCusCode,
cHandler
from UFDATA_005_2024.dbo.rdrecord32
union all
select
'1201' as AccId,
'1UFDATA_201_2023' as AccCode,
'201'+CAST(id AS VARCHAR(100)) as ids,
id,
cdlcode,
'' as couttype,
ccode,
ddate,
cCusCode,
cHandler
from UFDATA_201_2023.dbo.rdrecord32
)m1 where cCusCode not in ('001','002','004','005') and cHandler is not null
<if test="ids != null and ids != ''">and ids = #{ids} </if>
</select>
<!--通过主键修改方法-->
<update id="entity_update" parameterType="com.hzya.frame.u8.saleout.entity.SaleOutEntity">
update #{AccCode}.dbo.rdrecords32 set sync_flag = #{state}
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,15 @@
package com.hzya.frame.u8.saleout.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
/**
*
* @content 销售出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface ISaleOutDetaiService extends IBaseService<SaleOutDetailEntity,String> {
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8.saleout.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.u8.saleout.entity.SaleOutEntity;
/**
*
* @content 销售出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
public interface ISaleOutService extends IBaseService<SaleOutEntity,String> {
/**
*
* @content 获取U8销售出库单到CRM
* @className: Administrator
* @author laborer
* @date 2024-10-18 10:15
*
*/
void getU8SaleOutToCrm(JSONObject requestJson);
}

View File

@ -0,0 +1,25 @@
package com.hzya.frame.u8.saleout.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.u8.saleout.dao.ISaleOutDetailDao;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
import com.hzya.frame.u8.saleout.service.ISaleOutDetaiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
* @content 销售出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "SaleOutDetaiServiceImpl")
public class SaleOutDetaiServiceImpl extends BaseService<SaleOutDetailEntity,String> implements ISaleOutDetaiService {
Logger logger = LogManager.getLogger(getClass());
}

View File

@ -0,0 +1,204 @@
package com.hzya.frame.u8.saleout.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.crm.util.CrmUtil;
import com.hzya.frame.seeyon.util.RestUtil;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.u8.saleout.dao.ISaleOutDao;
import com.hzya.frame.u8.saleout.dao.ISaleOutDetailDao;
import com.hzya.frame.u8.saleout.dao.impl.SaleOutDetailDaoImpl;
import com.hzya.frame.u8.saleout.entity.SaleOutDetailEntity;
import com.hzya.frame.u8.saleout.entity.SaleOutEntity;
import com.hzya.frame.u8.saleout.service.ISaleOutService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
*
* @content 销售出库单
* @className: Administrator
* @author laborer
* @date 2024-10-18 9:27
*
*/
@Service(value = "SaleOutServiceImpl")
public class SaleOutServiceImpl extends BaseService<SaleOutEntity,String> implements ISaleOutService {
Logger logger = LogManager.getLogger(getClass());
@Autowired
private ISaleOutDao saleOutDao;
@Autowired
private ISaleOutDetailDao saleOutDetailDao;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
/**
*
* @content 获取U8销售出库单到CRM
* @className: Administrator
* @author laborer
* @date 2024-10-18 10:15
*
*/
@Override
public void getU8SaleOutToCrm(JSONObject requestJson) {
//获取重推信息id并记录日志
JSONObject requestJsonObj = JSON.parseObject(requestJson.toString(),JSONObject.class);
String interId = requestJsonObj.getString("integration_task_living_details_id");
logger.info("U8销售出库单重推解析后"+requestJsonObj.toString());
logger.info("U8销售出库单推送CRM重新执行的任务主键"+interId);
//更换数据源
JsonResultEntity resultEntity = new JsonResultEntity();
SaleOutEntity entity = new SaleOutEntity();
requestJson.put("db_code","YONYOUU8");
entity.setDataSourceCode(requestJson.getString("db_code"));
//根据重推信息id查询该条重推记录信息
IntegrationTaskLivingDetailsEntity oldMsg = new IntegrationTaskLivingDetailsEntity();
if(StrUtil.isNotEmpty(interId)){
oldMsg = taskLivingDetailsService.get(interId);
}
String rootAppPk = oldMsg.getRootAppPk();
entity.setIds(rootAppPk);
StrUtil.isEmpty(rootAppPk);//entity.setQueryState("查询");
//如果是重推是否通过entity传入的id只能查到一条数据
//entity.setId("-8845102890648320822");
List<SaleOutEntity> soleList = saleOutDao.getU8SaleOut(entity);
logger.info("销售出库查询数据{}",JSONObject.toJSONString(soleList));
if(CollectionUtils.isNotEmpty(soleList)){
soleList.forEach(sale -> {
try{
//获取明细数据进行拼接
String id = sale.getId();
if(!StrUtil.isEmpty(id)){
SaleOutDetailEntity line = new SaleOutDetailEntity();
line.setId(id);
line.setAccId(id);
line.setDataSourceCode(requestJson.getString("db_code"));
List<SaleOutDetailEntity> lineList = saleOutDetailDao.getU8SaleOutLine(line);
logger.info("销售出库单明细查询数据{}",JSONObject.toJSONString(lineList));
sale.setSaleOutDetailEntityList(lineList);
logger.info("组装数据");
JSONObject main = bindingAdd(sale);
logger.info("销售出库推送数据:"+main.toString());
String result = CrmUtil.sendU8TOCrmEsb(main.toString(), "8000340003");
logger.info("销售出库推送结果:"+result);
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(sale.getIds());
logDetails.setRootAppBill(sale.getCcode());
logDetails.setNewTransmitInfo(result);
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(JSON.toJSONString(sale));
logDetails.setPluginId("SaleConPlugin");
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.getString("code").equals("0");
if(flag){
logDetails.setNewTransmitInfo("推送成功");
// 推送成功更新状态
sale.setState("Y");
}else{
// 推送失败
sale.setState("N");
}
sale.setDataSourceCode(requestJson.getString("db_code"));
try{
saveLog(interId, logDetails, flag);
}catch (Exception e){
logger.error("保存日志失败"+e.getMessage());
saleOutDao.updateState(sale);
e.printStackTrace();
}
saleOutDao.updateState(sale);
}
} catch (Exception e) {
logger.error("销售出库执行失败"+e.getMessage());
e.printStackTrace();
}
});
}
}
/**
*
* @content 保存日志信息
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:27
*
*/
private void saveLog(String interId, IntegrationTaskLivingDetailsEntity logDetails, boolean flag) throws Exception {
if(StrUtil.isEmpty(interId)){
if(flag){
//首推成功
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else{
//首推失败
taskLivingDetailsService.saveLogToFail(logDetails);
}
}else{
logDetails.setId(interId);
if(flag){
//重推成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else{
//重推失败把失败信息更新到重推表中
taskLivingDetailsService.updateLogFailToSuccess(logDetails);
}
}
}
/**
*
* @content 组装推送参数
* @className: Administrator
* @author laborer
* @date 2024-10-18 11:13
*
*/
private JSONObject bindingAdd(SaleOutEntity sale) {
JSONObject main = new JSONObject();
main.put("AccId",sale.getAccId());
main.put("billid",sale.getId());
main.put("LoginDate", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
JSONObject head = new JSONObject();
head.put("cdlcode",sale.getCdlcode());
head.put("couttype",sale.getOuttype());
head.put("ccode",sale.getCcode());
head.put("ddate",sale.getDdate());
JSONArray body = new JSONArray();
List<SaleOutDetailEntity> lineList = sale.getSaleOutDetailEntityList();
if(CollectionUtils.isNotEmpty(lineList)){
lineList.forEach(line -> {
JSONObject lineObj = new JSONObject();
lineObj.put("cinvcode",line.getCinvcode());
lineObj.put("cinvname",line.getCinvname());
lineObj.put("iquantity",line.getIquantity());
lineObj.put("inum",line.getInum());
lineObj.put("idlrowno",line.getIdlrowno());
body.add(lineObj);
});
}
main.put("head",head);
main.put("body",body);
return main;
}
}