通用数据

This commit is contained in:
hecan 2024-05-27 11:22:38 +08:00
parent 96dc367b37
commit 587c969243
6 changed files with 816 additions and 0 deletions

View File

@ -0,0 +1,49 @@
package com.hzya.frame.sysnew.generalData.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity;
import java.util.List;
public interface IGeneralDataDao extends IBaseDao<GeneralDataEntity, String> {
/**
*
* @content 新增通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 16:49
* **/
GeneralDataEntity saveGeneralDataByType(GeneralDataEntity generalDataEntity);
/**
*
* @content 查询通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 16:51
* **/
List<GeneralDataEntity> queryGeneralData(GeneralDataEntity generalDataEntity);
/**
*
* @content 编辑通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 17:17
* **/
Integer updateGeneralDataByType(GeneralDataEntity generalDataEntity);
/**
*
* @content 删除通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 17:20
* **/
Integer deleteGeneralDataByType(GeneralDataEntity generalDataEntity);
}

View File

@ -0,0 +1,40 @@
package com.hzya.frame.sysnew.generalData.dao.impl;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.sysnew.generalData.dao.IGeneralDataDao;
import com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository(value = "generalDataDaoImpl")
public class GeneralDataDaoImpl extends MybatisGenericDao<GeneralDataEntity, String> implements IGeneralDataDao {
//新增通用数据
@Override
public GeneralDataEntity saveGeneralDataByType(GeneralDataEntity generalDataEntity) {
generalDataEntity = super.save(getSqlIdPrifx() + "saveGeneralDataByType", generalDataEntity);
return generalDataEntity;
}
//查询通用数据
@Override
public List<GeneralDataEntity> queryGeneralData(GeneralDataEntity generalDataEntity) {
List<GeneralDataEntity> query = super.query(getSqlIdPrifx() + "queryGeneralData", generalDataEntity);
return query;
}
//编辑通用数据
@Override
public Integer updateGeneralDataByType(GeneralDataEntity generalDataEntity) {
int update = super.update(getSqlIdPrifx() + "updateGeneralDataByType", generalDataEntity);
return update;
}
//删除通用数据
@Override
public Integer deleteGeneralDataByType(GeneralDataEntity generalDataEntity) {
int update = super.update(getSqlIdPrifx() + "deleteGeneralDataByType", generalDataEntity);
return update;
}
}

View File

@ -0,0 +1,169 @@
package com.hzya.frame.sysnew.generalData.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 通用数据接口实体类
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 16:21
* **/
public class GeneralDataEntity extends BaseEntity {
private String archivesType;//类型
private String leftCode;//左编码
private String rightCode;//右编码
private String leftAppId;//左应用id
private String leftAppCode;//左应用编码
private String leftAppName;//左应用名称
private String leftApiId;//左接口ID
private String leftId;//左id
private String leftName;//左名称
private String rightAppId;//右应用id
private String rightAppCode;//右应用编码
private String rightAppName;//右应用名称
private String rightApiId;//右接口ID
private String rightId;//右id
private String rightName;//右名称
private String leftOrg;//左公司
private String rightOrg;//右公司
public String getLeftOrg() {
return leftOrg;
}
public void setLeftOrg(String leftOrg) {
this.leftOrg = leftOrg;
}
public String getRightOrg() {
return rightOrg;
}
public void setRightOrg(String rightOrg) {
this.rightOrg = rightOrg;
}
public String getArchivesType() {
return archivesType;
}
public void setArchivesType(String archivesType) {
this.archivesType = archivesType;
}
public String getLeftCode() {
return leftCode;
}
public void setLeftCode(String leftCode) {
this.leftCode = leftCode;
}
public String getRightCode() {
return rightCode;
}
public void setRightCode(String rightCode) {
this.rightCode = rightCode;
}
public String getLeftAppId() {
return leftAppId;
}
public void setLeftAppId(String leftAppId) {
this.leftAppId = leftAppId;
}
public String getLeftAppCode() {
return leftAppCode;
}
public void setLeftAppCode(String leftAppCode) {
this.leftAppCode = leftAppCode;
}
public String getLeftAppName() {
return leftAppName;
}
public void setLeftAppName(String leftAppName) {
this.leftAppName = leftAppName;
}
public String getLeftApiId() {
return leftApiId;
}
public void setLeftApiId(String leftApiId) {
this.leftApiId = leftApiId;
}
public String getLeftId() {
return leftId;
}
public void setLeftId(String leftId) {
this.leftId = leftId;
}
public String getLeftName() {
return leftName;
}
public void setLeftName(String leftName) {
this.leftName = leftName;
}
public String getRightAppId() {
return rightAppId;
}
public void setRightAppId(String rightAppId) {
this.rightAppId = rightAppId;
}
public String getRightAppCode() {
return rightAppCode;
}
public void setRightAppCode(String rightAppCode) {
this.rightAppCode = rightAppCode;
}
public String getRightAppName() {
return rightAppName;
}
public void setRightAppName(String rightAppName) {
this.rightAppName = rightAppName;
}
public String getRightApiId() {
return rightApiId;
}
public void setRightApiId(String rightApiId) {
this.rightApiId = rightApiId;
}
public String getRightId() {
return rightId;
}
public void setRightId(String rightId) {
this.rightId = rightId;
}
public String getRightName() {
return rightName;
}
public void setRightName(String rightName) {
this.rightName = rightName;
}
}

View File

@ -0,0 +1,258 @@
<?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.sysnew.generalData.dao.impl.GeneralDataDaoImpl">
<resultMap id="get-GeneralDataEntity-result" type="com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="leftAppId" column="left_app_id" jdbcType="VARCHAR"/>
<result property="leftAppCode" column="left_app_code" jdbcType="VARCHAR"/>
<result property="leftAppName" column="left_app_name" jdbcType="VARCHAR"/>
<result property="leftApiId" column="left_api_id" jdbcType="VARCHAR"/>
<result property="leftId" column="left_id" jdbcType="VARCHAR"/>
<result property="leftCode" column="left_code" jdbcType="VARCHAR"/>
<result property="leftName" column="left_name" jdbcType="VARCHAR"/>
<result property="rightAppId" column="right_app_id" jdbcType="VARCHAR"/>
<result property="rightAppCode" column="right_app_code" jdbcType="VARCHAR"/>
<result property="rightAppName" column="right_app_name" jdbcType="VARCHAR"/>
<result property="rightApiId" column="right_api_id" jdbcType="VARCHAR"/>
<result property="rightId" column="right_id" jdbcType="VARCHAR"/>
<result property="rightCode" column="right_code" jdbcType="VARCHAR"/>
<result property="rightName" column="right_name" jdbcType="VARCHAR"/>
<result property="leftOrg" column="left_org" jdbcType="VARCHAR"/>
<result property="rightOrg" column="right_org" jdbcType="VARCHAR"/>
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
<result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryGeneralData" resultMap="get-GeneralDataEntity-result"
parameterType="com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity">
select
*
from
<choose>
<when test="archivesType == '1'.toString()"> sys_personnel_control </when>
<when test="archivesType == '2'.toString()"> sys_org_control </when>
<when test="archivesType == '6'.toString()"> sys_stock_control </when>
<when test="archivesType == '73'.toString()"> sys_merchant_control </when>
<when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
<when test="archivesType == '93'.toString()"> sys_bank_control </when>
<when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
<when test="archivesType == '22'.toString()"> sys_assets_control </when>
</choose>
<trim prefix="where" prefixOverrides="and">
<if test="leftCode != null and leftCode != ''">and left_code like concat('%',#{leftCode},'%')</if>
<if test="rightCode != null and rightCode != ''">and right_code like concat('%',#{rightCode},'%')</if>
<if test="leftAppCode != null and leftAppCode != ''">and left_app_code like concat('%',#{leftAppCode},'%')</if>
<if test="rightAppCode != null and rightAppCode != ''">and right_app_code like concat('%',#{rightAppCode},'%')</if>
<if test="leftName != null and leftName != ''">and left_name like concat('%',#{leftName},'%')</if>
<if test="rightName != null and rightName != ''">and right_name like concat('%',#{rightName},'%')</if>
<if test="rightAppName != null and rightAppName != ''">and right_app_name like concat('%',#{rightAppName},'%')</if>
<if test="leftAppName != null and leftAppName != ''">and left_app_name like concat('%',#{rightAppCode},'%')</if>
<if test="leftOrg != null and leftOrg != ''">and left_org like concat('%',#{leftOrg},'%')</if>
<if test="rightOrg != null and rightOrg != ''">and right_org like concat('%',#{rightOrg},'%')</if>
and sts='Y'
</trim>
</select>
<!--查询单个-->
<select id="entity_list_base" resultMap="get-GeneralDataEntity-result"
parameterType="com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity">
select
*
from
<choose>
<when test="archivesType == '1'.toString()"> sys_personnel_control </when>
<when test="archivesType == '2'.toString()"> sys_org_control </when>
<when test="archivesType == '6'.toString()"> sys_stock_control </when>
<when test="archivesType == '73'.toString()"> sys_merchant_control </when>
<when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
<when test="archivesType == '93'.toString()"> sys_bank_control </when>
<when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
<when test="archivesType == '22'.toString()"> sys_assets_control </when>
</choose>
where id=#{id} and sts='Y'
</select>
<!--新增所有列-->
<insert id="saveGeneralDataByType" parameterType = "com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity">
insert into
<choose>
<when test="archivesType == '1'.toString()"> sys_personnel_control </when>
<when test="archivesType == '2'.toString()"> sys_org_control </when>
<when test="archivesType == '6'.toString()"> sys_stock_control </when>
<when test="archivesType == '73'.toString()"> sys_merchant_control </when>
<when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
<when test="archivesType == '93'.toString()"> sys_bank_control </when>
<when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
<when test="archivesType == '22'.toString()"> sys_assets_control </when>
</choose>
(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> id , </if>
<if test="leftAppId != null and leftAppId != ''"> left_app_id , </if>
<if test="leftAppCode != null and leftAppCode != ''"> left_app_code , </if>
<if test="leftAppName != null and leftAppName != ''"> left_app_name , </if>
<if test="leftApiId != null and leftApiId != ''"> left_api_id , </if>
<if test="leftId != null and leftId != ''"> left_id , </if>
<if test="leftCode != null and leftCode != ''"> left_code , </if>
<if test="leftName != null and leftName != ''"> left_name , </if>
<if test="rightAppId != null and rightAppId != ''"> right_app_id , </if>
<if test="rightAppCode != null and rightAppCode != ''"> right_app_code , </if>
<if test="rightAppName != null and rightAppName != ''"> right_app_name , </if>
<if test="rightApiId != null and rightApiId != ''"> right_api_id , </if>
<if test="rightId != null and rightId != ''"> right_id , </if>
<if test="rightCode != null and rightCode != ''"> right_code , </if>
<if test="rightName != null and rightName != ''"> right_name , </if>
<if test="leftOrg != null and leftOrg != ''"> left_org , </if>
<if test="rightOrg != null and rightOrg != ''"> right_org , </if>
<if test="sorts == null"> sorts , </if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
create_time,
modify_time,
sts
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> #{id} ,</if>
<if test="leftAppId != null and leftAppId != ''"> #{leftAppId} ,</if>
<if test="leftAppCode != null and leftAppCode != ''"> #{leftAppCode} ,</if>
<if test="leftAppName != null and leftAppName != ''"> #{leftAppName} ,</if>
<if test="leftApiId != null and leftApiId != ''"> #{leftApiId} ,</if>
<if test="leftId != null and leftId != ''"> #{leftId} ,</if>
<if test="leftCode != null and leftCode != ''"> #{leftCode} ,</if>
<if test="leftName != null and leftName != ''"> #{leftName} ,</if>
<if test="rightAppId != null and rightAppId != ''"> #{rightAppId} ,</if>
<if test="rightAppCode != null and rightAppCode != ''"> #{rightAppCode} ,</if>
<if test="rightAppName != null and rightAppName != ''"> #{rightAppName} ,</if>
<if test="rightApiId != null and rightApiId != ''"> #{rightApiId} ,</if>
<if test="rightId != null and rightId != ''"> #{rightId} ,</if>
<if test="rightCode != null and rightCode != ''"> #{rightCode} ,</if>
<if test="rightName != null and rightName != ''"> #{rightName} ,</if>
<if test="leftOrg != null and leftOrg != ''"> #{leftOrg} , </if>
<if test="rightOrg != null and rightOrg != ''"> #{rightOrg} , </if>
<if test="sorts != null"> #{sorts} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from
<choose>
<when test="archivesType == '1'.toString()"> sys_personnel_control </when>
<when test="archivesType == '2'.toString()"> sys_org_control </when>
<when test="archivesType == '6'.toString()"> sys_stock_control </when>
<when test="archivesType == '73'.toString()"> sys_merchant_control </when>
<when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
<when test="archivesType == '93'.toString()"> sys_bank_control </when>
<when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
<when test="archivesType == '22'.toString()"> sys_assets_control </when>
</choose>
a WHERE a.sts = 'Y' ),</if>
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
<if test="org_id != null and org_id != ''"> #{org_id} ,</if>
<if test="companyId != null and companyId != ''"> #{companyId} ,</if>
<if test="create_time != null"> #{create_time} ,</if>
<if test="create_time == null">now() ,</if>
<if test="modify_time != null"> #{modify_time} ,</if>
<if test="modify_time == null"> now() ,</if>
<if test="sts != null and sts != ''"> #{sts} ,</if>
<if test="sts == null ">'Y'</if>
</trim>
)
</insert>
<!--通过主键修改方法-->
<update id="updateGeneralDataByType" parameterType = "com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity" >
update
<choose>
<when test="archivesType == '1'.toString()"> sys_personnel_control </when>
<when test="archivesType == '2'.toString()"> sys_org_control </when>
<when test="archivesType == '6'.toString()"> sys_stock_control </when>
<when test="archivesType == '73'.toString()"> sys_merchant_control </when>
<when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
<when test="archivesType == '93'.toString()"> sys_bank_control </when>
<when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
<when test="archivesType == '22'.toString()"> sys_assets_control </when>
</choose>
set
<trim suffix="" suffixOverrides=",">
<if test="leftAppId != null and leftAppId != ''"> left_app_id = #{leftAppId},</if>
<if test="leftAppCode != null and leftAppCode != ''"> left_app_code = #{leftAppCode},</if>
<if test="leftAppName != null and leftAppName != ''"> left_app_name = #{leftAppName},</if>
<if test="leftApiId != null and leftApiId != ''"> left_api_id = #{leftApiId},</if>
<if test="leftId != null and leftId != ''"> left_id = #{leftId},</if>
<if test="leftCode != null and leftCode != ''"> left_code = #{leftCode},</if>
<if test="leftName != null and leftName != ''"> left_name = #{leftName},</if>
<if test="rightAppId != null and rightAppId != ''"> right_app_id = #{rightAppId},</if>
<if test="rightAppCode != null and rightAppCode != ''"> right_app_code = #{rightAppCode},</if>
<if test="rightAppName != null and rightAppName != ''"> right_app_name = #{rightAppName},</if>
<if test="rightApiId != null and rightApiId != ''"> right_api_id = #{rightApiId},</if>
<if test="rightId != null and rightId != ''"> right_id = #{rightId},</if>
<if test="rightCode != null and rightCode != ''"> right_code = #{rightCode},</if>
<if test="rightName != null and rightName != ''"> right_name = #{rightName},</if>
<if test="leftOrg != null and leftOrg != ''"> left_org = #{leftOrg} , </if>
<if test="rightOrg != null and rightOrg != ''"> right_org = #{rightOrg} , </if>
<if test="sorts != null"> sorts = #{sorts},</if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id = #{create_user_id},</if>
<if test="create_time != null"> create_time = #{create_time},</if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id = #{modify_user_id},</if>
<if test="modify_time != null"> modify_time = #{modify_time},</if>
<if test="modify_time == null"> modify_time = now(),</if>
<if test="sts != null and sts != ''"> sts = #{sts},</if>
<if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
<if test="companyId != null and companyId != ''"> company_id = #{companyId}</if>
</trim>
where id = #{id}
</update>
<!-- 多条件逻辑删除 -->
<update id="deleteGeneralDataByType" parameterType = "com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity" >
update
<choose>
<when test="archivesType == '1'.toString()"> sys_personnel_control </when>
<when test="archivesType == '2'.toString()"> sys_org_control </when>
<when test="archivesType == '6'.toString()"> sys_stock_control </when>
<when test="archivesType == '73'.toString()"> sys_merchant_control </when>
<when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
<when test="archivesType == '93'.toString()"> sys_bank_control </when>
<when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
<when test="archivesType == '22'.toString()"> sys_assets_control </when>
</choose>
set sts= 'N' ,modify_time = now(),modify_user_id = #{modify_user_id}
<trim prefix="where" prefixOverrides="and">
<if test="leftAppId != null and leftAppId != ''"> and left_app_id = #{leftAppId} </if>
<if test="leftAppCode != null and leftAppCode != ''"> and left_app_code = #{leftAppCode} </if>
<if test="leftAppName != null and leftAppName != ''"> and left_app_name = #{leftAppName} </if>
<if test="leftApiId != null and leftApiId != ''"> and left_api_id = #{leftApiId} </if>
<if test="leftId != null and leftId != ''"> and left_id = #{leftId} </if>
<if test="leftCode != null and leftCode != ''"> and left_code = #{leftCode} </if>
<if test="leftName != null and leftName != ''"> and left_name = #{leftName} </if>
<if test="rightAppId != null and rightAppId != ''"> and right_app_id = #{rightAppId} </if>
<if test="rightAppCode != null and rightAppCode != ''"> and right_app_code = #{rightAppCode} </if>
<if test="rightAppName != null and rightAppName != ''"> and right_app_name = #{rightAppName} </if>
<if test="rightApiId != null and rightApiId != ''"> and right_api_id = #{rightApiId} </if>
<if test="rightId != null and rightId != ''"> and right_id = #{rightId} </if>
<if test="rightCode != null and rightCode != ''"> and right_code = #{rightCode} </if>
<if test="rightName != null and rightName != ''"> and right_name = #{rightName} </if>
<if test="leftOrg != null and leftOrg != ''"> left_org = #{leftOrg} , </if>
<if test="rightOrg != null and rightOrg != ''"> right_org = #{rightOrg} , </if>
<if test="sorts != null"> and sorts = #{sorts} </if>
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
and id=#{id} and sts='Y'
</trim>
</update>
</mapper>

View File

@ -0,0 +1,59 @@
package com.hzya.frame.sysnew.generalData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IGeneralDataService extends IBaseService<GeneralDataEntity, String> {
/**
*
* @content 新增通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 16:23
* **/
JsonResultEntity saveEntity(JSONObject jsonObject);
/**
*
* @content 查询通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 17:00
* **/
JsonResultEntity queryEntityPage(JSONObject jsonObject);
/**
*
* @content 编辑通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 17:16
* **/
JsonResultEntity updateEntity(JSONObject jsonObject);
/**
*
* @content 删除通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 17:23
* **/
JsonResultEntity deleteEntity(JSONObject jsonObject);
/**
*
* @content 查询单个通用数据
* @Param
* @Return
* @Author hecan
* @Date 2024/5/6 17:26
* **/
JsonResultEntity getEntity(JSONObject jsonObject);
}

View File

@ -0,0 +1,241 @@
package com.hzya.frame.sysnew.generalData.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.sysnew.generalData.dao.IGeneralDataDao;
import com.hzya.frame.sysnew.generalData.entity.GeneralDataEntity;
import com.hzya.frame.sysnew.generalData.service.IGeneralDataService;
import com.hzya.frame.sysnew.homeComponent.dao.ISysHomeComponentDao;
import com.hzya.frame.uuid.UUIDLong;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service(value = "generalDataServiceImpl")
public class GeneralDataServiceImpl extends BaseService<GeneralDataEntity, String> implements IGeneralDataService {
private IGeneralDataDao generalDataDao;
@Autowired
public void setGeneralDataDao(IGeneralDataDao dao) {
this.generalDataDao = dao;
this.dao = dao;
}
//新增通用数据
@Override
public JsonResultEntity saveEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
if(jsonObject == null ){
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("通用数据类型为空");
}
if(!checkStr(jsonObject.getString("leftCode"))){
return BaseResult.getFailureMessageEntity("左编码为空");
}
if(!checkStr(jsonObject.getString("rightCode"))){
return BaseResult.getFailureMessageEntity("右编码为空");
}
if(!checkStr(jsonObject.getString("leftAppCode"))){
return BaseResult.getFailureMessageEntity("左应用编码为空");
}
if(!checkStr(jsonObject.getString("rightAppCode"))){
return BaseResult.getFailureMessageEntity("右应用编码为空");
}
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
/* switch (jsonObject.getString("archivesType")){
case "1"://人员对照
GeneralDataEntity generalDataEntityPersonnel = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityPersonnel);
break;
case "2"://部门档案
GeneralDataEntity generalDataEntityOrg = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityOrg);
break;
case "6"://存货对照
GeneralDataEntity generalDataEntityStock = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityStock);
break;
case "73"://客商辅助核算
GeneralDataEntity generalDataEntityMerchant = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityMerchant);
break;
case "D01"://税率
GeneralDataEntity generalDataEntityTaxrate = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityTaxrate);
break;
case "jobass"://项目辅助核算
GeneralDataEntity generalDataEntityProject = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityProject);
break;
case "93"://银行类别
GeneralDataEntity generalDataEntityBank = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityBank);
break;
case "96"://银行账户
GeneralDataEntity generalDataEntityBankaccount = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityBankaccount);
break;
case "22"://资产类别
GeneralDataEntity generalDataEntityAssets = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataDao.saveGeneralDataByType(generalDataEntityAssets);
break;
default:
break;
}*/
GeneralDataEntity generalDataEntity = jsonObject.toJavaObject(GeneralDataEntity.class);
generalDataEntity.setId(UUIDUtils.getUUID());
generalDataEntity.setCreate_user_id("1");
generalDataEntity.setModify_user_id("1");
generalDataEntity.setOrg_id("0");
generalDataEntity.setCompanyId("0");
try {
GeneralDataEntity generalDataEntitySave = generalDataDao.saveGeneralDataByType(generalDataEntity);
return BaseResult.getSuccessMessageEntity("新增成功",generalDataEntitySave);
}catch (Exception e){
logger.info("通用数据新增错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("新增失败",e.getMessage());
}
}
//查询通用数据
@Override
public JsonResultEntity queryEntityPage(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
if(jsonObject == null ){
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("通用数据类型为空");
}
/*if(!checkStr(jsonObject.getString("leftCode"))){
return BaseResult.getFailureMessageEntity("左编码为空");
}
if(!checkStr(jsonObject.getString("rightCode"))){
return BaseResult.getFailureMessageEntity("右编码为空");
}*/
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
GeneralDataEntity generalDataEntity = jsonObject.toJavaObject(GeneralDataEntity.class);
try {
List<GeneralDataEntity> generalDataEntities = generalDataDao.queryGeneralData(generalDataEntity);
PageInfo pageInfo=new PageInfo(generalDataEntities);
return BaseResult.getSuccessMessageEntity("查询成功",pageInfo);
}catch (Exception e){
logger.info("通用数据查询错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("查询失败",e.getMessage());
}
}
//编辑通用数据
@Override
public JsonResultEntity updateEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
if(jsonObject == null ){
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("id"))){
return BaseResult.getFailureMessageEntity("id为空");
}
if(!checkStr(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("通用数据类型为空");
}
/*if(!checkStr(jsonObject.getString("leftCode"))){
return BaseResult.getFailureMessageEntity("左编码为空");
}
if(!checkStr(jsonObject.getString("rightCode"))){
return BaseResult.getFailureMessageEntity("右编码为空");
}
if(!checkStr(jsonObject.getString("leftAppCode"))){
return BaseResult.getFailureMessageEntity("左应用编码为空");
}
if(!checkStr(jsonObject.getString("rightAppCode"))){
return BaseResult.getFailureMessageEntity("右应用编码为空");
}*/
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
GeneralDataEntity generalDataEntity = jsonObject.toJavaObject(GeneralDataEntity.class);
try {
generalDataDao.updateGeneralDataByType(generalDataEntity);
return BaseResult.getSuccessMessageEntity("编辑成功");
}catch (Exception e){
logger.info("通用数据编辑失败:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("编辑失败",e.getMessage());
}
}
//删除通用数据
@Override
public JsonResultEntity deleteEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
if(jsonObject == null ){
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("id"))){
return BaseResult.getFailureMessageEntity("id为空");
}
if(!checkStr(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("通用数据类型为空");
}
/*if(!checkStr(jsonObject.getString("leftCode"))){
return BaseResult.getFailureMessageEntity("左编码为空");
}
if(!checkStr(jsonObject.getString("rightCode"))){
return BaseResult.getFailureMessageEntity("右编码为空");
}
if(!checkStr(jsonObject.getString("leftAppCode"))){
return BaseResult.getFailureMessageEntity("左应用编码为空");
}
if(!checkStr(jsonObject.getString("rightAppCode"))){
return BaseResult.getFailureMessageEntity("右应用编码为空");
}*/
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
GeneralDataEntity generalDataEntity = jsonObject.toJavaObject(GeneralDataEntity.class);
try {
generalDataEntity.setCreate_user_id("1");
generalDataEntity.setModify_user_id("1");
generalDataDao.deleteGeneralDataByType(generalDataEntity);
return BaseResult.getSuccessMessageEntity("删除成功");
}catch (Exception e){
logger.info("通用数据删除失败:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("删除失败",e.getMessage());
}
}
//查询单个通用数据对象
@Override
public JsonResultEntity getEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
if(jsonObject == null ){
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("id"))){
return BaseResult.getFailureMessageEntity("id为空");
}
GeneralDataEntity generalDataEntity = jsonObject.toJavaObject(GeneralDataEntity.class);
try {
GeneralDataEntity generalDataEntityOne = generalDataDao.queryOne(generalDataEntity);
return BaseResult.getSuccessMessageEntity("查询单个成功",generalDataEntityOne);
}catch (Exception e){
logger.info("查询单个通用数据错误:{}",e.getMessage());
return BaseResult.getSuccessMessageEntity("查询单个失败",e.getMessage());
}
}
}