wangzhinan 3 anni fa
parent
commit
6a8e6aaab0

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

@ -92,9 +92,22 @@ public class MedicineShipmentLog extends UuidIdentityEntityWithOperator implemen
     */
    private String orgName;
    private String equName;
    private String equNum;
    public MedicineShipmentLog() {
    }
    public String getEquName() {
        return equName;
    }
    public void setEquName(String equName) {
        this.equName = equName;
    }
    public String getDeviceId() {
        return deviceId;
    }
@ -231,4 +244,12 @@ public class MedicineShipmentLog extends UuidIdentityEntityWithOperator implemen
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getEquNum() {
        return equNum;
    }
    public void setEquNum(String equNum) {
        this.equNum = equNum;
    }
}

+ 14 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MediicinecabinetInventory.java

@ -104,6 +104,11 @@ public class MediicinecabinetInventory extends UuidIdentityEntityWithOperator im
    private String equNum;
    /**
     * 合并,列组,英文逗号分隔
     */
    private String merge;
    public MediicinecabinetInventory() {
    }
@ -250,4 +255,13 @@ public class MediicinecabinetInventory extends UuidIdentityEntityWithOperator im
    public void setEquNum(String equNum) {
        this.equNum = equNum;
    }
    public String getMerge() {
        return merge;
    }
    public void setMerge(String merge) {
        this.merge = merge;
    }
}

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

@ -178,11 +178,13 @@ public class BaseRequestMapping {
        public static final String updateCommunity  = "/updateCommunity";
        public static final String updateAddressInfo  = "/updateAddressInfo";
        public static final String UPDATESTATUS  = "/updateStatus";
        public static final String updateUpgrAdesit  = "/updateUpgrAdesit";
        public static final String updateNetWorkStatus  = "/updateNetWorkStatus";
        public static final String UPDATESALESTATUS  = "/updateSaleStatus";
        public static final String UNBINDDEVICE  = "/unbindDevice";
        public static final String getDeviceListByUserId  = "/getDeviceListByUserId";
        public static final String getDeviceListWithUserId  = "/getDeviceListWithUserId";
        public static final String getInitDeviceByPage  = "/getInitDeviceByPage";
        public static final String getUserListByDeviceId  = "/getUserListByDeviceId";
        public static final String getOutOfStockDeviceList  = "/getOutOfStockDeviceList";
        public static final String getOutOfStockDeviceListByUserId  = "/getOutOfStockDeviceListByUserId";
@ -195,6 +197,7 @@ public class BaseRequestMapping {
        public static final String getDevicesByMoreContent  = "/getDevicesByMoreContent";
        public static final String getOrderDetailListById  = "/getOrderDetailListById";
        public static final String enableOrDis  = "/enableOrDis";
        public static final String getDeviceListByPage  = "/getDeviceListByPage";
        public static final String docFullInfo  = "/docFullInfo";
        public static final String docOrgDutyTreeInfo  = "/docOrgDutyTreeInfo";
        public static final String docOrgDeptTreeInfo  = "/docOrgDeptTreeInfo";

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

@ -12,10 +12,10 @@ import java.util.Map;
public interface MediicinecabinetInventoryDao extends PagingAndSortingRepository<MediicinecabinetInventory, String>, JpaSpecificationExecutor<MediicinecabinetInventory> {
    MediicinecabinetInventory findMediicinecabinetInventoryByIdDeviceAndLayerNoAndWayerNo(String deviceId, String layerNo, String wayerNo);
        MediicinecabinetInventory findMediicinecabinetInventoryByIdDeviceAndLayerNoAndWayerNo(String deviceId, String layerNo, String wayerNo);
    @Query("from MediicinecabinetInventory t where  t.idDevice=?1")
    List<MediicinecabinetInventory> findMediicinecabinetInventoryByDeviceId(String deviceId);
        @Query("from MediicinecabinetInventory t where  t.idDevice=?1")
        List<MediicinecabinetInventory> findMediicinecabinetInventoryByDeviceId(String deviceId);
    @Query("select layerNo as layerNo from MediicinecabinetInventory where idDevice=?1 group by layerNo")
    List<Map<String,Object>> selectByDeviceIdGroup(String  deviceId);

+ 114 - 45
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -44,11 +44,11 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.BaseDevice.CREATE)
    @ApiOperation(value = "新增设备信息")
    public Envelop createDevice(@ApiParam(name = "deviceId", value = "deviceId", required = true)
                                    @RequestParam(value = "deviceId") String deviceId,
                                @RequestParam(value = "deviceId") String deviceId,
                                @ApiParam(name = "layer", value = "层, 默认6", required = true)
                                @RequestParam(value = "layer", required = true, defaultValue = "6") String layer,
                                @ApiParam(name = "wayer", value = "列, 默认40", required = true)
                                    @RequestParam(value = "wayer", required = true, defaultValue = "40") String wayer){
                                @RequestParam(value = "wayer", required = true, defaultValue = "40") String wayer) {
        JSONObject jsonObject = new JSONObject();
        String str = deviceService.createDevice(deviceId, layer, wayer);
        jsonObject = JSONObject.parseObject(str);
@ -169,8 +169,24 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        }
        return success(jsonObject.getString("response"));
    }
    //updateUpgrAdesit
    @PostMapping(value = BaseRequestMapping.BaseDevice.updateUpgrAdesit)
    @ApiOperation(value = "更新设备升级内容")
    public Envelop updateUpgrAdesit(
            @ApiParam(name = "deviceId", value = "设备Id", required = true)
            @RequestParam(value = "deviceId") String deviceId,
            @ApiParam(name = "upgrAdesit", value = "升级内容", required = true)
            @RequestParam(value = "upgrAdesit") String upgrAdesit) throws Exception {
        String str = deviceService.updateUpgrAdesit(deviceId, upgrAdesit);
        JSONObject jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("response"));
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.updateNetWorkStatus)
    @ApiOperation(value = "更新设备网络状态")
    public Envelop updateNetWorkStatus(
@ -202,7 +218,6 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.UNBINDDEVICE)
    @ApiOperation(value = "设备解绑")
    public Envelop unbindDevice(
@ -216,6 +231,27 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(jsonObject.getString("response"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDeviceListByPage)
    @ApiOperation(value = "分页查询设备列表")
    public PageEnvelop getDeviceListByPage(
            @ApiParam(name = "content", value = "搜索内容")
            @RequestParam(value = "content", required = false) String content,
            @ApiParam(name = "equClass", value = "设备分类")
            @RequestParam(value = "equClass", required = false) String equClass,
            @ApiParam(name = "belongCommunity", value = "所属")
            @RequestParam(value = "belongCommunity", required = false) String belongCommunity,
            @ApiParam(name = "networkStatus", value = "网络状态")
            @RequestParam(value = "networkStatus", required = false) String networkStatus,
            @ApiParam(name = "saleStatus", value = "售卖状态")
            @RequestParam(value = "saleStatus", required = false) String saleStatus,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = deviceService.queryDeviceListFullInfo(content, equClass, belongCommunity, networkStatus, saleStatus, page, size, wechatId);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.docFullInfo)
    @ApiOperation(value = "获取设备信息基础信息列表")
@ -234,12 +270,12 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = deviceService.queryDeviceListFullInfo(content, equClass, belongCommunity, networkStatus, saleStatus,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
        JSONObject result = deviceService.queryDeviceListFullInfo(content, equClass, belongCommunity, networkStatus, saleStatus, page, size, wechatId);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDevicesByMoreContent)
    @ApiOperation(value = "通过搜索内容查询设备列表" , notes="获取设备列表")
    @ApiOperation(value = "通过搜索内容查询设备列表", notes = "获取设备列表")
    public ListEnvelop<Mediicinedevice> getDevicesByMoreContent(
            @ApiParam(name = "content", value = "搜索内容")
            @RequestParam(value = "content", required = false) String content,
@ -263,15 +299,14 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "deliveryAddress", value = "投放地址")
            @RequestParam(value = "deliveryAddress", required = false) String deliveryAddress) throws Exception {
        JSONObject result = deviceService.getDevicesByMoreContent(content, equClass, belongCommunity, networkStatus,saleStatus, machineCode, deviceType, equArea, del, status, deliveryAddress, wechatId);
        JSONObject result = deviceService.getDevicesByMoreContent(content, equClass, belongCommunity, networkStatus, saleStatus, machineCode, deviceType, equArea, del, status, deliveryAddress, wechatId);
        List<Mediicinedevice> list = JSONObject.parseArray(result.getJSONArray("msg").toJSONString(), Mediicinedevice.class);
        return success(list, Mediicinedevice.class);
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDeviceListByUserId)
    @ApiOperation(value = "通过人员id获取设备列表" , notes="获取设备列表")
    @ApiOperation(value = "通过人员id获取设备列表", notes = "获取设备列表")
    public ListEnvelop<Mediicinedevice> getDeviceListByUserId(
            @ApiParam(name = "userId", value = "人员id", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
@ -282,7 +317,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.getUserListByDeviceId)
    @ApiOperation(value = "通过设备id获取补货员列表" , notes="获取补货员列表")
    @ApiOperation(value = "通过设备id获取补货员列表", notes = "获取补货员列表")
    public ListEnvelop<Mediicineuser> getUserListByDeviceId(
            @ApiParam(name = "deviceId", value = "设备id", required = true)
            @RequestParam(value = "deviceId") String deviceId) throws Exception {
@ -292,7 +327,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.FINDBYID)
    @ApiOperation(value = "获取设备信息" , notes="获取设备信息")
    @ApiOperation(value = "获取设备信息", notes = "获取设备信息")
    public Envelop getdevicedetail(
            @ApiParam(name = "deviceId", value = "设备id", required = true)
            @RequestParam(value = "deviceId") String deviceId) throws Exception {
@ -304,9 +339,8 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.countall)
    @ApiOperation(value = "获取设备总数量" , notes="参数未添加通过数据区域查询获取")
    @ApiOperation(value = "获取设备总数量", notes = "参数未添加通过数据区域查询获取")
    public Envelop countall() throws Exception {
        JSONObject jsonObject = deviceService.countAll();
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
@ -317,9 +351,9 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.countAllDevice)
    @ApiOperation(value = "获取设备总计" , notes="参数未添加通过数据区域查询获取")
    @ApiOperation(value = "获取设备总计", notes = "参数未添加通过数据区域查询获取")
    public Envelop countAllDevice(@ApiParam(name = "userId", value = "用户id", required = true)
                                      @RequestParam(value = "userId") String userId) throws Exception {
                                  @RequestParam(value = "userId") String userId) throws Exception {
        JSONObject jsonObject = deviceService.countAllDevice(userId);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
@ -328,7 +362,6 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    }
//    @ApiOperation(value = "获取设备总数量", notes="参数未添加通过数据区域查询获取")
//    @GetMapping("/countall")
//    public Long countall(){
@ -337,7 +370,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.countOnline)
    @ApiOperation(value = "获取在线设备总数量" , notes="参数未添加通过数据区域查询获取")
    @ApiOperation(value = "获取在线设备总数量", notes = "参数未添加通过数据区域查询获取")
    public Envelop countOnline() throws Exception {
        JSONObject jsonObject = deviceService.countOnline();
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
@ -353,13 +386,12 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
//    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getOutOfStockDeviceList)
    @ApiOperation(value = "获取缺货设备列表" , notes="获取缺货设备列表")
    public Envelop getOutOfStockDeviceList( @ApiParam(name = "replenishEr", value = "补货员")
                                                @RequestParam(value = "replenishEr", required = false) String replenishEr,
                                            @ApiParam(name = "address", value = "地址")
                                            @RequestParam(value = "address", required = false) String address) throws Exception {
    @ApiOperation(value = "获取缺货设备列表", notes = "获取缺货设备列表")
    public Envelop getOutOfStockDeviceList(@ApiParam(name = "replenishEr", value = "补货员")
                                           @RequestParam(value = "replenishEr", required = false) String replenishEr,
                                           @ApiParam(name = "address", value = "地址")
                                           @RequestParam(value = "address", required = false) String address) throws Exception {
        JSONObject jsonObject = deviceService.getOutOfStockDeviceList(replenishEr, address);
//        List<Mediicinedevice> list = JSONObject.parseArray(jsonObject.getJSONArray("msg").toJSONString(), Mediicinedevice.class);
        return success(jsonObject.getJSONArray("msg"));
@ -367,11 +399,11 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.getOutOfStockDeviceListByUserId)
    @ApiOperation(value = "获取缺货设备列表夹带userId" , notes="获取缺货设备列表")
    public Envelop getOutOfStockDeviceListByUserId( @ApiParam(name = "userId", value = "用户id")
                                            @RequestParam(value = "userId", required = true) String userId,
                                            @ApiParam(name = "content", value = "搜索内容")
                                            @RequestParam(value = "content", required = false) String content) throws Exception {
    @ApiOperation(value = "获取缺货设备列表夹带userId", notes = "获取缺货设备列表")
    public Envelop getOutOfStockDeviceListByUserId(@ApiParam(name = "userId", value = "用户id")
                                                   @RequestParam(value = "userId", required = true) String userId,
                                                   @ApiParam(name = "content", value = "搜索内容")
                                                   @RequestParam(value = "content", required = false) String content) throws Exception {
        JSONObject jsonObject = deviceService.getOutOfStockDeviceListByUserId(userId, content);
        return success(jsonObject.getJSONArray("msg"));
    }
@ -379,15 +411,50 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDeviceListWithUserId)
    @ApiOperation(value = "获取设备列表夹带userId" , notes="获取设备列表")
    public Envelop getDeviceListWithUserId( @ApiParam(name = "userId", value = "用户id")
                                                    @RequestParam(value = "userId", required = true) String userId,
                                                    @ApiParam(name = "content", value = "搜索内容")
                                                    @RequestParam(value = "content", required = false) String content) throws Exception {
        JSONObject jsonObject = deviceService.getDeviceListByUserId(userId, content);
        return success(jsonObject.getJSONArray("msg"));
    @ApiOperation(value = "获取设备列表夹带userId", notes = "获取设备列表")
    public PageEnvelop getDeviceListWithUserId(@ApiParam(name = "content", value = "搜索内容")
                                               @RequestParam(value = "content", required = false) String content,
                                               @ApiParam(name = "networkStatus", value = "设备网络状态")
                                               @RequestParam(value = "networkStatus", required = false) String networkStatus,
                                               @ApiParam(name = "community", value = "所属社区")
                                               @RequestParam(value = "community", required = false) String community,
                                               @ApiParam(name = "saleStatus", value = "设备销售状态")
                                               @RequestParam(value = "saleStatus", required = false) String saleStatus,
                                               @ApiParam(name = "equType", value = "设备类型")
                                               @RequestParam(value = "equType", required = false) String equType,
                                               @ApiParam(name = "userId", value = "用户id", required = true)
                                                   @RequestParam(value = "userId") String userId,
                                               @ApiParam(name = "page", value = "页码", required = true, defaultValue = "1")
                                               @RequestParam(value = "page") int page,
                                               @ApiParam(name = "size", value = "分页大小", required = true, defaultValue = "15")
                                               @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = deviceService.getDeviceListByUserId(content, networkStatus, community,
                saleStatus, equType,
                userId, page, size);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getInitDeviceByPage)
    @ApiOperation(value = "获取初始化设备分页列表", notes = "获取初始化设备分页列表")
    public PageEnvelop getInitDeviceByPage(@ApiParam(name = "content", value = "搜索内容")
                                               @RequestParam(value = "content", required = false) String content,
                                               @ApiParam(name = "networkStatus", value = "设备网络状态")
                                               @RequestParam(value = "networkStatus", required = false) String networkStatus,
                                               @ApiParam(name = "community", value = "所属社区")
                                               @RequestParam(value = "community", required = false) String community,
                                               @ApiParam(name = "saleStatus", value = "设备销售状态")
                                               @RequestParam(value = "saleStatus", required = false) String saleStatus,
                                               @ApiParam(name = "equType", value = "设备类型")
                                               @RequestParam(value = "equType", required = false) String equType,
                                               @ApiParam(name = "page", value = "页码", required = true, defaultValue = "1")
                                               @RequestParam(value = "page") int page,
                                               @ApiParam(name = "size", value = "分页大小", required = true, defaultValue = "15")
                                               @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = deviceService.getInitDeviceByPage(content, networkStatus, community,
                saleStatus, equType,
                page, size);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.getDetialOutOfStock)
    @ApiOperation(value = "获取缺货信息")
@ -411,8 +478,9 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        JSONObject jsonObject = deviceService.getDevInventory(belongCommunity, deviceId, netStatus);
        return success(jsonObject.getJSONArray("msg"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDevicesDeliveryList)
    @ApiOperation(value = "设备投放地址列表" , notes="获取设备投放地址列表")
    @ApiOperation(value = "设备投放地址列表", notes = "获取设备投放地址列表")
    public ListEnvelop getDevicesDelivery(
            @ApiParam(name = "belongCommunity", value = "所属社区", required = true)
            @RequestParam(value = "belongCommunity", required = true) String belongCommunity) throws Exception {
@ -421,7 +489,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.findMediicinecabinetInventoryByDeviceId)
    @ApiOperation(value = "根据设备id查询设备轨道数据" , notes="根据设备id查询设备轨道数据")
    @ApiOperation(value = "根据设备id查询设备轨道数据", notes = "根据设备id查询设备轨道数据")
    public ListEnvelop selectById(
            @ApiParam(name = "deviceId", value = "设备id", required = true)
            @RequestParam(value = "deviceId", required = true) String deviceId) throws Exception {
@ -429,7 +497,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.updateMediicinecabineInventory)
    @ApiOperation(value = "更换商品,或者设定商品" , notes="更换商品,或者设定商品")
    @ApiOperation(value = "更换商品,或者设定商品", notes = "更换商品,或者设定商品")
    public Envelop updateMediicinecabineInventory(
            @ApiParam(name = "id", value = "货道id", required = true)
            @RequestParam(value = "id", required = true) String id,
@ -437,11 +505,11 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "drugId", required = true) String drugId,
            @ApiParam(name = "qty", value = "库存", required = true)
            @RequestParam(value = "qty", required = true) String qty) throws Exception {
        return success(deviceService.updateMediicinecabineInventoryById(id,drugId,qty));
        return success(deviceService.updateMediicinecabineInventoryById(id, drugId, qty));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.selectMediicinecabineInventoryById)
    @ApiOperation(value = "根据货道id获取单个货道详情" , notes="根据货道id获取单个货道详情")
    @ApiOperation(value = "根据货道id获取单个货道详情", notes = "根据货道id获取单个货道详情")
    public Envelop selectMediicinecabineInventoryById(
            @ApiParam(name = "id", value = "货道id", required = true)
            @RequestParam(value = "id", required = true) String id) throws Exception {
@ -450,15 +518,16 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    /**
     * 矫正库存\ 更新容量 \下架商品
     * @param id 货到id
     * @param qty 库存
     *
     * @param id            货到id
     * @param qty           库存
     * @param cargoCapacity 容量
     * @param status 下架状态0
     * @param status        下架状态0
     * @return
     * @throws Exception
     */
    @PostMapping(value = BaseRequestMapping.BaseDevice.updateMediicinecabineInventoryInfoById)
    @ApiOperation(value = "矫正库存\\ 更新容量 \\下架商品" , notes="矫正库存\\ 更新容量 \\下架商品")
    @ApiOperation(value = "矫正库存\\ 更新容量 \\下架商品", notes = "矫正库存\\ 更新容量 \\下架商品")
    public Envelop updateMediicinecabineInventoryInfoById(
            @ApiParam(name = "id", value = "货道id", required = true)
            @RequestParam(value = "id", required = true) String id,
@ -468,7 +537,7 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "cargoCapacity", required = false) String cargoCapacity,
            @ApiParam(name = "status", value = "下架状态0", required = false)
            @RequestParam(value = "status", required = false) String status) throws Exception {
        return success(deviceService.updateMediicinecabineInventoryInfoById(id,qty,cargoCapacity,status));
        return success(deviceService.updateMediicinecabineInventoryInfoById(id, qty, cargoCapacity, status));
    }

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOutEndpoint.java

@ -135,10 +135,10 @@ public class MedicineOutEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "replenishEr", required = false) String replenishEr,
            @ApiParam(name = "docNum", value = "单号")
            @RequestParam(value = "docNum", required = false) String docNum,
            @ApiParam(name = "userId", value = "用户id")
            @RequestParam(value = "userId", required = true) String userId,
            @ApiParam(name = "receiveState", value = "领料状态")
            @RequestParam(value = "receiveState") String receiveState,
            @RequestParam(value = "receiveState", required = false) String receiveState,
            @ApiParam(name = "userId", value = "用户id")
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")

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

@ -20,10 +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;
import java.util.*;
import java.util.logging.Logger;
/**
@ -361,7 +358,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        jsonObject.put("drugList", orderdetailDao.getorderdetail(orderId));
        List<MedicineShipmentLog> shipmentLogs = shipmentLogDao.findMedicineShipmentLogsByOrderId(orderId);
        jsonObject.put("outList", (shipmentLogs == null && shipmentLogs.size() == 0) ? null : shipmentLogs);
        Map<String, String> orderTypeMap = new HashMap<>();
        //订单类型字典设置start
        orderTypeMap.put("1", "123");
        //end
        jsonObject.put("patientName", mediicineorder.getName());
        jsonObject.put("patientSex", mediicineorder.getSex());
        jsonObject.put("patientIdNum", mediicineorder.getIdNum());
@ -373,8 +373,12 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        jsonObject.put("prescribeTime", mediicineorder.getPrescribeTime());
        jsonObject.put("amount", mediicineorder.getAmount());
        jsonObject.put("socialinsurPayment", mediicineorder.getSocialinsurPayment());
        jsonObject.put("orderState", mediicineorder.getOrderState());
        jsonObject.put("sellState", mediicineorder.getSellState());
        jsonObject.put("sellStateName", "0".equals(mediicineorder.getSellState()) ? "未取药" : "已取药");
        jsonObject.put("infoAccess", mediicineorder.getInfoAccess());
        jsonObject.put("orderTypeName", orderTypeMap.get(mediicineorder.getOrderType()));
        //取药码
        jsonObject.put("pickUpNum", mediicineorder.getPickUpNum());
        jsonObject.put("device",StringUtils.isEmpty(mediicineorder.getShippingEqu()) ?  null : deviceDao.findOne(mediicineorder.getShippingEqu()));
        result.put("msg", jsonObject);
        result.put("response", ConstantUtils.SUCCESS);
@ -681,7 +685,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                "                t.specif AS specif,\n" +
                "                t.unit AS unit,\n" +
                "                t.org_code AS orgCode,\n" +
                "                t.org_name AS orgName\n" +
                "                t.org_name AS orgName,\n" +
                "                t.equ_name AS equName\n" +
                "            FROM\n" +
                "                t_medicine_shipment_log AS t" +
                "        WHERE \n" +
@ -744,7 +749,11 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                deviceDao.save(mediicinedevice);
            }
            inventoryDao.save(inventory);
            //绑定订单跟出货设备的关系,
            Mediicineorder mediicineorder = orderDao.findOne(medicineShipmentLog.getOrderId());
            mediicineorder.setShippingEqu(medicineShipmentLog.getEquNum());
            mediicineorder.setShippingTime(new Date());
            orderDao.save(mediicineorder);
        }
        //查询更新订单信息start
        //订单id
@ -819,6 +828,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                    "\t\t\tFROM\n" +
                    "\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + mediicineorderdetail.getDrugCode() + "'\n" +
                    "\t\t\tAND t.org_code = '" + mediicineorderdetail.getOrgCode() + "'\n" +
//                    "\t\t\tAND t.state = '1'\n" +
                    "\t\t\tAND CONCAT(t.id_device, t.equ_num) like '%"+ deviceId + "%'\n" +
                    "\t\t\tGROUP BY\n" +
                    "\t\t\t\tt.drug_code,\n" +
@ -835,7 +845,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                mediicineorderdetail.setOrderState("0");
            }
        }
        Mediicinedevice mediicinedevice = deviceDao.findMediicinedeviceByEquNum(deviceId);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status", 0);
        if (!isInStock) {
@ -878,7 +888,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                    "\tt.specif AS specif,\n" +
                    "\tt.unit AS unit,\n" +
                    "\tt.org_code AS orgCode,\n" +
                    "\tt.org_name AS orgName\n" +
                    "\tt.org_name AS orgName,\n" +
                    "\tt.equ_name AS equName\n" +
                    "FROM\n" +
                    "\tt_medicine_shipment_log AS t\n" +
                    "WHERE \n" +
@ -931,6 +942,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                        shipmentLog.setPrice(mediicinedrugs.getPrice());
                        shipmentLog.setSpecif(mediicinedrugs.getSpecif());
                        shipmentLog.setUnit(mediicinedrugs.getUnit());
                        shipmentLog.setEquName(mediicinedevice.getEquName());
                        shipmentLog.setEquNum(mediicinedevice.getEquNum());
                        shipmentLogDao.save(shipmentLog);
                        shipmentLogs.add(shipmentLog);
                    }

+ 314 - 104
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -20,13 +20,16 @@ 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.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
@ -376,7 +379,39 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        return result.toJSONString();
    }
    /**
     * 更新设备升级情况
     * @param deviceId
     * @param status
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String updateUpgrAdesit(String deviceId, String UpgrAdesitContent){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(UpgrAdesitContent)){
            result.put("msg","deviceId and UpgrAdesitContent 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.setUpgrAdesit(UpgrAdesitContent);
        this.save(mediicinedevice);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",mediicinedevice);
        return result.toJSONString();
    }
    /**
     * 更新设备网络状态
     * @param deviceId
     * @param networkStatus
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String updateDeviceNetworkStatus(String deviceId, String networkStatus){
        JSONObject result = new JSONObject();
@ -441,27 +476,53 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        for (String deviceId : deviceIds.split(",")) {
            if(!StringUtils.isEmpty(deviceId)){
                Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
                if (mediicinedevice == null) {
                    result.put("msg","device doesn't exist");
                    result.put("response", ConstantUtils.FAIL);
                    return result.toJSONString();
                }
                List<Map<String, Object>> list = null;
                list = hibenateUtils.createSQLQuery("SELECT * FROM t_mediicine_device_user where del = 1 AND device_id = '" + deviceId + "'");
                if (list != null && list.size() > 0) {
                    for (Map<String, Object> stringObjectMap : list) {
                        if (!StringUtils.isEmpty(stringObjectMap.get("id").toString())) {
                            MediicineDeviceUser mediicineDeviceUser = deviceUserDao.findOne(stringObjectMap.get("id").toString());
                            if (mediicineDeviceUser != null) {
                                mediicineDeviceUser.setDel("0");
                                deviceUserDao.save(mediicineDeviceUser);
                //删除补货员
                {
                    List<Map<String, Object>> list = null;
                    list = hibenateUtils.createSQLQuery("SELECT * FROM t_mediicine_device_user where del = 1 AND device_id = '" + deviceId + "'");
                    if (list != null && list.size() > 0) {
                        for (Map<String, Object> stringObjectMap : list) {
                            if (!StringUtils.isEmpty(stringObjectMap.get("id").toString())) {
                                MediicineDeviceUser mediicineDeviceUser = deviceUserDao.findOne(stringObjectMap.get("id").toString());
                                if (mediicineDeviceUser != null) {
                                    mediicineDeviceUser.setDel("0");
                                    deviceUserDao.save(mediicineDeviceUser);
                                }
                            }
                        }
                    }
                }
                //删除社区,社区中心名称
                mediicinedevice.setBelongCommunity(null);
                mediicinedevice.setCommunity(null);
                mediicinedevice.setStatus("0");
                mediicinedevice.setSaleStatus("2");
                mediicinedevice.setAisles(String.valueOf(Integer.parseInt(mediicinedevice.getLayer()) *
                        Integer.parseInt(mediicinedevice.getWayer())));
                mediicinedevice.setCargoCapacity("5");
                mediicinedevice.setCapacity(String.valueOf(Integer.parseInt(mediicinedevice.getAisles()) *
                        Integer.parseInt(mediicinedevice.getCargoCapacity())));
                mediicinedevice.setDeliveryAddress(null);
                mediicinedevice.setDetailAddress(null);
                mediicinedevice.setEquArea(null);
                this.save(mediicinedevice);
                //更新库存
                List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByDeviceId(deviceId);
                for (MediicinecabinetInventory inventory : list) {
                    inventory.setPic(null);
                    inventory.setShelfStatus("0");
                    inventory.setQty("0");
                    inventory.setDrugCode(null);
                    inventory.setDrugId(null);
                    inventory.setDrugName(null);
                    inventory.setPrice(null);
                    inventory.setSku(null);
                    inventory.setDrugSku(null);
                    inventory.setNum("0");
                    inventory.setLongtime(null);
                    inventory.setOrgCode(null);
                    inventoryDao.save(inventory);
                }
            }
        }
        result.put("response",ConstantUtils.SUCCESS);
@ -470,8 +531,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    /**
     * 分页查询设备信息
     * 分页查询设备信息getDeviceListByPage
     * @param content
     * @param equClass
     * @param belongCommunity
@ -560,7 +622,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
//                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", "在线");
@ -987,7 +1049,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    public  JSONObject countAllDevice(String userId) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject jsonObject = new JSONObject();
//        String userId = userAgent.getUID();
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        //设备总数
@ -1106,7 +1167,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        jsonObject.put("total", count);
        jsonObject.put("onlineTotal", onlineCount);
        jsonObject.put("saleTotal", saleCount);
        jsonObject.put("onlineRate", onlineCount * 1.0 / count);
        jsonObject.put("onlineRate", new BigDecimal(onlineCount * 1.0 / count).setScale(2, BigDecimal.ROUND_HALF_UP));
        jsonObject.put("outCount", outCount);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
@ -1397,7 +1458,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "t.del = 1 AND  \n" +
                    "t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
            if (!StringUtils.isEmpty(content)) {
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '" + content +"'";
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'";
            }
             deviceList = hibenateUtils.createSQLQuery(sencodSql);
        } else {
@ -1490,7 +1551,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "t.del = 1 AND  \n" +
                    "t.`status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
            if (!StringUtils.isEmpty(content)) {
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '" + content +"'";
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'";
            }
@ -1515,15 +1576,22 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "WHERE\n" +
                    "\tconcat(t.id_device, t.equ_num) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "AND t.shelf_status = 0";
            stringObjectMap.put("xiajiaQty", jdbcTemplate.queryForObject( tempSql, Integer.class));
            Date buhuoDate = jdbcTemplate.queryForObject( "SELECT\n" +
            Integer xiajiaQty = jdbcTemplate.queryForObject(tempSql, Integer.class);
            if (xiajiaQty != null) {
                stringObjectMap.put("xiajiaQty", xiajiaQty);
            }
            tempSql = "SELECT\n" +
                    "\tcreate_time\n" +
                    "FROM\n" +
                    "\tt_mediicine_stockrecord_detail\n" +
                    "ORDER BY\n" +
                    "\tcreate_time DESC\n" +
                    "LIMIT 1", Date.class);
            stringObjectMap.put("buhuoTime", DateUtil.dateToStr(buhuoDate, "yyyy-MM-dd HH:mm:ss" ));
                    "LIMIT 1";
            Date buhuoDate = jdbcTemplate.queryForObject(tempSql, Date.class);
            if (buhuoDate != null) {
                stringObjectMap.put("buhuoTime", DateUtil.dateToStr(buhuoDate, "yyyy-MM-dd HH:mm:ss" ));
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
@ -1533,45 +1601,108 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    /**
     * 获取设备列表,userId, 数据隔离的
     * 获取设备列表,夹带userId, 数据隔离的
     * @param content           搜索内容like eqyNum equName
     * @param networkStatus     网络状态    1在线0离线
     * @param community
     * @param saleStatus
     * @param equType
     * @param userId
     * @param content
     * @return
     * @throws Exception
     */
    public JSONObject getDeviceListByUserId(String userId, String content) throws Exception {
    public JSONObject getDeviceListByUserId(String content,String networkStatus, String community,
                                            String saleStatus,String equType,String userId, int page, int size) throws Exception {
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(userId)) {
            return result;
        }
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<Map<String, Object>> deviceList = null;
        //查询控制语句
        String conditionSql = "";
        if ("replenisher".equals(role.getCode())) {
            //补货员所分配的设备
            String sql = "SELECT\n" +
                    "\tdevice_id\n" +
                    "FROM\n" +
                    "\tt_mediicine_device_user\n" +
                    "WHERE\n" +
                    "\tuser_id = '" + userId +"'\n" +
                    "AND del = 1";
            //设备列表
            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
            String deviceIds = "";
            for (Map<String, Object> stringObjectMap : list) {
                if (stringObjectMap.get("device_id") != null && !StringUtils.isEmpty(stringObjectMap.get("device_id").toString())) {
                    if (StringUtils.isEmpty(deviceIds)) {
                        deviceIds += stringObjectMap.get("device_id").toString();
                    } else {
                        deviceIds += "," +  stringObjectMap.get("device_id").toString();
            {
                String sql = "SELECT\n" +
                        "\tdevice_id\n" +
                        "FROM\n" +
                        "\tt_mediicine_device_user\n" +
                        "WHERE\n" +
                        "\tuser_id = '" + userId +"'\n" +
                        "AND del = 1";
                //设备列表
                List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
                for (Map<String, Object> stringObjectMap : list) {
                    if (stringObjectMap.get("device_id") != null && !StringUtils.isEmpty(stringObjectMap.get("device_id").toString())) {
                        if (StringUtils.isEmpty(deviceIds)) {
                            deviceIds += stringObjectMap.get("device_id").toString();
                        } else {
                            deviceIds += "," +  stringObjectMap.get("device_id").toString();
                        }
                    }
                }
            }
            //模拟补货员未绑定设备
            deviceIds = "";
            String sencodSql = "SELECT\n" +
            conditionSql  = "AND ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
        } else {
            String belongCommunitys = "";
            String tempSql = "";
            //获取管理员所在社区id字符串
            {
                //市管理员
                if ("saasAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tid\tas community\n" +
                            "FROM\n" +
                            "\tdm_hospital\n" +
                            "WHERE\n" +
                            "\tdel = 1";
                }
                //区域管理员
                if ("regionAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tdh.id AS community\n" +
                            "FROM\n" +
                            "\twlyy_user_area t\n" +
                            "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
                            "WHERE\n" +
                            "\tt.user_id = '" + userId + "'\n" +
                            "AND t.del = 1\n" +
                            "AND dh.del = 1";
                }
                //社区管理员
                if ("communityAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "t.hospital AS community\n" +
                            "FROM\n" +
                            "wlyy_user_area AS t\n" +
                            "WHERE\n" +
                            "t.user_id = '" + userId + "'\n" +
                            "AND t.del = 1";
                }
                List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempSql);
                for (Map<String, Object> stringObjectMap : list) {
                    if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                        if (StringUtils.isEmpty(belongCommunitys)) {
                            belongCommunitys += stringObjectMap.get("community").toString();
                        } else {
                            belongCommunitys += "," +  stringObjectMap.get("community").toString();
                        }
                    }
                }
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                conditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
            }
        }
        String sql = "";
        {
            sql += "SELECT\n" +
                    "    t.id AS id,\n" +
                    "    t.belong_community AS belongCommunity,\n" +
                    "    t.community AS community,\n" +
@ -1612,59 +1743,110 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "    t.wayer AS wayer\n" +
                    "FROM\n" +
                    "    t_mediicine_device AS t\n" +
                    "WHERE\n" +
                    "t.del = 1 AND  \n" +
                    " ',"+ deviceIds +",' LIKE CONCAT('%,',t.id,',%')\n";
            if (!StringUtils.isEmpty(content)) {
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '" + content +"'";
            }
            deviceList = hibenateUtils.createSQLQuery(sencodSql);
        } else {
            String belongCommunitys = "";
            String sql = "";
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
                    "WHERE 1=1 AND t.del = 1\n";
        }
        if (!StringUtils.isEmpty(content)) {
            conditionSql += "AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"%'\n";
        }
        if (!StringUtils.isEmpty(networkStatus)) {
            conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
        }
        if (!StringUtils.isEmpty(community)) {
            conditionSql += "AND t.belong_community = '" + community +"'\n";
        }
        if (!StringUtils.isEmpty(saleStatus)) {
            conditionSql += "AND t.sale_status = '" + saleStatus +"'\n";
        }
        if (!StringUtils.isEmpty(equType)) {
            conditionSql += "AND t.equ_type = '" + equType +"'\n";
        }
        conditionSql += "AND t.belong_community IS NOT NULL\n";
        //true
//        if (isAllocate) {
//
//        } else{
//            conditionSql += "AND t.belong_community IS NULL\n";
//        }
        sql = sql + conditionSql;
        deviceList = hibenateUtils.createSQLQuery(sql, page, size);
        Map<String, String> equTypeMap = new HashMap<>();
        equTypeMap.put("1", "测试类型1");
        equTypeMap.put("2", "测试类型2");
        equTypeMap.put("3", "测试类型3");
        for (Map<String, Object> stringObjectMap : deviceList) {
            if(!StringUtils.isEmpty(stringObjectMap.get("equType"))){
                stringObjectMap.put("equTypeName", equTypeMap.get(stringObjectMap.get("equType")));
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
                        "WHERE\n" +
                        "\tt.user_id = '" + userId + "'\n" +
                        "AND t.del = 1\n" +
                        "AND dh.del = 1";
            if(!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 ("communityAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "t.hospital AS community\n" +
                        "FROM\n" +
                        "wlyy_user_area AS t\n" +
                        "WHERE\n" +
                        "t.user_id = '" + userId + "'\n" +
                        "AND t.del = 1";
            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", "故障");
                }
            }
            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
            for (Map<String, Object> stringObjectMap : list) {
                if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                    if (StringUtils.isEmpty(belongCommunitys)) {
                        belongCommunitys += stringObjectMap.get("community").toString();
                    } else {
                        belongCommunitys += "," +  stringObjectMap.get("community").toString();
                    }
            if(!StringUtils.isEmpty(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", "未知");
                }
            }
        }
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "   from " +
                "     t_mediicine_device t " +
                "  where " +
                "  1=1  and t.del = 1  " +
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
            String sencodSql = "SELECT\n" +
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(deviceList));
        return result;
    }
    /**
     * 获取初始化设备列表
     * @param content
     * @param networkStatus
     * @param community
     * @param saleStatus
     * @param equType
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public JSONObject getInitDeviceByPage(String content,String networkStatus, String community,
                                            String saleStatus,String equType, int page, int size) throws Exception {
        JSONObject result = new JSONObject();
        //查询控制语句
        String conditionSql = "";
        String sql = "";
        {
            sql += "SELECT\n" +
                    "    t.id AS id,\n" +
                    "    t.belong_community AS belongCommunity,\n" +
                    "    t.community AS community,\n" +
@ -1705,16 +1887,34 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "    t.wayer AS wayer\n" +
                    "FROM\n" +
                    "    t_mediicine_device AS t\n" +
                    "WHERE\n" +
                    "t.del = 1 AND  \n" +
                    " ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
            if (!StringUtils.isEmpty(content)) {
                sencodSql += " AND CONCAT(t.equ_num, t.equ_name) like '" + content +"'";
            }
            deviceList = hibenateUtils.createSQLQuery(sencodSql);
                    "WHERE 1=1 AND t.del = 1\n";
        }
        if (!StringUtils.isEmpty(content)) {
            conditionSql += "AND CONCAT(t.equ_num, t.equ_name) like '%" + content +"'%\n";
        }
        if (!StringUtils.isEmpty(networkStatus)) {
            conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
        }
        if (!StringUtils.isEmpty(community)) {
            conditionSql += "AND t.belong_community = '" + community +"'\n";
        }
        if (!StringUtils.isEmpty(saleStatus)) {
            conditionSql += "AND t.sale_status = '" + saleStatus +"'\n";
        }
        if (!StringUtils.isEmpty(equType)) {
            conditionSql += "AND t.equ_type = '" + equType +"'\n";
        }
        conditionSql += "AND t.belong_community IS NULL\n";
        sql = sql + conditionSql;
        List<Map<String, Object>> deviceList = hibenateUtils.createSQLQuery(sql, page, size);
        Map<String, String> equTypeMap = new HashMap<>();
        equTypeMap.put("1", "测试类型1");
        equTypeMap.put("2", "测试类型2");
        equTypeMap.put("3", "测试类型3");
        for (Map<String, Object> stringObjectMap : deviceList) {
            if(!StringUtils.isEmpty(stringObjectMap.get("equType"))){
                stringObjectMap.put("equTypeName", equTypeMap.get(stringObjectMap.get("equType")));
            }
            if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
                if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
                    stringObjectMap.put("networkStatusName", "在线");
@ -1746,12 +1946,22 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                }
            }
        }
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "   from " +
                "     t_mediicine_device t " +
                "  where " +
                "  1=1  and t.del = 1  " +
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg",deviceList);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(deviceList));
        return result;
    }
    /**
     * 获取所属id的缺货信息
     * @param ids