Browse Source

眼科医院处方物流

ysj 4 years ago
parent
commit
ae42008226

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithTime.java

@ -0,0 +1,62 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.util.Date;
/**
 * 统一定义id的entity基类.
 * 主键生成策略是UUID
 * 还包含业务表用的 创建时间 ,修改时间
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class UuidIdentityEntityWithTime extends UuidIdentityEntity {
    //创建时间
	@CreatedDate
	protected Date createTime;
    //更新时间 数据库设置自动更新
    @LastModifiedDate
	protected Date updateTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time", nullable = false, length = 0,updatable = false)
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}

+ 100 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceInventoryWarningDO.java

@ -0,0 +1,100 @@
package com.yihu.jw.entity.iot.device;
import com.yihu.jw.entity.UuidIdentityEntityWithTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 设备库存预警设置
 * @author yeshijie on 2020/06/01.
 */
@Entity
@Table(name = "iot_device_inventory_warning")
public class IotDeviceInventoryWarningDO extends UuidIdentityEntityWithTime implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "product_id")
    private String productId;//产品id
    @Column(name = "product_name")
    private String productName;//设备名称
    @Column(name = "hospital")
    private String hospital;//归属社区
    @Column(name = "hospital_name")
    private String hospitalName;//归属社区名称 单位
    @Column(name = "inventory_upper")
    private Integer inventoryUpper;//库存上限提醒值 -- 库存字段,无效-移到 IotDeviceInventoryWarningDO
    @Column(name = "inventory_floor")
    private Integer inventoryFloor;//库存下限提醒值
    @Column(name = "del")
    private Integer del;//删除标志(1有效,0删除)
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getProductId() {
        return productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public Integer getInventoryUpper() {
        return inventoryUpper;
    }
    public void setInventoryUpper(Integer inventoryUpper) {
        this.inventoryUpper = inventoryUpper;
    }
    public Integer getInventoryFloor() {
        return inventoryFloor;
    }
    public void setInventoryFloor(Integer inventoryFloor) {
        this.inventoryFloor = inventoryFloor;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java

@ -78,7 +78,7 @@ public class IotProductBaseInfoDO extends UuidIdentityEntityWithOperator impleme
    @Column(name = "category_code")
    private String categoryCode;//设备类型标识
    @Column(name = "inventory_upper")
    private Integer inventoryUpper;//库存上限提醒值
    private Integer inventoryUpper;//库存上限提醒值 -- 库存字段,无效-移到 IotDeviceInventoryWarningDO
    @Column(name = "inventory_floor")
    private Integer inventoryFloor;//库存下限提醒值

+ 5 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -231,6 +231,11 @@ public class IotRequestMapping {
        public static final String getDeviceInventoryLog = "getDeviceInventoryLog";
        public static final String getDeviceInventoryLogDetail = "getDeviceInventoryLogDetail";
        //预警
        public static final String getInventoryWarningHospital = "getInventoryWarningHospital";
        public static final String getInventoryWarningName = "getInventoryWarningName";
        //设备调拨
        public static final String getDeviceTransfersList = "getDeviceTransfersList";
        public static final String createDeviceTransfers = "createDeviceTransfers";

+ 45 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/common/BaseTimeVO.java

@ -0,0 +1,45 @@
package com.yihu.jw.restmodel.iot.common;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * @author yeshijie on 2020/6/1.
 */
public class BaseTimeVO {
    protected String id;  // 非业务主键
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    protected Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    protected Date updateTime;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 87 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceInventoryWarningVO.java

@ -0,0 +1,87 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseTimeVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 设备库存预警设置
 * @author yeshijie on 2020/6/1.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "设备库存预警设置", description = "设备库存预警设置")
public class IotDeviceInventoryWarningVO extends BaseTimeVO implements Serializable {
    @ApiModelProperty("产品id")
    private String productId;
    @ApiModelProperty("设备名称")
    private String productName;
    @ApiModelProperty("归属社区")
    private String hospital;
    @ApiModelProperty("归属社区名称")
    private String hospitalName;
    @ApiModelProperty("库存上限提醒值")
    private Integer inventoryUpper;
    @ApiModelProperty("库存下限提醒值")
    private Integer inventoryFloor;
    @ApiModelProperty("删除标志(1有效,0删除)")
    private Integer del;//
    public String getProductId() {
        return productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public Integer getInventoryUpper() {
        return inventoryUpper;
    }
    public void setInventoryUpper(Integer inventoryUpper) {
        this.inventoryUpper = inventoryUpper;
    }
    public Integer getInventoryFloor() {
        return inventoryFloor;
    }
    public void setInventoryFloor(Integer inventoryFloor) {
        this.inventoryFloor = inventoryFloor;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 2 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAUtils.java

@ -49,11 +49,13 @@ public class RSAUtils {
        try {
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
            Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding", "BC");
            System.out.println("keyPair.getPublic():"+keyPair.getPublic());
            RSAPrivateKey pbk = (RSAPrivateKey)keyPair.getPrivate();
            cipher.init(Cipher.DECRYPT_MODE, pbk);
            byte[] plainText = cipher.doFinal(string);
            return plainText;
        }catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

+ 1 - 1
svr/svr-iot-job/src/main/java/com/yihu/jw/service/device/InventoryWarningService.java

@ -24,7 +24,7 @@ public class InventoryWarningService {
    public void remind() {
        String sql = "select d.product_id,d.`name`,d.category_code,d.category_name,d.manufacturer_id,d.manufacturer_name,d.hospital,d.hospital_name,count(d.id) inventoryCount ,p.inventory_floor,p.inventory_upper " +
                "FROM `iot_device` d LEFT JOIN iot_product_base_info p on d.product_id = p.id and p.del = 1 where p.del=1 and is_grant=0 GROUP BY d.product_id, d.manufacturer_id, d.hospital, d.category_code ";
                "FROM `iot_device` d LEFT JOIN iot_device_inventory_warning p on d.product_id = p.product_id and p.del = 1 where d.del=1 and is_grant=0 GROUP BY d.product_id, d.manufacturer_id, d.hospital, d.category_code ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : list){
            Integer inventoryCount = map.get("inventoryCount") == null ? 0: Integer.parseInt(map.get("inventoryCount") + "");

+ 30 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceInventoryController.java

@ -1,8 +1,11 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceInventoryService;
import com.yihu.iot.service.device.IotDeviceInventoryWarningService;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryWarningVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -22,6 +25,8 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceInventoryService deviceInventoryService;
    @Autowired
    private IotDeviceInventoryWarningService deviceInventoryWarningService;
    @GetMapping(value = IotRequestMapping.Device.getDeviceInventoryList)
    @ApiOperation(value = "获取设备库存列表", notes = "获取设备库存列表")
@ -92,4 +97,29 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.getInventoryWarningHospital)
    @ApiOperation(value = "库存预警,获取单位接口", notes = "库存预警,获取单位接口")
    public MixEnvelop getInventoryWarningHospital() {
        try {
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryService.getInventoryWarningHospital());
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.getInventoryWarningName)
    @ApiOperation(value = "库存预警,获取设备名称接口", notes = "库存预警,获取设备名称接口")
    public MixEnvelop getInventoryWarningName(@ApiParam(name = "hospital", value = "单位code")
                                                  @RequestParam(value = "hospital", required = true) String hospital) {
        try {
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryService.getInventoryWarningName(hospital));
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 9 - 5
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -1,9 +1,12 @@
package com.yihu.iot.controller.product;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.device.IotDeviceInventoryWarningService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.product.IotProductBaseInfoService;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryWarningVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.iot.product.IotMaintenanceUnitVO;
@ -35,6 +38,8 @@ public class IotProductController extends EnvelopRestEndpoint {
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private IotDeviceInventoryWarningService deviceInventoryWarningService;
    @GetMapping(value = IotRequestMapping.Product.findProductPage)
@ -203,14 +208,13 @@ public class IotProductController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Product.setInventoryById)
    @ApiOperation(value = "根据产品id设置库存上下限预警值")
    public MixEnvelop<IotProductVO, IotProductVO> setInventoryById(@ApiParam(name = "jsonData", value = "设置库存预警提醒json数组", defaultValue = "[]")
    public MixEnvelop<IotDeviceInventoryWarningVO, IotDeviceInventoryWarningVO> setInventoryById(@ApiParam(name = "jsonData", value = "设置库存预警提醒json数组", defaultValue = "[]")
                                                                       @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            List<IotProductBaseInfoDO> productBaseInfoDOList = iotProductBaseInfoService.setInventoryById(jsonData);
            List<IotDeviceInventoryWarningDO> doList = deviceInventoryWarningService.setInventoryById(jsonData);
            //DO转VO
            List<IotProductBaseInfoVO> productVOList = convertToModels(productBaseInfoDOList,new ArrayList<>(productBaseInfoDOList.size()),IotProductBaseInfoVO.class);
            iotProductBaseInfoService.translateDictForList(productVOList);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, productVOList);
            List<IotDeviceInventoryWarningVO> voList = convertToModels(doList,new ArrayList<>(doList.size()),IotDeviceInventoryWarningVO.class);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, voList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 13 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceInventoryWarningDao.java

@ -0,0 +1,13 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2020/6/1.
 */
public interface IotDeviceInventoryWarningDao extends PagingAndSortingRepository<IotDeviceInventoryWarningDO,String>,JpaSpecificationExecutor<IotDeviceInventoryWarningDO> {
}

+ 30 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java

@ -7,11 +7,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceInventoryLogDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryLogDO;
import com.yihu.jw.entity.iot.device.IotDeviceOrderDO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
@ -40,6 +42,8 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
    private IotDeviceOrderDao deviceOrderDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    /**
     * 获取库存列表接口
@ -75,6 +79,32 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
        }
    }
    /**
     * 库存预警,获取单位接口
     * @return
     */
    public MixEnvelop getInventoryWarningHospital() {
        String sql = "select d.hospital,d.hospital_name FROM `iot_device` d where del=1 and is_grant=0 GROUP BY d.hospital";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, list);
    }
    /**
     * 库存预警,获取设备名称接口
     * @param hospital
     * @return
     */
    public MixEnvelop getInventoryWarningName(String hospital) {
        String sql = "select d.product_id,d.name FROM `iot_device` d where del=1 and is_grant=0 ";
        if (StringUtils.isNotBlank(hospital)) {
            sql += "and hospital = '" + hospital + "' ";
        }
        sql += "GROUP BY d.product_id ";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, list);
    }
    public Integer updateInventory(String jsonData) {
        List<IotDeviceDO> deviceDOList = new ArrayList<>();
        JSONArray jsonArray = JSONArray.parseArray(jsonData);

+ 76 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryWarningService.java

@ -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;
    }
}