|
@ -868,7 +868,6 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
|
* 更新设备缺货信息
|
|
|
* @param medicineShipmentLog
|
|
|
*/
|
|
|
public void updateDeviceState(String cargoId, InventoryDO inventoryDO) {
|
|
|
//包含原来药品信息
|
|
@ -2119,24 +2118,79 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
// return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
|
|
|
// }
|
|
|
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, int page, int size) {
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
|
page=(page-1)*size;
|
|
|
List<Mediicinedevice> mediicinedevices = new ArrayList<>();
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)&& !org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
mediicinedevices= deviceDao.findDeviceByCommunity(page, size,belongCommunity);
|
|
|
}else if(org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)&& org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
mediicinedevices= deviceDao.findDeviceByEquNum(page, size,equNum);
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum,String userId,int page, int size) throws Exception {
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
if (role==null){
|
|
|
throw new Exception("角色为空!");
|
|
|
}
|
|
|
String areaCondition = "";
|
|
|
//市管理员
|
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
|
areaCondition = "SELECT\n" +
|
|
|
"\t`code`\tas community\n" +
|
|
|
"FROM\n" +
|
|
|
"\tdm_hospital\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tdel = 1";
|
|
|
}
|
|
|
//区域管理员
|
|
|
if ("regionAdmin".equals(role.getCode())) {
|
|
|
areaCondition = "SELECT\n" +
|
|
|
"\tdh.`code` AS community\n" +
|
|
|
"FROM\n" +
|
|
|
"\twlyy_user_area t\n" +
|
|
|
"LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.user_id = '" + userId + "'\n" +
|
|
|
"AND t.del = 1\n" +
|
|
|
"AND dh.del = 1";
|
|
|
}
|
|
|
//社区管理员
|
|
|
if ("communityAdmin".equals(role.getCode())) {
|
|
|
areaCondition = "SELECT\n" +
|
|
|
"t.hospital AS community\n" +
|
|
|
"FROM\n" +
|
|
|
"wlyy_user_area AS t\n" +
|
|
|
"WHERE\n" +
|
|
|
"t.user_id = '" + userId + "'\n" +
|
|
|
"AND t.del = 1";
|
|
|
}
|
|
|
|
|
|
for (Mediicinedevice mediicinedevice : mediicinedevices) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("community", mediicinedevice.getCommunity());
|
|
|
map.put("equName", mediicinedevice.getEquNum() + (mediicinedevice.getEquName() == null ? "" : "/" + mediicinedevice.getEquName()));
|
|
|
//社区管理员
|
|
|
if ("replenisher".equals(role.getCode())) {
|
|
|
areaCondition = "SELECT\n" +
|
|
|
"t.hospital AS community\n" +
|
|
|
"FROM\n" +
|
|
|
"wlyy_user_area AS t\n" +
|
|
|
"WHERE\n" +
|
|
|
"t.user_id = '" + userId + "'\n" +
|
|
|
"AND t.del = 1";
|
|
|
}
|
|
|
|
|
|
String sql = "select belong_community as \"belongCommunity\"," +
|
|
|
"community as \"community\",id as \"id\",equ_name as \"equName\",equ_num as \"equNum\" from t_mediicine_device where 1=1 ";
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(areaCondition)){
|
|
|
sql += " and belong_community in("+areaCondition+") ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
sql += " and belong_community ='"+belongCommunity+"' ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
sql += " and equ_num = '%"+equNum+"%' ";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> mediicinedevices = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
|
|
|
for (Map<String,Object> map : mediicinedevices) {
|
|
|
map.put("equName",map.get("equNum").toString()+"/"+map.get("equName").toString());
|
|
|
String oneSql = "SELECT SUM(t.amount) AS sumAmount,\n" +
|
|
|
" COUNT(*) AS count,\n" +
|
|
|
" t.shipping_equ AS equNum\n" +
|
|
|
" FROM t_mediicine_order t WHERE t.sell_state = 1 AND t.shipping_equ = '" + mediicinedevice.getEquNum() + "'";
|
|
|
" FROM t_mediicine_order t WHERE t.sell_state = 1 AND t.shipping_equ = '" + map.get("equNum").toString() + "'";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(oneSql);
|
|
|
for (Map<String,Object> oneMap:list){
|
|
|
String count = oneMap.get("count")==null?"0":oneMap.get("count").toString();
|
|
@ -2147,7 +2201,6 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
map.put("ordercount",count);
|
|
|
map.put("sumAmount",m_price);
|
|
|
}
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
@ -2155,11 +2208,23 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
" t_mediicine_device as t " +
|
|
|
" where " +
|
|
|
" 1=1 " ;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(areaCondition)){
|
|
|
countSql += " and belong_community in("+areaCondition+") ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
countSql += " and belong_community ='"+belongCommunity+"' ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
countSql += " and equ_num = '%"+equNum+"%' ";
|
|
|
}
|
|
|
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int decCount = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
//总页数
|
|
|
int total=decCount/size+(decCount%size>0?1:0);
|
|
|
MixEnvelop mixEnvelop = MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
|
|
|
MixEnvelop mixEnvelop = MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mediicinedevices);
|
|
|
mixEnvelop.setTotalCount(decCount);
|
|
|
mixEnvelop.setTotalPage(total);
|
|
|
return mixEnvelop;
|