|
@ -5262,7 +5262,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getFirstPageInfo(String userId) throws Exception {
|
|
|
public JSONObject getFirstPageInfo(String belongCommunity, String userId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
String condition = "";
|
|
@ -5281,7 +5281,17 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
if ("replenisher".equals(role.getCode())) {
|
|
|
deviceIds = mediicineDeviceUserDao.getdevicesbyuserid(userId, "1");
|
|
|
conditionSql = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',d.id,',%')\n";
|
|
|
orderConditionSql = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',d.shipping_equ,',%')\n";
|
|
|
// orderConditionSql = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',d.shipping_equ,',%')\n";
|
|
|
List<String> belongCommunitys = new ArrayList<>();
|
|
|
for (String deviceId : deviceIds) {
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
if (mediicinedevice != null) {
|
|
|
if (belongCommunitys.indexOf(mediicinedevice.getBelongCommunity()) == -1) {
|
|
|
belongCommunitys.add(mediicinedevice.getBelongCommunity());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
orderConditionSql += "AND ',"+ String.join(",", belongCommunitys) +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
|
|
|
} else {
|
|
|
String belongCommunitys = "";
|
|
|
String tempSql = "";
|
|
@ -5329,6 +5339,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//选择单个社区
|
|
|
if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
|
|
|
belongCommunitys = belongCommunity;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
|
conditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
|
|
|
orderConditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
|
|
@ -5410,11 +5424,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
jsonObject.put("maintain", maintain);
|
|
|
|
|
|
jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1));
|
|
|
jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(belongCommunity, userId, 1));
|
|
|
//非设备管理员
|
|
|
if (!"replenisher".equals(role.getCode())) {
|
|
|
jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(userId, 1));
|
|
|
jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1));
|
|
|
jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(belongCommunity, userId, 1));
|
|
|
jsonObject.put("shippingType", getShippingTypeByUserId(belongCommunity, userId, 1));
|
|
|
}
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg", jsonObject);
|
|
@ -5428,7 +5442,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getDevicePriceStatisticsByUserId(String userId,Integer day){
|
|
|
public JSONObject getDevicePriceStatisticsByUserId(String belongCommunity, String userId,Integer day){
|
|
|
JSONObject object = new JSONObject();
|
|
|
String condition = "";
|
|
|
|
|
@ -5486,6 +5500,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
|
|
|
belongCommunitys = belongCommunity;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
|
condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
|
|
|
}
|
|
@ -5561,7 +5578,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getShippingTypeByUserId(String userId,Integer day){
|
|
|
public JSONObject getShippingTypeByUserId(String belongCommunity, String userId,Integer day){
|
|
|
JSONObject object = new JSONObject();
|
|
|
String condition = "";
|
|
|
|
|
@ -5619,6 +5636,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
|
|
|
belongCommunitys = belongCommunity;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
|
condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
|
|
|
}
|
|
@ -5678,18 +5698,24 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @param day
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day){
|
|
|
public JSONObject getPrescriptionStaticsByUserId(String belongCommunity, String userId,Integer day){
|
|
|
JSONObject object = new JSONObject();
|
|
|
String condition = "";
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
List<String> deviceIds = null;
|
|
|
String conditionSql = "";
|
|
|
String orderConditionSql = "";
|
|
|
String oorderConditionSql = "";
|
|
|
if ("replenisher".equals(role.getCode())) {
|
|
|
deviceIds = mediicineDeviceUserDao.getdevicesbyuserid(userId, "1");
|
|
|
condition = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',o.shipping_equ,',%')\n";
|
|
|
List<String> belongCommunitys = new ArrayList<>();
|
|
|
for (String deviceId : deviceIds) {
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
if (mediicinedevice != null) {
|
|
|
if (belongCommunitys.indexOf(mediicinedevice.getBelongCommunity()) == -1) {
|
|
|
belongCommunitys.add(mediicinedevice.getBelongCommunity());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
orderConditionSql += "AND ',"+ String.join(",", belongCommunitys) +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
|
|
|
} else {
|
|
|
String belongCommunitys = "";
|
|
|
String tempSql = "";
|
|
@ -5737,8 +5763,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
|
|
|
belongCommunitys = belongCommunity;
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
|
condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
|
|
|
orderConditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
|
|
|
}
|
|
|
}
|
|
|
Date startDate = null;
|
|
@ -5753,7 +5782,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
String endTime = DateUtil.getStringDate();
|
|
|
timeCondition = " and o.create_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.create_time <= '" + endTime + "' ";
|
|
|
}
|
|
|
String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition;
|
|
|
String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE 1=1 "+orderConditionSql+ timeCondition;
|
|
|
Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
|
|
|
int total =0;
|
|
|
if (totalMap!=null){
|
|
@ -5763,7 +5792,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
}
|
|
|
object.put("total",total);
|
|
|
String drugSql = "select sum(od.quantity) as quantity from t_mediicine_order_detail od where od.id_order IN (SELECT o.id as id FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition+")";
|
|
|
String drugSql = "select sum(od.quantity) as quantity from t_mediicine_order_detail od where od.id_order IN (SELECT o.id as id FROM t_mediicine_order o WHERE 1=1 "+orderConditionSql+ timeCondition+")";
|
|
|
Map<String,Object> drugTotalMap = jdbcTemplate.queryForMap(drugSql);
|
|
|
Double quantity =0.0;
|
|
|
if (drugTotalMap!=null){
|