Prechádzať zdrojové kódy

Merge branch 'dev' of chaoren1/wlyy2.0 into medicare

wangzhinan 3 rokov pred
rodič
commit
5c630b210a
31 zmenil súbory, kde vykonal 1242 pridanie a 1019 odobranie
  1. 5 2
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/DrugDO.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MedicineDeviceDelivery.java
  3. 113 0
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MedicineShipmentLog.java
  4. 3 0
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MediicineDeviceUser.java
  5. 74 5
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MediicinecabinetInventory.java
  6. 24 23
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinedevice.java
  7. 159 5
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicineorder.java
  8. 145 3
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicineorderdetail.java
  9. 8 8
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestockoutdetail.java
  10. 7 2
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestockrecorddetail.java
  11. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestockup.java
  12. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestockupdetail.java
  13. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestore.java
  14. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicineuser.java
  15. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinewarray.java
  16. 11 8
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/OutDO.java
  17. 5 2
      common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/UpDO.java
  18. 3 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  19. 11 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MedicineShipmentLogDao.java
  20. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineDeviceDao.java
  21. 11 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicinecabinetInventoryDao.java
  22. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicinedrugsDao.java
  23. 5 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineorderDao.java
  24. 3 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineorderdetailDao.java
  25. 46 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOrderEndpoint.java
  26. 15 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineDrugsService.java
  27. 225 15
      svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineOrderService.java
  28. 2 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineStockOutService.java
  29. 6 4
      svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineStockUpService.java
  30. 66 879
      svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineUserService.java
  31. 288 53
      svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

+ 5 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/DrugDO.java

@ -8,16 +8,19 @@ public class DrugDO implements Serializable {
    /**
     * 状态
     * 药品在药品表的id
     */
    private String drugId;
    /**
     * 名称
     * 数量
     */
    private Integer qty;
    public DrugDO() {
    }
    public String getDrugId() {
        return drugId;
    }

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

@ -7,7 +7,7 @@ import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name="t_medicine_device_delivery")

+ 113 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MedicineShipmentLog.java

@ -0,0 +1,113 @@
package com.yihu.jw.entity.a1entity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name = "t_medicine_shipment_log")
public class MedicineShipmentLog extends UuidIdentityEntityWithOperator implements Serializable {
    /**
     * 出货设备
     */
    private String deviceId;
    /**
     * 订单id
     */
    private String orderId;
    /**
     * 药品id
     */
    private String drugId;
    /**
     * 出货状态
     */
    private String status;
    /**
     * 出货时间
     */
    private String outTime;
    /**
     * 层
     */
    private String layerNo;
    /**
     * 列
     */
    private String wayerNo;
    /**
     * 描述
     */
    private String description;
    public MedicineShipmentLog() {
    }
    public String getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getDrugId() {
        return drugId;
    }
    public void setDrugId(String drugId) {
        this.drugId = drugId;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getOutTime() {
        return outTime;
    }
    public void setOutTime(String outTime) {
        this.outTime = outTime;
    }
    public String getLayerNo() {
        return layerNo;
    }
    public void setLayerNo(String layerNo) {
        this.layerNo = layerNo;
    }
    public String getWayerNo() {
        return wayerNo;
    }
    public void setWayerNo(String wayerNo) {
        this.wayerNo = wayerNo;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 3 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MediicineDeviceUser.java

@ -18,6 +18,9 @@ public class MediicineDeviceUser extends UuidIdentityEntityWithOperator implemen
    private String del;
    public MediicineDeviceUser() {
    }
    public String getDeviceId() {
        return deviceId;
    }

+ 74 - 5
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MediicinecabinetInventory.java

@ -12,8 +12,6 @@ import java.util.Date;
public class MediicinecabinetInventory extends UuidIdentityEntityWithOperator implements Serializable {
    /**
     * 设备id
     */
@ -41,9 +39,19 @@ public class MediicinecabinetInventory extends UuidIdentityEntityWithOperator im
    private Date longtime;
    /**
     * 药品编号
     * 药品id
     */
    private String drugId;
    /**
     * 药品sku
     */
    private String barcode;
    private String drugSku;
    /**
     * 药品编码
     */
    private String drugCode;
    /**
     * 层
@ -60,9 +68,14 @@ public class MediicinecabinetInventory extends UuidIdentityEntityWithOperator im
     */
    private String qty;
    /**
     * 药品机构编码
     */
    private String orgCode;
    public MediicinecabinetInventory() {
    }
    
    public String getIdDevice() {
        return idDevice;
@ -103,4 +116,60 @@ public class MediicinecabinetInventory extends UuidIdentityEntityWithOperator im
    public void setLongtime(Date longtime) {
        this.longtime = longtime;
    }
    public String getDrugId() {
        return drugId;
    }
    public void setDrugId(String drugId) {
        this.drugId = drugId;
    }
    public String getDrugSku() {
        return drugSku;
    }
    public void setDrugSku(String drugSku) {
        this.drugSku = drugSku;
    }
    public String getDrugCode() {
        return drugCode;
    }
    public void setDrugCode(String drugCode) {
        this.drugCode = drugCode;
    }
    public String getLayerNo() {
        return layerNo;
    }
    public void setLayerNo(String layerNo) {
        this.layerNo = layerNo;
    }
    public String getWayerNo() {
        return wayerNo;
    }
    public void setWayerNo(String wayerNo) {
        this.wayerNo = wayerNo;
    }
    public String getQty() {
        return qty;
    }
    public void setQty(String qty) {
        this.qty = qty;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
}

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

@ -160,7 +160,9 @@ public class Mediicinedevice extends UuidIdentityEntityWithOperator implements S
     */
    private String cargoCapacity;
    //层数
    /**
     * 层数
     */
    private String layer;
    /**
@ -171,20 +173,12 @@ public class Mediicinedevice extends UuidIdentityEntityWithOperator implements S
    public Mediicinedevice() {
    }
    public String getLayer() {
        return layer;
    }
    public void setLayer(String layer) {
        this.layer = layer;
    }
    public String getWayer() {
        return wayer;
    public String getBelongCommunity() {
        return belongCommunity;
    }
    public void setWayer(String wayer) {
        this.wayer = wayer;
    public void setBelongCommunity(String belongCommunity) {
        this.belongCommunity = belongCommunity;
    }
    public String getEquClass() {
@ -195,14 +189,6 @@ public class Mediicinedevice extends UuidIdentityEntityWithOperator implements S
        this.equClass = equClass;
    }
    public String getBelongCommunity() {
        return belongCommunity;
    }
    public void setBelongCommunity(String belongCommunity) {
        this.belongCommunity = belongCommunity;
    }
    public String getNetworkStatus() {
        return networkStatus;
    }
@ -266,12 +252,11 @@ public class Mediicinedevice extends UuidIdentityEntityWithOperator implements S
    public void setEquInfo(String equInfo) {
        this.equInfo = equInfo;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getRegDate() {
        return regDate;
    }
    public void setRegDate(Date regDate) {
        this.regDate = regDate;
    }
@ -419,4 +404,20 @@ public class Mediicinedevice extends UuidIdentityEntityWithOperator implements S
    public void setCargoCapacity(String cargoCapacity) {
        this.cargoCapacity = cargoCapacity;
    }
    public String getLayer() {
        return layer;
    }
    public void setLayer(String layer) {
        this.layer = layer;
    }
    public String getWayer() {
        return wayer;
    }
    public void setWayer(String wayer) {
        this.wayer = wayer;
    }
}

+ 159 - 5
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicineorder.java

@ -1,7 +1,6 @@
package com.yihu.jw.entity.a1entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
@ -11,11 +10,10 @@ import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name="t_mediicine_order")
@Table(name = "t_mediicine_order")
public class Mediicineorder extends UuidIdentityEntityWithOperator implements Serializable {
    /**
     * 订单号
     */
@ -161,6 +159,59 @@ public class Mediicineorder extends UuidIdentityEntityWithOperator implements Se
    private String cargoInfo;
    /**
     *订单属性
     */
    private String attr;
    /**
     *商户ID
     */
    private String userId;
    /**
     *门店编号
     */
    private String shopNo;
    /**
     *医院信息
     */
    private String hospitalInfo;
    /**
     *出生日期
     */
    private String birth;
    /**
     *科室信息
     */
    private String deptNum;
    /**
     *科室名称
     */
    private String deptName;
    /**
     *医生信息
     */
    private String doctorNum;
    /**
     *医生姓名
     */
    private String doctorName;
    /**
     *医嘱
     */
    private String doctorAdvice;
    /**
     *过敏史
     */
    private String allergyInfo;
    /**
     *诊断信息
     */
    private String info;
    /**
     *社保卡号
     */
    private String socialSecurityCardNum;
    public Mediicineorder() {
    }
@ -196,7 +247,7 @@ public class Mediicineorder extends UuidIdentityEntityWithOperator implements Se
    public void setDispensingWindow(String dispensingWindow) {
        this.dispensingWindow = dispensingWindow;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPrescribeTime() {
        return prescribeTime;
    }
@ -237,7 +288,6 @@ public class Mediicineorder extends UuidIdentityEntityWithOperator implements Se
        this.goodsTotalAmount = goodsTotalAmount;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPayTime() {
        return payTime;
    }
@ -389,4 +439,108 @@ public class Mediicineorder extends UuidIdentityEntityWithOperator implements Se
    public void setCargoInfo(String cargoInfo) {
        this.cargoInfo = cargoInfo;
    }
    public String getAttr() {
        return attr;
    }
    public void setAttr(String attr) {
        this.attr = attr;
    }
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    public String getShopNo() {
        return shopNo;
    }
    public void setShopNo(String shopNo) {
        this.shopNo = shopNo;
    }
    public String getHospitalInfo() {
        return hospitalInfo;
    }
    public void setHospitalInfo(String hospitalInfo) {
        this.hospitalInfo = hospitalInfo;
    }
    public String getBirth() {
        return birth;
    }
    public void setBirth(String birth) {
        this.birth = birth;
    }
    public String getDeptNum() {
        return deptNum;
    }
    public void setDeptNum(String deptNum) {
        this.deptNum = deptNum;
    }
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getDoctorNum() {
        return doctorNum;
    }
    public void setDoctorNum(String doctorNum) {
        this.doctorNum = doctorNum;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getDoctorAdvice() {
        return doctorAdvice;
    }
    public void setDoctorAdvice(String doctorAdvice) {
        this.doctorAdvice = doctorAdvice;
    }
    public String getAllergyInfo() {
        return allergyInfo;
    }
    public void setAllergyInfo(String allergyInfo) {
        this.allergyInfo = allergyInfo;
    }
    public String getInfo() {
        return info;
    }
    public void setInfo(String info) {
        this.info = info;
    }
    public String getSocialSecurityCardNum() {
        return socialSecurityCardNum;
    }
    public void setSocialSecurityCardNum(String socialSecurityCardNum) {
        this.socialSecurityCardNum = socialSecurityCardNum;
    }
}

+ 145 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicineorderdetail.java

@ -8,7 +8,7 @@ import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name="t_mediicine_order_detail")
@Table(name = "t_mediicine_order_detail")
public class Mediicineorderdetail extends UuidIdentityEntityWithOperator implements Serializable {
@ -190,12 +190,58 @@ public class Mediicineorderdetail extends UuidIdentityEntityWithOperator impleme
     */
    private Date shippingTime;
    /**
     * 药品sku
     */
    private String drugSku;
    /**
     *药品购买数量
     */
    private String drugNum;
    /**
     *药品规格
     */
    private String specif;
    /**
     *药品使用数量
     */
    private String useNum;
    /**
     *药品使用方法
     */
    private String useWay;
    /**
     *药品使用频率
     */
    private String useRate;
    /**
     *药品每次服用量
     */
    private String useDose;
    /**
     *每次服用单位
     */
    private String unit;
    /**
     *补充用法
     */
    private String useWayAdd;
    /**
     *厂商
     */
    private String manufactor;
    /**
     *社保卡号
     */
    private String socialSecurityCardNum;
    /**
     *药品机构
     */
    private String orgCode;
    public Mediicineorderdetail() {
    }
    public String getIdOrder() {
        return idOrder;
    }
@ -475,4 +521,100 @@ public class Mediicineorderdetail extends UuidIdentityEntityWithOperator impleme
    public void setShippingTime(Date shippingTime) {
        this.shippingTime = shippingTime;
    }
    public String getDrugSku() {
        return drugSku;
    }
    public void setDrugSku(String drugSku) {
        this.drugSku = drugSku;
    }
    public String getDrugNum() {
        return drugNum;
    }
    public void setDrugNum(String drugNum) {
        this.drugNum = drugNum;
    }
    public String getSpecif() {
        return specif;
    }
    public void setSpecif(String specif) {
        this.specif = specif;
    }
    public String getUseNum() {
        return useNum;
    }
    public void setUseNum(String useNum) {
        this.useNum = useNum;
    }
    public String getUseWay() {
        return useWay;
    }
    public void setUseWay(String useWay) {
        this.useWay = useWay;
    }
    public String getUseRate() {
        return useRate;
    }
    public void setUseRate(String useRate) {
        this.useRate = useRate;
    }
    public String getUseDose() {
        return useDose;
    }
    public void setUseDose(String useDose) {
        this.useDose = useDose;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public String getUseWayAdd() {
        return useWayAdd;
    }
    public void setUseWayAdd(String useWayAdd) {
        this.useWayAdd = useWayAdd;
    }
    public String getManufactor() {
        return manufactor;
    }
    public void setManufactor(String manufactor) {
        this.manufactor = manufactor;
    }
    public String getSocialSecurityCardNum() {
        return socialSecurityCardNum;
    }
    public void setSocialSecurityCardNum(String socialSecurityCardNum) {
        this.socialSecurityCardNum = socialSecurityCardNum;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
}

+ 8 - 8
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestockoutdetail.java

@ -88,14 +88,6 @@ public class Mediicinestockoutdetail extends UuidIdentityEntityWithOperator impl
    public Mediicinestockoutdetail() {
    }
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
    public String getIdStockOut() {
        return idStockOut;
    }
@ -199,4 +191,12 @@ public class Mediicinestockoutdetail extends UuidIdentityEntityWithOperator impl
    public void setIdOrderDetail(String idOrderDetail) {
        IdOrderDetail = idOrderDetail;
    }
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
}

+ 7 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinestockrecorddetail.java

@ -8,7 +8,7 @@ import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name="t_mediicine_stockup_detail")
@Table(name="t_mediicine_stockrecord_detail")
public class Mediicinestockrecorddetail extends UuidIdentityEntityWithOperator implements Serializable {
@ -67,14 +67,19 @@ public class Mediicinestockrecorddetail extends UuidIdentityEntityWithOperator i
     */
    private String productPic;
    /**
     * 层
     */
    private String layerNo;
    /**
     * 列
     */
    private String wayerNo;
    public Mediicinestockrecorddetail() {
    }
    public String getIdstockup() {
        return idstockup;
    }

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

@ -70,7 +70,6 @@ public class Mediicinestockup extends UuidIdentityEntityWithOperator implements
    public Mediicinestockup() {
    }
    public String getCommunity() {
        return community;
    }

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

@ -91,7 +91,6 @@ public class Mediicinestockupdetail extends UuidIdentityEntityWithOperator imple
    public Mediicinestockupdetail() {
    }
    public String getIdstockup() {
        return idstockup;
    }

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

@ -42,7 +42,6 @@ public class Mediicinestore extends UuidIdentityEntityWithOperator implements Se
    public Mediicinestore() {
    }
    
    public String getIdDevice() {
        return idDevice;

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

@ -74,7 +74,6 @@ public class Mediicineuser extends UuidIdentityEntityWithOperator implements Ser
    public Mediicineuser() {
    }
    public String getName() {
        return name;
    }

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

@ -162,7 +162,6 @@ public class Mediicinewarray extends UuidIdentityEntityWithOperator implements S
    public Mediicinewarray() {
    }
    
    public String getType() {
        return type;

+ 11 - 8
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/OutDO.java

@ -35,6 +35,17 @@ public class OutDO implements Serializable {
     */
    private List<DrugDO> drugs;
    public OutDO() {
    }
    public String getUpId() {
        return upId;
    }
    public void setUpId(String upId) {
        this.upId = upId;
    }
    public String getRemark() {
        return remark;
    }
@ -66,12 +77,4 @@ public class OutDO implements Serializable {
    public void setDrugs(List<DrugDO> drugs) {
        this.drugs = drugs;
    }
    public String getUpId() {
        return upId;
    }
    public void setUpId(String upId) {
        this.upId = upId;
    }
}

+ 5 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/UpDO.java

@ -9,16 +9,19 @@ public class UpDO implements Serializable {
    /**
     * 状态
     * 设备id
     */
    private String deviceId;
    /**
     * 名称
     * 药品列表,id and qty
     */
    private List<DrugDO> drugs;
    public UpDO() {
    }
    public String getDeviceId() {
        return deviceId;
    }

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

@ -142,6 +142,9 @@ public class BaseRequestMapping {
        public static final String CREATE  = "/create";
        public static final String getOrderDetailListById  = "/getOrderDetailListById";
        public static final String getOrderDetailById  = "/getOrderDetailById";
        public static final String checkOrder  = "/checkOrder";
        public static final String getOrderOutList  = "/getOrderOutList";
        public static final String updateOrderOutStatus  = "/updateOrderOutStatus";
        public static final String sumamount  = "/sumamount";
        public static final String getcount  = "/getcount";
        public static final String getsumquantity  = "/getsumquantity";

+ 11 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MedicineShipmentLogDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.base.dao.a2dao;
import com.yihu.jw.entity.a1entity.MedicineShipmentLog;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface MedicineShipmentLogDao extends PagingAndSortingRepository<MedicineShipmentLog, String> {
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineDeviceDao.java

@ -9,11 +9,11 @@ public interface MediicineDeviceDao extends PagingAndSortingRepository<Mediicine
    //所有设备
    @Query("select count(1) from Mediicinedevice a ")
    @Query("select count(1) from Mediicinedevice a where a.del = 1 ")
    long countAll();
    //在线设备 离线设备 直接减
    @Query("select count(1) from Mediicinedevice a where a.status = 1 ")
    @Query("select count(1) from Mediicinedevice a where a.del = 1 and a.status = 1 ")
    long countOnline();
}

+ 11 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicinecabinetInventoryDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.base.dao.a2dao;
import com.yihu.jw.entity.a1entity.MediicinecabinetInventory;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface MediicinecabinetInventoryDao extends PagingAndSortingRepository<MediicinecabinetInventory, String> {
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicinedrugsDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.base.dao.a2dao;
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -13,4 +14,7 @@ public interface MediicinedrugsDao extends PagingAndSortingRepository<Mediicined
    @Query("select a from Mediicinedrugs a  ")
    List<Mediicinedrugs> getorderdetail();
    Mediicinedrugs findByDrugCodeAndOrgCode(String drugCode, String orgCode);
}

+ 5 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineorderDao.java

@ -19,5 +19,10 @@ public interface MediicineorderDao extends PagingAndSortingRepository<Mediicineo
    //统计时间段的天的订单数量
    @Query("select count(1) from Mediicineorder a where a.prescribeTime >= ?1 and a.prescribeTime<=?2")
    int getcount(Date beg , Date end);
    Mediicineorder findMediicineorderByPickUpNum(String pickUpNum);
    Mediicineorder findMediicineorderBySocialSecurityCardNum(String cardNum);
}

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineorderdetailDao.java

@ -19,4 +19,7 @@ public interface MediicineorderdetailDao extends PagingAndSortingRepository<Medi
    //返回订单明细
    @Query("select a from Mediicineorderdetail a where a.idOrder =  ?1 ")
    List<Mediicineorderdetail> getorderdetail(String idOrder);
    List<Mediicineorderdetail> findMediicineorderdetailsByIdOrder(String orderId);
}

+ 46 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOrderEndpoint.java

@ -6,8 +6,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.service.a3service.MedicineOrderService;
import com.yihu.jw.base.service.a3service.MedicinedeviceService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.a1entity.MedicineShipmentLog;
import com.yihu.jw.entity.a1entity.Mediicineorderdetail;
import com.yihu.jw.entity.a1entity.Mediicinestockoutdetail;
import com.yihu.jw.entity.a1entity.Mediicinestockrecorddetail;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
import com.yihu.jw.restmodel.web.Envelop;
@ -207,6 +209,50 @@ public class MedicineOrderEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseRequestMapping.BaseOrder.checkOrder)
    @ApiOperation(value = "检查订单" , notes="检查订单")
    public Envelop checkOrder(
            @ApiParam(name = "deviceId", value = "设备id", required = true)
            @RequestParam(value = "deviceId", required = true) String deviceId,
            @ApiParam(name = "pickUpNum", value = "取药码")
            @RequestParam(value = "pickUpNum", required = false) String pickUpNum,
            @ApiParam(name = "cardNum", value = "社保卡号")
            @RequestParam(value = "cardNum", required = false) String cardNum
    ) {
        JSONObject jsonObject =  orderservice.checkOrder(deviceId, pickUpNum, cardNum);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getJSONObject("msg"));
    }
    @GetMapping(value = BaseRequestMapping.BaseOrder.getOrderOutList)
    @ApiOperation(value = "通过orderId查询订单出货单" , notes="通过orderId查询订单出货单")
    public Envelop getOrderOutList(
            @ApiParam(name = "orderId", value = "订单id", required = true)
            @RequestParam(value = "orderId", required = true) String orderId
    ) throws Exception {
        JSONObject jsonObject =  orderservice.getOrderOutList(orderId);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        List<MedicineShipmentLog> list = JSONObject.parseArray(jsonObject.getJSONArray("msg").toJSONString(), MedicineShipmentLog.class);
        return success(list, MedicineShipmentLog.class);
    }
    @PostMapping(value = BaseRequestMapping.BaseOrder.updateOrderOutStatus)
    @ApiOperation(value = "更新订单出货单状态" , notes="更新订单出货单状态")
    public Envelop updateOrderOut(
            @ApiParam(name = "shipmentLogId", value = "订单id", required = true)
            @RequestParam(value = "shipmentLogId", required = true) String shipmentLogId,
            @ApiParam(name = "status", value = "目标状态", required = true)
            @RequestParam(value = "status", required = true) String status
    ) throws Exception {
        JSONObject jsonObject =  orderservice.updateOrderOutStatus(shipmentLogId, status);
        return success(jsonObject.getString("msg"));
    }

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

@ -263,8 +263,22 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        for (Map<String,Object> map:list){
        for (Map<String,Object> stringObjectMap:list){
            if (!StringUtils.isEmpty(stringObjectMap.get("state").toString())) {
                if ("1".equals(stringObjectMap.get("state").toString())) {
                    stringObjectMap.put("stateName", "已上架");
                }
                if ("2".equals(stringObjectMap.get("state").toString())) {
                    stringObjectMap.put("stateName", "已下架");
                }
                if ("3".equals(stringObjectMap.get("state").toString())) {
                    stringObjectMap.put("stateName", "处方");
                }
                if ("4".equals(stringObjectMap.get("state").toString())) {
                    stringObjectMap.put("stateName", "非处方");
                }
            }
        }
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

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

@ -10,6 +10,7 @@ import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.a1entity.*;
import com.yihu.jw.entity.patient.Message;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.elasticsearch.common.recycler.Recycler;
@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -39,9 +41,19 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
    @Autowired
    private MediicinestockoutdetailDao stockoutdetailDao;
    @Autowired
    private MedicineShipmentLogDao shipmentLogDao;
    @Autowired
    private MediicinecabinetInventoryDao inventoryDao;
    @Autowired
    private MediicineDeviceDao deviceDao;
    @Autowired
    private MediicinedrugsDao drugsDao;
    @Autowired
    private ObjectMapper objectMapper;
@ -186,7 +198,20 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                "    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" +
                "    t.update_user_name as updateUserName,\n" +
                "    t.attr AS attr,\n" +
                "    t.userId AS userId,\n" +
                "    t.shopNo AS shopNo,\n" +
                "    t.hospitalInfo AS hospitalInfo,\n" +
                "    t.birth AS birth,\n" +
                "    t.deptNum AS deptNum,\n" +
                "    t.deptName AS deptName,\n" +
                "    t.doctorNum AS doctorNum,\n" +
                "    t.doctorName AS doctorName,\n" +
                "    t.doctorAdvice AS doctorAdvice,\n" +
                "    t.allergyInfo AS allergyInfo,\n" +
                "    t.info AS info,\n" +
                "    t.socialSecurityCardNum AS socialSecurityCardNum\n" +
                "FROM\n" +
                "    t_mediicine_order AS t where 1=1";
@ -230,8 +255,15 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        for (Map<String,Object> map:list){
        for (Map<String, Object> stringObjectMap : list) {
            if (!StringUtils.isEmpty(stringObjectMap.get("sellState").toString())) {
                if ("0".equals(stringObjectMap.get("sellState").toString())) {
                    stringObjectMap.put("sellStateName", "未取药");
                }
                if ("1".equals(stringObjectMap.get("sellState").toString())) {
                    stringObjectMap.put("sellStateName", "已取药");
                }
            }
        }
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
@ -345,18 +377,44 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
    /**
     * 检查设备订单是否有药品
     * 检查设备订单是否有药品和,生成出库单
     * @param deviceId
     * @param orderId
     * @param pickUpNum
     * @param cardNum
     * @return
     */
    public JSONObject checkOrder(String deviceId, String orderId) {
    @Transactional(rollbackFor = Exception.class)
    public JSONObject checkOrder(String deviceId, String pickUpNum, String cardNum) {
        JSONObject result = new JSONObject();
        if (deviceId == null || orderId == null || StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(orderId)) {
            result.put("msg","parameter deviceId and orderId is null or empty");
        if (deviceId == null || StringUtils.isEmpty(deviceId)) {
            result.put("msg","parameter deviceId is null or empty");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        if (pickUpNum == null && cardNum == null) {
            result.put("msg","parameter packUpNum or cardNum is null");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        if (StringUtils.isEmpty(pickUpNum) && StringUtils.isEmpty(cardNum)) {
            result.put("msg","parameter pickUpNum or cardNum is empty");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        Mediicineorder  mediicineorder = null;
        if (!StringUtils.isEmpty(pickUpNum)) {
            mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
        }
        if (!StringUtils.isEmpty(cardNum)) {
            mediicineorder = orderDao.findMediicineorderBySocialSecurityCardNum(cardNum);
        }
        if (mediicineorder == null) {
            result.put("msg","order doesn't exist");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        //订单详细内容--备用方案
//        List<Mediicineorderdetail> list = orderdetailDao.findMediicineorderdetailsByIdOrder(mediicineorder.getId());
        String sql = "SELECT\n" +
                "    t.id AS id,\n" +
                "    t.batch_num AS batchNum,\n" +
@ -409,23 +467,175 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                "    t.use_dose AS useDose,\n" +
                "    t.unit AS unit,\n" +
                "    t.use_way_add AS useWayAdd,\n" +
                "    t.manufactor AS manufactor\n" +
                "    t.manufactor AS manufactor,\n" +
                "    t.social_security_card_num AS socialSecurityCardNum,\n" +
                "    t.org_code AS orgCode\n" +
                "FROM\n" +
                "    t_mediicine_order_detail AS t\n" +
                "WHERE t.id_order = '" + orderId + "'";
                "    t_mediicine_order_detail AS t\n";
        if (!StringUtils.isEmpty(pickUpNum)) {
             sql += "WHERE t.pick_up_num = '" + pickUpNum + "'";
        }
        if (!StringUtils.isEmpty(cardNum)) {
            if (!StringUtils.isEmpty(pickUpNum)) {
                sql += "AND t.social_security_card_num = '" + cardNum + "'";
            } else {
                sql += "WHERE t.social_security_card_num = '" + cardNum + "'";
            }
        }
        List<Map<String,Object>> list = null;
        //订单详细内容
        list = hibenateUtils.createSQLQuery(sql);
        //没有订单信息
        for (Map<String, Object> stringObjectMap : list) {
            String secondSql = "SELECT\n" +
                    "\tifnull(\n" +
                    "\t\t(\n" +
                    "\t\t\tSELECT\n" +
                    "\t\t\t\tcount(DISTINCT(t.id))\n" +
                    "\t\t\tFROM\n" +
                    "\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + stringObjectMap.get("drugCode") + "'\n" +
                    "\t\t\tAND t.org_code = '" + stringObjectMap.get("orgCode") + "'\n" +
                    "\t\t\tAND t.id_device = '"+ deviceId + "'\n" +
                    "\t\t\tGROUP BY\n" +
                    "\t\t\t\tt.drug_code,\n" +
                    "\t\t\t\tt.org_code\n" +
                    "\t\t\tHAVING\n" +
                    "\t\t\t\tsum(t.qty) >= " + Integer.parseInt(String.valueOf(stringObjectMap.get("quantity"))) + "\n" +
                    "\t\t),\n" +
                    "\t\t0\n" +
                    "\t)";
            int count = jdbcTemplate.queryForObject(secondSql,Integer.class);
            if (count == 0) {
                result.put("response", ConstantUtils.FAIL);
                return result;
            }
        }
        JSONObject jsonObject = new JSONObject();
        //生成出货单
        int count = jdbcTemplate.queryForObject(
                "SELECT\n" +
                        "\tcount(DISTINCT(id))\n" +
                        "FROM\n" +
                        "\tt_medicine_shipment_log\n" +
                        "WHERE\n" +
                        "\torder_id = '" + list.get(0).get("idOrder") + "'",Integer.class);
        if (count > 0) {
            jsonObject.put("orderId", mediicineorder.getId());
            result.put("response", ConstantUtils.SUCCESS);
            result.put("msg", jsonObject);
            return result;
        }
        //订单详情遍历
        for (Map<String, Object> stringObjectMap : list) {
            Mediicinedrugs mediicinedrugs = drugsDao.findByDrugCodeAndOrgCode(stringObjectMap.get("drugCode").toString(), stringObjectMap.get("orgCode").toString());
            //订单药品数目
            Integer qty = Integer.parseInt(String.valueOf(stringObjectMap.get("quantity")));
            //库存集合
            List<Map<String, Object>> tempList = hibenateUtils.createSQLQuery(
                    "SELECT\n" +
                            "    t.id,\n" +
                            "    t.layer_no AS layerNo,\n" +
                            "    t.wayer_no AS wayerNo,\n" +
                            "    t.qty\n" +
                            "FROM\n" +
                            "\tt_mediicinecabinet_inventory t\n" +
                            "WHERE\n" +
                            "\tt.drug_code = '"+ stringObjectMap.get("drugCode") +"'\n" +
                            "AND t.org_code = '" + stringObjectMap.get("orgCode") +"'\n" +
                            "AND t.id_device = '" + deviceId + "'\n" +
                            "and t.qty > 0"
            );
            for (int i = 0; i < qty; i++) {
                for (Map<String, Object> objectMap : tempList) {
                    if (Integer.parseInt(String.valueOf(objectMap.get("qty"))) >0) {
                        objectMap.put("qty",Integer.parseInt(String.valueOf(objectMap.get("qty"))) - 1 );
                        MedicineShipmentLog shipmentLog = new MedicineShipmentLog();
                        shipmentLog.setDeviceId(deviceId);
                        shipmentLog.setOrderId(stringObjectMap.get("idOrder").toString());
                        shipmentLog.setDrugId(mediicinedrugs.getId());
                        shipmentLog.setStatus("1");
                        shipmentLog.setLayerNo(objectMap.get("layerNo").toString());
                        shipmentLog.setWayerNo(objectMap.get("wayerNo").toString());
                        shipmentLogDao.save(shipmentLog);
                    }
                }
            }
            //只生成出货单,不扣减药柜库存
//            for (Map<String, Object> objectMap : tempList) {
//                MediicinecabinetInventory inventory = inventoryDao.findOne(objectMap.get("id").toString());
//                inventory.setQty(String.valueOf(objectMap.get("qty")));
//                inventoryDao.save(inventory);
//            }
        }
        jsonObject.put("orderId", mediicineorder.getId());
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
        return result;
    }
        for (Map<String, Object> stringObjectMap : list) {
            String secondSql = "SELECT * FROM t_mediicinecabinet_inventory where barcode = '" + stringObjectMap.get("drugId") + "' AND id_device  = '" + deviceId + "'";
    public JSONObject getOrderOutList(String orderId) throws Exception {
        JSONObject result = new JSONObject();
        if (orderId == null || StringUtils.isEmpty(orderId)) {
            result.put("response", ConstantUtils.FAIL);
            result.put("msg", "orderId is null or empty");
            return result;
        }
        String sql = "SELECT\n" +
                "            t.id,\n" +
                "            t.device_id,\n" +
                "            t.order_id,\n" +
                "            t.drug_id,\n" +
                "            t.`status`,\n" +
                "            t.out_time,\n" +
                "            t.layer_no,\n" +
                "            t.wayer_no,\n" +
                "            t.description,\n" +
                "            t.create_time,\n" +
                "            t.create_user,\n" +
                "            t.create_user_name,\n" +
                "            t.update_time,\n" +
                "            t.update_user,\n" +
                "            t.update_user_name\n" +
                "        FROM\n" +
                "            t_medicine_shipment_log AS t \n" +
                "        WHERE \n" +
                "            t.order_id = '" + orderId + "'";
        List<Map<String,Object >> list = null;
        list = hibenateUtils.createSQLQuery(sql);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        result.put("response", ConstantUtils.SUCCESS);
        return  result;
    }
        Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
    public JSONObject updateOrderOutStatus(String shipmentLogId, String status) {
        JSONObject result = new JSONObject();
        if (shipmentLogId == null || StringUtils.isEmpty(shipmentLogId)) {
            result.put("msg", "shipmentLogId is null or empty");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        if (status == null || StringUtils.isEmpty(status)) {
            result.put("msg", "status is null or empty");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        MedicineShipmentLog medicineShipmentLog = shipmentLogDao.findOne(shipmentLogId);
        if (medicineShipmentLog == null) {
            result.put("msg", "medicineShipmentLog doesn't exist");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        medicineShipmentLog.setStatus(status);
        shipmentLogDao.save(medicineShipmentLog);
        result.put("msg", ConstantUtils.SUCCESS);
        result.put("response", ConstantUtils.SUCCESS);
        return result;
    }
}

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

@ -262,7 +262,8 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
                "    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" +
                "    t.update_user_name as updateUserName,\n" +
                "    t.up_num as upNum\n" +
                "FROM\n" +
                "    t_mediicine_stockout AS t where 1=1";
        String conditionSql = "";

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

@ -302,7 +302,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
                "    tmd.equ_num as equNum,\n" +
                "    tmu.name as replenishErName\n" +
                "FROM\n" +
                "    t_mediicine_stockrecord AS t left join t_mediicine_device tmd on replenish_equ = tmd.id left join t_mediicine_user tmu on t.replenish_er = tmu.id  where 1=1 and tmd.del = 1";
                "    t_mediicine_stockrecord AS t left join t_mediicine_device tmd on replenish_equ = tmd.id left join base_user tmu on t.replenish_er = tmu.id  where 1=1 and tmd.del = 1";
        String conditionSql = "";
        //社区
@ -319,7 +319,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
            conditionSql += " and tmd.equ_num like '%" + equCode + "%'";
        }
        if (!StringUtils.isEmpty(replenishEr)){
            conditionSql += " and CONCAT(tmu.name,tmu.account) like '%" + replenishEr + "%'";
            conditionSql += " and CONCAT(tmu.name,tmu.mobile) like '%" + replenishEr + "%'";
        }
@ -331,7 +331,7 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "   from " +
                "     t_mediicine_stockrecord t left join t_mediicine_device tmd on replenish_equ = tmd.id left join t_mediicine_user tmu on t.replenish_er = tmu.id  " +
                "     t_mediicine_stockrecord t left join t_mediicine_device tmd on replenish_equ = tmd.id left join base_user tmu on t.replenish_er = tmu.id  " +
                "  where " +
                "  1=1  and tmd.del = 1  " +
                conditionSql;
@ -368,7 +368,9 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
                "    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" +
                "    t.update_user_name AS updateUserName,\n" +
                "    t.layer_no AS layerNo,\n" +
                "    t.wayer_no AS wayerNo\n" +
                "FROM\n" +
                "    t_mediicine_stockrecord_detail AS t where idstockup = '" + idstockup + "'";
        List<Map<String,Object>> list=null;

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

@ -46,138 +46,6 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
    private HibenateUtils hibenateUtils;
//    /**
//     * 新增设备
//     * @param jsonData
//     * @return
//     */
//    @Transactional(rollbackFor = Exception.class)
//    public String createDevice(String jsonData) {
//
//        JSONObject result = new JSONObject();
//        if(StringUtils.isEmpty(jsonData)){
//            result.put("msg","jsonData is null");
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        JSONObject device = JSONObject.parseObject(jsonData);
//        if(null == device){
//            result.put("msg","parameter device of jsonData is null");
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        //判断设备id是否存在
////        if(StringUtils.isEmpty(device.getString("id"))){
////            result.put("msg","parameter id for device is null when update device");
////            result.put("response", ConstantUtils.FAIL);
////            return result.toJSONString();
////        }
//        Mediicinedevice mediicinedevice = null;
//        try {
//            mediicinedevice = objectMapper.readValue(device.toJSONString(), Mediicinedevice.class);
//        } catch (IOException e) {
//            result.put("msg", "convert device jsonObject to BaseDoctorDO failed," + e.getCause());
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        } catch (Exception e) {
//            result.put("msg", "convert device birth failed," + e.getCause());
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        this.save(mediicinedevice);
//        result.put("response",ConstantUtils.SUCCESS);
//        result.put("msg",mediicinedevice);
//        return result.toJSONString();
//    }
//    /**
//     * 修改设备
//     * @param jsonData
//     * @return
//     */
//    @Transactional(rollbackFor = Exception.class)
//    public String updateDevice(String jsonData){
//        JSONObject result = new JSONObject();
//        if(StringUtils.isEmpty(jsonData)){
//            result.put("msg","jsonData is null");
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        JSONObject device = JSONObject.parseObject(jsonData);
//        if(null == device){
//            result.put("msg","parameter device of jsonData is null");
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        String orgCode="";
//        //判断设备id是否存在
//        if(StringUtils.isEmpty(device.getString("id"))){
//            result.put("msg","parameter id for device is null when update device");
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        Mediicinedevice mediicinedevice = null;
//        try {
//            mediicinedevice = objectMapper.readValue(device.toJSONString(), Mediicinedevice.class);
//        } catch (IOException e) {
//            result.put("msg", "convert device jsonObject to BaseDoctorDO failed," + e.getCause());
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        } catch (Exception e) {
//            result.put("msg", "convert device birth failed," + e.getCause());
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
//        }
//        this.save(mediicinedevice);
//        result.put("response",ConstantUtils.SUCCESS);
//        result.put("msg",mediicinedevice);
//        return result.toJSONString();
//    }
//    @Transactional(rollbackFor = Exception.class)
//    public String updateDeviceCommunity(String deviceId, String communityId, String community){
//        JSONObject result = new JSONObject();
//        if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(communityId)){
//            result.put("msg","deviceId and communityId 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.setBelongCommunity(communityId);
//        mediicinedevice.setCommunity(community);
//        this.save(mediicinedevice);
//        result.put("response",ConstantUtils.SUCCESS);
//        result.put("msg",mediicinedevice);
//        return result.toJSONString();
//    }
//    @Transactional(rollbackFor = Exception.class)
//    public String updateDeviceAddress(String deviceId, String address){
//        JSONObject result = new JSONObject();
//        if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(address)){
//            result.put("msg","deviceId and address 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.setDeliveryAddress(address);
//        this.save(mediicinedevice);
//        result.put("response",ConstantUtils.SUCCESS);
//        result.put("msg",mediicinedevice);
//        return result.toJSONString();
//    }
    /**
     * 分页查询补货员信息
     * @param content
@ -190,31 +58,72 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
    public JSONObject queryUserListFullInfo(String content,int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        String sql = "SELECT\n" +
                "    t.id AS id,\n" +
                "    t.account AS account,\n" +
                "    t.belong_community AS belongCommunity,\n" +
                "    t.bir_date AS birDate,\n" +
                "    t.confirm_password AS confirmPassword,\n" +
                "    t.contact_info AS contactInfo,\n" +
                "    t.`name` AS `name`,\n" +
                "    t.`password` AS `password`,\n" +
                "    t.res_med_cabinet AS resMedCabinet,\n" +
                "    t.res_pon_area AS resPonArea,\n" +
                "    t.role AS role,\n" +
                "    t.sex AS sex,\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" +
                "\tb.id AS id,\n" +
                "\tb.create_time AS createTime,\n" +
                "\tb.create_user AS createUser,\n" +
                "\tb.create_user_name AS createUserName,\n" +
                "\tb.update_time AS updateTime,\n" +
                "\tb.update_user AS updateUser,\n" +
                "\tb.update_user_name AS updateUserName,\n" +
                "\tb.username AS username,\n" +
                "\tb.`password` AS `password`,\n" +
                "\tb.salt AS salt,\n" +
                "\tb.`name` AS `name`,\n" +
                "\tb.gender AS gender,\n" +
                "\tb.idcard AS idcard,\n" +
                "\tb.mobile AS mobile,\n" +
                "\tb.ak AS ak,\n" +
                "\tb.email AS email,\n" +
                "\tb.enabled AS enabled,\n" +
                "\tb.locked AS locked,\n" +
                "\tb.locked_date AS lockedDate,\n" +
                "\tb.login_date AS loginDate,\n" +
                "\tb.saas_id AS saasId,\n" +
                "\tb.login_failure_count AS loginFailureCount,\n" +
                "\tb.last_login_failure_time AS lastLoginFailureTime,\n" +
                "\tb.role_id AS roleId\n" +
                "FROM\n" +
                "    t_mediicine_user AS t\n" +
                "\tbase_user b\n" +
                "WHERE\n" +
                "    1=1\n";
                "\tb.role_id IN (\n" +
                "\t\tSELECT\n" +
                "\t\t\tid\n" +
                "\t\tFROM\n" +
                "\t\t\tbase_role\n" +
                "\t\tWHERE\n" +
                "\t\t\tcode = 'replenisher'\n" +
                "\t\t\tAND status = 1\n" +
                "\t)\n" +
                "\tAND b.enabled = 1\n" +
                "\tAND b.locked = 0\n";
//        String sql = "SELECT\n" +
//                "    t.id AS id,\n" +
//                "    t.account AS account,\n" +
//                "    t.belong_community AS belongCommunity,\n" +
//                "    t.bir_date AS birDate,\n" +
//                "    t.confirm_password AS confirmPassword,\n" +
//                "    t.contact_info AS contactInfo,\n" +
//                "    t.`name` AS `name`,\n" +
//                "    t.`password` AS `password`,\n" +
//                "    t.res_med_cabinet AS resMedCabinet,\n" +
//                "    t.res_pon_area AS resPonArea,\n" +
//                "    t.role AS role,\n" +
//                "    t.sex AS sex,\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_user AS t\n" +
//                "WHERE\n" +
//                "    1=1\n";
        String conditionSql = "";
        if (!StringUtils.isEmpty(content)){
            conditionSql += " AND CONCAT(t.account, t.`name`) like '%"+ content +"%'";
//            conditionSql += " AND CONCAT(t.account, t.`name`) like '%"+ content +"%'";
            conditionSql += "\tAND CONCAT(b.mobile,b.name) like '%"+ content +"%'";
        }
        sql = sql + conditionSql;
@ -232,11 +141,11 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
            stringObjectMap.put("deviceQty", deviceDao.countAll());
        }
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "     COUNT(DISTINCT (b.id)) as count " +
                "   from " +
                "     t_mediicine_user t " +
                "  where " +
                "  1=1   " +
                "     base_user b " +
                "  where 1=1 and b.role_id in (select id from base_role where code = 'replenisher' and status = 1 )" +
                "  and b.enabled = 1 and b.locked = 0  " +
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
@ -341,728 +250,6 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
        return result;
    }
    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" +
                "    t.aisles as aisles,\n" +
                "    t.capacity as capacity,\n" +
                "    t.ratio as ratio,\n" +
                "    t.cargo_capacity as cargoCapacity,\n" +
                "    t.layer as layer,\n" +
                "    t.wayer as wayer\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);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
                }
            }
        }
        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" +
                "    t.aisles as aisles,\n" +
                "    t.capacity as capacity,\n" +
                "    t.ratio as ratio,\n" +
                "    t.cargo_capacity as cargoCapacity,\n" +
                "    t.layer as layer,\n" +
                "    t.wayer as wayer\n" +
                "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;
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
                }
            }
        }
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        return result;
    }
    /**
     * 根据设备id,查询与之绑定的补货员
     * @param deviceId
     * @return
     * @throws Exception
     */
    public JSONObject getUsers(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;
        }
        String sql = "SELECT\n" +
                "    t.id AS id,\n" +
                "    t.account AS account,\n" +
                "    t.belong_community AS belongCommunity,\n" +
                "    t.bir_date AS birDate,\n" +
                "    t.confirm_password AS confirmPassword,\n" +
                "    t.contact_info AS contactInfo,\n" +
                "    t.`name` AS `name`,\n" +
                "    t.`password` AS `password`,\n" +
                "    t.res_med_cabinet AS resMedCabinet,\n" +
                "    t.res_pon_area AS resPonArea,\n" +
                "    t.role AS role,\n" +
                "    t.sex AS sex,\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_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;
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : 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 = userDao.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();
        JSONObject jsonObject = new JSONObject();
        String sql = "select count(1) from t_mediicine_device a where a.del = 1";
        int count = jdbcTemplate.queryForObject(sql,Integer.class);
        jsonObject.put("count", count);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
        return result;
    }
    //获取当前设备数量
//    public  long countAll() {
//        return deviceDao.countAll();
//    }
    /**
     * 获取当前设备数量
     * @return
     * @throws Exception
     */
    public JSONObject countOnline() throws Exception{
        JSONObject result = new JSONObject();
        String sql = "select count(1) from t_mediicine_device a where a.del = 1 and a.status = 1";
        int count = jdbcTemplate.queryForObject(sql,Integer.class);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("count",count);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",jsonObject);
        return result;
    }
    //获取当前设备数量
//    public  long countOnline() {
//        return deviceDao.countOnline();
//    }
    public JSONObject saveDmMedicineDevice(String json) throws IOException {
        JSONObject result = new JSONObject();
//        MedicineDevice device = objectMapper.readValue(json,MedicineDevice.class);
//        Integer deviceType = device.getMedicineDeviceType();
//        String categoryCode = device.getCategoryCode();
//        String name = device.getName();
//        String model = device.getCategoryCode();
//        String brands = device.getBrands();
//        String photo =device.getPhoto();
//        String isMultiUser = device.getIsMultiUser();
//        if (null==deviceType||StringUtils.isBlank(categoryCode)||StringUtils.isBlank(name)||StringUtils.isBlank(model)||
//                StringUtils.isBlank(brands)||StringUtils.isBlank(photo)||StringUtils.isBlank(isMultiUser)){
//            result.put(ResponseContant.resultFlag,ResponseContant.fail);
//            result.put(ResponseContant.resultMsg,"数据数据错误,必填字段为空");
//            return result;
//        }
//        //判断型号是否重复
//        MedicineDevice deviceTmp = deviceDao.findByModel(device.getModel());
//        if (null!=deviceTmp){
//            if (null==device.getId()){
//                result.put(ResponseContant.resultFlag,ResponseContant.fail);
//                result.put(ResponseContant.resultMsg,"设备型号已存在");
//                return result;
//            }else if (deviceTmp.getId().longValue()!=device.getId().longValue()){//
//                result.put(ResponseContant.resultFlag,ResponseContant.fail);
//                result.put(ResponseContant.resultMsg,"设备型号已存在");
//                return result;
//            }
//        }
//        if (null==device.getId()){
//            device.setDel("1");
//        }
//        deviceDao.save(device);
//        result.put(ResponseContant.resultFlag,ResponseContant.success);
//        result.put(ResponseContant.resultMsg,"success");
        return result;
    }
    /**
     * 获取缺货设备列表
     * @param replenishEr
     * @param address
     * @return
     * @throws Exception
     */
    public JSONObject getOutOfStockDeviceList(String replenishEr, String address) throws Exception {
        JSONObject result = new JSONObject();
        String sql = "SELECT\n" +
                "\tifnull(sum(tmi.qty), 0) AS totalQty,\n" +
                "\tifnull(\n" +
                "\t\tt.aisles - count(tmi.id),\n" +
                "\t\tt.aisles\n" +
                "\t) AS unusedAisles,\n" +
                "\tifnull(\n" +
                "\t\tt.capacity - sum(tmi.qty),\n" +
                "\t\tt.capacity\n" +
                "\t) AS unuserdCapacity,\n" +
                "\tifnull((t.capacity - sum(tmi.qty)) / t.capacity, 0) AS idleRate,\n" +
                "\tt.id as id,\n" +
                "\tt.belong_community as belongCommunity,\n" +
                "\tt.community as community,\n" +
                "\tt.del as del,\n" +
                "\tt.delivery_address as deliveryAddress,\n" +
                "\tt.detail_address as detailAddress,\n" +
                "\tt.equ_area as equArea,\n" +
                "\tt.equ_class as equClass,\n" +
                "\tt.equ_info as equInfo,\n" +
                "\tt.equ_name as equName,\n" +
                "\tt.equ_num as equNum,\n" +
                "\tt.equ_type as equType,\n" +
                "\tt.fbelong_community as fbelongCommunity,\n" +
                "\tt.machine_code as machineCode,\n" +
                "\tt.network_status as networkStatus,\n" +
                "\tt.poweron_test as poweronTest,\n" +
                "\tt.reg_date as regDate,\n" +
                "\tt.sale_status as saleStatus,\n" +
                "\tt.signalintensity as signalintensity,\n" +
                "\tt.upgr_adesit as upgrAdesit,\n" +
                "\tt.`status` as `status`,\n" +
                "\tt.card_status as cardStatus,\n" +
                "\tt.operator as operator,\n" +
                "\tt.pack_age as packAge,\n" +
                "\tt.usage_flow as usageFlow,\n" +
                "\tt.flow as flow,\n" +
                "\tt.create_time as createTime,\n" +
                "\tt.create_user as createUser,\n" +
                "\tt.create_user_name as createUserName,\n" +
                "\tt.update_time as updateTime,\n" +
                "\tt.update_user as updateUser,\n" +
                "\tt.update_user_name as updateUserName,\n" +
                "\tt.aisles as aisles,\n" +
                "\tt.capacity as capacity,\n" +
                "\tt.ratio as ratio,\n" +
                "\tt.cargo_capacity as cargoCapacity,\n" +
                "\tt.layer as layer,\n" +
                "\tt.wayer as wayer\n" +
                "FROM\n" +
                "\tt_mediicine_device t\n" +
                "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 t_mediicine_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.account) like '%" + replenishEr + "%')\n";
        }
        if (!StringUtils.isEmpty(address)) {
            sql += " AND CONCAT(t.detail_address,t.delivery_address) like '%" + address + "%'\n";
        }
       sql += "GROUP BY\n" +
            "\tt.id\n" +
            "HAVING\n" +
            "\tsum(tmi.qty) < t.capacity * t.ratio\n" +
            "OR sum(tmi.qty) IS NULL";
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
                }
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",list);
        return result;
    }
    /**
     * 获取所属id的缺货信息
     * @param ids
     * @return
     * @throws Exception
     */
    public JSONObject getDetialOutOfStock(String ids) 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" +
                "    t.aisles AS aisles,\n" +
                "    t.capacity AS capacity,\n" +
                "    t.ratio AS ratio,\n" +
                "    t.cargo_capacity AS cargoCapacity,\n" +
                "    t.layer AS layer,\n" +
                "    t.wayer AS wayer\n" +
                "FROM\n" +
                "    t_mediicine_device AS t WHERE t.del = 1 and  ',"+ ids +",' LIKE CONCAT('%,',t.id,',%')";
        String sencordSql = "SELECT\n" +
                "\ttmi.layer_no AS layerNo,\n" +
                "\ttmi.wayer_no AS wayerNo,\n" +
                "\ttmi.qty AS qty,\n" +
                "\ttmd.id AS id,\n" +
                "\ttmd.approval_num AS approvalNum,\n" +
                "\ttmd.barcode AS barcode,\n" +
                "\ttmd.brand AS brand,\n" +
                "\ttmd.dos_form AS dosForm,\n" +
                "\ttmd.state AS state,\n" +
                "\ttmd.drug_bar_code AS drugBarCode,\n" +
                "\ttmd.drug_class AS drugClass,\n" +
                "\ttmd.drug_class_code AS drugClassCode,\n" +
                "\ttmd.drug_code AS drugCode,\n" +
                "\ttmd.drug_name AS drugName,\n" +
                "\ttmd.drug_name_alies AS drugNameAlies,\n" +
                "\ttmd.drug_short_code AS drugShortCode,\n" +
                "\ttmd.drug_type_code AS drugTypeCode,\n" +
                "\ttmd.earlywarningcate AS earlywarningcate,\n" +
                "\ttmd.inventory AS inventory,\n" +
                "\ttmd.manufactor AS manufactor,\n" +
                "\ttmd.med_cabinet AS medCabinet,\n" +
                "\ttmd.pic AS pic,\n" +
                "\ttmd.price AS price,\n" +
                "\ttmd.sale_volume AS saleVolume,\n" +
                "\ttmd.self_code AS selfCode,\n" +
                "\ttmd.specif AS specif,\n" +
                "\ttmd.unit AS unit,\n" +
                "\ttmd.create_time AS createTime,\n" +
                "\ttmd.create_user AS createUser,\n" +
                "\ttmd.create_user_name AS createUserName,\n" +
                "\ttmd.update_time AS updateTime,\n" +
                "\ttmd.update_user AS updateUser,\n" +
                "\ttmd.update_user_name AS updateUserName,\n" +
                "\ttmd.drug_sku AS drugSku,\n" +
                "\ttmd.drug_num AS drugNum,\n" +
                "\ttmd.use_num AS useNum,\n" +
                "\ttmd.use_way AS useWay,\n" +
                "\ttmd.use_rate AS useRate,\n" +
                "\ttmd.use_dose AS useDose,\n" +
                "\ttmd.use_way_add AS useWayAdd,\n" +
                "\ttmd.org_code AS orgCode,\n" +
                "\ttmd.org_name AS orgName\n" +
                "FROM\n" +
                "\tt_mediicinecabinet_inventory tmi\n" +
                "LEFT JOIN t_mediicine_drugs tmd ON tmi.barcode = tmd.id";
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
            String tempStr = "";
//            tempStr = sencordSql + " where ',"+stringObjectMap.get("id")+",' LIKE CONCAT('%,',tmi.id_device,',%')";
            tempStr = sencordSql + " WHERE tmi.id_device = '" + stringObjectMap.get("id").toString() + "'";
            List<Map<String, Object>> childList = null;
            childList = hibenateUtils.createSQLQuery(tempStr);
            if (childList != null) {
                for (Map<String, Object> objectMap : childList) {
                    objectMap.put("upInventory", Integer.parseInt(stringObjectMap.get("cargoCapacity").toString()) - Integer.parseInt(objectMap.get("qty").toString()));
                }
                stringObjectMap.put("children", childList);
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",list);
        return result;
    }
    /**
     * 获取设备库存
     * @param belongCommunity
     * @param deviceId
     * @param netStatus
     * @return
     * @throws Exception
     */
    public JSONObject getDevInventory(String belongCommunity, String deviceId, String netStatus) 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" +
                "    t.aisles AS aisles,\n" +
                "    t.capacity AS capacity,\n" +
                "    t.ratio AS ratio,\n" +
                "    t.cargo_capacity AS cargoCapacity,\n" +
                "    t.layer AS layer,\n" +
                "    t.wayer AS wayer\n" +
                "FROM\n" +
                "    t_mediicine_device AS t WHERE 1=1 and t.del = 1";
        if (!StringUtils.isEmpty(deviceId)) {
            sql += " AND t.id = '" + deviceId + "'";
        }
        if (!StringUtils.isEmpty(belongCommunity)) {
            sql += " AND t.belong_community = '" + belongCommunity + "'";
        }
        if (!StringUtils.isEmpty(netStatus)) {
            sql += " AND t.network_status = '" + netStatus + "'";
        }
        String sencordSql = "SELECT\n" +
                "\ttmi.layer_no AS layerNo,\n" +
                "\ttmi.wayer_no AS wayerNo,\n" +
                "\ttmi.qty AS qty,\n" +
                "\ttmd.id AS id,\n" +
                "\ttmd.approval_num AS approvalNum,\n" +
                "\ttmd.barcode AS barcode,\n" +
                "\ttmd.brand AS brand,\n" +
                "\ttmd.dos_form AS dosForm,\n" +
                "\ttmd.state AS state,\n" +
                "\ttmd.drug_bar_code AS drugBarCode,\n" +
                "\ttmd.drug_class AS drugClass,\n" +
                "\ttmd.drug_class_code AS drugClassCode,\n" +
                "\ttmd.drug_code AS drugCode,\n" +
                "\ttmd.drug_name AS drugName,\n" +
                "\ttmd.drug_name_alies AS drugNameAlies,\n" +
                "\ttmd.drug_short_code AS drugShortCode,\n" +
                "\ttmd.drug_type_code AS drugTypeCode,\n" +
                "\ttmd.earlywarningcate AS earlywarningcate,\n" +
                "\ttmd.inventory AS inventory,\n" +
                "\ttmd.manufactor AS manufactor,\n" +
                "\ttmd.med_cabinet AS medCabinet,\n" +
                "\ttmd.pic AS pic,\n" +
                "\ttmd.price AS price,\n" +
                "\ttmd.sale_volume AS saleVolume,\n" +
                "\ttmd.self_code AS selfCode,\n" +
                "\ttmd.specif AS specif,\n" +
                "\ttmd.unit AS unit,\n" +
                "\ttmd.create_time AS createTime,\n" +
                "\ttmd.create_user AS createUser,\n" +
                "\ttmd.create_user_name AS createUserName,\n" +
                "\ttmd.update_time AS updateTime,\n" +
                "\ttmd.update_user AS updateUser,\n" +
                "\ttmd.update_user_name AS updateUserName,\n" +
                "\ttmd.drug_sku AS drugSku,\n" +
                "\ttmd.drug_num AS drugNum,\n" +
                "\ttmd.use_num AS useNum,\n" +
                "\ttmd.use_way AS useWay,\n" +
                "\ttmd.use_rate AS useRate,\n" +
                "\ttmd.use_dose AS useDose,\n" +
                "\ttmd.use_way_add AS useWayAdd,\n" +
                "\ttmd.org_code AS orgCode,\n" +
                "\ttmd.org_name AS orgName\n" +
                "FROM\n" +
                "\tt_mediicinecabinet_inventory tmi\n" +
                "LEFT JOIN t_mediicine_drugs tmd ON tmi.barcode = tmd.id";
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
//            String tempStr = sencordSql + " where ',"+stringObjectMap.get("id").toString()+",' LIKE CONCAT('%,',tmi.id_device,',%')";
            String tempStr = sencordSql + " WHERE tmi.id_device = '" + stringObjectMap.get("id").toString() + "'";
            List<Map<String, Object>> childList = null;
            childList = hibenateUtils.createSQLQuery(tempStr);
            if (childList != null) {
                for (Map<String, Object> objectMap : childList) {
                    objectMap.put("upInventory", Integer.parseInt(stringObjectMap.get("cargoCapacity").toString()) - Integer.parseInt(objectMap.get("qty").toString()));
                }
                stringObjectMap.put("children", childList);
                stringObjectMap.put("totalQty", childList.stream().reduce(0, (sum,  p) -> sum += Integer.parseInt(p.get("qty").toString()), Integer::sum));
            }
            //历史订单数
            String secondSql = "SELECT COUNT(DISTINCT(t.id)) FROM t_mediicine_order t WHERE t.shipping_equ = '" + stringObjectMap.get("id").toString() + "'";
            stringObjectMap.put("orderQty", jdbcTemplate.queryForObject(secondSql, Integer.class));
            //总销售额
            secondSql = "SELECT SUM(t.amount) FROM t_mediicine_order t WHERE t.shipping_equ = '" + stringObjectMap.get("id").toString() + "'";
            stringObjectMap.put("orderTotalAmount", jdbcTemplate.queryForObject(secondSql, Integer.class));
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",list);
        return result;
    }
}

+ 288 - 53
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -205,6 +205,13 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    }
    /**
     * 更新设备社区
     * @param deviceId
     * @param communityId
     * @param community
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String updateDeviceCommunity(String deviceId, String communityId, String community){
        JSONObject result = new JSONObject();
@ -227,6 +234,13 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        return result.toJSONString();
    }
    /**
     * 更新设备投放地址
     * @param deviceIds
     * @param address
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String updateDeviceAddress(String deviceIds, String address){
        JSONObject result = new JSONObject();
@ -235,7 +249,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        for (String deviceId : deviceIds.split(",")) {
            if(!StringUtils.isEmpty(deviceId)){
                Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
@ -432,15 +445,45 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql,page,size);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
//            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
//                if ("1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "在线");
//                }
//                if ("0".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "离线");
//                }
//                if ("-1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "异常");
//                }
//            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
        }
@ -547,15 +590,45 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
//            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
//                if ("1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "在线");
//                }
//                if ("0".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "离线");
//                }
//                if ("-1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "异常");
//                }
//            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
        }
@ -642,15 +715,45 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
//            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
//                if ("1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "在线");
//                }
//                if ("0".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "离线");
//                }
//                if ("-1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "异常");
//                }
//            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
        }
@ -675,26 +778,32 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            return result;
        }
        String sql = "SELECT\n" +
                "    t.id AS id,\n" +
                "    t.account AS account,\n" +
                "    t.belong_community AS belongCommunity,\n" +
                "    t.bir_date AS birDate,\n" +
                "    t.confirm_password AS confirmPassword,\n" +
                "    t.contact_info AS contactInfo,\n" +
                "    t.`name` AS `name`,\n" +
                "    t.`password` AS `password`,\n" +
                "    t.res_med_cabinet AS resMedCabinet,\n" +
                "    t.res_pon_area AS resPonArea,\n" +
                "    t.role AS role,\n" +
                "    t.sex AS sex,\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" +
                "\tt.id AS id,\n" +
                "\tt.create_time AS createTime,\n" +
                "\tt.create_user AS createUser,\n" +
                "\tt.create_user_name AS createUserName,\n" +
                "\tt.update_time AS updateTime,\n" +
                "\tt.update_user AS updateUser,\n" +
                "\tt.update_user_name AS updateUserName,\n" +
                "\tt.username AS username,\n" +
                "\tt.`password` AS `password`,\n" +
                "\tt.salt AS salt,\n" +
                "\tt.`name` AS `name`,\n" +
                "\tt.gender AS gender,\n" +
                "\tt.idcard AS idcard,\n" +
                "\tt.mobile AS mobile,\n" +
                "\tt.ak AS ak,\n" +
                "\tt.email AS email,\n" +
                "\tt.enabled AS enabled,\n" +
                "\tt.locked AS locked,\n" +
                "\tt.locked_date AS lockedDate,\n" +
                "\tt.login_date AS loginDate,\n" +
                "\tt.saas_id AS saasId,\n" +
                "\tt.login_failure_count AS loginFailureCount,\n" +
                "\tt.last_login_failure_time AS lastLoginFailureTime,\n" +
                "\tt.role_id AS roleId\n" +
                "FROM\n" +
                "    t_mediicine_user AS t where\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 + "')";
@ -897,7 +1006,7 @@ 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 t_mediicine_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.account) 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(tmu.name,tmu.mobile) like '%" + replenishEr + "%')\n";
        }
        if (!StringUtils.isEmpty(address)) {
            sql += " AND CONCAT(t.detail_address,t.delivery_address) like '%" + address + "%'\n";
@ -912,15 +1021,45 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> stringObjectMap : list) {
            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
                if ("1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "在线");
//            if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
//                if ("1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "在线");
//                }
//                if ("0".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "离线");
//                }
//                if ("-1".equals(stringObjectMap.get("status").toString())) {
//                    stringObjectMap.put("statusName", "异常");
//                }
//            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
                if ("0".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "离线");
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("-1".equals(stringObjectMap.get("status").toString())) {
                    stringObjectMap.put("statusName", "异常");
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
@ -1025,7 +1164,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "\ttmd.org_name AS orgName\n" +
                "FROM\n" +
                "\tt_mediicinecabinet_inventory tmi\n" +
                "LEFT JOIN t_mediicine_drugs tmd ON tmi.barcode = tmd.id";
                "LEFT JOIN t_mediicine_drugs tmd ON tmi.drug_id = tmd.id";
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
@ -1038,9 +1177,54 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            if (childList != null) {
                for (Map<String, Object> objectMap : childList) {
                    objectMap.put("upInventory", Integer.parseInt(stringObjectMap.get("cargoCapacity").toString()) - Integer.parseInt(objectMap.get("qty").toString()));
                    if (!StringUtils.isEmpty(objectMap.get("state").toString())) {
                        if ("1".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "已上架");
                        }
                        if ("2".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "已下架");
                        }
                        if ("3".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "处方");
                        }
                        if ("4".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "非处方");
                        }
                    }
                }
                stringObjectMap.put("children", childList);
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
@ -1156,7 +1340,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                "\ttmd.org_name AS orgName\n" +
                "FROM\n" +
                "\tt_mediicinecabinet_inventory tmi\n" +
                "LEFT JOIN t_mediicine_drugs tmd ON tmi.barcode = tmd.id";
                "LEFT JOIN t_mediicine_drugs tmd ON tmi.drug_id = tmd.id";
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql);
@ -1168,6 +1352,21 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            if (childList != null) {
                for (Map<String, Object> objectMap : childList) {
                    objectMap.put("upInventory", Integer.parseInt(stringObjectMap.get("cargoCapacity").toString()) - Integer.parseInt(objectMap.get("qty").toString()));
                    if (!StringUtils.isEmpty(objectMap.get("state").toString())) {
                        if ("1".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "已上架");
                        }
                        if ("2".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "已下架");
                        }
                        if ("3".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "处方");
                        }
                        if ("4".equals(objectMap.get("state").toString())) {
                            objectMap.put("stateName", "非处方");
                        }
                    }
                }
                stringObjectMap.put("children", childList);
                stringObjectMap.put("totalQty", childList.stream().reduce(0, (sum,  p) -> sum += Integer.parseInt(p.get("qty").toString()), Integer::sum));
@ -1178,14 +1377,50 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            //总销售额
            secondSql = "SELECT SUM(t.amount) FROM t_mediicine_order t WHERE t.shipping_equ = '" + stringObjectMap.get("id").toString() + "'";
            stringObjectMap.put("orderTotalAmount", jdbcTemplate.queryForObject(secondSql, Integer.class));
            //状态
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
                }
                if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "离线");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
                if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "在售");
                }
                if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "停售");
                }
                if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
                    stringObjectMap.put("saleStatusName", "故障");
                }
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
                if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "正常");
                }
                if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "到期");
                }
                if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
                    stringObjectMap.put("cardStatusName", "未知");
                }
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",list);
        return result;
    }
    //getDevicesDelivery
    /**
     * 获取社区投放地址
     * @param belongCommunity
     * @return
     */
    public List<Map<String,Object>> getDevicesDelivery(String belongCommunity){
        String sql = "SELECT\n" +
                "    t.id AS id,\n" +