wangzhinan %!s(int64=3) %!d(string=hai) anos
pai
achega
57587a44ae

+ 26 - 22
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperator.java

@ -8,16 +8,20 @@ package com.yihu.jw.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.util.StringFStringEncryptConverter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.Auditable;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.Instant;
import java.time.ZoneId;
import java.util.Date;
/**
@ -31,32 +35,16 @@ import java.util.Date;
@EntityListeners(AuditingEntityListener.class)
public abstract class UuidIdentityEntityWithOperator extends UuidIdentityEntity {
    //创建时间
	@CreatedDate
	protected Date createTime;
	//创建者
    @CreatedBy
	protected String createUser;
    //创建者
    @CreatedBy
    protected String createUserName;
    //更新时间
    @LastModifiedDate
	protected String createUserName;
	protected Date updateTime;
	//更新者
    @LastModifiedBy
	protected String updateUser;
	//更新者
    @LastModifiedBy
	protected String updateUserName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time", nullable = false, length = 0,updatable = false)
	@CreatedDate
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "create_time", nullable = false, length = 0,updatable = false)
	public Date getCreateTime() {
		return createTime;
	}
@ -65,13 +53,19 @@ public abstract class UuidIdentityEntityWithOperator extends UuidIdentityEntity
		this.createTime = createTime;
	}
	@Column(name = "create_user",updatable = false)
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
		if (StringUtils.isNoneBlank(createUser)){
			this.createUser = createUser;
		}else {
			this.createUser = "123";
		}
	}
	@Column(name = "create_user_name",updatable = false)
@ -80,9 +74,14 @@ public abstract class UuidIdentityEntityWithOperator extends UuidIdentityEntity
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
		if (StringUtils.isNoneBlank(createUserName)){
			this.createUserName = createUserName;
		}else {
			this.createUserName = "123";
		}
	}
	@LastModifiedDate
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
@ -93,15 +92,18 @@ public abstract class UuidIdentityEntityWithOperator extends UuidIdentityEntity
		this.updateTime = updateTime;
	}
	@LastModifiedBy
	@Column(name = "update_user")
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@LastModifiedBy
	@Column(name = "update_user_name")
	public String getUpdateUserName() {
		return updateUserName;
@ -110,4 +112,6 @@ public abstract class UuidIdentityEntityWithOperator extends UuidIdentityEntity
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinedevice.java

@ -11,7 +11,7 @@ import java.util.Date;
@Entity
@Table(name="t_mediicine_device")
public class Mediicinedevice extends UuidIdentityEntityWithOperator implements Serializable {
public class Mediicinedevice extends UuidIdentityEntityWithOperator{
    /**

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -182,6 +182,7 @@ public class BaseRequestMapping {
        public static final String updateNetWorkStatus  = "/updateNetWorkStatus";
        public static final String updateTAndH  = "/updateTAndH";
        public static final String UPDATESALESTATUS  = "/updateSaleStatus";
        public static final String updateDevEquName  = "/updateDevEquName";
        public static final String UNBINDDEVICE  = "/unbindDevice";
        public static final String mergeAndSplitCargo  = "/mergeAndSplitCargo";
        public static final String getDeviceListByUserId  = "/getDeviceListByUserId";

+ 15 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -250,6 +250,21 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(jsonObject.getString("response"));
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.updateDevEquName)
    @ApiOperation(value = "更新设备名称")
    public Envelop updateDevEquName(
            @ApiParam(name = "deviceId", value = "设备Id", required = true)
            @RequestParam(value = "deviceId", required = true) String deviceId,
            @ApiParam(name = "equName", value = "设备名称", required = true)
            @RequestParam(value = "equName", required = true) String equName) throws Exception {
        String str = deviceService.updateDevEquName(deviceId, equName);
        JSONObject jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("response"));
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.UNBINDDEVICE)
    @ApiOperation(value = "设备解绑")

+ 4 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineUpEndpoint.java

@ -41,9 +41,11 @@ public class MedicineUpEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "生成备货单信息")
    public Envelop createUp(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData,
            @ApiParam(name = "userId", value = "用户id", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        JSONObject jsonObject = null;
        String str = stockupService.createDetailUp(jsonData);
        String str = stockupService.createDetailUp(jsonData, userId);
        jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineDrugsService.java

@ -236,7 +236,7 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
            conditionSql += " and t.state = '" + state + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.drug_code, t.drug_bar_code, t.drug_name, t.drug_short_code) like '%"+content+"%'";
            conditionSql += " AND CONCAT(IFNULL(t.`drug_code`,''), IFNULL(t.`drug_bar_code`,''), IFNULL(t.`drug_name`,''), IFNULL(t.`drug_short_code`,'')) like '%"+content+"%'";
        }
        if (!StringUtils.isEmpty(drugClass)){
            conditionSql += " and t.drug_class_code = '" + drugClass + "'";
@ -438,7 +438,7 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
            conditionSql += " and t.state = '" + state + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.drug_code, t.drug_bar_code, drug_name, t.drug_short_code) like '%"+content+"%'";
            conditionSql += " and CONCAT(IFNULL(t.`drug_code`,''), IFNULL(t.`drug_bar_code`,''), IFNULL(t.`drug_name`,''), IFNULL(t.`drug_short_code`,'')) like '%"+content+"%'";
        }
        if (!StringUtils.isEmpty(drugClass)){
            conditionSql += " and t.drug_class_code = '" + drugClass + "'";

+ 4 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineOrderService.java

@ -184,7 +184,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
@ -193,7 +193,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id AS community\n" +
                        "\tdh.`code` AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
@ -850,7 +850,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                    "\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + mediicineorderdetail.getDrugCode() + "'\n" +
                    "\t\t\tAND t.org_code = '" + mediicineorderdetail.getOrgCode() + "'\n" +
//                    "\t\t\tAND t.state = '1'\n" +
                    "\t\t\tAND CONCAT(t.id_device, t.equ_num) like '%" + deviceId + "%'\n" +
                    "\t\t\tAND CONCAT(IFNULL(t.`id_device`,''), IFNULL(t.`equ_num`,'')) like '%" + deviceId + "%'\n" +
                    "\t\t\tGROUP BY\n" +
                    "\t\t\t\tt.drug_code,\n" +
                    "\t\t\t\tt.org_code\n" +
@ -951,7 +951,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                            "WHERE\n" +
                            "\tt.drug_code = '" + mediicineorderdetail.getDrugCode() + "'\n" +
                            "AND t.org_code = '" + mediicineorderdetail.getOrgCode() + "'\n" +
                            "AND CONCAT(t.id_device, t.equ_num) like '%" + deviceId + "%'\n" +
                            "AND CONCAT(IFNULL(t.`id_device`,''), IFNULL(t.`equ_num`,'')) like '%" + deviceId + "%'\n" +
                            "AND ( t.state = '1' or t.state = '21')\n" +
                            "and t.qty > 0"
            );

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineStockOutService.java

@ -262,7 +262,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "\tcode\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
@ -271,7 +271,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id AS community\n" +
                        "\tdh.`code` AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +

+ 23 - 15
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineStockUpService.java

@ -60,7 +60,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String createDetailUp(String jsonData) {
    public String createDetailUp(String jsonData, String userId) {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(jsonData)){
@ -68,6 +68,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        UserDO user = userDao.findOne(userId);
        JSONObject up = JSONObject.parseObject(jsonData);
        List<UpDO> list = JSONObject.parseArray(up.getJSONArray("list").toJSONString(), UpDO.class);
@ -89,7 +90,10 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
            mediicinestockup.setReplenishEqu(upDO.getDeviceId());
            mediicinestockup.setState("1");
            mediicinestockup.setReplenishInventory(String.valueOf(upDO.getDrugs().stream().mapToInt(DrugDO::getQty).sum()));
//            mediicinestockup.setReplenishEr("123");
            mediicinestockup.setCreateUser(userId);
            mediicinestockup.setCreateUserName(user.getName());
            mediicinestockup.setUpdateUser(userId);
            mediicinestockup.setUpdateUserName(user.getName());
            upDao.save(mediicinestockup);
            for (DrugDO drug : upDO.getDrugs()) {
                Mediicinedrugs mediicinedrugs = drugsDao.findOne(drug.getDrugId());
@ -214,7 +218,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
@ -223,7 +227,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id AS community\n" +
                        "\tdh.`code` AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
@ -242,18 +246,21 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
                        "t.user_id = '" + userId + "'\n" +
                        "AND t.del = 1";
            }
            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
            for (Map<String, Object> stringObjectMap : list) {
                if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                    if (StringUtils.isEmpty(belongCommunitys)) {
                        belongCommunitys += stringObjectMap.get("community").toString();
                    } else {
                        belongCommunitys += "," +  stringObjectMap.get("community").toString();
            //sql为空,即表示,不是系统所分配的角色
            if (!StringUtils.isEmpty(sql)) {
                List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
                for (Map<String, Object> stringObjectMap : list) {
                    if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                        if (StringUtils.isEmpty(belongCommunitys)) {
                            belongCommunitys += stringObjectMap.get("community").toString();
                        } else {
                            belongCommunitys += "," +  stringObjectMap.get("community").toString();
                        }
                    }
                }
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.community,',%')\n";
                if (!StringUtils.isEmpty(belongCommunitys)) {
                    conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.community,',%')\n";
                }
            }
        }
        String sql = "SELECT\n" +
@ -374,12 +381,13 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
        }
        if (!StringUtils.isEmpty(equName)){
            conditionSql += " and tmd.equ_name like '%" + equName + "%'";
//            conditionSql += " and IFNULL(tmd.`equ_name`,'') like '%" + equName + "%'";
        }
        if (!StringUtils.isEmpty(equCode)){
            conditionSql += " and tmd.equ_num like '%" + equCode + "%'";
        }
        if (!StringUtils.isEmpty(replenishEr)){
            conditionSql += " and CONCAT(tmu.name,tmu.mobile) like '%" + replenishEr + "%'";
            conditionSql += " and CONCAT(IFNULL(tmu.`name`,''),IFNULL(tmu.`mobile`,'')) like '%" + replenishEr + "%'";
        }

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineUserService.java

@ -123,7 +123,7 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
        String conditionSql = "";
        if (!StringUtils.isEmpty(content)){
//            conditionSql += " AND CONCAT(t.account, t.`name`) like '%"+ content +"%'";
            conditionSql += "\tAND CONCAT(b.mobile,b.name) like '%"+ content +"%'";
            conditionSql += "\tAND CONCAT(IFNULL(b.`mobile`,''),IFNULL(b.`name`,'')) like '%"+ content +"%'";
        }
        sql = sql + conditionSql;

+ 7 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineWarrayService.java

@ -101,7 +101,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.temperature <= " + heightT;
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
            conditionSql += "  AND  t.log_time >= '" + startTime +"'" +
@ -194,7 +194,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.humidity <= " + heightT;
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
            conditionSql += "  AND  t.log_time >= '" + startTime +"'" +
@ -282,7 +282,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.network_status = '" + netStatus + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
            conditionSql += "  AND  t.log_time >= '" + startTime +"'" +
@ -370,7 +370,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.network_status = '" + netStatus + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
            conditionSql += "  AND  t.log_time >= '" + startTime +"'" +
@ -456,7 +456,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.network_status = '" + netStatus + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
            conditionSql += "  AND  t.log_time >= '" + startTime +"'" +
@ -543,7 +543,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.network_status = '" + netStatus + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
            conditionSql += "  AND  t.log_time >= '" + startTime +"'" +
@ -630,7 +630,7 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            conditionSql += " and t.network_status = '" + netStatus + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (!StringUtils.isEmpty(type)) {
            if("1".equalsIgnoreCase(type)){

+ 55 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -522,6 +522,34 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        result.put("msg",mediicinedevice);
        return result.toJSONString();
    }
    /**
     * 更新设备名称
     * @param deviceId
     * @param equName
     * @return
     */
    public String updateDevEquName(String deviceId, String equName){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(equName)){
            result.put("msg","deviceId and equName is null");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
        if (mediicinedevice == null) {
            result.put("msg","device doesn't exist");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        mediicinedevice.setEquName(equName);
        this.save(mediicinedevice);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",mediicinedevice);
        return result.toJSONString();
    }
    /**
     * 解绑设备
     * @param deviceIds
@ -716,7 +744,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        String conditionSql = "";
        if (!StringUtils.isEmpty(content)){
            conditionSql += " AND CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " AND CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (!StringUtils.isEmpty(equClass)){
            conditionSql += " AND t.equ_class = '"+equClass + "'";
@ -843,7 +871,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        String conditionSql = "";
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
            conditionSql += " and CONCAT(IFNULL(t.`equ_name`,''), IFNULL(t.`equ_num`,'')) like '%" + content + "%'";
        }
        if (!StringUtils.isEmpty(equClass)){
            conditionSql += " and t.equ_class = '"+equClass + "'";
@ -997,7 +1025,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "FROM\n" +
                "    t_mediicine_device AS t where t.del = 1\n";
//        String conditionSql = " t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and ',"+userId+",' LIKE CONCAT('%,',du.user_id,',%'))";
        String conditionSql = " and t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and du.user_id = '" + userId + "')";
        sql = sql + conditionSql;
@ -1096,7 +1123,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "FROM\n" +
                "    base_user AS t where\n";
//        String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and ',"+deviceId+",' LIKE CONCAT('%,',du.device_id,',%'))";
        String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and du.device_id = '" + deviceId + "')";
        sql = sql + conditionSql;
@ -1229,7 +1255,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
@ -1238,7 +1264,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id AS community\n" +
                        "\tdh.`code` AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
@ -1434,10 +1460,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "LEFT JOIN t_mediicinecabinet_inventory tmi ON t.id = tmi.id_device\n" +
                "WHERE 1=1 and t.del = 1\n" ;
        if (!StringUtils.isEmpty(replenishEr)) {
            sql +=" AND t.id in (select device_id from t_mediicine_device_user tmdu left join base_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.mobile) like '%" + replenishEr + "%')\n";
            sql +=" AND t.id in (select device_id from t_mediicine_device_user tmdu left join base_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(IFNULL(tmu.`name`,''),IFNULL(tmu.`mobile`,'')) like '%" + replenishEr + "%')\n";
        }
        if (!StringUtils.isEmpty(address)) {
            sql += " AND CONCAT(t.detail_address,t.delivery_address) like '%" + address + "%'\n";
            sql += " AND CONCAT(IFNULL(tmu.`detail_address`,''),IFNULL(tmu.`delivery_address`,'')) like '%" + address + "%'\n";
        }
       sql += "GROUP BY\n" +
@ -1582,7 +1608,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "t.del = 1 AND  \n" +
                    "t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
            if (!StringUtils.isEmpty(content)) {
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'";
                sencodSql += " AND CONCAT(IFNULL(tmu.`equ_num`,''), IFNULL(tmu.`equ_name`,'')) like '%" + content +"%'";
            }
             deviceList = hibenateUtils.createSQLQuery(sencodSql);
        } else {
@ -1591,7 +1617,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
@ -1600,7 +1626,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id AS community\n" +
                        "\tdh.`code` AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
@ -1675,7 +1701,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "t.del = 1 AND  \n" +
                    "t.`status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
            if (!StringUtils.isEmpty(content)) {
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'";
                sencodSql += " AND CONCAT(IFNULL(tmu.`equ_num`,''), IFNULL(tmu.`equ_name`,'')) like '%" + content +"%'";
            }
@ -1687,7 +1713,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tconcat(t.id_device, t.equ_num) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "\tconcat(IFNULL(t.`id_device`, ''), IFNULL(t.`equ_num`, '')) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "AND t.shelf_status = 1";
            //库存
            Integer qty = jdbcTemplate.queryForObject(tempSql, Integer.class);
@ -1698,7 +1724,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tconcat(t.id_device, t.equ_num) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "\tconcat(IFNULL(t.`id_device`, ''), IFNULL(t.`equ_num`, '')) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "AND t.shelf_status = 0";
            Integer xiajiaQty = jdbcTemplate.queryForObject(tempSql, Integer.class);
            if (xiajiaQty != null) {
@ -1781,7 +1807,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                //市管理员
                if ("saasAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tid\tas community\n" +
                            "\t`code`\tas community\n" +
                            "FROM\n" +
                            "\tdm_hospital\n" +
                            "WHERE\n" +
@ -1790,7 +1816,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                //区域管理员
                if ("regionAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tdh.id AS community\n" +
                            "\tdh.`code` AS community\n" +
                            "FROM\n" +
                            "\twlyy_user_area t\n" +
                            "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
@ -1871,7 +1897,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "WHERE 1=1 AND t.del = 1\n";
        }
        if (!StringUtils.isEmpty(content)) {
            conditionSql += "AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'\n";
            conditionSql += "AND CONCAT(IFNULL(t.`equ_num`, ''), IFNULL(t.`equ_name`, '')) like '%" + content +"%'\n";
        }
        if (!StringUtils.isEmpty(networkStatus)) {
            conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
@ -2015,7 +2041,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "WHERE 1=1 AND t.del = 1\n";
        }
        if (!StringUtils.isEmpty(content)) {
            conditionSql += "AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"'%\n";
            conditionSql += "AND CONCAT(IFNULL(t.`equ_num`, ''), IFNULL(t.`equ_name`, '')) like '%" + content +"%'\n";
        }
        if (!StringUtils.isEmpty(networkStatus)) {
            conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
@ -2485,12 +2511,12 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        } else {
            String belongCommunitys = "";
            String tempSql = "";
            //获取管理员所在社区id字符串
            //获取管理员所在社区code字符串
            {
                //市管理员
                if ("saasAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tid\tas community\n" +
                            "\t`code`\tas community\n" +
                            "FROM\n" +
                            "\tdm_hospital\n" +
                            "WHERE\n" +
@ -2499,7 +2525,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                //区域管理员
                if ("regionAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tdh.id AS community\n" +
                            "\tdh.`code` AS community\n" +
                            "FROM\n" +
                            "\twlyy_user_area t\n" +
                            "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
@ -2784,12 +2810,20 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    public MediicinecabinetInventory updateMediicinecabineInventoryInfoById(String id,String qty,String cargoCapacity,String status) throws Exception {
        MediicinecabinetInventory inventory =  inventoryDao.findOne(id);
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(qty)){
            //提升容量至库存数(修改的库存数大于容量时)
            if (Integer.parseInt(qty) > Integer.parseInt(inventory.getCargoCapacity())) {
                inventory.setCargoCapacity(qty);
            }
            inventory.setQty(qty);
        }
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoCapacity)){
            inventory.setCargoCapacity(cargoCapacity);
        }
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
            //下架时,清空库存
            if ("0".equals(status)) {
                inventory.setQty("0");
            }
            inventory.setShelfStatus(status);
        }
        inventory.setUpdateTime(new Date());