wangzhinan 3 rokov pred
rodič
commit
7e7e2f2a76

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

@ -20,4 +20,5 @@ public interface MediicinecabinetInventoryDao extends PagingAndSortingRepository
    @Query("select layerNo as layerNo from MediicinecabinetInventory where idDevice=?1 group by layerNo")
    List<Map<String,Object>> selectByDeviceIdGroup(String  deviceId);
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/nologin/ServiceNoLoginEndPoint.java

@ -3,6 +3,7 @@ package com.yihu.jw.base.endpoint.open.nologin;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.a3service.MedicineOrderService;
import com.yihu.jw.base.service.a3service.MedicinedeviceService;
import com.yihu.jw.base.service.advrtisement.AdvertisementLaunchService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.a1entity.MedicineShipmentLog;
@ -38,6 +39,9 @@ public class ServiceNoLoginEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private MedicineOrderService orderservice;
    @Autowired
    MedicinedeviceService deviceService;
    @GetMapping(value = "/devinfo")
    @ApiOperation(value = "获取单个设备上的所有广告")
    public Envelop solo(
@ -111,4 +115,21 @@ public class ServiceNoLoginEndPoint extends EnvelopRestEndpoint {
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.CREATE)
    @ApiOperation(value = "新增设备信息")
    public Envelop createDevice(@ApiParam(name = "deviceId", value = "deviceId", required = true)
                                @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){
        JSONObject jsonObject = new JSONObject();
        String str = deviceService.createDevice(deviceId, layer, wayer);
        jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("response"));
    }
}

+ 102 - 18
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -46,6 +46,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    @Autowired
    private MedicineDeviceDeliveryDao deviceDeliveryDao;
    @Autowired
    private MediicinecabinetInventoryDao inventoryDao;
    @Autowired
    private ObjectMapper objectMapper;
@ -61,8 +64,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private MediicinecabinetInventoryDao inventoryDao;
    @Autowired
    private MediicinedrugsDao mediicinedrugsDao;
@ -77,11 +78,34 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "   from " +
                "     t_mediicine_device t " +
                "  where " +
                "  1=1  and t.del = 1 and t.equ_num = ' " + deviceId + "' ";
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        if (count > 0) {
            result.put("msg","deviceId is exist");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        Mediicinedevice mediicinedevice = new Mediicinedevice();
        mediicinedevice.setEquNum(deviceId);
        mediicinedevice.setLayer(layer);
        mediicinedevice.setWayer(wayer);
        mediicinedevice.setCargoCapacity("5");
        mediicinedevice.setCapacity(String.valueOf(5 * Integer.parseInt(layer) * Integer.parseInt(wayer)));
        mediicinedevice.setAisles(String.valueOf(Integer.parseInt(layer) * Integer.parseInt(wayer)));
        //缺货状态0缺货
        mediicinedevice.setStatus("0");
        //停售状态
        mediicinedevice.setSaleStatus("2");
        //网络状态
        mediicinedevice.setNetworkStatus("1");
        mediicinedevice.setRegDate(new Date());
        mediicinedevice.setEquType("03");
        mediicinedevice.setDel("1");
        deviceDao.save(mediicinedevice);
        for (int i = 0; i < Integer.parseInt(layer); i++) {
            for (int i1 = 0; i1 < Integer.parseInt(wayer); i1++) {
@ -1278,7 +1302,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    /**
     * 获取缺货设备,夹带userId,用于数据隔离
     * 获取缺货设备列表,夹带userId,用于数据隔离
     * @param userId
     * @param content
     * @return
@ -1359,14 +1383,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "    t_mediicine_device AS t\n" +
                    "WHERE\n" +
                    "t.del = 1 AND  \n" +
                    "CONCAT(t.equ_num, t.equ_name) like '" + content +"' AND  \n" +
                    "t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',a.id,',%')";
             deviceList = hibenateUtils.createSQLQuery(sencodSql);
        } else {
            String belongCommunitys = "";
            String sql = "";
            //市管理员
@ -1400,7 +1420,6 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                        "t.user_id = '" + userId + "'\n" +
                        "AND t.del = 1";
            }
            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
            for (Map<String, Object> stringObjectMap : list) {
                if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
@ -1412,16 +1431,81 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                }
            }
            String sencodSql = "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\n" +
                    "WHERE\n" +
                    "t.del = 1 AND  \n" +
                    "CONCAT(t.equ_num, t.equ_name) like '" + content +"' AND  \n" +
                    "t.`status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
//            sencodSql = "SELECT\n" +
//                    "\tcount(DISTINCT(id))\n" +
//                    "FROM\n" +
//                    "\tt_mediicine_device\n" +
//                    "WHERE\n" +
//                    "\tdel = 1\n" +
//                    "AND `status` = 0  and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
//
//            outCount = jdbcTemplate.queryForObject(sencodSql, Integer.class);
            deviceList = hibenateUtils.createSQLQuery(sencodSql);
        }
        for (Map<String, Object> stringObjectMap : deviceList) {
            //库存
            Integer qty = jdbcTemplate.queryForObject("SELECT\n" +
                    "\tsum(t.qty)\n" +
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tt.id_device = '" + stringObjectMap.get("equNum") +"'\n" +
                    "AND t.shelf_status = 1", Integer.class);
            stringObjectMap.put("daibuQty", Integer.parseInt(stringObjectMap.get("capacity").toString()) - qty);
            stringObjectMap.put("xiajiaQty", jdbcTemplate.queryForObject("SELECT\n" +
                    "\tCOUNT(DISTINCT(id))\n" +
                    "FROM\n" +
                    "\tt_mediicinecabinet_inventory t\n" +
                    "WHERE\n" +
                    "\tt.id_device = ''\n" +
                    "AND t.shelf_status = 0", Integer.class));
            Date buhuoDate = jdbcTemplate.queryForObject("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" ));
        }
        result.put("response", ConstantUtils.SUCCESS);