|
@ -10,6 +10,7 @@ import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedevice;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.logging.Logger;
|
|
@ -126,6 +128,19 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分页查询设备信息
|
|
|
* @param content
|
|
|
* @param equClass
|
|
|
* @param belongCommunity
|
|
|
* @param networkStatus
|
|
|
* @param saleStatus
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @param wechatId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject queryDeviceListFullInfo(String content, String equClass, String belongCommunity,
|
|
|
String networkStatus, String saleStatus, int page, int size,String wechatId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
@ -204,16 +219,245 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取当前设备数量
|
|
|
public long countAll() {
|
|
|
return deviceDao.countAll();
|
|
|
|
|
|
public JSONObject getDevicesByMoreContent(String content, String equClass, String belongCommunity,
|
|
|
String networkStatus, String saleStatus, String machineCode, String deviceType, String equArea, String del, String status,String deliveryAddress, String wechatId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "SELECT\n" +
|
|
|
" t.id as id,\n" +
|
|
|
" t.belong_community as belongCommunity,\n" +
|
|
|
" t.community as community,\n" +
|
|
|
" t.del as del,\n" +
|
|
|
" t.delivery_address as deliveryAddress,\n" +
|
|
|
" t.detail_address as detailAddress,\n" +
|
|
|
" t.equ_area as equArea,\n" +
|
|
|
" t.equ_class as equClass,\n" +
|
|
|
" t.equ_info as equInfo,\n" +
|
|
|
" t.equ_name as equName,\n" +
|
|
|
" t.equ_num as equNum,\n" +
|
|
|
" t.equ_type as equType,\n" +
|
|
|
" t.fbelong_community as fbelongCommunity,\n" +
|
|
|
" t.machine_code as machineCode,\n" +
|
|
|
" t.network_status as networkStatus,\n" +
|
|
|
" t.poweron_test as poweronTest,\n" +
|
|
|
" t.reg_date as regDate,\n" +
|
|
|
" t.sale_status as saleStatus,\n" +
|
|
|
" t.signalintensity as signalintensity,\n" +
|
|
|
" t.upgr_adesit as upgrAdesit,\n" +
|
|
|
" t.`status` as `status`,\n" +
|
|
|
" t.card_status as cardStatus,\n" +
|
|
|
" t.operator as operator,\n" +
|
|
|
" t.pack_age as packAge,\n" +
|
|
|
" t.usage_flow as usageFlow,\n" +
|
|
|
" t.flow as flow,\n" +
|
|
|
" t.create_time as createTime,\n" +
|
|
|
" t.create_user as createUser,\n" +
|
|
|
" t.create_user_name as createUserName,\n" +
|
|
|
" t.update_time as updateTime,\n" +
|
|
|
" t.update_user as updateUser,\n" +
|
|
|
" t.update_user_name as updateUserName\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where 1=1\n";
|
|
|
|
|
|
String conditionSql = "";
|
|
|
if (!StringUtils.isEmpty(content)){
|
|
|
conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(equClass)){
|
|
|
conditionSql += " and t.equ_class = "+equClass;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunity)){
|
|
|
conditionSql += " and t.belong_community = " + belongCommunity;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(networkStatus)){
|
|
|
conditionSql += " and t.network_status = " + networkStatus;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(saleStatus)){
|
|
|
conditionSql += " and t.sale_status = " + saleStatus;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(machineCode)){
|
|
|
conditionSql += " and t.machine_code like '%" + machineCode + "%'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(deviceType)){
|
|
|
conditionSql += " and t.equ_type = "+deviceType;
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isEmpty(equArea)){
|
|
|
conditionSql += " and t.equ_area = "+equArea;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(del)){
|
|
|
conditionSql += " and t.del = "+del;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(status)){
|
|
|
conditionSql += " and t.`status` = "+status;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(deliveryAddress)){
|
|
|
conditionSql += " and t.delivery_address = "+deliveryAddress;
|
|
|
}
|
|
|
sql = sql + conditionSql;
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
" from " +
|
|
|
" t_mediicine_device t " +
|
|
|
" where " +
|
|
|
" 1=1 " +
|
|
|
conditionSql;
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
for (Map<String,Object> map:list){
|
|
|
|
|
|
}
|
|
|
result.put("count", count);
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据人员id,查询与之绑定的设备
|
|
|
* @param userId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getDevices(String userId) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(userId)){
|
|
|
result.put("msg","parameter userId is null ");
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
String sql = "SELECT\n" +
|
|
|
" t.id as id,\n" +
|
|
|
" t.belong_community as belongCommunity,\n" +
|
|
|
" t.community as community,\n" +
|
|
|
" t.del as del,\n" +
|
|
|
" t.delivery_address as deliveryAddress,\n" +
|
|
|
" t.detail_address as detailAddress,\n" +
|
|
|
" t.equ_area as equArea,\n" +
|
|
|
" t.equ_class as equClass,\n" +
|
|
|
" t.equ_info as equInfo,\n" +
|
|
|
" t.equ_name as equName,\n" +
|
|
|
" t.equ_num as equNum,\n" +
|
|
|
" t.equ_type as equType,\n" +
|
|
|
" t.fbelong_community as fbelongCommunity,\n" +
|
|
|
" t.machine_code as machineCode,\n" +
|
|
|
" t.network_status as networkStatus,\n" +
|
|
|
" t.poweron_test as poweronTest,\n" +
|
|
|
" t.reg_date as regDate,\n" +
|
|
|
" t.sale_status as saleStatus,\n" +
|
|
|
" t.signalintensity as signalintensity,\n" +
|
|
|
" t.upgr_adesit as upgrAdesit,\n" +
|
|
|
" t.`status` as `status`,\n" +
|
|
|
" t.card_status as cardStatus,\n" +
|
|
|
" t.operator as operator,\n" +
|
|
|
" t.pack_age as packAge,\n" +
|
|
|
" t.usage_flow as usageFlow,\n" +
|
|
|
" t.flow as flow,\n" +
|
|
|
" t.create_time as createTime,\n" +
|
|
|
" t.create_user as createUser,\n" +
|
|
|
" t.create_user_name as createUserName,\n" +
|
|
|
" t.update_time as updateTime,\n" +
|
|
|
" t.update_user as updateUser,\n" +
|
|
|
" t.update_user_name as updateUserName\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where\n";
|
|
|
|
|
|
String conditionSql = " t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and du.user_id = " + userId + ")";
|
|
|
|
|
|
sql = sql + conditionSql;
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
|
|
for (Map<String,Object> map:list){
|
|
|
|
|
|
}
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject getOneDeviceInfo(String deviceId) throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(deviceId)){
|
|
|
result.put("msg","parameter deviceId is null ");
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
Mediicinedevice device = deviceDao.findOne(deviceId);
|
|
|
if(null == device){
|
|
|
result.put("msg","设备不存在:" + deviceId);
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("device",device);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg",jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
// /**
|
|
|
// * 获取设备总数
|
|
|
// * @return
|
|
|
// * @throws Exception
|
|
|
// */
|
|
|
// public JSONObject countAll() throws Exception{
|
|
|
// JSONObject result = new JSONObject();
|
|
|
//
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
// jsonObject.put("count",deviceDao.countAll());
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",jsonObject);
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 获取设备总数
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject countAll() throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "select count(1) from t_mediicine_device a";
|
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg", count);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取当前设备数量
|
|
|
public long countOnline() {
|
|
|
return deviceDao.countOnline();
|
|
|
// public long countAll() {
|
|
|
// return deviceDao.countAll();
|
|
|
// }
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取当前设备数量
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject countOnline() throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("count",deviceDao.countOnline());
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg",jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取当前设备数量
|
|
|
// public long countOnline() {
|
|
|
// return deviceDao.countOnline();
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject saveDmMedicineDevice(String json) throws IOException {
|