alwaysfrin 7 years ago
commit 9ea6567876

@ -23,6 +23,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>

@ -48,7 +48,7 @@ public class Pager {
totalPages++;
}
currentPage = 1;
startRow = 1;
startRow = 0;
resetEndRow();
}
@ -63,7 +63,7 @@ public class Pager {
totalPages++;
}
currentPage = 1;
startRow = 1;
startRow = 0;
resetEndRow();
}
@ -125,7 +125,7 @@ public class Pager {
public void resetEndRow() {
if (startRow + pageSize <= totalRows) {
endRow = startRow + pageSize - 1;
endRow = startRow + pageSize;
} else {
endRow = totalRows;
}
@ -133,7 +133,7 @@ public class Pager {
public void first() {
currentPage = 1;
startRow = 1;
startRow = 0;
resetEndRow();
}
@ -142,7 +142,7 @@ public class Pager {
return;
}
currentPage--;
startRow = (currentPage - 1) * pageSize + 1;
startRow = (currentPage - 1) * pageSize;
resetEndRow();
}
@ -150,7 +150,7 @@ public class Pager {
if (currentPage < totalPages) {
currentPage++;
}
startRow = (currentPage - 1) * pageSize + 1;
startRow = (currentPage - 1) * pageSize;
resetEndRow();
}
@ -163,7 +163,7 @@ public class Pager {
} else {
currentPage = totalPages;
}
startRow = (currentPage - 1) * pageSize + 1;
startRow = (currentPage - 1) * pageSize;
resetEndRow();
}
@ -182,7 +182,7 @@ public class Pager {
if (currentPage > totalPages) {
last();
} else {
startRow = (currentPage - 1) * pageSize + 1;
startRow = (currentPage - 1) * pageSize;
}
}

@ -58,7 +58,7 @@ public class PagerHelper {
}
pager.setCurrentPage(currentPage);
int startRow = (currentPage - 1) * pageSize + 1;
int startRow = (currentPage - 1) * pageSize;
pager.setStartRow(startRow);
int endRow = 0;

@ -285,7 +285,6 @@ public class CommonEnumUtil {
}
}
/**
*
* 1
@ -388,7 +387,6 @@ public class CommonEnumUtil {
}
}
/**
*
*/
@ -422,7 +420,6 @@ public class CommonEnumUtil {
}
}
/**
*
*/
@ -455,4 +452,39 @@ public class CommonEnumUtil {
return tmp;
}
}
/**
*
*/
public enum PARENT{
DEFAULT(-1L,"根节点");
private Long value = -1L;
private String description = null;
public Long getValue() {
return value;
}
public String getDescription() {
return description;
}
private PARENT(Long value, String description) {
this.value = value;
this.description = description;
}
public static String valueOf(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].description;
}
}
return tmp;
}
}
}

@ -640,7 +640,7 @@ public class ImppEnumUtil {
* 1.SYSTEM
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SYS_PARAM_TYPE{
public enum SYS_CONFIG_TYPE{
SYSTEM(1,"系统参数","系统参数");
@ -648,77 +648,10 @@ public class ImppEnumUtil {
private String name;
private String description;
SYS_PARAM_TYPE() {
SYS_CONFIG_TYPE() {
}
SYS_PARAM_TYPE(int value, String name, String description) {
this.value = value;
this.name = name;
this.description = description;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public static String valueOfCode(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].name;
}
}
return tmp;
}
public static String valueOfDescription(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].description;
}
}
return tmp;
}
public static String codeOfDescription(String code) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].name.equals(code)) {
tmp = values()[i].description;
}
}
return tmp;
}
}
/**
*
* 1.ENABLE
* 2.DISABLE
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum COMM_STATUS{
ENABLE(1,"启用","fa fa-success cell-fa fa-check"),
DISABLE(2,"禁用","fa fa-disabled cell-fa fa-times-circle");
private int value;
private String name;
private String description;
COMM_STATUS() {
}
COMM_STATUS(int value, String name, String description) {
SYS_CONFIG_TYPE(int value, String name, String description) {
this.value = value;
this.name = name;
this.description = description;

@ -77,6 +77,12 @@ public interface BaseRepository <T, ID extends Serializable> extends JpaReposito
public void deleteByProperties(String[] propName, Object[] propValue);
/**
* in
* @param ids
*/
public void deleteByIdIn(long[] ids);
/**
*
* @param conditionName
* @param conditionValue
@ -112,6 +118,24 @@ public interface BaseRepository <T, ID extends Serializable> extends JpaReposito
*/
public int updateByProperties(String[] conditionName, Object[] conditionValue, String[] propertyName, Object[] propertyValue);
/**
* hqlWhere
* @param hqlWhere
* @param propertyName
* @param propertyValue
* @return
*/
public int updateByHqlWhere(String hqlWhere,String propertyName, Object propertyValue);
/**
*
* @param hqlWhere HQL where
* @param propertyName
* @param propertyValue
* @return
*/
public int updateByHqlWhere(String hqlWhere,String[] propertyName, Object[] propertyValue);
public T getById(long id);
public List<T> list();

@ -1,14 +1,15 @@
package cn.estsh.i3plus.pojo.base.jpa.daoimpl;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
import cn.estsh.i3plus.pojo.base.tool.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.common.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.*;
@ -22,6 +23,8 @@ import java.util.*;
**/
public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, Serializable>
implements BaseRepository<T, Serializable> {
public static final Logger LOGGER = LoggerFactory.getLogger(BaseRepositoryImpl.class);
/**
*
*/
@ -141,6 +144,19 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
}
@Override
public void deleteByIdIn(long[] ids) {
if(ids != null && ids.length > 0){
String hql = "delete from " + persistentClass.getName() + " o where o.id in(:ids) ";
Query query = entityManager.createQuery(hql);
query.setParameter("ids", Arrays.asList(ids));
query.executeUpdate();
}else{
throw new IllegalArgumentException("Method deleteByPropertiesIn argument is illegal! ids:" + ids);
}
}
@Override
public int updateByProperties(String conditionName, Object conditionValue, String propertyName, Object propertyValue) {
return updateByProperties(new String[] { conditionName }, new Object[] { conditionValue }, new String[] { propertyName }, new Object[] { propertyValue });
}
@ -161,17 +177,20 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
&& (propertyValue.length > 0) && (propertyName.length == propertyValue.length)
&& (conditionValue != null) && (conditionValue.length > 0)) {
StringBuffer sb = new StringBuffer();
sb.append("update " + persistentClass.getName() + " o set ");
for (int i = 0; i < propertyName.length; i++) {
sb.append(propertyName[i] + " = :p_" + propertyName[i] + ",");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(" where 1=1 ");
appendQL(sb, conditionName, conditionValue);
Query query = entityManager.createQuery(sb.toString());
for (int i = 0; i < propertyName.length; i++) {
query.setParameter("p_" + propertyName[i], propertyValue[i]);
}
setParameter(query, conditionName, conditionValue);
return query.executeUpdate();
} else {
@ -181,6 +200,36 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
}
@Override
public int updateByHqlWhere(String hqlWhere, String propertyName, Object propertyValue) {
return updateByHqlWhere(hqlWhere, new String[]{propertyName}, new Object[]{propertyValue});
}
@Override
public int updateByHqlWhere(String hqlWhere, String[] propertyName, Object[] propertyValue) {
if ((propertyName != null) && (propertyName.length > 0) && (propertyValue != null)
&& (propertyValue.length > 0) && (propertyName.length == propertyValue.length)) {
StringBuffer sb = new StringBuffer();
sb.append("update " + persistentClass.getName() + " o set ");
for (int i = 0; i < propertyName.length; i++) {
sb.append(propertyName[i] + " = :p_" + propertyName[i] + ",");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(" where 1=1 ");
sb.append(hqlWhere);
Query query = entityManager.createQuery(sb.toString());
for (int i = 0; i < propertyName.length; i++) {
query.setParameter("p_" + propertyName[i], propertyValue[i]);
}
return query.executeUpdate();
} else {
throw new IllegalArgumentException("Method updateByProperties argument is illegal! propertyName:" + propertyName + ",propertyValue:" + propertyValue);
}
}
@Override
public T getById(long id) {
return entityManager.find(persistentClass,id);
}
@ -292,7 +341,6 @@ public class BaseRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRep
return queryObject.getResultList();
}
@Override
public T getByProperty(String propertyName, Object value) {
String queryString = "from " + persistentClass.getSimpleName() + " as model where model." + propertyName + "= :" + propertyName;

@ -55,9 +55,6 @@ public class Department extends BaseBean {
}
}
@ApiParam(value ="子部门列表")
private transient List<Department> childList;
@Column(name="RED_ORGANIZATION_NAME")
@ApiParam(value ="所属组织名称" , access ="所属组织名称")
private String redOrganizeName;
@ -71,4 +68,7 @@ public class Department extends BaseBean {
@ApiParam(value ="排序" , example ="1" , access ="排序")
private Integer departmentSort;
@ApiParam(value ="子集列表")
private transient List<Department> childList;
}

@ -13,6 +13,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.text.DecimalFormat;
import java.util.List;
/**
* @Description :
@ -41,11 +42,11 @@ public class Organize extends BaseBean {
@Column(name="ORGANIZE_TYPE_ID")
@ApiParam(value ="组织类型ID枚举1.集团2.公司3.工厂)" , example ="1")
private Integer organizeTypeId;
// 默认值 -1
@Column(name="PARENT_ID")
@ApiParam(value ="父节点" , access ="父节点" ,example = "-1")
@JsonSerialize(using = ToStringSerializer.class)
// 默认值 -1
private Long parentId;
public Long getParentId() {
@ -71,4 +72,6 @@ public class Organize extends BaseBean {
@ApiParam(value ="组织状态枚举1.正常2.禁用)" , example ="1")
private Integer organizeStatusId;
@ApiParam(value ="子集列表")
private transient List<Organize> childList;
}

@ -37,11 +37,11 @@ public class Position extends BaseBean {
@Column(name="POSITION_CODE")
@ApiParam(value ="岗位代码" , access ="岗位代码")
private String positionCode;
// 默认值 -1
@Column(name="PARENT_ID")
@ApiParam(value ="上级岗位" , example ="-1" , access ="上级岗位")
@JsonSerialize(using = ToStringSerializer.class)
// 默认值 -1
private Long parentId;
public Long getParentId() {

@ -35,7 +35,7 @@ public class SessionUser implements Serializable {
private SysUser user;
@ApiParam("用户对象信息")
private SysUser userInfo;
private SysUserInfo userInfo;
@ApiParam(value = "角色信息",access = "用户所拥有岗位信息集合")
private List<SysRole> roleList;

@ -29,7 +29,6 @@ import java.text.DecimalFormat;
@Api(value="系统字典",description = "系统字典")
public class SysDictionary extends BaseBean {
@Column(name="NAME")
@ApiParam(value ="字典名称")
private String name;
@ -51,11 +50,15 @@ public class SysDictionary extends BaseBean {
return parentId;
}
}
@Column(name="RED_PARENT_NAME")
@ApiParam(value ="父级节点名称")
private String redParentName;
@Column(name="RED_PARENT_CODEE")
@ApiParam(value ="父级节点代码")
private String redParentCode;
@Column(name="DICTIONARY_VALUE")
@ApiParam(value ="字典值")
private String dictionaryValue;

@ -1,6 +1,7 @@
package cn.estsh.i3plus.pojo.platform.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
@ -28,6 +29,11 @@ public class SysLocaleResource extends BaseBean {
@ApiParam(value = "资源类型",example = "1",access = "使用枚举CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE")
private Integer resourceType;
private transient String resourceTypeTxt;
public String getResourceTypeTxt(){
return CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE.valueOf(this.resourceType);
}
@Column(name="language_code")
@ApiParam(value = "语言编码",example = "浏览器语言编码")
private String languageCode;

@ -13,6 +13,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.text.DecimalFormat;
import java.util.List;
/**
* @Description :
@ -32,7 +33,11 @@ public class SysMenu extends BaseBean {
@Column(name="NAME")
@ApiParam(value ="功能名称")
private String name;
@Column(name="MENU_CODE")
@ApiParam(value ="功能代码")
private String menuCode;
@Column(name="MENU_TYPE_ID")
@ApiParam(value ="功能类型枚举1.模块2.菜单3.按钮)" , example ="-1")
private Integer menuTypeId;
@ -79,4 +84,7 @@ public class SysMenu extends BaseBean {
@ApiParam(value ="功能状态1.正常2.禁用)" , example ="1" , access ="功能状态1.正常2.禁用)",defaultValue="1")
private Integer menuStatus = 1;
@ApiParam(value ="子集列表")
private transient List<SysMenu> childList;
}

@ -1,10 +1,7 @@
package cn.estsh.i3plus.pojo.platform.sqlpack;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource;
import cn.estsh.i3plus.pojo.platform.bean.*;
import java.util.Arrays;
@ -56,54 +53,158 @@ public class CoreHqlPack {
}
/**
* In
* @param columnName
* @return
*/
public static String packHqlIds(String columnName,String[] params){
StringBuffer result = new StringBuffer();
// 参数数组 [1,2,3] -> "1,2,3"
HqlPack.getInPack(String.join(",",params),columnName,result);
return result.toString();
}
/**
*
* @param position
* @return
*/
public static String packHqlPosition(Position position) {
public static String packHqlPosition(Position position){
StringBuffer result = new StringBuffer();
// 岗位名称
HqlPack.getStringLikerPack(position.getName(),"positionName",result);
// 岗位代码
// 查询参数封装
HqlPack.getNumEqualPack(position.getParentId(),"parentId",result);
HqlPack.getStringLikerPack(position.getName(),"name",result);
HqlPack.getStringLikerPack(position.getPositionCode(),"positionCode",result);
// 父级岗位
HqlPack.getNumEqualPack(position.getId(),"parentId",result);
return result.toString();
}
/**
* In
* @param columnName
*
* @param organize
* @return
*/
public static String packHqlIds(String columnName,String[] params){
StringBuffer result = new StringBuffer();
public static String packHqlOrganize(Organize organize){
StringBuffer result = new StringBuffer();
// 查询参数封装
HqlPack.getNumEqualPack(organize.getParentId(),"parentId",result);
HqlPack.getStringLikerPack(organize.getName(),"name",result);
HqlPack.getStringLikerPack(organize.getOrganizeCode(),"organizeCode",result);
// 参数数组 [1,2,3] -> "1,2,3"
HqlPack.getInPack(String.join(",",params),columnName,result);
return result.toString();
}
/**
*
* @param department
* @return
*/
public static String packHqlPosition(Department department) {
public static String packHqlDepartment(Department department){
StringBuffer result = new StringBuffer();
// 查询参数封装
HqlPack.getNumEqualPack(department.getParentId(),"parentId",result);
HqlPack.getStringLikerPack(department.getName(),"name",result);
HqlPack.getStringLikerPack(department.getDepartmentCode(),"departmentCode",result);
return result.toString();
}
/**
*
* @param menu
* @return
*/
public static String packHqlSysMenu(SysMenu menu){
StringBuffer result = new StringBuffer();
// 查询参数封装
HqlPack.getNumEqualPack(menu.getParentId(),"parentId",result);
HqlPack.getNumEqualPack(menu.getMenuStatus(),"menuStatus",result);
HqlPack.getStringLikerPack(menu.getName(),"name",result);
HqlPack.getStringLikerPack(menu.getMenuCode(),"menuCode",result);
return result.toString();
}
/**
*
* @param role
* @return
*/
public static String packHqlSysRole(SysRole role){
StringBuffer result = new StringBuffer();
// 查询参数封装
HqlPack.getNumEqualPack(role.getRoleStatusId(),"roleStatusId",result);
HqlPack.getStringLikerPack(role.getName(),"name",result);
return result.toString();
}
/**
*
* @param sysConfig
* @return
*/
public static String packHqlSysConfig(SysConfig sysConfig) {
StringBuffer result = new StringBuffer();
// hql拼接
HqlPack.getStringLikerPack(sysConfig.getName(),"name",result);
HqlPack.getStringLikerPack(sysConfig.getConfigCode(),"configCode",result);
HqlPack.getNumEqualPack(sysConfig.getConfigTypeId(),"configTypeId",result);
return result.toString();
}
/**
*
* @param sysDictionary
* @return
*/
public static String packHqlSysDictionary(SysDictionary sysDictionary) {
StringBuffer result = new StringBuffer();
// hql拼接
HqlPack.getStringLikerPack(sysDictionary.getName(),"name",result);
HqlPack.getStringLikerPack(sysDictionary.getDictionaryCode(),"dictionaryCode",result);
HqlPack.getNumEqualPack(sysDictionary.getParentId(),"parentId",result);
return result.toString();
}
/**
*
* @param toolType
* @return
*/
public static String packHqlToolType(ToolType toolType) {
StringBuffer result = new StringBuffer();
// hql拼接
HqlPack.getStringLikerPack(toolType.getName(),"name",result);
return result.toString();
}
/**
*
* @param tool
* @return
*/
public static String packHqlTool(Tool tool) {
StringBuffer result = new StringBuffer();
// 部门名称
HqlPack.getStringLikerPack(department.getName(),"positionName",result);
// 部门代码
HqlPack.getStringLikerPack(department.getDepartmentCode(),"positionCode",result);
// 父级部门id
HqlPack.getNumEqualPack(department.getId(),"parentId",result);
// 所属组织id
HqlPack.getNumEqualPack(department.getOrganizeId(),"organizeId",result);
// hql拼接
HqlPack.getStringLikerPack(tool.getName(),"name",result);
HqlPack.getNumEqualPack(tool.getToolTypeId(),"toolTypeId",result);
HqlPack.getNumEqualPack(tool.getToolStatusId(),"toolStatusId",result);
HqlPack.getStringLikerPack(tool.getName(),"name",result);
HqlPack.getStringLikerPack(tool.getName(),"name",result);
return result.toString();
}

@ -3,6 +3,9 @@ package cn.estsh.i3plus.pojo.wms.bean;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -15,7 +18,10 @@ import javax.persistence.Table;
* @CreateDate : 2018-09-04 15:58
* @Modify:
**/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name="factory_store")
@Api("工厂仓库")
public class FactoryStore extends BaseBean {
@ -27,40 +33,4 @@ public class FactoryStore extends BaseBean {
@Column(name="store_name")
@ApiParam("仓库名称")
public String storeName;
public FactoryStore() {
}
public FactoryStore(String storeCode, String storeName) {
this.storeCode = storeCode;
this.storeName = storeName;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
@Override
public String toString() {
return "FactoryStore{" +
"storeCode='" + storeCode + '\'' +
", storeName='" + storeName + '\'' +
", id=" + id +
", isValid=" + isValid +
", createDate='" + createDatetime + '\'' +
", modifyDate='" + modifyDatetime + '\'' +
'}';
}
}

@ -0,0 +1,34 @@
package cn.estsh.i3plus.pojo.wms.sqlpack;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource;
import cn.estsh.i3plus.pojo.wms.bean.FactoryStore;
/**
* @Description :
* @Reference :
* @Author : silliter.yuan
* @CreateDate : 2018-10-31 10:45
* @Modify:
**/
public class WmsHqlPack {
/**
*
* @param factoryStore
* @return
*/
public static String packHqlFactoryStore(FactoryStore factoryStore) {
StringBuffer result = new StringBuffer();
// 部门名称
HqlPack.getStringLikerPack(factoryStore.getStoreCode(),"storeCode", result);
// 部门代码
HqlPack.getStringLikerPack(factoryStore.getStoreName(),"storeName", result);
return result.toString();
}
}
Loading…
Cancel
Save