From 4c50b026f8560528fa72d6240b3a098e45943e70 Mon Sep 17 00:00:00 2001 From: hecan <1718492867@qq.com> Date: Tue, 27 Aug 2024 15:11:56 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=87=AD=E8=AF=81?= =?UTF-8?q?=E5=8F=B7=E6=9F=A5=E8=AF=A2=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nxproof/glPzml/dao/ISenderGlPzmlDao.java | 11 ++ .../glPzml/dao/impl/SenderGlPzmlDaoImpl.java | 7 ++ .../glPzml/entity/SenderGlPzmlEntity.java | 10 ++ .../glPzml/entity/SenderGlPzmlEntity.xml | 25 +++++ .../glPzml/service/ISenderGlPzmlService.java | 4 +- .../service/impl/SenderGlPzmlServiceImpl.java | 106 +++++++++++++----- 6 files changed, 134 insertions(+), 29 deletions(-) diff --git a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/ISenderGlPzmlDao.java b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/ISenderGlPzmlDao.java index 529198c9..fda53f20 100644 --- a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/ISenderGlPzmlDao.java +++ b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/ISenderGlPzmlDao.java @@ -4,6 +4,7 @@ import com.hzya.frame.basedao.dao.IBaseDao; import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity; import java.util.List; +import java.util.Map; /** * (gl_pzml: table)表数据库访问层 @@ -83,6 +84,16 @@ public interface ISenderGlPzmlDao extends IBaseDao { * **/ Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity); + /** + * + * @content 查询凭证 商学院 + * @Param + * @Return + * @Author hecan + * @Date 2024/8/14 16:25 + * **/ + List queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity); + } diff --git a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/impl/SenderGlPzmlDaoImpl.java b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/impl/SenderGlPzmlDaoImpl.java index 9b4655f7..ccaa162a 100644 --- a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/impl/SenderGlPzmlDaoImpl.java +++ b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/dao/impl/SenderGlPzmlDaoImpl.java @@ -8,6 +8,7 @@ import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Map; /** * (GlPzml)表数据库访问层 @@ -60,5 +61,11 @@ public class SenderGlPzmlDaoImpl extends MybatisGenericDao queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity) { + return (List) super.selectList("queryGlPzmlSxy",senderGlPzmlEntity); + } } diff --git a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.java b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.java index bcaf3369..11865f92 100644 --- a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.java +++ b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.java @@ -54,6 +54,16 @@ public class SenderGlPzmlEntity extends BaseEntity { private String stamp; private String yspzje; + private String bmdm; + + public String getBmdm() { + return bmdm; + } + + public void setBmdm(String bmdm) { + this.bmdm = bmdm; + } + public String getPzsbm() { return pzsbm; } diff --git a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.xml b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.xml index 86d48292..a130f435 100644 --- a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.xml +++ b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/entity/SenderGlPzmlEntity.xml @@ -259,6 +259,31 @@ + + + insert into gl_pzml( diff --git a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/service/ISenderGlPzmlService.java b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/service/ISenderGlPzmlService.java index ad085e24..c0397b3b 100644 --- a/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/service/ISenderGlPzmlService.java +++ b/service/src/main/java/com/hzya/frame/grpU8/nxproof/glPzml/service/ISenderGlPzmlService.java @@ -95,11 +95,11 @@ public interface ISenderGlPzmlService extends IBaseService pzmlEntities = senderGlPzmlDao.query(glPzmlEntity); - if(CollectionUtils.isEmpty(pzmlEntities)){ + List list = senderGlPzmlDao.queryGlPzmlSxy(glPzmlEntity); + if(CollectionUtils.isEmpty(list)){ return BaseResult.getSuccessMessageEntity("没有需要同步得凭证",null); } - for (SenderGlPzmlEntity pzmlEntity : pzmlEntities) { - String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh(); - JSONObject jsonObjectParams=new JSONObject(); - jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid - jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度 - jsonObjectParams.put("applyDate",DateUtil.format(new Date(),"yyyy-MM-dd"));//日期 - jsonObjectParams.put("userCode","");//用户编码 - jsonObjectParams.put("depCode","");//部门编码 - jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明 - jsonObjectParams.put("amount",pzmlEntity.getPzje());//金额 - jsonObjectParams.put("pzNum",pzNum);//凭证号 例如:公司代码+账套号+会计期间+凭证号:001_001_202408_付款_1 - JSONArray jsonArray=new JSONArray(); - jsonArray.add(jsonObjectParams); - JSONObject jsonObjectData=new JSONObject(); - jsonObjectData.put("data",jsonArray); - - + try { + String result=null; + for (SenderGlPzmlEntity pzmlEntity : list) { + String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh(); + //转换日期,如将20240514转为2024-05-14 + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd"); + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = inputFormat.parse(pzmlEntity.getSrrq()); + String outputDateString = outputFormat.format(date); + //将金额四舍五入 + BigDecimal bigDecimalValue = new BigDecimal(pzmlEntity.getPzje()); + BigDecimal roundedValue = bigDecimalValue.setScale(2, + RoundingMode.HALF_UP); + JSONObject jsonObjectParams=new JSONObject(); + 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 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 Date: Wed, 28 Aug 2024 10:19:42 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=94=9F=E6=88=90=E8=8F=9C=E5=8D=95=E7=9B=AE=E5=BD=95?= =?UTF-8?q?id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mdm/mdmModule/service/impl/MdmModuleServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java b/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java index 82c9f218..7169f57f 100644 --- a/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java @@ -351,7 +351,7 @@ public class MdmModuleServiceImpl extends BaseService i sysMenuConfigEntities.get(i).setParentMenuId("ea22757e99c144fb9ef381dd322e233c"); } else { //2、单据 - sysMenuConfigEntities.get(i).setParentMenuId("58714ddb7ec94f5da91df74efada042f"); + sysMenuConfigEntities.get(i).setParentMenuId("67f82a6e7f664c5a89b7fc7b8fc817b0"); } sysMenuConfigEntities.get(i).setMenuName(entity.getMdmName()); sysMenuConfigEntities.get(i).setMenuEnglishName("integrationOptionAdmin" + entity.getMdmCode()); @@ -1713,7 +1713,7 @@ public class MdmModuleServiceImpl extends BaseService i module.setParentMenuId("ea22757e99c144fb9ef381dd322e233c"); } else { //2、单据 - module.setParentMenuId("58714ddb7ec94f5da91df74efada042f"); + module.setParentMenuId("67f82a6e7f664c5a89b7fc7b8fc817b0"); } module.setMenuName(mdmModuleEntity.getMdmName()); module.setMenuEnglishName("integrationOptionAdmin" + mdmModuleEntity.getMdmCode()); @@ -1785,7 +1785,7 @@ public class MdmModuleServiceImpl extends BaseService i module.setParentMenuId("ea22757e99c144fb9ef381dd322e233c"); } else { //2、单据 - module.setParentMenuId("58714ddb7ec94f5da91df74efada042f"); + module.setParentMenuId("67f82a6e7f664c5a89b7fc7b8fc817b0"); } module.setMenuName(mdmModuleEntity.getMdmName()); module.setMenuEnglishName("integrationOptionAdmin" + mdmModuleEntity.getMdmCode()); From a7b25fa268f38e04103c4cfeea8b309702d64932 Mon Sep 17 00:00:00 2001 From: lvleigang <957075182@qq.com> Date: Wed, 28 Aug 2024 11:00:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildpackage/src/main/resources/application-dev.yml | 7 +++++-- .../download/service/impl/FileDownloadServiceImpl.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/buildpackage/src/main/resources/application-dev.yml b/buildpackage/src/main/resources/application-dev.yml index 8dffa2d4..5e9c4b36 100644 --- a/buildpackage/src/main/resources/application-dev.yml +++ b/buildpackage/src/main/resources/application-dev.yml @@ -19,8 +19,11 @@ spring: savefile: # 文件保存路径 path: /home/webservice/zt/file - pluginpath: D:/local/plugin/ - tomcatpath: E:\apache-tomcat-9.0.27\webapps\kangarooDataCenterV3\WEB-INF\classes\ +# path: D:\webservice\file +# 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: appId: 1P4AGrpz appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a diff --git a/service/src/main/java/com/hzya/frame/sys/file/download/service/impl/FileDownloadServiceImpl.java b/service/src/main/java/com/hzya/frame/sys/file/download/service/impl/FileDownloadServiceImpl.java index ccdd9f4e..036d31a7 100644 --- a/service/src/main/java/com/hzya/frame/sys/file/download/service/impl/FileDownloadServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/sys/file/download/service/impl/FileDownloadServiceImpl.java @@ -90,7 +90,7 @@ public class FileDownloadServiceImpl extends BaseService< FileDownloadEntity,Lo } /** 拼接文件路径*/ 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); }else{ filePath = DSK + fileDownloadEntity.getFilepath().replace("/",File.separator).replace("\\",File.separator); From ef85056b113803f7a3fd3a466efd1180fc431761 Mon Sep 17 00:00:00 2001 From: hecan <1718492867@qq.com> Date: Wed, 28 Aug 2024 14:06:50 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=85=88=E6=9F=A5=E8=AF=A2=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=AD=98=E5=9C=A8=EF=BC=8C=E5=AD=98=E5=9C=A8=E5=88=99?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ComparisonServiceImpl.java | 247 +++++++++--------- 1 file changed, 124 insertions(+), 123 deletions(-) diff --git a/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java b/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java index de8412fa..9b4c57ae 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java @@ -213,150 +213,151 @@ public class ComparisonServiceImpl extends BaseService //根据data_id判断数据是否已经保存在相关表中,避免重复保存 List fields = getFields(comparisonEntity); - Map mapDataId=new HashMap<>(); - mapDataId.put("data_id",jsonObjectMain.getString("data_id")); - ComparisonEntity comparisonDataId=new ComparisonEntity(); + Map mapDataId = new HashMap<>(); + mapDataId.put("data_id", jsonObjectMain.getString("data_id")); + ComparisonEntity comparisonDataId = new ComparisonEntity(); comparisonDataId.setMap(mapDataId); comparisonDataId.setDbName(comparisonEntity.getDbName()); comparisonDataId.setFields(fields); List> listDataId = comparisonDao.queryComparisonPage(comparisonDataId); - if(CollectionUtils.isNotEmpty(listDataId)){ - return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据"); - } - - //判断输入的主表字段是否是必填项 - for (ComparisonEntity entity : comparisonEntities) { - //如果必填字段不为空 - if(entity.getRuleValue()!=null && entity.getDbType().equals("1")){ + if (CollectionUtils.isNotEmpty(listDataId)) { + //return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据"); + updateEntity(json); + } else { + //判断输入的主表字段是否是必填项 + for (ComparisonEntity entity : comparisonEntities) { + //如果必填字段不为空 + 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"); - return BaseResult.getFailureMessageEntity(entity.getDbName()+"表的"+entity.getEnName()+"字段不能为空"); + 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() + "字段不能为空"); } - } - } - - 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("保存失败"); - } - try { - List list = new ArrayList<>(); - JSONObject jsonObjectList = new JSONObject(); + 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"); - //判断明细表字段是否是必填项 - 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()+"字段不能为空"); + 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("保存失败"); + } + try { + List 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); - jsonObjectList.put(comparisonEntityOne.getDbName(),map); - //保存子表数据 - if (arrayList != null && arrayList.size() > 0) { - mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList); - if(mapDetails.size()>0 && mapDetails!=null ){ - for (List> mapDetail : mapDetails) { - for (Map stringObjectMap : mapDetail) { - stringObjectMap.put("id", UUIDLong.longUUID()); - stringObjectMap.put("formmain_id", uuid); - stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); - stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); - stringObjectMap.put("org_id", "0"); - stringObjectMap.put("create_time", new Date()); - stringObjectMap.put("modify_time", new Date()); - stringObjectMap.put("sts", "Y"); - stringObjectMap.put("data_status", "Y");//新增状态 - comparisonDetailsEntity.setMapDetails(stringObjectMap); - comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name"))); - stringObjectMap.remove("table_name"); - ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity); - comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne); - //保存操作日志 - //controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log"); + //保存主表数据 + ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule); + jsonObjectList.put(comparisonEntityOne.getDbName(), map); + //保存子表数据 + if (arrayList != null && arrayList.size() > 0) { + mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList); + if (mapDetails.size() > 0 && mapDetails != null) { + for (List> mapDetail : mapDetails) { + for (Map stringObjectMap : mapDetail) { + stringObjectMap.put("id", UUIDLong.longUUID()); + stringObjectMap.put("formmain_id", uuid); + stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); + stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); + stringObjectMap.put("org_id", "0"); + stringObjectMap.put("create_time", new Date()); + stringObjectMap.put("modify_time", new Date()); + stringObjectMap.put("sts", "Y"); + stringObjectMap.put("data_status", "Y");//新增状态 + comparisonDetailsEntity.setMapDetails(stringObjectMap); + comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name"))); + stringObjectMap.remove("table_name"); + ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity); + comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne); + //保存操作日志 + //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.put(comparisonDetailsEntity.getDbName(), new ArrayList<>()); - } - jsonObjectList.remove(null); - list.add(jsonObjectList); - //保存操作日志 - controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","1"); - JSONObject json1 = new JSONObject(); - json1.put("status","200"); - json1.put("list",list); - return json1; - } 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"); + jsonObjectList.remove(null); + list.add(jsonObjectList); + //保存操作日志 + controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "1"); + JSONObject json1 = new JSONObject(); + json1.put("status", "200"); + json1.put("list", list); + return json1; + } 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("保存失败"); + return BaseResult.getFailureMessageEntity("保存失败"); + } } } } From 9e54b38c9a2a852fad6d1a8624cf8374eafa77c4 Mon Sep 17 00:00:00 2001 From: hecan <1718492867@qq.com> Date: Wed, 28 Aug 2024 18:26:53 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=BF=94=E5=9B=9Ereturn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comparison/service/impl/ComparisonServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java b/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java index 9b4c57ae..72718c51 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/sysnew/comparison/service/impl/ComparisonServiceImpl.java @@ -222,7 +222,7 @@ public class ComparisonServiceImpl extends BaseService List> listDataId = comparisonDao.queryComparisonPage(comparisonDataId); if (CollectionUtils.isNotEmpty(listDataId)) { //return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据"); - updateEntity(json); + return updateEntity(json); } else { //判断输入的主表字段是否是必填项 for (ComparisonEntity entity : comparisonEntities) { @@ -361,7 +361,7 @@ public class ComparisonServiceImpl extends BaseService } } } - return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); + return BaseResult.getFailureMessageEntity("保存失败","请检查传递参数"); } //更新通用数据数据 @@ -500,7 +500,7 @@ public class ComparisonServiceImpl extends BaseService return BaseResult.getFailureMessageEntity("更新失败"); } } - return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); + return BaseResult.getFailureMessageEntity("更新失败","请检查传递参数"); } private List getFields(ComparisonEntity comparisonEntity) { @@ -612,7 +612,7 @@ public class ComparisonServiceImpl extends BaseService return BaseResult.getFailureMessageEntity("删除失败"); } } - return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); + return BaseResult.getFailureMessageEntity("删除失败","请检查传递参数"); } //根据应用key和应用密钥获取应用编码和应用名称