Commit 8574cbff by 史文博

Merge branch 'feature/form_statistics_05' into 'develop'

Feature/form statistics 05

See merge request kunlun/xyst_dinas/xyst_dinas_backend!82
parents cfdeb508 927aaad7
...@@ -14,8 +14,10 @@ public interface WarehouseUserDao extends BaseDao { ...@@ -14,8 +14,10 @@ public interface WarehouseUserDao extends BaseDao {
KObject findByUsernameOrTelephone(String username); KObject findByUsernameOrTelephone(String username);
List<KObject> findAllByStationId(UUID stationId); List<KObject> findAllByStationId(UUID stationId);
List<String> findAllByStationListId(List<String> stationListId);
List<KObject> queryPositionByName(String phone); List<KObject> queryPositionByName(String phone);
List<KObject> userNameRepeatCheck(String username); List<KObject> userNameRepeatCheck(String username);
List<KObject> getAllByUserId(List<UUID> userListId);
} }
...@@ -86,4 +86,16 @@ public class SandUserDaoImpl extends AbstractBaseDao { ...@@ -86,4 +86,16 @@ public class SandUserDaoImpl extends AbstractBaseDao {
}); });
} }
public List<KObject> getAllByUserListId(List<UUID> userListId) {
// TODO Auto-generated method stub
return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer(
"FROM " + getModelName() + " WHERE id in (:userListId) AND enabled = 1 AND discard = 0 ");
// 创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameterList("userListId", userListId);
return query.getResultList();
});
}
} }
package com.beecode.inz.basis.internal.dao; package com.beecode.inz.basis.internal.dao;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.Tuple;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Session; import org.hibernate.Session;
...@@ -11,6 +15,7 @@ import org.springframework.orm.hibernate5.HibernateCallback; ...@@ -11,6 +15,7 @@ import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.beecode.amino.common.Convert;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.WarehouseUserConstants; import com.beecode.inz.basis.config.constants.WarehouseUserConstants;
import com.beecode.inz.basis.dao.WarehouseUserDao; import com.beecode.inz.basis.dao.WarehouseUserDao;
...@@ -21,7 +26,7 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs ...@@ -21,7 +26,7 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs
@Autowired @Autowired
private HibernateTemplate template; private HibernateTemplate template;
public WarehouseUserDaoImpl(){ public WarehouseUserDaoImpl() {
} }
...@@ -38,12 +43,13 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs ...@@ -38,12 +43,13 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs
@Override @Override
public KObject findByUsernameOrTelephone(String username) { public KObject findByUsernameOrTelephone(String username) {
return getHibernateTemplate().execute(session -> { return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer("FROM " + getModelName() + " WHERE (username = :username OR telephone = :username) AND enabled = 1 AND discard = 0 "); StringBuffer sql = new StringBuffer("FROM " + getModelName()
//创建查询 + " WHERE (username = :username OR telephone = :username) AND enabled = 1 AND discard = 0 ");
// 创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class); Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameter("username", username); query.setParameter("username", username);
List<KObject> result = query.getResultList(); List<KObject> result = query.getResultList();
if(result != null && result.size() > 0) { if (result != null && result.size() > 0) {
return result.get(0); return result.get(0);
} }
return null; return null;
...@@ -56,8 +62,9 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs ...@@ -56,8 +62,9 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs
@Override @Override
public List<KObject> findAllByStationId(UUID stationId) { public List<KObject> findAllByStationId(UUID stationId) {
return getHibernateTemplate().execute(session -> { return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer("FROM " + getModelName() + " WHERE stationId = :stationId AND enabled = 1 AND discard = 0 "); StringBuffer sql = new StringBuffer(
//创建查询 "FROM " + getModelName() + " WHERE stationId = :stationId AND enabled = 1 AND discard = 0 ");
// 创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class); Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameter("stationId", stationId); query.setParameter("stationId", stationId);
return query.getResultList(); return query.getResultList();
...@@ -76,11 +83,14 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs ...@@ -76,11 +83,14 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs
@Override @Override
public List<KObject> queryPositionByName(String phone) { public List<KObject> queryPositionByName(String phone) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() { return (List<KObject>) template.execute(new HibernateCallback<List<KObject>>() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<KObject> doInHibernate(Session session) throws HibernateException { public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + WarehouseUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and telephone =:phone ", KObject.class); Query<KObject> query = session.createQuery(
"from " + WarehouseUserConstants.ENTITY
+ " where (discard is null or discard = 0) and (enabled = 1) and telephone =:phone ",
KObject.class);
query.setParameter("phone", phone); query.setParameter("phone", phone);
return query.getResultList(); return query.getResultList();
} }
...@@ -89,15 +99,52 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs ...@@ -89,15 +99,52 @@ public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUs
@Override @Override
public List<KObject> userNameRepeatCheck(String username) { public List<KObject> userNameRepeatCheck(String username) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() { return (List<KObject>) template.execute(new HibernateCallback<List<KObject>>() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<KObject> doInHibernate(Session session) throws HibernateException { public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + WarehouseUserConstants.ENTITY + " where (discard is null or discard = 0) and (enabled = 1) and username =:username ", KObject.class); Query<KObject> query = session.createQuery(
"from " + WarehouseUserConstants.ENTITY
+ " where (discard is null or discard = 0) and (enabled = 1) and username =:username ",
KObject.class);
query.setParameter("username", username); query.setParameter("username", username);
return query.getResultList(); return query.getResultList();
} }
}); });
} }
@Override
public List<String> findAllByStationListId(List<String> stationListId) {
List<String> params = stationListId.stream().map(station -> station = station.replaceAll("-", "")).collect(Collectors.toList());
return getHibernateTemplate().execute(session -> { //
StringBuffer sql = new StringBuffer("select warehouseUser.id as id FROM xyst_dinas_basis_warehouse_user AS warehouseUser WHERE hex(warehouseUser.station_Id) in (:stationId) AND warehouseUser.enabled = 1 AND warehouseUser.discard = 0"); //创建查询
Query<Tuple> query = session.createNativeQuery(sql.toString(), Tuple.class);
query.setParameterList("stationId", params);
List<Tuple> resultList = query.getResultList();
if (resultList.isEmpty()) {
return null;
}
List<String> resultUserList = new ArrayList<String>();
for (Tuple resule : resultList) {
resultUserList.add(Convert.toUUID(resule.get(0)).toString());
}
return resultUserList;
});
}
@Override
public List<KObject> getAllByUserId(List<UUID> userListId) {
// TODO Auto-generated method stub
return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer(
"FROM " + getModelName() + " WHERE id in (:userListId) AND enabled = 1 AND discard = 0 ");
// 创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameterList("userListId", userListId);
return query.getResultList();
});
}
} }
...@@ -219,6 +219,12 @@ public class SandUserServiceImpl implements SandUserService { ...@@ -219,6 +219,12 @@ public class SandUserServiceImpl implements SandUserService {
} }
@Override
public List<KObject> getAllByUserListId(List<UUID> userListId) {
// TODO Auto-generated method stub
return dao.getAllByUserListId(userListId);
}
......
...@@ -220,6 +220,18 @@ public class WarehouseUserServiceImpl implements WarehouseUserService { ...@@ -220,6 +220,18 @@ public class WarehouseUserServiceImpl implements WarehouseUserService {
return flag; return flag;
} }
@Override
public List<String> getAllByStationListId(List<String> stationListId) {
// TODO Auto-generated method stub
return dao.findAllByStationListId(stationListId);
}
@Override
public List<KObject> getAllByUserId(List<UUID> userListId) {
// TODO Auto-generated method stub
return dao.getAllByUserId(userListId);
}
} }
...@@ -58,6 +58,7 @@ public interface SandUserService { ...@@ -58,6 +58,7 @@ public interface SandUserService {
void updatePassword(UUID id, String newPassword); void updatePassword(UUID id, String newPassword);
List<KObject> getAllBySandId(UUID id); List<KObject> getAllBySandId(UUID id);
List<KObject> getAllByUserListId(List<UUID> userListId);
Boolean repeatCheck(String parameter, String string); Boolean repeatCheck(String parameter, String string);
......
...@@ -62,9 +62,12 @@ public interface WarehouseUserService { ...@@ -62,9 +62,12 @@ public interface WarehouseUserService {
* @return * @return
*/ */
List<KObject> getAllByStationId(UUID stationId); List<KObject> getAllByStationId(UUID stationId);
List<String> getAllByStationListId(List<String> stationListId);
Boolean phoneRepeatCheck(String parameter); Boolean phoneRepeatCheck(String parameter);
Boolean userNameRepeatCheck(String parameter); Boolean userNameRepeatCheck(String parameter);
List<KObject> getAllByUserId(List<UUID> userId);
} }
...@@ -221,5 +221,26 @@ public class SandUserController { ...@@ -221,5 +221,26 @@ public class SandUserController {
return ResponseObj.error(); return ResponseObj.error();
} }
}/**
* 查询场站用户
* @param obj
* @return
*/
@PostMapping("/sandUser/user/userListId")
public Object getAllByUserId( @RequestBody List<UUID> userListId) {
if(userListId.size()<0) {
return ResponseObj.error("userListId不能为空");
}
try {
List<KObject> list = sandUserService.getAllByUserListId(userListId);
return ResponseObj.success("操作成功", list);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return ResponseObj.error("stationId错误");
} catch (Exception e) {
e.printStackTrace();
return ResponseObj.error("操作失败");
}
} }
} }
package com.beecode.inz.basis.web; package com.beecode.inz.basis.web;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.json.JSONArray;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,6 +29,7 @@ import com.beecode.inz.basis.pojo.WarehouseUser; ...@@ -27,6 +29,7 @@ import com.beecode.inz.basis.pojo.WarehouseUser;
import com.beecode.inz.basis.service.WarehouseUserService; import com.beecode.inz.basis.service.WarehouseUserService;
import com.beecode.inz.basis.team.pojo.ResponseObj; import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.basis.util.JsonUtil; import com.beecode.inz.basis.util.JsonUtil;
import com.beecode.xlib.json.JSONException; import com.beecode.xlib.json.JSONException;
import com.beecode.xlib.json.JSONObject; import com.beecode.xlib.json.JSONObject;
import com.beecode.xlib.runtime.Assert; import com.beecode.xlib.runtime.Assert;
...@@ -97,6 +100,51 @@ public class WarehouseUserController { ...@@ -97,6 +100,51 @@ public class WarehouseUserController {
} }
/** /**
* 创建场站用户
* @param obj
* @return
*/
@PostMapping("/warehouse/user/stationList")
public Object getByStationListId( @RequestBody List<String> stationListId) {
if(stationListId.size()<0) {
return ResponseObj.error("stationListId不能为空");
}
try {
List<String> list = warehouseUserService.getAllByStationListId(stationListId);
return ResponseObj.success("操作成功", list);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return ResponseObj.error("stationId错误");
} catch (Exception e) {
e.printStackTrace();
return ResponseObj.error("操作失败");
}
}
/**
* 查询场站用户
* @param obj
* @return
*/
@PostMapping("/warehouse/user/userListId")
public Object getAllByUserId( @RequestBody List<UUID> userListId) {
if(userListId.size()<0) {
return ResponseObj.error("userListId不能为空");
}
try {
List<KObject> list = warehouseUserService.getAllByUserId(userListId);
return ResponseObj.success("操作成功", list);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return ResponseObj.error("stationId错误");
} catch (Exception e) {
e.printStackTrace();
return ResponseObj.error("操作失败");
}
}
/**
* 根据id查询用户 * 根据id查询用户
* @param obj * @param obj
* @return * @return
...@@ -116,6 +164,8 @@ public class WarehouseUserController { ...@@ -116,6 +164,8 @@ public class WarehouseUserController {
} }
} }
/** /**
* 编辑 * 编辑
* @param obj * @param obj
......
...@@ -129,6 +129,15 @@ ...@@ -129,6 +129,15 @@
</ref> </ref>
<description></description> <description></description>
</field> </field>
<field title='场站'>
<name>station.id</name>
<type>uuid</type>
<ref>
<type></type>
<name>com.xyst.dinas.biz.datamodel.Station</name>
</ref>
<description></description>
</field>
<field title='项目名称'> <field title='项目名称'>
<name>project.projectName</name> <name>project.projectName</name>
<type>string</type> <type>string</type>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment