|
@ -0,0 +1,76 @@
|
|
|
package com.yihu.iot.service.device;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.iot.dao.device.IotDeviceInventoryWarningDao;
|
|
|
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
|
|
|
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by yeshijie on 2020/6/1.
|
|
|
*/
|
|
|
@Service
|
|
|
public class IotDeviceInventoryWarningService extends BaseJpaService<IotDeviceInventoryWarningDO,IotDeviceInventoryWarningDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private IotDeviceInventoryWarningDao deviceInventoryWarningDao;
|
|
|
|
|
|
/**
|
|
|
* 设置库存上下限提醒值
|
|
|
* @param jsonData
|
|
|
* @return
|
|
|
*/
|
|
|
public List<IotDeviceInventoryWarningDO> setInventoryById(String jsonData) {
|
|
|
List<IotDeviceInventoryWarningDO> list = new ArrayList();
|
|
|
JSONArray jsonArray = JSONArray.parseArray(jsonData);
|
|
|
for (Object object : jsonArray){
|
|
|
JSONObject jsonObject = (JSONObject) object;
|
|
|
String id = jsonObject.getString("id");
|
|
|
String hospital = jsonObject.getString("hospital");
|
|
|
String hospitalName = jsonObject.getString("hospitalName");
|
|
|
String produceName = jsonObject.getString("produceName");
|
|
|
Integer inventoryUpper = jsonObject.getInteger("inventoryUpper");
|
|
|
Integer inventoryFloor = jsonObject.getInteger("inventoryFloor");
|
|
|
IotDeviceInventoryWarningDO warningDO = new IotDeviceInventoryWarningDO();
|
|
|
warningDO.setDel(1);
|
|
|
warningDO.setHospital(hospital);
|
|
|
warningDO.setHospitalName(hospitalName);
|
|
|
warningDO.setInventoryFloor(inventoryFloor);
|
|
|
warningDO.setInventoryUpper(inventoryUpper);
|
|
|
warningDO.setProductId(id);
|
|
|
warningDO.setProductName(produceName);
|
|
|
warningDO.setCreateTime(new Date());
|
|
|
list.add(warningDO);
|
|
|
}
|
|
|
deviceInventoryWarningDao.save(list);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增预警
|
|
|
* @return
|
|
|
*/
|
|
|
public IotDeviceInventoryWarningDO addInventoryWarning(String hospital,String hospitalName,Integer inventoryFloor
|
|
|
,Integer inventoryUpper,String productId,String produceName){
|
|
|
IotDeviceInventoryWarningDO warningDO = new IotDeviceInventoryWarningDO();
|
|
|
warningDO.setDel(1);
|
|
|
warningDO.setHospital(hospital);
|
|
|
warningDO.setHospitalName(hospitalName);
|
|
|
warningDO.setInventoryFloor(inventoryFloor);
|
|
|
warningDO.setInventoryUpper(inventoryUpper);
|
|
|
warningDO.setProductId(productId);
|
|
|
warningDO.setProductName(produceName);
|
|
|
warningDO.setCreateTime(new Date());
|
|
|
deviceInventoryWarningDao.save(warningDO);
|
|
|
return warningDO;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|