日志长度
This commit is contained in:
parent
b5270cb219
commit
fb13a15a69
|
@ -0,0 +1,14 @@
|
||||||
|
package com.hzya.frame.plugin.nuonuo.dao;
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface INuoNuoDao extends IBaseDao<NuoNuoEntity, String> {
|
||||||
|
|
||||||
|
int updateHpdata(NuoNuoEntity nuoNuoEntity);
|
||||||
|
|
||||||
|
List<NuoNuoEntity> queryAffair(NuoNuoEntity nuoNuoEntity);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.hzya.frame.plugin.nuonuo.dao.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.dao.INuoNuoDao;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity;
|
||||||
|
import com.hzya.frame.seeyon.entity.NuoNuoCallbackEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class NuoNuoDaoImpl extends MybatisGenericDao<NuoNuoEntity, String> implements INuoNuoDao {
|
||||||
|
|
||||||
|
@DS("#entity.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public int updateHpdata(NuoNuoEntity entity) {
|
||||||
|
return super.update(getSqlIdPrifx()+"updateHpdata",entity);
|
||||||
|
}
|
||||||
|
@DS("#entity.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public List<NuoNuoEntity> queryAffair(NuoNuoEntity entity) {
|
||||||
|
return (List<NuoNuoEntity>) super.selectList(getSqlIdPrifx()+"queryAffair",entity);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.hzya.frame.plugin.nuonuo.entity;
|
||||||
|
|
||||||
|
import com.hzya.frame.web.entity.BaseEntity;
|
||||||
|
|
||||||
|
public class NuoNuoEntity extends BaseEntity {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String field0191;//申请编号
|
||||||
|
private String field0192;//红字确认单状态
|
||||||
|
private String field0193;//红字确认单描述
|
||||||
|
private String field0194;//红冲状态
|
||||||
|
private String field0195;//红冲描述
|
||||||
|
private String affairId;
|
||||||
|
private String noname;
|
||||||
|
private String nodename;
|
||||||
|
|
||||||
|
public String getNodename() {
|
||||||
|
return nodename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodename(String nodename) {
|
||||||
|
this.nodename = nodename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNoname() {
|
||||||
|
return noname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoname(String noname) {
|
||||||
|
this.noname = noname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAffairId() {
|
||||||
|
return affairId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAffairId(String affairId) {
|
||||||
|
this.affairId = affairId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField0191() {
|
||||||
|
return field0191;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField0191(String field0191) {
|
||||||
|
this.field0191 = field0191;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField0192() {
|
||||||
|
return field0192;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField0192(String field0192) {
|
||||||
|
this.field0192 = field0192;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField0193() {
|
||||||
|
return field0193;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField0193(String field0193) {
|
||||||
|
this.field0193 = field0193;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField0194() {
|
||||||
|
return field0194;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField0194(String field0194) {
|
||||||
|
this.field0194 = field0194;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField0195() {
|
||||||
|
return field0195;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField0195(String field0195) {
|
||||||
|
this.field0195 = field0195;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?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.plugin.nuonuo.dao.impl.NuoNuoDaoImpl">
|
||||||
|
|
||||||
|
<update id="updateHpdata" parameterType="com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity">
|
||||||
|
update formmain_11970 set
|
||||||
|
<trim suffix="" suffixOverrides=",">
|
||||||
|
<if test="field0191 != null and field0191 !='' "> field0191 = #{field0191},</if>
|
||||||
|
<if test="field0192 != null and field0192 !='' "> field0192 = #{field0192},</if>
|
||||||
|
<if test="field0193 != null and field0193 !='' "> field0193 = #{field0193},</if>
|
||||||
|
<if test="field0194 != null and field0194 !='' "> field0194 = #{field0194},</if>
|
||||||
|
<if test="field0195 != null and field0195 !='' "> field0195 = #{field0195},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="queryAffair" resultType="com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity" parameterType="com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity">
|
||||||
|
select NODE_NAME as noname,NODE_POLICY as nodename from ctp_affair
|
||||||
|
<trim prefix="where" prefixOverrides="and">
|
||||||
|
<if test="affairId != null and affairId !='' ">id = #{affairId} </if>
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.hzya.frame.plugin.nuonuo.plugin;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.base.PluginBaseEntity;
|
||||||
|
import com.hzya.frame.plugin.masterData.plugin.MdmPluginInitializer;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.service.INuoNuoService;
|
||||||
|
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 诺诺发票
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-06-21 13:52:35
|
||||||
|
*/
|
||||||
|
public class NuoNuoPluginInitializer extends PluginBaseEntity{
|
||||||
|
Logger logger = LoggerFactory.getLogger(NuoNuoPluginInitializer.class);
|
||||||
|
@Autowired
|
||||||
|
private INuoNuoService nuoNuoService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
logger.info(getPluginLabel() + "执行初始化方法initialize()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
logger.info(getPluginLabel() + "执行销毁方法destroy()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginId() {
|
||||||
|
return "NuoNuoPlugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginName() {
|
||||||
|
return "NuoNuoPlugin插件";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginLabel() {
|
||||||
|
return "NuoNuoPlugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginType() {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||||
|
try {
|
||||||
|
logger.info("======开始执行诺诺发票同步========");
|
||||||
|
return nuoNuoService.sendNuoNuoFaPiao(requestJson);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("======执行诺诺发票同步失败:{}========",e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.hzya.frame.plugin.nuonuo.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.basedao.service.IBaseService;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
|
||||||
|
public interface INuoNuoService extends IBaseService<NuoNuoEntity, String>{
|
||||||
|
/**
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 同步诺诺发票蓝字
|
||||||
|
* @Date 5:31 下午 2025/6/26
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
**/
|
||||||
|
JsonResultEntity sendNuoNuoFaPiao(JSONObject requestJson);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 诺诺发票确认单
|
||||||
|
* @Date 4:35 下午 2025/7/2
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
**/
|
||||||
|
JsonResultEntity sendNuoNuoFaPiaoQrd(JSONObject requestJson);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 诺诺发票红冲
|
||||||
|
* @Date 4:35 下午 2025/7/2
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
**/
|
||||||
|
JsonResultEntity sendNuoNuoFaPiaoHc(JSONObject requestJson);
|
||||||
|
|
||||||
|
JsonResultEntity sendNuoNuoFaPiaoHp(JSONObject requestJson);
|
||||||
|
}
|
|
@ -0,0 +1,763 @@
|
||||||
|
package com.hzya.frame.plugin.nuonuo.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.dao.INuoNuoDao;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.entity.NuoNuoEntity;
|
||||||
|
import com.hzya.frame.plugin.nuonuo.service.INuoNuoService;
|
||||||
|
import com.hzya.frame.seeyon.enums.ColEventTypeEnum;
|
||||||
|
import com.hzya.frame.web.entity.BaseResult;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NuoNuoServiceImpl extends BaseService<NuoNuoEntity, String> implements INuoNuoService {
|
||||||
|
@Value("${zt.url}")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private INuoNuoDao nuoNuoDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setNuoNuoCustomerDao(INuoNuoDao dao) {
|
||||||
|
this.nuoNuoDao = dao;
|
||||||
|
this.dao = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 同步发票
|
||||||
|
* @Date 5:31 下午 2025/6/26
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity sendNuoNuoFaPiao(JSONObject requestJson) {
|
||||||
|
logger.error("诺诺发票蓝票节点参数:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
String affairId = jsonStr.getString("affairId");
|
||||||
|
if (affairId != null && !"".equals(affairId)) {
|
||||||
|
NuoNuoEntity nuoNuoEntity = new NuoNuoEntity();
|
||||||
|
nuoNuoEntity.setDataSourceCode("SW-OA");
|
||||||
|
nuoNuoEntity.setAffairId(affairId);
|
||||||
|
List<NuoNuoEntity> nuoNuoEntities = nuoNuoDao.queryAffair(nuoNuoEntity);
|
||||||
|
if (nuoNuoEntities != null && nuoNuoEntities.size() == 1) {
|
||||||
|
if (nuoNuoEntities.get(0).getNoname() != null) {
|
||||||
|
if ("确认申请".equals(nuoNuoEntities.get(0).getNoname()) || "确认申请".equals(nuoNuoEntities.get(0).getNodename())) {
|
||||||
|
return sendNuoNuoFaPiaolp(requestJson);
|
||||||
|
} else if ("ERP审批".equals(nuoNuoEntities.get(0).getNoname()) || "ERP审批".equals(nuoNuoEntities.get(0).getNodename())) {
|
||||||
|
return sendBipFaPiaolp(requestJson);
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 发送Bip
|
||||||
|
* @Date 1:44 下午 2025/7/9
|
||||||
|
**/
|
||||||
|
private JsonResultEntity sendBipFaPiaolp(JSONObject requestJson) {
|
||||||
|
logger.error("同步应收单:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject mainData = businessDataStr.getJSONObject("formmain_11951");
|
||||||
|
if (mainData == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONArray detailArray = businessDataStr.getJSONArray("formson_11953");
|
||||||
|
//组装发送数据
|
||||||
|
JSONObject sendData = null;
|
||||||
|
try {
|
||||||
|
sendData = getSendYsdData(mainData, detailArray);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return BaseResult.getFailureMessageEntity("推送应收单失败:组装数据失败");
|
||||||
|
}
|
||||||
|
//发送数据
|
||||||
|
logger.error("推送应收单推送:" + sendData.toJSONString());
|
||||||
|
|
||||||
|
String tokenResult = HttpRequest.post(url).
|
||||||
|
header("appId", "800050").
|
||||||
|
header("apiCode", "8000500023").
|
||||||
|
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
|
||||||
|
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||||
|
body(sendData.toJSONString()).
|
||||||
|
execute().
|
||||||
|
body();
|
||||||
|
logger.error("推送应收单返回:" + tokenResult);
|
||||||
|
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
|
||||||
|
if (resoutJson.getBoolean("flag")) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("推送应收单成功");
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("推送应收单失败:" + resoutJson.getString("msg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mainData
|
||||||
|
* @param detailArray
|
||||||
|
* @return com.alibaba.fastjson.JSONObject
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 组装数据
|
||||||
|
* @Date 6:12 下午 2025/6/27
|
||||||
|
**/
|
||||||
|
private JSONObject getSendYsdData(JSONObject mainData, JSONArray detailArray) throws ParseException {
|
||||||
|
// 创建主JSONObject
|
||||||
|
JSONObject mainJson = new JSONObject();
|
||||||
|
mainJson.put("billtype", "ys");
|
||||||
|
// 创建data JSONObject
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("sourceSystem", "OA");
|
||||||
|
data.put("billcode", mainData.getString("field0001"));
|
||||||
|
if ("cs199".equals(mainData.getString("field0130"))) {
|
||||||
|
data.put("orgcode", "666");
|
||||||
|
} else {
|
||||||
|
data.put("orgcode", mainData.getString("field0130"));
|
||||||
|
}
|
||||||
|
data.put("billdate", mainData.getString("field0151"));
|
||||||
|
data.put("busidate", mainData.getString("field0151"));
|
||||||
|
data.put("pk_psndoc", mainData.getString("field0006"));
|
||||||
|
data.put("scomment", "");
|
||||||
|
data.put("objtype", "0");
|
||||||
|
data.put("tradingCode", mainData.getString("field0091"));
|
||||||
|
data.put("amount", mainData.getString("field0174"));
|
||||||
|
data.put("usercode", "OA01");
|
||||||
|
data.put("deptcode", mainData.getString("field0124"));
|
||||||
|
data.put("projectno", null);
|
||||||
|
data.put("paytype", null);
|
||||||
|
data.put("fkxz", null);
|
||||||
|
//data.put("ipo", "");
|
||||||
|
//data.put("cpo", "");
|
||||||
|
data.put("recaccount", mainData.getString("field0165"));
|
||||||
|
data.put("currency", "CNY");
|
||||||
|
//data.put("bankSeq", "");
|
||||||
|
data.put("localAmount", mainData.getString("field0174"));
|
||||||
|
data.put("rate", "1");
|
||||||
|
data.put("creator", "OA01");
|
||||||
|
JSONArray expenseList = new JSONArray();
|
||||||
|
|
||||||
|
if (detailArray != null && detailArray.size() > 0) {
|
||||||
|
for (int i = 0; i < detailArray.size(); i++) {
|
||||||
|
// 创建expenseList JSONArray
|
||||||
|
JSONObject expenseItem = new JSONObject();
|
||||||
|
expenseItem.put("materialCode", "");
|
||||||
|
expenseItem.put("invoiceno", mainData.getString("field0150"));
|
||||||
|
expenseItem.put("sklx", "");
|
||||||
|
expenseItem.put("buysellflag", "1");
|
||||||
|
expenseItem.put("szxm", "");
|
||||||
|
expenseItem.put("notaxAmount", detailArray.getJSONObject(i).getString("field0160"));
|
||||||
|
expenseItem.put("localNotaxAmount", detailArray.getJSONObject(i).getString("field0160"));
|
||||||
|
expenseItem.put("srcDetailId", null);
|
||||||
|
expenseItem.put("balatype", null);
|
||||||
|
expenseItem.put("cashaccount", null);
|
||||||
|
expenseItem.put("scomment", mainData.getString("field0191"));
|
||||||
|
expenseItem.put("amount", detailArray.getJSONObject(i).getString("field0149"));
|
||||||
|
expenseItem.put("deptcode", detailArray.getJSONObject(i).getString("field0124"));
|
||||||
|
expenseItem.put("recaccount", detailArray.getJSONObject(i).getString("field0165"));
|
||||||
|
expenseItem.put("taxAmount", detailArray.getJSONObject(i).getString("field0159"));
|
||||||
|
expenseItem.put("quantity", detailArray.getJSONObject(i).getString("field0157"));
|
||||||
|
expenseItem.put("localAmount", detailArray.getJSONObject(i).getString("field0149"));
|
||||||
|
expenseItem.put("detailId", detailArray.getJSONObject(i).getString("field0192"));
|
||||||
|
if(detailArray.getJSONObject(i).getString("field0156") != null && !"".equals(detailArray.getJSONObject(i).getString("field0156"))){
|
||||||
|
BigDecimal value = detailArray.getJSONObject(i).getBigDecimal("field0156");
|
||||||
|
int result = value.multiply(BigDecimal.valueOf(100)).intValue(); // 结果:5
|
||||||
|
expenseItem.put("taxRate", String.valueOf(result));
|
||||||
|
}else {
|
||||||
|
expenseItem.put("taxRate", "0");
|
||||||
|
|
||||||
|
}
|
||||||
|
expenseItem.put("kplx", detailArray.getJSONObject(i).getString("field0148"));
|
||||||
|
//expenseItem.put("areacl", "");
|
||||||
|
expenseItem.put("subjectCode", "1122");
|
||||||
|
expenseItem.put("projectCode", detailArray.getJSONObject(i).getString("field0190")); // 项目号
|
||||||
|
expenseItem.put("ghNo", ""); // 收入确认单号
|
||||||
|
expenseItem.put("ghNo", detailArray.getJSONObject(i).getString("field0148")); // 应收业务性质
|
||||||
|
|
||||||
|
expenseList.add(expenseItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 将expenseList添加到data
|
||||||
|
data.put("expenseList", expenseList);
|
||||||
|
// 将data添加到主JSONObject
|
||||||
|
mainJson.put("data", data);
|
||||||
|
return mainJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 发送蓝票
|
||||||
|
* @Date 1:44 下午 2025/7/9
|
||||||
|
**/
|
||||||
|
public JsonResultEntity sendNuoNuoFaPiaolp(JSONObject requestJson) {
|
||||||
|
logger.error("同步诺诺发票蓝字:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject mainData = businessDataStr.getJSONObject("formmain_11951");
|
||||||
|
if (mainData == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONArray detailArray = businessDataStr.getJSONArray("formson_11953");
|
||||||
|
if (mainData.getString("field0168") != null && "SJ".equals(mainData.getString("field0168"))) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("发票类型为SJ,不传诺税通");
|
||||||
|
}
|
||||||
|
if (mainData.getString("field0150") != null && !"".equals(mainData.getString("field0150"))) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("发票号码已存在,不传诺税通");
|
||||||
|
}
|
||||||
|
//组装发送数据
|
||||||
|
JSONObject sendData = null;
|
||||||
|
try {
|
||||||
|
sendData = getSendData(mainData, detailArray);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return BaseResult.getFailureMessageEntity("推送诺诺发票失败:组装数据失败");
|
||||||
|
|
||||||
|
}
|
||||||
|
//发送数据
|
||||||
|
logger.error("推送诺诺发票推送:" + sendData.toJSONString());
|
||||||
|
|
||||||
|
String tokenResult = HttpRequest.post(url).
|
||||||
|
header("appId", "800051").
|
||||||
|
header("apiCode", "8000510012").
|
||||||
|
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
|
||||||
|
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||||
|
body(sendData.toJSONString()).
|
||||||
|
execute().
|
||||||
|
body();
|
||||||
|
logger.error("推送诺诺发票返回:" + tokenResult);
|
||||||
|
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
|
||||||
|
if (resoutJson.getBoolean("flag")) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("推送诺诺发票成功");
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("推送诺诺发票失败:" + resoutJson.getString("msg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mainData
|
||||||
|
* @param detailArray
|
||||||
|
* @return com.alibaba.fastjson.JSONObject
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 组装数据
|
||||||
|
* @Date 6:12 下午 2025/6/27
|
||||||
|
**/
|
||||||
|
private JSONObject getSendData(JSONObject mainData, JSONArray detailArray) throws ParseException {
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
sendData.put("buyerName", mainData.getString("field0092"));//购方名称
|
||||||
|
sendData.put("buyerTaxnum", mainData.getString("field0146"));//购方税号
|
||||||
|
sendData.put("buyerAddress", mainData.getString("field0134"));//购方地址
|
||||||
|
sendData.put("buyerPhone", mainData.getString("field0135"));//购方电话
|
||||||
|
sendData.put("buyerBank", mainData.getString("field0128"));//购方开户行
|
||||||
|
sendData.put("buyerAccount", mainData.getString("field0139"));//购方银行账号
|
||||||
|
sendData.put("orderNo", mainData.getString("field0001"));//订单编号
|
||||||
|
//sendData.put("bizCallbackUrl", "http://10.0.2.112:9021/kangarooDataCenterV3/entranceController/nuoNuoCallback");//回调地址测试
|
||||||
|
sendData.put("bizCallbackUrl","http://10.0.2.112:9011/kangarooDataCenterV3/entranceController/nuoNuoCallback");//回调地址正式
|
||||||
|
sendData.put("sellerName", mainData.getString("field0129"));//销方名称
|
||||||
|
sendData.put("sellerTaxnum", mainData.getString("field0162"));//销方税号
|
||||||
|
sendData.put("sellerAddress", mainData.getString("field0161"));//销方地址
|
||||||
|
sendData.put("sellerPhone", mainData.getString("field0163"));//销方电话
|
||||||
|
sendData.put("sellerBank", mainData.getString("field0164"));//销方开户银行
|
||||||
|
sendData.put("sellerAccount", mainData.getString("field0165"));//销方银行账号
|
||||||
|
sendData.put("invoiceLine", mainData.getString("field0168"));//发票种类,bs:数电专票(电子),pc:数电普票(电子)
|
||||||
|
sendData.put("invoiceType", 1);//开票类型,1:蓝票;2:红票
|
||||||
|
sendData.put("substituteFlag", 0);//代开标志,0:非代开;1:代开。
|
||||||
|
sendData.put("listFlag", 0);//清单标志,0:非清单;1:清单
|
||||||
|
sendData.put("notifyType", -1);//推送方式,-1:不推送;0:邮箱;1:手机(默认);2:邮箱、手机;3:根据交付手机、邮箱动态交付
|
||||||
|
sendData.put("requestSrc", 0);//请求来源,0 :api接口
|
||||||
|
sendData.put("checkBlue", 0);//开具红票时是否校验蓝票 0.校验蓝票是否存在诺税通 1.不校验蓝票是否存在诺税通但校验可冲红金额 2.不校验蓝票是否存在诺税通且不校验可冲红金额
|
||||||
|
JSONArray sendArray = new JSONArray();
|
||||||
|
|
||||||
|
String ys = null;
|
||||||
|
String field0177 = null;
|
||||||
|
String field0190 = null;
|
||||||
|
if (detailArray != null && detailArray.size() > 0) {
|
||||||
|
for (int i = 0; i < detailArray.size(); i++) {
|
||||||
|
if (detailArray.getJSONObject(i).getString("field0193") != null && "06".equals(detailArray.getJSONObject(i).getString("field0193"))) {
|
||||||
|
ys = "06";
|
||||||
|
field0177 = detailArray.getJSONObject(i).getString("field0177");
|
||||||
|
}
|
||||||
|
if (detailArray.getJSONObject(i).getString("field0193") != null && "03".equals(detailArray.getJSONObject(i).getString("field0193"))) {
|
||||||
|
ys = "03";
|
||||||
|
field0190 = detailArray.getJSONObject(i).getString("field0190");
|
||||||
|
}
|
||||||
|
JSONObject detail = new JSONObject();
|
||||||
|
detail.put("detailIndex", detailArray.getJSONObject(i).getString("field0147"));//明细序号数电票明细行必须从1开始编号
|
||||||
|
detail.put("detailType", 0);//明细行性质:0,正常行;1,折扣行;2,被折扣行
|
||||||
|
detail.put("goodsName", detailArray.getJSONObject(i).getString("field0148"));//商品名称
|
||||||
|
if (detailArray.getJSONObject(i).getString("field0159") != null && !"".equals(detailArray.getJSONObject(i).getString("field0159"))
|
||||||
|
&& detailArray.getJSONObject(i).getBigDecimal("field0159").compareTo(BigDecimal.ONE) == 0 //税额
|
||||||
|
) {
|
||||||
|
detail.put("withTaxFlag", 0);//含税标志,0:不含税,1:含税
|
||||||
|
} else {
|
||||||
|
detail.put("withTaxFlag", 1);//含税标志,0:不含税,1:含税
|
||||||
|
}
|
||||||
|
if(ys == null || !"03".equals(ys)){
|
||||||
|
detail.put("goodsPrice", detailArray.getJSONObject(i).getString("field0154"));//含税单价
|
||||||
|
detail.put("taxFreePrice", detailArray.getJSONObject(i).getString("field0155"));//不含税单价
|
||||||
|
detail.put("goodsNum", detailArray.getJSONObject(i).getString("field0157"));//数量
|
||||||
|
}
|
||||||
|
detail.put("taxrate", detailArray.getJSONObject(i).getString("field0156"));//税率
|
||||||
|
detail.put("goodsCode", detailArray.getJSONObject(i).getString("field0158"));//税收分类编码
|
||||||
|
detail.put("favouredPolicyCode", detailArray.getJSONObject(i).getString("field0170"));//优惠政策编码
|
||||||
|
detail.put("deduction", detailArray.getJSONObject(i).getString("field0172"));//扣除额
|
||||||
|
detail.put("taxFreeAmount", detailArray.getJSONObject(i).getString("field0160"));//不含税金额
|
||||||
|
detail.put("tax", detailArray.getJSONObject(i).getString("field0159"));//税额
|
||||||
|
detail.put("taxAmount", detailArray.getJSONObject(i).getString("field0149"));//含税金额
|
||||||
|
if (detailArray.getJSONObject(i).getString("field0147") != null && !"".equals(detailArray.getJSONObject(i).getString("field0147"))) {
|
||||||
|
detail.put("favouredPolicyFlag", "1");//优惠政策标识,0:不使用;1:使用 数电发票时为空,仅传入优惠政策编码即可
|
||||||
|
} else {
|
||||||
|
detail.put("favouredPolicyFlag", "0");//优惠政策标识,0:不使用;1:使用 数电发票时为空,仅传入优惠政策编码即可
|
||||||
|
}
|
||||||
|
sendArray.add(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendData.put("detail", sendArray);
|
||||||
|
if ("06".equals(ys)) {
|
||||||
|
sendData.put("specificFactor", "06");//不动产租赁发票
|
||||||
|
JSONArray realPropertyRentInfoList = new JSONArray();
|
||||||
|
JSONObject detail = new JSONObject();
|
||||||
|
detail.put("realPropertyAddress", mainData.getString("field0182"));//不动产地址
|
||||||
|
detail.put("detailAddress", mainData.getString("field0180"));//不动产详细地址
|
||||||
|
detail.put("realPropertyCertificate", field0177);//规格型号/不动产权证
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date date = inputFormat.parse(mainData.getString("field0183"));
|
||||||
|
detail.put("rentStartDate", sdf.format(date));//租赁期起期,停车费业务支持yyyy-MM-dd HH:mm格式
|
||||||
|
Date date1 = inputFormat.parse(mainData.getString("field0184"));
|
||||||
|
detail.put("rentEndDate", sdf.format(date1));//租赁期止期支持yyyy-MM-dd HH:mm格式
|
||||||
|
if (mainData.getString("field0185") != null && "1".equals(mainData.getString("field0185"))) {
|
||||||
|
detail.put("crossCityFlag", 1);//跨地市标志
|
||||||
|
} else {
|
||||||
|
detail.put("crossCityFlag", 0);//跨地市标志
|
||||||
|
}
|
||||||
|
detail.put("unit", mainData.getString("field0186"));//面积单位(默认平方米)
|
||||||
|
realPropertyRentInfoList.add(detail);
|
||||||
|
sendData.put("realPropertyRentInfoList", realPropertyRentInfoList);//不动产租赁发票
|
||||||
|
}else if ("03".equals(ys)) {
|
||||||
|
sendData.put("specificFactor", "03");//建筑服务
|
||||||
|
JSONObject detail = new JSONObject();
|
||||||
|
detail.put("buildingAddress", mainData.getString("field0182"));//建筑服务发生地
|
||||||
|
detail.put("detailedAddress", mainData.getString("field0180"));//不动产详细地址
|
||||||
|
detail.put("landVatItemNo", mainData.getString("field0194"));//土地增值税项目编号
|
||||||
|
detail.put("itemName", field0190);//项目名称
|
||||||
|
detail.put("taxRelatedNumber", mainData.getString("field0196"));//跨区域涉税事项报验管理编号
|
||||||
|
|
||||||
|
if (mainData.getString("field0185") != null && "1".equals(mainData.getString("field0185"))) {
|
||||||
|
detail.put("crossCityFlag", 1);//跨地市标志
|
||||||
|
} else {
|
||||||
|
detail.put("crossCityFlag", 0);//跨地市标志
|
||||||
|
}
|
||||||
|
sendData.put("invoiceBuildingInfo", detail);//不动产租赁发票
|
||||||
|
}else {
|
||||||
|
StringBuffer asd = new StringBuffer();
|
||||||
|
if(mainData.getString("field0179") != null){
|
||||||
|
asd.append(mainData.getString("field0179"));
|
||||||
|
asd.append(" ");
|
||||||
|
}
|
||||||
|
if(mainData.getString("field0180") != null){
|
||||||
|
asd.append(mainData.getString("field0180"));
|
||||||
|
asd.append(" ");
|
||||||
|
}
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
if(mainData.getString("field0183") != null){
|
||||||
|
Date date = inputFormat.parse(mainData.getString("field0183"));
|
||||||
|
asd.append(sdf.format(date));
|
||||||
|
asd.append(" ");
|
||||||
|
}
|
||||||
|
if(mainData.getString("field0184") != null){
|
||||||
|
Date date = inputFormat.parse(mainData.getString("field0184"));
|
||||||
|
asd.append(sdf.format(date));
|
||||||
|
asd.append(" ");
|
||||||
|
}
|
||||||
|
if(asd != null && !"".equals(asd.toString())){
|
||||||
|
sendData.put("remark",asd.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sendData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 诺诺发票确认单
|
||||||
|
* @Date 4:35 下午 2025/7/2
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity sendNuoNuoFaPiaoQrd(JSONObject requestJson) {
|
||||||
|
logger.error("同步诺诺发票确认单:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject mainData = businessDataStr.getJSONObject("formmain_11970");
|
||||||
|
if (mainData == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONArray detailArray = businessDataStr.getJSONArray("formson_11971");
|
||||||
|
if (mainData.getString("field0168") != null && "SJ".equals(mainData.getString("field0168"))) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("发票类型为SJ,不传诺税通");
|
||||||
|
}
|
||||||
|
//组装发送数据
|
||||||
|
JSONObject sendData = getSendDataQrd(mainData, detailArray);
|
||||||
|
//发送数据
|
||||||
|
logger.error("推送诺诺发票确认单推送:" + sendData.toJSONString());
|
||||||
|
|
||||||
|
String tokenResult = HttpRequest.post(url).
|
||||||
|
header("appId", "800051").
|
||||||
|
header("apiCode", "8000510013").
|
||||||
|
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
|
||||||
|
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||||
|
body(sendData.toJSONString()).
|
||||||
|
execute().
|
||||||
|
body();
|
||||||
|
logger.error("推送诺诺发票确认单返回1:" + tokenResult);
|
||||||
|
try {
|
||||||
|
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
|
||||||
|
logger.error("推送诺诺发票确认单返回2:" + resoutJson.toJSONString());
|
||||||
|
|
||||||
|
if (resoutJson.getBoolean("flag")) {
|
||||||
|
try {
|
||||||
|
JSONObject attribute = resoutJson.getJSONObject("attribute");
|
||||||
|
logger.error("推送诺诺发票确认单返回3:" + attribute.toJSONString());
|
||||||
|
NuoNuoEntity nuoNuoEntity = new NuoNuoEntity();
|
||||||
|
nuoNuoEntity.setDataSourceCode("SW-OA");
|
||||||
|
nuoNuoEntity.setId(mainData.getString("id"));
|
||||||
|
nuoNuoEntity.setField0191(attribute.getString("data"));
|
||||||
|
nuoNuoDao.updateHpdata(nuoNuoEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("推送诺诺发票确认单保存错误" + e.getMessage());
|
||||||
|
}
|
||||||
|
return BaseResult.getSuccessMessageEntity("推送诺诺发票确认单成功");
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("推送诺诺发票确认单失败:" + resoutJson.getString("msg"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("推送诺诺发票确认单保存错误1" + e.getMessage());
|
||||||
|
return BaseResult.getFailureMessageEntity("推送诺诺发票确认单失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject getSendDataQrd(JSONObject mainData, JSONArray detailArray) {
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
sendData.put("applySource", 0);//申请方身份:0 销方
|
||||||
|
sendData.put("taxNum", mainData.getString("field0162"));//销方税号
|
||||||
|
sendData.put("blueInvoiceNumber", mainData.getString("field0178"));//蓝子发票号
|
||||||
|
if (mainData.getString("field0190") != null) {
|
||||||
|
if ("6299379468699910521".equals(mainData.getString("field0190"))) {
|
||||||
|
sendData.put("redReason", "2");//冲红原因:1销货退回2开票有误3服务中止4销售折让
|
||||||
|
} else if ("1471920473864226411".equals(mainData.getString("field0190"))) {
|
||||||
|
sendData.put("redReason", "3");//冲红原因:1销货退回2开票有误3服务中止4销售折让
|
||||||
|
} else if ("2608861944110465928".equals(mainData.getString("field0190"))) {
|
||||||
|
sendData.put("redReason", "4");//冲红原因:1销货退回2开票有误3服务中止4销售折让
|
||||||
|
} else if ("-2754201006580086516".equals(mainData.getString("field0190"))) {
|
||||||
|
sendData.put("redReason", "1");//冲红原因:1销货退回2开票有误3服务中止4销售折让
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sendData.put("bizCallbackUrl", "http://10.0.2.112:9021/kangarooDataCenterV3/entranceController/nuoNuoQrdCallback");//回调地址测试
|
||||||
|
sendData.put("bizCallbackUrl","http://10.0.2.112:9011/kangarooDataCenterV3/entranceController/nuoNuoQrdCallback");//回调地址正式
|
||||||
|
return sendData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 诺诺发票红冲
|
||||||
|
* @Date 4:35 下午 2025/7/2
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity sendNuoNuoFaPiaoHc(JSONObject requestJson) {
|
||||||
|
logger.error("同步诺诺发票红冲:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject mainData = businessDataStr.getJSONObject("formmain_11970");
|
||||||
|
if (mainData == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONArray detailArray = businessDataStr.getJSONArray("formson_11971");
|
||||||
|
if (mainData.getString("field0168") != null && "SJ".equals(mainData.getString("field0168"))) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("发票类型为SJ,不传诺税通");
|
||||||
|
}
|
||||||
|
if (mainData.getString("field0192") == null) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("红字确认单状态为空");
|
||||||
|
}
|
||||||
|
if ("01".equals(mainData.getString("field0192")) || "04".equals(mainData.getString("field0192"))) {
|
||||||
|
//组装发送数据
|
||||||
|
JSONObject sendData = getSendDataHc(mainData, detailArray);
|
||||||
|
//发送数据
|
||||||
|
logger.error("推送诺诺发票红冲推送:" + sendData.toJSONString());
|
||||||
|
|
||||||
|
String tokenResult = HttpRequest.post(url).
|
||||||
|
header("appId", "800051").
|
||||||
|
header("apiCode", "8000510014").
|
||||||
|
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
|
||||||
|
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||||
|
body(sendData.toJSONString()).
|
||||||
|
execute().
|
||||||
|
body();
|
||||||
|
logger.error("推送诺诺发票红冲返回:" + tokenResult);
|
||||||
|
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
|
||||||
|
if (resoutJson.getBoolean("flag")) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("推送诺诺发票红冲成功");
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("推送诺诺发票红冲失败:" + resoutJson.getString("msg"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("红字确认单状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject getSendDataHc(JSONObject mainData, JSONArray detailArray) {
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
sendData.put("fastRedType", 1);//快捷冲红类型 不填或者0为普通快捷冲红 1:数电发票快捷冲红(数电发票必传1)
|
||||||
|
sendData.put("sellerTaxnum", mainData.getString("field0162"));//销方税号
|
||||||
|
sendData.put("invoiceNumber", mainData.getString("field0178"));//蓝票发票号码
|
||||||
|
//sendData.put("invoiceCode",mainData.getString("field0178"));//蓝票发票代码
|
||||||
|
//可能需要转换
|
||||||
|
sendData.put("billId", mainData.getString("field0191"));//红字确认单申请单号
|
||||||
|
//sendData.put("bizCallbackUrl", "http://10.0.2.112:9021/kangarooDataCenterV3/entranceController/nuoNuoHcCallback");//回调地址测试
|
||||||
|
sendData.put("bizCallbackUrl","http://10.0.2.112:9011/kangarooDataCenterV3/entranceController/nuoNuoHcCallback");//回调地址正式
|
||||||
|
return sendData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity sendNuoNuoFaPiaoHp(JSONObject requestJson) {
|
||||||
|
logger.error("诺诺发票红冲节点参数:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
String affairId = jsonStr.getString("affairId");
|
||||||
|
if (affairId != null && !"".equals(affairId)) {
|
||||||
|
NuoNuoEntity nuoNuoEntity = new NuoNuoEntity();
|
||||||
|
nuoNuoEntity.setDataSourceCode("SW-OA");
|
||||||
|
nuoNuoEntity.setAffairId(affairId);
|
||||||
|
List<NuoNuoEntity> nuoNuoEntities = nuoNuoDao.queryAffair(nuoNuoEntity);
|
||||||
|
if (nuoNuoEntities != null && nuoNuoEntities.size() == 1) {
|
||||||
|
if (nuoNuoEntities.get(0).getNoname() != null) {
|
||||||
|
if ("确认申请".equals(nuoNuoEntities.get(0).getNoname()) || "确认申请".equals(nuoNuoEntities.get(0).getNodename())) {
|
||||||
|
return sendNuoNuoFaPiaoQrd(requestJson);
|
||||||
|
} else if ("红字开票".equals(nuoNuoEntities.get(0).getNoname()) || "红字开票".equals(nuoNuoEntities.get(0).getNodename())) {
|
||||||
|
return sendNuoNuoFaPiaoHc(requestJson);
|
||||||
|
} else if ("ERP审批".equals(nuoNuoEntities.get(0).getNoname()) || "ERP审批".equals(nuoNuoEntities.get(0).getNodename())) {
|
||||||
|
return sendBipFaPiaoHc(requestJson);
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("节点查找失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param requestJson
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 发送BIP红冲
|
||||||
|
* @Date 1:49 下午 2025/7/9
|
||||||
|
**/
|
||||||
|
private JsonResultEntity sendBipFaPiaoHc(JSONObject requestJson) {
|
||||||
|
logger.error("同步红冲应收单:" + requestJson.toJSONString());
|
||||||
|
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
|
||||||
|
if (jsonStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
|
||||||
|
if (businessDataStr == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONObject mainData = businessDataStr.getJSONObject("formmain_11970");
|
||||||
|
if (mainData == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("系统错误");
|
||||||
|
}
|
||||||
|
JSONArray detailArray = businessDataStr.getJSONArray("formson_11971");
|
||||||
|
//组装发送数据
|
||||||
|
JSONObject sendData = null;
|
||||||
|
try {
|
||||||
|
sendData = getSendHcYsdData(mainData, detailArray);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return BaseResult.getFailureMessageEntity("推送红冲应收单失败:组装数据失败");
|
||||||
|
}
|
||||||
|
//发送数据
|
||||||
|
logger.error("推送红冲应收单推送:" + sendData.toJSONString());
|
||||||
|
|
||||||
|
String tokenResult = HttpRequest.post(url).
|
||||||
|
header("appId", "800050").
|
||||||
|
header("apiCode", "8000500024").
|
||||||
|
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
|
||||||
|
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
||||||
|
body(sendData.toJSONString()).
|
||||||
|
execute().
|
||||||
|
body();
|
||||||
|
logger.error("推送红冲应收单返回:" + tokenResult);
|
||||||
|
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
|
||||||
|
if (resoutJson.getBoolean("flag")) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("推送红冲应收单成功");
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("推送红冲应收单失败:" + resoutJson.getString("msg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mainData
|
||||||
|
* @param detailArray
|
||||||
|
* @return com.alibaba.fastjson.JSONObject
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 组装数据
|
||||||
|
* @Date 6:12 下午 2025/6/27
|
||||||
|
**/
|
||||||
|
private JSONObject getSendHcYsdData(JSONObject mainData, JSONArray detailArray) throws ParseException {
|
||||||
|
// 创建主JSONObject
|
||||||
|
JSONObject mainJson = new JSONObject();
|
||||||
|
mainJson.put("billtype", "ys");
|
||||||
|
// 创建data JSONObject
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("sourceSystem", "OA");
|
||||||
|
data.put("billcode", mainData.getString("field0001"));
|
||||||
|
if ("cs199".equals(mainData.getString("field0130"))) {
|
||||||
|
data.put("orgcode", "666");
|
||||||
|
} else {
|
||||||
|
data.put("orgcode", mainData.getString("field0130"));
|
||||||
|
}
|
||||||
|
data.put("billdate", mainData.getString("field0151"));
|
||||||
|
data.put("busidate", mainData.getString("field0151"));
|
||||||
|
data.put("pk_psndoc", mainData.getString("field0006"));
|
||||||
|
data.put("scomment", "");
|
||||||
|
data.put("objtype", "0");
|
||||||
|
data.put("tradingCode", mainData.getString("field0091"));
|
||||||
|
data.put("amount", mainData.getString("field0174") != null ? mainData.getBigDecimal("field0174") : "0");
|
||||||
|
data.put("usercode", "OA01");
|
||||||
|
data.put("deptcode", mainData.getString("field0124"));
|
||||||
|
data.put("projectno", null);
|
||||||
|
data.put("paytype", null);
|
||||||
|
data.put("fkxz", null);
|
||||||
|
//data.put("ipo", "");
|
||||||
|
//data.put("cpo", "");
|
||||||
|
data.put("recaccount", mainData.getString("field0165"));
|
||||||
|
data.put("currency", "CNY");
|
||||||
|
//data.put("bankSeq", "");
|
||||||
|
data.put("localAmount", mainData.getString("field0174") != null ? mainData.getBigDecimal("field0174") : "0");
|
||||||
|
data.put("rate", "1");
|
||||||
|
data.put("creator", "OA01");
|
||||||
|
JSONArray expenseList = new JSONArray();
|
||||||
|
|
||||||
|
if (detailArray != null && detailArray.size() > 0) {
|
||||||
|
for (int i = 0; i < detailArray.size(); i++) {
|
||||||
|
// 创建expenseList JSONArray
|
||||||
|
JSONObject expenseItem = new JSONObject();
|
||||||
|
expenseItem.put("materialCode", "");
|
||||||
|
expenseItem.put("invoiceno", mainData.getString("field0150"));
|
||||||
|
expenseItem.put("sklx", "");
|
||||||
|
expenseItem.put("buysellflag", "1");
|
||||||
|
expenseItem.put("szxm", "");
|
||||||
|
expenseItem.put("notaxAmount", detailArray.getJSONObject(i).getString("field0160") != null ? detailArray.getJSONObject(i).getBigDecimal("field0160") : "0");
|
||||||
|
expenseItem.put("localNotaxAmount", detailArray.getJSONObject(i).getString("field0160") != null ? detailArray.getJSONObject(i).getBigDecimal("field0160") : "0");
|
||||||
|
expenseItem.put("srcDetailId", null);
|
||||||
|
expenseItem.put("balatype", null);
|
||||||
|
expenseItem.put("cashaccount", null);
|
||||||
|
expenseItem.put("scomment", mainData.getString("field0178"));
|
||||||
|
expenseItem.put("amount", detailArray.getJSONObject(i).getString("field0149") != null ? detailArray.getJSONObject(i).getBigDecimal("field0149") : "0");
|
||||||
|
expenseItem.put("deptcode", detailArray.getJSONObject(i).getString("field0124"));
|
||||||
|
expenseItem.put("recaccount", detailArray.getJSONObject(i).getString("field0165"));
|
||||||
|
expenseItem.put("taxAmount", detailArray.getJSONObject(i).getString("field0159") != null ? detailArray.getJSONObject(i).getBigDecimal("field0159") : "0");
|
||||||
|
expenseItem.put("quantity", detailArray.getJSONObject(i).getString("field0157"));
|
||||||
|
expenseItem.put("localAmount", detailArray.getJSONObject(i).getString("field0149") != null ? detailArray.getJSONObject(i).getBigDecimal("field0149") : "0");
|
||||||
|
expenseItem.put("detailId", detailArray.getJSONObject(i).getString("field0197"));
|
||||||
|
if(detailArray.getJSONObject(i).getString("field0156") != null && !"".equals(detailArray.getJSONObject(i).getString("field0156"))){
|
||||||
|
BigDecimal value = detailArray.getJSONObject(i).getBigDecimal("field0156");
|
||||||
|
int result = value.multiply(BigDecimal.valueOf(100)).intValue(); // 结果:5
|
||||||
|
expenseItem.put("taxRate", String.valueOf(result));
|
||||||
|
}else {
|
||||||
|
expenseItem.put("taxRate", "0");
|
||||||
|
}
|
||||||
|
expenseItem.put("kplx", detailArray.getJSONObject(i).getString("field0148"));
|
||||||
|
//expenseItem.put("areacl", "");
|
||||||
|
expenseItem.put("subjectCode", "1122");
|
||||||
|
expenseItem.put("projectCode", detailArray.getJSONObject(i).getString("field0188")); // 项目号
|
||||||
|
expenseItem.put("ghNo", ""); // 收入确认单号
|
||||||
|
expenseItem.put("ghNo", detailArray.getJSONObject(i).getString("field0148")); // 应收业务性质
|
||||||
|
expenseList.add(expenseItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 将expenseList添加到data
|
||||||
|
data.put("expenseList", expenseList);
|
||||||
|
// 将data添加到主JSONObject
|
||||||
|
mainJson.put("data", data);
|
||||||
|
return mainJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue