This commit is contained in:
username 2024-08-29 15:08:18 +08:00
commit 2651fecbe9
10 changed files with 270 additions and 161 deletions

View File

@ -19,8 +19,11 @@ spring:
savefile: savefile:
# 文件保存路径 # 文件保存路径
path: /home/webservice/zt/file path: /home/webservice/zt/file
pluginpath: D:/local/plugin/ # path: D:\webservice\file
tomcatpath: E:\apache-tomcat-9.0.27\webapps\kangarooDataCenterV3\WEB-INF\classes\ # pluginpath: D:\webservice\plugin
pluginpath: /home/webservice/zt/plugin
# tomcatpath: D:\apache-tomcat-9.0.69\webapps\kangarooDataCenter\WEB-INF\classes\
tomcatpath: /home/webservice/zt/tomcatV3/webapps/kangarooDataCenterV3/WEB-INF/classes/
cbs8: cbs8:
appId: 1P4AGrpz appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a

View File

@ -4,6 +4,7 @@ import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity; import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* (gl_pzml: table)表数据库访问层 * (gl_pzml: table)表数据库访问层
@ -83,6 +84,16 @@ public interface ISenderGlPzmlDao extends IBaseDao<SenderGlPzmlEntity, String> {
* **/ * **/
Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity); Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity);
/**
*
* @content 查询凭证 商学院
* @Param
* @Return
* @Author hecan
* @Date 2024/8/14 16:25
* **/
List<SenderGlPzmlEntity> queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity);
} }

View File

@ -8,6 +8,7 @@ import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* (GlPzml)表数据库访问层 * (GlPzml)表数据库访问层
@ -60,5 +61,11 @@ public class SenderGlPzmlDaoImpl extends MybatisGenericDao<SenderGlPzmlEntity, S
public Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity) { public Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity) {
return super.delete("SenderGlPzmlEntity_delete_pzml",senderGlPzmlEntity); return super.delete("SenderGlPzmlEntity_delete_pzml",senderGlPzmlEntity);
} }
@Override
@DS("#senderGlPzmlEntity.dataSourceCode")
public List<SenderGlPzmlEntity> queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity) {
return (List<SenderGlPzmlEntity>) super.selectList("queryGlPzmlSxy",senderGlPzmlEntity);
}
} }

View File

@ -54,6 +54,16 @@ public class SenderGlPzmlEntity extends BaseEntity {
private String stamp; private String stamp;
private String yspzje; private String yspzje;
private String bmdm;
public String getBmdm() {
return bmdm;
}
public void setBmdm(String bmdm) {
this.bmdm = bmdm;
}
public String getPzsbm() { public String getPzsbm() {
return pzsbm; return pzsbm;
} }

View File

@ -259,6 +259,31 @@
</trim> </trim>
</select> </select>
<!-- 查询列表 商学院所需要的凭证数据-->
<select id="queryGlPzmlSxy" resultMap="get-SenderGlPzmlEntity-result" parameterType = "com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity">
select
pzml.idpzh as idpzh,
pzml.kjqj as kjqj,
pzml.srrq as srrq,
pzml.srID as srID,
pznr.bmdm as bmdm,
pzml.pzzy as pzzy,
sum(pznr.je) as pzje,
pzml.gsdm,pzml.zth,pzml.kjqj,pzml.pzh
from GL_Pzml pzml
left join gl_pznr pznr on pznr.idpzh=pzml.idpzh and pzml.kjqj=pznr.kjqj
<trim prefix="where" prefixOverrides="and">
<if test="idpzh !=null and idpzh!='' "> and pzml.idpzh = #{idpzh} </if>
and pzml.kjqj =#{kjqj} and pznr.kjqj =#{kjqj} and pznr.zbid!=0
</trim>
group by pzml.idpzh,
pzml.kjqj,
pzml.srrq,
pzml.pzzy,
pzml.gsdm,pzml.zth,pzml.kjqj,pzml.pzh,pzml.srID,pznr.bmdm
</select>
<!--新增所有列--> <!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity" keyProperty="" useGeneratedKeys="true"> <insert id="entity_insert" parameterType = "com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity" keyProperty="" useGeneratedKeys="true">
insert into gl_pzml( insert into gl_pzml(

View File

@ -95,11 +95,11 @@ public interface ISenderGlPzmlService extends IBaseService<SenderGlPzmlEntity, S
/** /**
* *
* @content 保存凭证 商学院 确定指标被哪些凭证使用 * @content 查询凭证 商学院 确定指标被哪些凭证使用
* @Param * @Param
* @Return * @Return
* @Author hecan * @Author hecan
* @Date 2024/8/13 17:00 * @Date 2024/8/13 17:00
* **/ * **/
Object saveGlPzmlSxy(JSONObject jsonObject); Object queryGlPzmlSxy(JSONObject jsonObject);
} }

View File

@ -8,6 +8,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService; import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.dao.IGbiZbsyrecDao;
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity;
import com.hzya.frame.grpU8.nxproof.gbizbxmb.dao.IGbiZbxmbDao;
import com.hzya.frame.grpU8.nxproof.gbizbxmb.entity.GbiZbxmbEntity;
import com.hzya.frame.grpU8.nxproof.glPzml.dao.ISenderGlPzmlDao; import com.hzya.frame.grpU8.nxproof.glPzml.dao.ISenderGlPzmlDao;
import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity; import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
import com.hzya.frame.grpU8.nxproof.glPzml.service.ISenderGlPzmlService; import com.hzya.frame.grpU8.nxproof.glPzml.service.ISenderGlPzmlService;
@ -22,10 +26,13 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Date; import java.math.RoundingMode;
import java.util.List; import java.text.DecimalFormat;
import java.util.UUID; import java.text.SimpleDateFormat;
import java.util.*;
import static org.aspectj.runtime.internal.Conversions.doubleValue;
/** /**
* (GlPzml)表服务实现类 * (GlPzml)表服务实现类
@ -41,6 +48,9 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
private ISenderGlPzmlDao senderGlPzmlDao; private ISenderGlPzmlDao senderGlPzmlDao;
@Autowired
private IGbiZbxmbDao gbiZbxmbDao;
@Autowired @Autowired
public void setSenderGlPzmlDao(ISenderGlPzmlDao dao) { public void setSenderGlPzmlDao(ISenderGlPzmlDao dao) {
this.senderGlPzmlDao = dao; this.senderGlPzmlDao = dao;
@ -668,7 +678,8 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
//保存凭证 商学院指标被哪些凭证使用 //保存凭证 商学院指标被哪些凭证使用
@Override @Override
public Object saveGlPzmlSxy(JSONObject jsonObject){ public Object queryGlPzmlSxy(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
SenderGlPzmlEntity glPzmlEntity = jsonObject.toJavaObject(SenderGlPzmlEntity.class); SenderGlPzmlEntity glPzmlEntity = jsonObject.toJavaObject(SenderGlPzmlEntity.class);
if(StrUtil.isEmpty(glPzmlEntity.getKjqj())){ if(StrUtil.isEmpty(glPzmlEntity.getKjqj())){
glPzmlEntity.setKjqj(DateUtil.format(new Date(),"yyyyMM")); glPzmlEntity.setKjqj(DateUtil.format(new Date(),"yyyyMM"));
@ -679,29 +690,71 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
return BaseResult.getFailureMessageEntity("token为空请先获取token"); return BaseResult.getFailureMessageEntity("token为空请先获取token");
} }
//查询凭证数据 //查询凭证数据
List<SenderGlPzmlEntity> pzmlEntities = senderGlPzmlDao.query(glPzmlEntity); List<SenderGlPzmlEntity> list = senderGlPzmlDao.queryGlPzmlSxy(glPzmlEntity);
if(CollectionUtils.isEmpty(pzmlEntities)){ if(CollectionUtils.isEmpty(list)){
return BaseResult.getSuccessMessageEntity("没有需要同步得凭证",null); return BaseResult.getSuccessMessageEntity("没有需要同步得凭证",null);
} }
for (SenderGlPzmlEntity pzmlEntity : pzmlEntities) { try {
String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh(); String result=null;
JSONObject jsonObjectParams=new JSONObject(); for (SenderGlPzmlEntity pzmlEntity : list) {
jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh();
jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度 //转换日期如将20240514转为2024-05-14
jsonObjectParams.put("applyDate",DateUtil.format(new Date(),"yyyy-MM-dd"));//日期 SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd");
jsonObjectParams.put("userCode","");//用户编码 SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
jsonObjectParams.put("depCode","");//部门编码 Date date = inputFormat.parse(pzmlEntity.getSrrq());
jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明 String outputDateString = outputFormat.format(date);
jsonObjectParams.put("amount",pzmlEntity.getPzje());//金额 //将金额四舍五入
jsonObjectParams.put("pzNum",pzNum);//凭证号 例如公司代码+账套号+会计期间+凭证号001_001_202408_付款_1 BigDecimal bigDecimalValue = new BigDecimal(pzmlEntity.getPzje());
JSONArray jsonArray=new JSONArray(); BigDecimal roundedValue = bigDecimalValue.setScale(2,
jsonArray.add(jsonObjectParams); RoundingMode.HALF_UP);
JSONObject jsonObjectData=new JSONObject(); JSONObject jsonObjectParams=new JSONObject();
jsonObjectData.put("data",jsonArray); jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid
jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度
jsonObjectParams.put("applyDate",outputDateString);//日期
jsonObjectParams.put("userCode",pzmlEntity.getSrid());//用户编码
jsonObjectParams.put("depCode","A518");//部门编码
jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明
jsonObjectParams.put("amount",roundedValue.doubleValue());//金额
jsonObjectParams.put("pzNum",pzNum);//凭证号 例如公司代码+账套号+会计期间+凭证号001_001_202408_付款_1
//根据idpzh查询指标id和指标金额
GbiZbxmbEntity gbiZbxmbEntity=new GbiZbxmbEntity();
gbiZbxmbEntity.setDjId(pzmlEntity.getIdpzh());
gbiZbxmbEntity.setKjnd(pzmlEntity.getKjqj().substring(0,4));
gbiZbxmbEntity.setDataSourceCode(glPzmlEntity.getDataSourceCode());
List<GbiZbxmbEntity> gbiZbsyrecEntities = gbiZbxmbDao.queryZbxmbByIdpzh(gbiZbxmbEntity);
logger.info("=======根据凭证idpzh:{}查询的指标金额和指标id数据有{}条",pzmlEntity.getIdpzh(),gbiZbsyrecEntities.size());
if(CollectionUtils.isEmpty(gbiZbsyrecEntities)){
jsonObjectParams.put("reimburseItems",new ArrayList<>());
}else{
JSONArray jsonArray=new JSONArray();
for (GbiZbxmbEntity zbxmbEntity : gbiZbsyrecEntities) {
BigDecimal bigDecimalValueZbxmb = new BigDecimal(zbxmbEntity.getJe());
BigDecimal roundedValueZbxmb = bigDecimalValueZbxmb.setScale(2, RoundingMode.HALF_UP);
JSONObject jsonObjectZbxm=new JSONObject();
jsonObjectZbxm.put("thirdProjectCode",zbxmbEntity.getZbid());
jsonObjectZbxm.put("amount",roundedValueZbxmb);
jsonObjectZbxm.put("financialCode",zbxmbEntity.getJjkmdm());
jsonArray.add(jsonObjectZbxm);
}
jsonObjectParams.put("reimburseItems",jsonArray);
}
JSONArray jsonArray=new JSONArray();
jsonArray.add(jsonObjectParams);
JSONObject jsonObjectData=new JSONObject();
jsonObjectData.put("data",jsonArray);
String params = jsonObjectData.toJSONString();
logger.info("调用商学院凭证保存接口请求参数:{}",params);
result = HttpRequest.post(URLTest + "/nky/service/zsApi/saveZJSYPZReimburse?accessToken="+token).header("Content-Type", "application/json;charset=UTF-8").timeout(30000).body(params).execute().body();
logger.info("调用商学院凭证保存接口返回参数:{}",result);
}
JSONObject jsonObjectResult=new JSONObject();
jsonObjectResult.put("status","200");
jsonObjectResult.put("pzml",result);
return jsonObjectResult;
}catch (Exception e){
logger.info("根据凭证idpzh:{}查询指标失败:{}",glPzmlEntity.getIdpzh(),e.getMessage());
return BaseResult.getFailureMessageEntity("根据凭证查询指标失败");
} }
return null;
} }
@ -713,7 +766,7 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
String params = jsonObject.toJSONString(); String params = jsonObject.toJSONString();
logger.info("=========获取凭证token请求参数:{}========",params); logger.info("=========获取凭证token请求参数:{}========",params);
String urlToken="nky/service/session/getAccessToken"; String urlToken="nky/service/session/getAccessToken";
String result = HttpRequest.post(URLTest + urlToken).header("Content-Type", "soap/xml").timeout(30000).body(params).execute().body(); String result = HttpRequest.post(URLTest + urlToken).header("Content-Type", "application/json;charset=UTF-8").timeout(30000).body(params).execute().body();
logger.info("=========获取凭证token返回结果:{}========",result); logger.info("=========获取凭证token返回结果:{}========",result);
JSONObject jsonObjectResult=JSONObject.parseObject(result); JSONObject jsonObjectResult=JSONObject.parseObject(result);
String value=jsonObjectResult.getString("value"); String value=jsonObjectResult.getString("value");
@ -724,7 +777,6 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
return accessToken; return accessToken;
} }
return null; return null;
} }

View File

@ -351,7 +351,7 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
sysMenuConfigEntities.get(i).setParentMenuId("ea22757e99c144fb9ef381dd322e233c"); sysMenuConfigEntities.get(i).setParentMenuId("ea22757e99c144fb9ef381dd322e233c");
} else { } else {
//2单据 //2单据
sysMenuConfigEntities.get(i).setParentMenuId("58714ddb7ec94f5da91df74efada042f"); sysMenuConfigEntities.get(i).setParentMenuId("67f82a6e7f664c5a89b7fc7b8fc817b0");
} }
sysMenuConfigEntities.get(i).setMenuName(entity.getMdmName()); sysMenuConfigEntities.get(i).setMenuName(entity.getMdmName());
sysMenuConfigEntities.get(i).setMenuEnglishName("integrationOptionAdmin" + entity.getMdmCode()); sysMenuConfigEntities.get(i).setMenuEnglishName("integrationOptionAdmin" + entity.getMdmCode());
@ -1713,7 +1713,7 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
module.setParentMenuId("ea22757e99c144fb9ef381dd322e233c"); module.setParentMenuId("ea22757e99c144fb9ef381dd322e233c");
} else { } else {
//2单据 //2单据
module.setParentMenuId("58714ddb7ec94f5da91df74efada042f"); module.setParentMenuId("67f82a6e7f664c5a89b7fc7b8fc817b0");
} }
module.setMenuName(mdmModuleEntity.getMdmName()); module.setMenuName(mdmModuleEntity.getMdmName());
module.setMenuEnglishName("integrationOptionAdmin" + mdmModuleEntity.getMdmCode()); module.setMenuEnglishName("integrationOptionAdmin" + mdmModuleEntity.getMdmCode());
@ -1785,7 +1785,7 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
module.setParentMenuId("ea22757e99c144fb9ef381dd322e233c"); module.setParentMenuId("ea22757e99c144fb9ef381dd322e233c");
} else { } else {
//2单据 //2单据
module.setParentMenuId("58714ddb7ec94f5da91df74efada042f"); module.setParentMenuId("67f82a6e7f664c5a89b7fc7b8fc817b0");
} }
module.setMenuName(mdmModuleEntity.getMdmName()); module.setMenuName(mdmModuleEntity.getMdmName());
module.setMenuEnglishName("integrationOptionAdmin" + mdmModuleEntity.getMdmCode()); module.setMenuEnglishName("integrationOptionAdmin" + mdmModuleEntity.getMdmCode());

View File

@ -90,7 +90,7 @@ public class FileDownloadServiceImpl extends BaseService< FileDownloadEntity,Lo
} }
/** 拼接文件路径*/ /** 拼接文件路径*/
String filePath = ""; String filePath = "";
if(fileDownloadEntity.getFileType().equals("2")){ if(fileDownloadEntity.getFileType() != null && fileDownloadEntity.getFileType().equals("2")){
filePath = PLUGINPATH + fileDownloadEntity.getFilepath().replace("/",File.separator).replace("\\",File.separator); filePath = PLUGINPATH + fileDownloadEntity.getFilepath().replace("/",File.separator).replace("\\",File.separator);
}else{ }else{
filePath = DSK + fileDownloadEntity.getFilepath().replace("/",File.separator).replace("\\",File.separator); filePath = DSK + fileDownloadEntity.getFilepath().replace("/",File.separator).replace("\\",File.separator);

View File

@ -213,154 +213,155 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
//根据data_id判断数据是否已经保存在相关表中,避免重复保存 //根据data_id判断数据是否已经保存在相关表中,避免重复保存
List<String> fields = getFields(comparisonEntity); List<String> fields = getFields(comparisonEntity);
Map<String,Object> mapDataId=new HashMap<>(); Map<String, Object> mapDataId = new HashMap<>();
mapDataId.put("data_id",jsonObjectMain.getString("data_id")); mapDataId.put("data_id", jsonObjectMain.getString("data_id"));
ComparisonEntity comparisonDataId=new ComparisonEntity(); ComparisonEntity comparisonDataId = new ComparisonEntity();
comparisonDataId.setMap(mapDataId); comparisonDataId.setMap(mapDataId);
comparisonDataId.setDbName(comparisonEntity.getDbName()); comparisonDataId.setDbName(comparisonEntity.getDbName());
comparisonDataId.setFields(fields); comparisonDataId.setFields(fields);
List<Map<String, Object>> listDataId = comparisonDao.queryComparisonPage(comparisonDataId); List<Map<String, Object>> listDataId = comparisonDao.queryComparisonPage(comparisonDataId);
if(CollectionUtils.isNotEmpty(listDataId)){ if (CollectionUtils.isNotEmpty(listDataId)) {
return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据"); //return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据");
} return updateEntity(json);
} else {
//判断输入的主表字段是否是必填项 //判断输入的主表字段是否是必填项
for (ComparisonEntity entity : comparisonEntities) { for (ComparisonEntity entity : comparisonEntities) {
//如果必填字段不为空 //如果必填字段不为空
if(entity.getRuleValue()!=null && entity.getDbType().equals("1")){ if (entity.getRuleValue() != null && entity.getDbType().equals("1")) {
//如果值为空说明没有传这个字段或者这个字段的值为空 //如果值为空说明没有传这个字段或者这个字段的值为空
if(jsonObjectMain.getString(entity.getEnName()) ==null || jsonObjectMain.getString(entity.getEnName()).equals("")){ if (jsonObjectMain.getString(entity.getEnName()) == null || jsonObjectMain.getString(entity.getEnName()).equals("")) {
//保存操作日志 //保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2"); controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
return BaseResult.getFailureMessageEntity(entity.getDbName()+"表的"+entity.getEnName()+"字段不能为空"); return BaseResult.getFailureMessageEntity(entity.getDbName() + "表的" + entity.getEnName() + "字段不能为空");
} }
}
}
map.put("id", uuid);
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("org_id", "0");
map.put("create_time", new Date());
map.put("modify_time", new Date());
map.put("sts", "Y");
map.put("data_status", "Y");//新增状态
map.put("add_status", "0");//新增状态
map.put("update_status", "1");//修改状态
map.put("delete_status", "1");//删除状态
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
//查询单据规则 只查询主表得明细表不用
try {
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
if (documentRule != null) {
//获取规则前缀 CK
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
//获取规则中间日期 yyyy-MM-dd
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
String ruleMiddle = getRuleDate(ruleDate);
//获取规则后缀
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
int ruleSuffix = ruleSuffixLength.length();
//生成单据规则
comparisonEntityRule.setRulePrefix(rulePrefix);
comparisonEntityRule.setRuleMiddle(ruleMiddle);
comparisonEntityRule.setRuleSuffix(ruleSuffix);
try {
//新生成单据规则保存到数据库
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
comparisonEntityRule.setMap(map);
} catch (Exception e) {
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败");
} }
} }
} catch (Exception e) {
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败"); map.put("id", uuid);
} map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
try { map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
List<JSONObject> list = new ArrayList<>(); map.put("org_id", "0");
JSONObject jsonObjectList = new JSONObject(); map.put("create_time", new Date());
map.put("modify_time", new Date());
map.put("sts", "Y");
map.put("data_status", "Y");//新增状态
map.put("add_status", "0");//新增状态
map.put("update_status", "1");//修改状态
map.put("delete_status", "1");//删除状态
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
//查询单据规则 只查询主表得明细表不用
try {
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
if (documentRule != null) {
//获取规则前缀 CK
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
//获取规则中间日期 yyyy-MM-dd
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
String ruleMiddle = getRuleDate(ruleDate);
//获取规则后缀
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
int ruleSuffix = ruleSuffixLength.length();
//生成单据规则
comparisonEntityRule.setRulePrefix(rulePrefix);
comparisonEntityRule.setRuleMiddle(ruleMiddle);
comparisonEntityRule.setRuleSuffix(ruleSuffix);
try {
//新生成单据规则保存到数据库
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
comparisonEntityRule.setMap(map);
} catch (Exception e) {
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
//判断明细表字段是否是必填项 return BaseResult.getFailureMessageEntity("保存失败");
if (arrayList != null && arrayList.size() > 0) { }
for (JSONArray jsonArrayDetails : arrayList) { }
for (Object object : jsonArrayDetails) { } catch (Exception e) {
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object); logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
for (ComparisonEntity entity : comparisonEntities) { //保存操作日志
if(entity.getRuleValue()!=null && entity.getDbType().equals("2")){ controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
//如果值为空说明没有传这个字段或者这个字段的值为空
if(jsonObjectDetails.getString(entity.getEnName())==null || jsonObjectDetails.getString(entity.getEnName()).equals("")){ return BaseResult.getFailureMessageEntity("保存失败");
//保存操作日志 }
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2"); try {
return BaseResult.getFailureMessageEntity(entity.getDbName()+"表的"+entity.getEnName()+"字段不能为空"); List<JSONObject> list = new ArrayList<>();
JSONObject jsonObjectList = new JSONObject();
//判断明细表字段是否是必填项
if (arrayList != null && arrayList.size() > 0) {
for (JSONArray jsonArrayDetails : arrayList) {
for (Object object : jsonArrayDetails) {
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
for (ComparisonEntity entity : comparisonEntities) {
if (entity.getRuleValue() != null && entity.getDbType().equals("2")) {
//如果值为空说明没有传这个字段或者这个字段的值为空
if (jsonObjectDetails.getString(entity.getEnName()) == null || jsonObjectDetails.getString(entity.getEnName()).equals("")) {
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
return BaseResult.getFailureMessageEntity(entity.getDbName() + "表的" + entity.getEnName() + "字段不能为空");
}
} }
} }
} }
} }
} }
}
//保存主表数据 //保存主表数据
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule); ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
jsonObjectList.put(comparisonEntityOne.getDbName(),map); jsonObjectList.put(comparisonEntityOne.getDbName(), map);
//保存子表数据 //保存子表数据
if (arrayList != null && arrayList.size() > 0) { if (arrayList != null && arrayList.size() > 0) {
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList); mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList);
if(mapDetails.size()>0 && mapDetails!=null ){ if (mapDetails.size() > 0 && mapDetails != null) {
for (List<Map<String, Object>> mapDetail : mapDetails) { for (List<Map<String, Object>> mapDetail : mapDetails) {
for (Map<String, Object> stringObjectMap : mapDetail) { for (Map<String, Object> stringObjectMap : mapDetail) {
stringObjectMap.put("id", UUIDLong.longUUID()); stringObjectMap.put("id", UUIDLong.longUUID());
stringObjectMap.put("formmain_id", uuid); stringObjectMap.put("formmain_id", uuid);
stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
stringObjectMap.put("org_id", "0"); stringObjectMap.put("org_id", "0");
stringObjectMap.put("create_time", new Date()); stringObjectMap.put("create_time", new Date());
stringObjectMap.put("modify_time", new Date()); stringObjectMap.put("modify_time", new Date());
stringObjectMap.put("sts", "Y"); stringObjectMap.put("sts", "Y");
stringObjectMap.put("data_status", "Y");//新增状态 stringObjectMap.put("data_status", "Y");//新增状态
comparisonDetailsEntity.setMapDetails(stringObjectMap); comparisonDetailsEntity.setMapDetails(stringObjectMap);
comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name"))); comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name")));
stringObjectMap.remove("table_name"); stringObjectMap.remove("table_name");
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity); ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity);
comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne); comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne);
//保存操作日志 //保存操作日志
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log"); //controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
}
} }
jsonObjectList.put(comparisonDetailsEntity.getDbName(), mapDetails);
} }
jsonObjectList.put(comparisonDetailsEntity.getDbName(), mapDetails); } else {
jsonObjectList.put(comparisonDetailsEntity.getDbName(), new ArrayList<>());
} }
} else { jsonObjectList.remove(null);
jsonObjectList.put(comparisonDetailsEntity.getDbName(), new ArrayList<>()); list.add(jsonObjectList);
} //保存操作日志
jsonObjectList.remove(null); controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "1");
list.add(jsonObjectList); JSONObject json1 = new JSONObject();
//保存操作日志 json1.put("status", "200");
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","1"); json1.put("list", list);
JSONObject json1 = new JSONObject(); return json1;
json1.put("status","200"); } catch (Exception e) {
json1.put("list",list); logger.info("保存通用数据时候错误:{}", e.getMessage());
return json1; //保存操作日志
} catch (Exception e) { controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
logger.info("保存通用数据时候错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败"); return BaseResult.getFailureMessageEntity("保存失败");
}
} }
} }
} }
return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); return BaseResult.getFailureMessageEntity("保存失败","请检查传递参数");
} }
//更新通用数据数据 //更新通用数据数据
@ -499,7 +500,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("更新失败"); return BaseResult.getFailureMessageEntity("更新失败");
} }
} }
return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); return BaseResult.getFailureMessageEntity("更新失败","请检查传递参数");
} }
private List<String> getFields(ComparisonEntity comparisonEntity) { private List<String> getFields(ComparisonEntity comparisonEntity) {
@ -611,7 +612,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("删除失败"); return BaseResult.getFailureMessageEntity("删除失败");
} }
} }
return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); return BaseResult.getFailureMessageEntity("删除失败","请检查传递参数");
} }
//根据应用key和应用密钥获取应用编码和应用名称 //根据应用key和应用密钥获取应用编码和应用名称