LAPTOP-KB9HII50\70708 2 months ago
parent
commit
86ab1b7834

+ 152 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/MedicinePatientLog.java

@ -0,0 +1,152 @@
package com.yihu.jw.entity.a1entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 药柜居民请求日志
 * Created by yeshijie on 2025/1/10.
 */
@Entity
@Table(name="t_medicine_patient_log")
public class MedicinePatientLog extends IdEntity implements Serializable {
    private String equNum;//设备编号
    private String orgCode;//机构编码
    private String methodType;//业务类型
    private String methodUrl;//请求url
    private String methodName;//业务名称
    private String cardNo;//卡号
    private String idcard;//身份证
    private String name;//居民姓名
    private String req;//请求参数
    private String res;//返回内容
    private Integer status;//状态1成功 0失败
    private String error;//错误内容
    private Long reqTime;//请求时长秒
    private Date createTime;//创建时间
    @Column(name = "equ_num")
    public String getEquNum() {
        return equNum;
    }
    public void setEquNum(String equNum) {
        this.equNum = equNum;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    @Column(name = "method_type")
    public String getMethodType() {
        return methodType;
    }
    public void setMethodType(String methodType) {
        this.methodType = methodType;
    }
    @Column(name = "method_url")
    public String getMethodUrl() {
        return methodUrl;
    }
    public void setMethodUrl(String methodUrl) {
        this.methodUrl = methodUrl;
    }
    @Column(name = "card_no")
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    @Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "req")
    public String getReq() {
        return req;
    }
    public void setReq(String req) {
        this.req = req;
    }
    @Column(name = "res")
    public String getRes() {
        return res;
    }
    public void setRes(String res) {
        this.res = res;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "error")
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    @Column(name = "req_time")
    public Long getReqTime() {
        return reqTime;
    }
    public void setReqTime(Long reqTime) {
        this.reqTime = reqTime;
    }
    @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;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "method_name")
    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
}

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/aop/IntefaceLogRequired.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.aop;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * Created by yeshijie on 2025/01/10.
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface IntefaceLogRequired {
}

+ 170 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/aop/IntefaceLogRequiredAOP.java

@ -0,0 +1,170 @@
package com.yihu.jw.base.aop;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yihu.jw.base.service.a3service.MedicinedeviceService;
import com.yihu.jw.base.useragent.UserAgent;
import com.yihu.jw.entity.iot.gateway.GcToken;
import com.yihu.jw.gateway.dao.GcTokenDao;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 接口调用日志记录
 * Created by yeshijie on 2025/01/10.
 */
@Aspect
@Component
public class IntefaceLogRequiredAOP {
    private Logger logger = LoggerFactory.getLogger(IntefaceLogRequiredAOP.class);
    @Autowired
    private MedicinedeviceService medicinedeviceService;
    //Controller层切点路径
    @Pointcut("execution(* com.yihu.jw.base..*.*(..))")
    public void controllerAspect() {
    }
    public IntefaceLogRequiredAOP() {
        //System.out.println("Observer---------------------------------------");
    }
    @Around("controllerAspect() && @annotation(com.yihu.jw.base.aop.IntefaceLogRequired)")
    public Object addIntefaceLog(ProceedingJoinPoint point) throws Throwable {
        Object o = null;
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        try {
            MethodSignature signature = (MethodSignature) point.getSignature();
            Method method = signature.getMethod();
            String params = getMethodParams(point);
            long start = System.currentTimeMillis();
            Object result = point.proceed();
            long end = System.currentTimeMillis();
            String deleteSensitiveContent =  deleteSensitiveContent(result);
            Map<String,String> paramsMap = getMehtodParam(request);
            String url = request.getRequestURL().toString();
            ApiOperation apiOperationAnnotation = method.getAnnotation(ApiOperation.class);
            medicinedeviceService.saveLog(paramsMap,deleteSensitiveContent, url,0,method.getName(),apiOperationAnnotation.notes(),end - start);
            logger.info("结束请求方法:[{}] 参数:[{}] 返回结果[{}] 耗时:[{}]毫秒 ",
                    method.getName(), params, deleteSensitiveContent, end - start);
            return result;
        }catch (Exception e){
            e.printStackTrace();
            //return o;
        }
         o = point.proceed();
        return o;
    }
    private String getMethodName(ProceedingJoinPoint joinPoint) {
        String methodName = joinPoint.getSignature().toShortString();
        String shortMethodNameSuffix = "(..)";
        if (methodName.endsWith(shortMethodNameSuffix)) {
            methodName = methodName.substring(0, methodName.length() - shortMethodNameSuffix.length());
        }
        return methodName;
    }
    private Map<String,String> getMehtodParam(HttpServletRequest request){
        Map<String,String> params = new HashMap<String,String>();
        Enumeration<String> e = request.getParameterNames();
        while(e.hasMoreElements()){
            String p = e.nextElement();
            if("logData".equals(p)){
                continue;
            }
            if("base64".equals(p)){
                continue;
            }
            params.put(p, request.getParameter(p));
        }
        return params;
    }
    private String getMethodParams(ProceedingJoinPoint joinPoint){
        Object[] arguments = joinPoint.getArgs();
        StringBuilder sb = new StringBuilder();
        if(arguments ==null || arguments.length <= 0){
            return sb.toString();
        }
        for (Object arg : arguments) {
            //移除敏感内容
            String paramStr;
            if (arg instanceof HttpServletResponse) {
                paramStr = HttpServletResponse.class.getSimpleName();
            } else if (arg instanceof HttpServletRequest) {
                paramStr = HttpServletRequest.class.getSimpleName();
            } else if (arg instanceof MultipartFile) {
                long size = ((MultipartFile) arg).getSize();
                paramStr = MultipartFile.class.getSimpleName() + " size:" + size;
            } else {
                paramStr = deleteSensitiveContent(arg);
            }
            sb.append(paramStr).append(",");
        }
        return sb.deleteCharAt(sb.length() - 1).toString();
    }
    /**
     * 删除参数中的敏感内容
     * @param obj 参数对象
     * @return 去除敏感内容后的参数对象
     */
    public static String deleteSensitiveContent(Object obj) {
        JSONObject jsonObject = new JSONObject();
        if (obj == null || obj instanceof Exception) {
            return jsonObject.toJSONString();
        }
        String param = JSON.toJSONString(obj);
        try {
            jsonObject = JSONObject.parseObject(param);
        }catch (Exception e) {
            return String.valueOf(obj);
        }
        List<String> sensitiveFieldList = getSensitiveFieldList();
        for (String sensitiveField : sensitiveFieldList) {
            if (jsonObject.containsKey(sensitiveField)) {
                jsonObject.put(sensitiveField, "******");
            }
        }
        return jsonObject.toJSONString();
    }
    /**
     * 敏感字段列表(当然这里你可以更改为可配置的)
     */
    private static List<String> getSensitiveFieldList() {
        List<String> sensitiveFieldList = Lists.newArrayList();
        sensitiveFieldList.add("pwd");
        sensitiveFieldList.add("password");
        return sensitiveFieldList;
    }
}

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MedicinePatientLogDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.dao.a2dao;
import com.yihu.jw.entity.a1entity.MedicinePatientLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2025/1/10.
 */
public interface MedicinePatientLogDao extends PagingAndSortingRepository<MedicinePatientLog, Long>,
        JpaSpecificationExecutor<MedicinePatientLog> {
}

+ 118 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -39,14 +39,127 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private MedicineServive medicineServive;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private MedicineStockOutService stockOutService;
    @Value("${wechat.id}")
    private String wechatId;
    @GetMapping(value = "patientReqLogPage")
    @ApiOperation(value = "居民请求运行日志")
    public PageEnvelop patientReqLogPage(
            @ApiParam(name = "name", value = "设备编码 所属社区名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "methodType", value = "错误类型")
            @RequestParam(value = "methodType", required = false) String methodType,
            @ApiParam(name = "orgCode", value = "所属机构code")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "startTime", value = "开始时间")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间")
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size){
        try {
            return deviceService.patientReqLogPage(page, size, name,orgCode, methodType, startTime, endTime);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "cabinetInventoryPage")
    @ApiOperation(value = "货道信息列表")
    public PageEnvelop cabinetInventoryPage(
            @ApiParam(name = "idDevice", value = "设备id")
            @RequestParam(value = "idDevice", required = false) String idDevice,
            @ApiParam(name = "startTime", value = "开始时间")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间")
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size){
        try {
            return deviceService.cabinetInventoryPage(page, size, idDevice, startTime, endTime);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "deviceCabinetInventoryPage")
    @ApiOperation(value = "设备货道信息列表")
    public PageEnvelop deviceCabinetInventoryPage(
            @ApiParam(name = "name", value = "设备编码 所属社区名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "orgCode", value = "所属机构code")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "networkStatus", value = "状态1在线0离线")
            @RequestParam(value = "networkStatus", required = false) String networkStatus,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size){
        try {
            return deviceService.deviceCabinetInventoryPage(page, size, name, orgCode, networkStatus);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "temperatureHumidityInfoPage")
    @ApiOperation(value = "温湿度信息列表")
    public PageEnvelop temperatureHumidityInfoPage(
            @ApiParam(name = "name", value = "设备编码 所属社区名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "orgCode", value = "所属机构code")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "temperatureStatus", value = "温度状态 1正常 2异常")
            @RequestParam(value = "temperatureStatus", required = false) String temperatureStatus,
            @ApiParam(name = "humidityStatus", value = "湿度状态 1正常 2异常")
            @RequestParam(value = "humidityStatus", required = false) String humidityStatus,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size){
        try {
            return deviceService.temperatureHumidityInfoPage(page, size, name,orgCode, temperatureStatus, humidityStatus);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "temperatureHumidityWarrayPage")
    @ApiOperation(value = "温湿度日志列表")
    public PageEnvelop temperatureHumidityWarrayPage(
            @ApiParam(name = "equNum", value = "设备编码")
            @RequestParam(value = "equNum", required = false) String equNum,
            @ApiParam(name = "temperatureEnd", value = "开始温度")
            @RequestParam(value = "temperatureEnd", required = false) String temperatureEnd,
            @ApiParam(name = "temperatureStart", value = "结束温度")
            @RequestParam(value = "temperatureStart", required = false) String temperatureStart,
            @ApiParam(name = "humidityStart", value = "开始湿度")
            @RequestParam(value = "humidityStart", required = false) String humidityStart,
            @ApiParam(name = "humidityEnd", value = "结束湿度")
            @RequestParam(value = "humidityEnd", required = false) String humidityEnd,
            @ApiParam(name = "startTime", value = "开始时间")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间")
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size){
        try {
            return deviceService.temperatureHumidityWarrayPage(page, size, startTime, endTime, temperatureEnd
                    , temperatureStart, humidityStart, humidityEnd, equNum);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.CREATE)
    @ApiOperation(value = "新增设备信息")
    public Envelop createDevice(@ApiParam(name = "deviceId", value = "deviceId", required = true)

+ 14 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOrderDrugsEndpoint.java

@ -1,6 +1,7 @@
package com.yihu.jw.base.endpoint.a4endpoint;
import com.yihu.jw.base.aop.IntefaceLogRequired;
import com.yihu.jw.base.service.a3service.MedOrderService;
import com.yihu.jw.base.service.a3service.MedicineDrugsService;
import com.yihu.jw.base.service.a3service.YlzService;
@ -36,6 +37,7 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/open/renew")
    @ApiOperation(value = "接收续方订单接口",notes = "接收续方订单接口" )
    @IntefaceLogRequired
    public Envelop renew(@ApiParam(name = "jsonData",value = "json数据",required = true)
                                @RequestParam(value = "jsonData",required = true)String jsonData){
        Map <String,Object>map =medOrderService.saveOrder(jsonData);
@ -49,6 +51,7 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/open/readCardInfo")
    @ApiOperation(value = "封装读卡参数,患者用医保凭证是改接口在getSettlementInfoList前调用,后续无需在重复读卡", notes = "封装读卡参数")
    @IntefaceLogRequired
    public Envelop readCardInfo(
            @ApiParam(name = "orgCode", value = "orgCode")
            @RequestParam(value = "orgCode", required = true) String orgCode,
@ -73,13 +76,13 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/open/getSettlementInfoList")
    @ApiOperation(value = "获取患者待结算信息", notes = "获取患者待结算信息")
    @IntefaceLogRequired
    public Envelop getSettlementInfoList(
            @ApiParam(name = "cardNo", value = "cardNo")
            @RequestParam(value = "cardNo", required = true) String cardNo,
            @ApiParam(name = "orgCode", value = "orgCode")
            @RequestParam(value = "orgCode", required = true) String orgCode){
        try {
            return success("操作成功", medOrderService.getSettlementInfoList(cardNo,orgCode));
        } catch (Exception e) {
            e.printStackTrace();
@ -88,7 +91,8 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping("/open/getSettlementInfoFirst")
    @ApiOperation(value = "获取患者待结算--个人信息、挂号接口封装", notes = "挂号接口封装")
    @ApiOperation(value = "获取患者待结算--个人信息、挂号接口封装", notes = "挂号接口")
    @IntefaceLogRequired
    public Envelop getSettlementInfoFirst(
            @ApiParam(name = "recipe_no", value = "recipe_no")
            @RequestParam(value = "recipe_no", required = true) String recipe_no,
@ -114,9 +118,9 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
            return Envelop.getError(e.getMessage());
        }
    }
    @IntefaceLogRequired
    @RequestMapping(value = "/open/getSettlementInfoSecode",method = {RequestMethod.POST,RequestMethod.GET})
    @ApiOperation(value = "获取患者待结算--费用明细上传接口封装", notes = "费用明细上传接口封装")
    @ApiOperation(value = "获取患者待结算--费用明细上传接口封装", notes = "费用明细上传接口")
    public Envelop getSettlementInfoSecode(
            @ApiParam(name = "recipe_no", value = "recipe_no")
            @RequestParam(value = "recipe_no", required = true) String recipe_no,
@ -146,6 +150,7 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "/open/getSettlementInfo",method = {RequestMethod.POST,RequestMethod.GET})
    @ApiOperation(value = "获取患者待His结算信息页面", notes = "获取患者待His结算信息页面")
    @IntefaceLogRequired
    public Envelop getSettlementInfo(
            @ApiParam(name = "chargeArr", value = "chargeArr")
            @RequestParam(value = "chargeArr", required = false) String chargeArr,
@ -168,6 +173,7 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/open/hlwyyRecharge")
    @ApiOperation(value = "院内确认结算", notes = "院内确认结算")
    @IntefaceLogRequired
    public Envelop hlwyyRecharge(
                @ApiParam(name = "recipe_no", value = "处方号,多笔结算逗号隔开(患者所有待结算订单需全部传入)")
                @RequestParam(value = "recipe_no", required = true) String recipe_no,
@ -189,6 +195,7 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/open/patient/hlwyyRecharge")
    @ApiOperation(value = "居民自助充值-预缴金", notes = "预缴金充值")
    @IntefaceLogRequired
    public Envelop patientHlwyyRecharge(
            @ApiParam(name="orgCode",value="机构code",defaultValue = "")
            @RequestParam(value = "orgCode",required = false) String orgCode,
@ -233,6 +240,7 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/open/hlwyyQueryDetail")
    @ApiOperation(value = "预缴金充值结果查询", notes = "预缴金充值结果查询")
    @IntefaceLogRequired
    public Envelop hlwyyQueryDetail(
                @ApiParam(name="orgCode",value="机构",defaultValue = "")
                @RequestParam(value = "orgCode",required = true) String orgCode,
@ -253,7 +261,8 @@ public class MedicineOrderDrugsEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping("/open/getYjjBalance")
    @ApiOperation(value = "获取预交金余额", notes = "预缴金充值结果查询")
    @ApiOperation(value = "获取预交金余额", notes = "获取预交金余额")
    @IntefaceLogRequired
    public Envelop getYjjBalance(
            @ApiParam(name="orgCode",value="机构",defaultValue = "")
            @RequestParam(value = "orgCode",required = true) String orgCode,

+ 3 - 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.area.service.BaseTownService;
import com.yihu.jw.base.aop.IntefaceLogRequired;
import com.yihu.jw.base.dao.role.RoleDao;
import com.yihu.jw.base.service.a3service.MedicineOrderService;
import com.yihu.jw.base.service.a3service.MedicineWarrayService;
@ -139,6 +140,7 @@ public class ServiceNoLoginEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseOrder.checkOrderAndReturnOrderList)
    @ApiOperation(value = "检查订单并且返回订单" , notes="检查订单并且返回订单")
    @IntefaceLogRequired
    public Envelop checkOrderAndReturnOrderList(
            @ApiParam(name = "deviceId", value = "设备id", required = true)
            @RequestParam(value = "deviceId", required = true) String deviceId,
@ -214,6 +216,7 @@ public class ServiceNoLoginEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.BaseOrder.updateOrderOutStatus)
    @ApiOperation(value = "更新订单出货单状态" , notes="更新订单出货单状态")
    @IntefaceLogRequired
    public Envelop updateOrderOut(
            @ApiParam(name = "shipmentLogId", value = "订单id", required = true)
            @RequestParam(value = "shipmentLogId", required = true) String shipmentLogId,

+ 267 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -17,6 +17,9 @@ import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.equipment.WlyyUserAreaDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.platform.IotInterfaceLogDO;
import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.sms.dao.HospitalSysDictDao;
import com.yihu.jw.util.common.LatitudeUtils;
@ -32,6 +35,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
@ -49,7 +53,8 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    @Autowired
    private MediicineDeviceDao deviceDao;
    @Autowired
    private MedicineShipmentLogDao shipmentLogDao;
    @Autowired
    private MediicineDeviceUserDao deviceUserDao;
@ -103,7 +108,268 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    private HospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private MedicineOrderService medicineOrderService;
    @Autowired
    private MedicinePatientLogDao medicinePatientLogDao;
    /**
     * 保存接口调用日志
     * @param paramsMap 入参
     * @param response 出参
     * @param url
     * @param state 调用状态
     */
    public void saveLog(Map<String,String> paramsMap,String response, String url, Integer state, String methodType, String methodName,Long reqTime){
        try {
            JSONObject resJson = JSONObject.parseObject(response);
            if(url.contains("updateOrderOutStatus")){
                if("success".equals(resJson.getString("message"))){
                    return;
                }
            }else if(resJson.containsKey("status")&&resJson.getInteger("status")==200){
                return;
            }
            String msg = resJson.containsKey("msg")?resJson.getString("msg"):resJson.getString("message");
            MedicinePatientLog log = new MedicinePatientLog();
            log.setMethodUrl(url);
            log.setReq(JSONObject.toJSONString(paramsMap));
            if(!StringUtils.isEmpty(response)){
                if (response.length() > 20000) {
                    response = response.substring(0, 20000);
                }
            }
            if(!StringUtils.isEmpty(msg)){
                if (msg.length() > 20000) {
                    msg = msg.substring(0, 20000);
                }
            }
            String cardNo = null;
            String idcard = null;
            String equNum = null;
            String orgCode = null;
            String name = null;
            if(paramsMap.containsKey("cardNo")){
                cardNo = paramsMap.get("cardNo");
            }
            if(paramsMap.containsKey("cardNum")){
                cardNo = paramsMap.get("cardNum");
            }
            if(paramsMap.containsKey("ssc")){
                cardNo = paramsMap.get("ssc");
            }
            if(paramsMap.containsKey("idcard")){
                idcard = paramsMap.get("idcard");
            }
            if(paramsMap.containsKey("equ_num")){
                equNum = paramsMap.get("equ_num");
            }
            if(paramsMap.containsKey("orgCode")){
                orgCode = paramsMap.get("orgCode");
            }
            if(paramsMap.containsKey("patientName")){
                name = paramsMap.get("patientName");
            }
            if(paramsMap.containsKey("userName")){
                name = paramsMap.get("userName");
            }
            String deviceId = paramsMap.get("deviceId");
            if(!StringUtils.isEmpty(deviceId)){
                Mediicinedevice mediicinedevice = deviceDao.findMediicinedeviceByEquNum(deviceId);
                if(mediicinedevice!=null){
                    equNum = mediicinedevice.getEquNum();
                    orgCode = mediicinedevice.getBelongCommunity();
                }
            }
            String shipmentLogId = paramsMap.get("shipmentLogId");
            if(!StringUtils.isEmpty(shipmentLogId)){
                MedicineShipmentLog medicineShipmentLog = shipmentLogDao.findOne(shipmentLogId);
                equNum = medicineShipmentLog.getEquNum();
                orgCode = medicineShipmentLog.getOrgCode();
            }
            log.setCardNo(cardNo);
            log.setIdcard(idcard);
            log.setEquNum(equNum);
            log.setOrgCode(orgCode);
            log.setName(name);
            log.setError(msg);
            log.setRes(response);
            log.setStatus(state);
            log.setMethodType(methodType);
            log.setMethodName(methodName);
            log.setReqTime(reqTime);
            log.setCreateTime(DateUtil.getNowDate());
            medicinePatientLogDao.save(log);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    //居民请求运行日志
    public PageEnvelop patientReqLogPage(Integer page,Integer size,String name,String orgCode,String methodType,String startTime,String endTime){
        String sql = "SELECT l.equ_num equNum,l.org_code orgCode,if(d1.id is null,d2.community,d1.community) orgName " +
                ",l.method_name methodName,l.method_type methodType,l.card_no cardNo,l.idcard,l.`name`,l.error,l.req_time reqTime " +
                ",DATE_FORMAT(l.create_time,'%Y-%m-%d %H:%i:%S') createTime ";
        String countSql = "select count(l.id)  ";
        String filter = " from t_medicine_patient_log l " +
                " LEFT JOIN t_mediicine_device d1 on d1.equ_num=l.equ_num " +
                " LEFT JOIN t_mediicine_device d2 on d2.belong_community=l.org_code" +
                " where 1=1";
        if(!StringUtils.isEmpty(name)){
            filter += " and (l.equ_num like '%"+name+"%' or d1.community like '%"+name+"%'or d2.community like '%"+name+"%')";
        }
        if(!StringUtils.isEmpty(orgCode)){
            filter += " l.org_code='"+orgCode+"' ";
        }
        if(!StringUtils.isEmpty(methodType)){
            filter += " l.method_type='"+methodType+"' ";
        }
        if(!StringUtils.isEmpty(startTime)){
            filter += " l.create_time>='"+startTime+"' ";
        }
        if(!StringUtils.isEmpty(endTime)){
            filter += " l.create_time<='"+endTime+" 23:59:59' ";
        }
        String orderBy = " order by l.id desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //货道信息列表
    public PageEnvelop cabinetInventoryPage(Integer page,Integer size,String idDevice,String startTime,String endTime){
        String sql = "select id,id_device idDevice,state,num,layer_no layerNo,wayer_no wayerNo,qty,drug_name drugName" +
                ",cargo_capacity cargoCapacity,shelf_status shelfStatus,cargo_state cargoState,fault_state faultState" +
                ",if(fault_state='1','故障',if(fault_state='0','正常','')) faultStateNam,if(cargo_state='1','开启',if(cargo_state='0','关闭','')) cargoStateName" +
                ",if(shelf_status='1','上架',if(shelf_status='0','下架','')) shelfStatusName";
        String countSql = "select count(id) ";
        String filter = " from t_mediicinecabinet_inventory where id_device='"+idDevice+"' ";
        if(!StringUtils.isEmpty(startTime)){
            filter += " and update_time>='"+startTime+"'";
        }
        if(!StringUtils.isEmpty(endTime)){
            filter += " and end_time>='"+endTime+"'";
        }
        String orderBy = " order by fault_state desc,update_time desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //设备货道信息列表
    public PageEnvelop deviceCabinetInventoryPage(Integer page,Integer size,String name,String orgCode,String networkStatus){
        String sql = " SELECT a.*,CONCAT(FORMAT(((a.normalCargoNumber-a.usedCargoNumber) / a.normalCargoNumber) * 100, 2),'%') kongzhilv " +
                ",(a.normalCargoNumber  - a.alreadySetDrugNumber) noSetDrugCargoNumber " +
                ",(a.normalOpenCargoCapacity - a.usedCargoCapacity) noUsedCargoCapacity  " ;
        String countSql = "select count(a.id)";
        String filter = " from ( " +
                "SELECT DISTINCT t.id,t.community,t.equ_num equNum,t.network_status,t.sale_status saleStatus,t.status " +
                ",if(t.status='1','不缺货',if(t.status='0','缺货','')) statusName " +
                ",if(t.network_status='1','在线',if(t.network_status='0','离线','')) networkStatusName " +
                ",if(t.sale_status='1','在售',if(t.sale_status='2','停售',if(t.sale_status='3','故障',''))) saleStatusName " +
                ",t.layer,t.aisles,SUM(if(i.cargo_state='1' and i.fault_state='0',i.cargo_capacity,0)) normalOpenCargoCapacity " +
                ",SUM(if(i.cargo_state='1' and i.fault_state='0',i.qty,0)) usedCargoCapacity " +
                ",sum(if(i.shelf_status = '1',i.qty,0)) inStock " +
                ",COUNT(if(i.cargo_state='1' and i.fault_state='0',i.id,null)) normalCargoNumber " +
                ",COUNT(if(i.cargo_state='1' and i.fault_state='0' and i.org_code is not null and i.drug_code is not null,i.id,null)) alreadySetDrugNumber " +
                ",COUNT(if(i.cargo_state='1' and i.fault_state='0' and i.org_code is not null and i.drug_code is not null and i.qty>0,i.id,null)) usedCargoNumber " +
                ",COUNT(if(i.cargo_state='1',i.id,null)) openCount,COUNT(if(i.cargo_state!='1',i.id,null)) closeCount " +
                ",COUNT(if(i.fault_state='1',i.id,null)) faultCount " +
                ",COUNT(if(i.fault_state='1' and i.update_time>'2025-01-01' ,i.id,null)) addFaultCount " +
                ",DATE_FORMAT(t.log_time,'%Y-%m-%d %H:%i:%S') logTime " +
                " from t_mediicine_device t " +
                "LEFT JOIN t_mediicinecabinet_inventory i on i.id_device = t.id and (i.state = '1' OR i.state = '21') " +
                "WHERE t.del=1 and t.belong_community is not null  ";
        if(!StringUtils.isEmpty(name)){
            filter += " and (t.equ_name like '%"+name+"%' or t.equ_num like '%"+name+"%')";
        }
        if(!StringUtils.isEmpty(orgCode)){
            filter += " and t.belong_community='"+orgCode+"'";
        }
        if(!StringUtils.isEmpty(networkStatus)){
            filter += " and t.network_status='"+networkStatus+"'";
        }
        filter += "GROUP BY t.id ) a ";
        String orderBy = " limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //温湿度信息列表
    public PageEnvelop temperatureHumidityInfoPage(Integer page,Integer size,String name,String orgCode,String temperatureStatus,String humidityStatus){
        String sql = "SELECT t.id,t.community,t.equ_name equName,t.equ_num equNum,t.delivery_address deliveryAddress " +
                ",t.now_temperature nowTemperature,t.now_humidity nowHumidity,t.abnormal,DATE_FORMAT(t.log_time,'%Y-%m-%d %H:%i:%S')  logTime ";
        String countSql = "select count(t.id)";
        String filter = " from t_mediicine_device t " +
                " WHERE t.del=1 and t.belong_community is not null ";
        if(!StringUtils.isEmpty(name)){
            filter += " and (t.equ_name like '%"+name+"%' or t.equ_num like '%"+name+"%')";
        }
        if(!StringUtils.isEmpty(orgCode)){
            filter += " and t.belong_community='"+orgCode+"'";
        }
        if("1".equals(temperatureStatus)){
            //正常
            filter += " and (t.temperaturecontrol!='1' or t.now_temperature is null or " +
                    " ( t.now_temperature <= t.waring_temperature_height and t.now_temperature >= t.waring_temperature_low))";
        }
        if("2".equals(temperatureStatus)){
            //异常
            filter += " and t.temperaturecontrol='1' and (t.now_temperature>t.waring_temperature_height or t.now_temperature<t.waring_temperature_low)";
        }
        if("1".equals(humidityStatus)){
            //正常
            filter += " and (t.humiditycontrol!='1' or t.now_humidity is null or " +
                    " ( t.now_humidity <= t.waring_humidity_height and t.now_humidity >= t.waring_humidity_low))";
        }
        if("2".equals(humidityStatus)){
            //异常
            filter += " and t.humiditycontrol='1' and (t.now_humidity>t.waring_humidity_height or t.now_humidity<t.waring_humidity_low)";
        }
        String orderBy = " limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //温湿度日志列表
    public PageEnvelop temperatureHumidityWarrayPage(Integer page,Integer size,String startTime,String endTime,String temperatureEnd
            ,String temperatureStart,String humidityStart,String humidityEnd,String equNum){
        String sql = "SELECT t.temperature,t.humidity,DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') createTime,t.type ";
        String countSql = "select count(t.id)";
        String filter = "  from t_mediicine_warray t " +
                "WHERE t.other_couont is NULL and t.equ_num='"+equNum+"' ";
        if(!StringUtils.isEmpty(startTime)){
            filter += " and t.create_time>='"+startTime+"'";
        }
        if(!StringUtils.isEmpty(endTime)){
            endTime = endTime.length()==10?endTime+" 23:59:59":endTime;
            filter += " and t.create_time<='"+endTime+"'";
        }
        if(!StringUtils.isEmpty(temperatureEnd)){
            filter += " and t.temperature<="+temperatureEnd;
        }
        if(!StringUtils.isEmpty(temperatureStart)){
            filter += " and t.temperature>="+temperatureStart;
        }
        if(!StringUtils.isEmpty(humidityStart)){
            filter += " and t.humidity>="+humidityStart;
        }
        if(!StringUtils.isEmpty(humidityEnd)){
            filter += " and t.humidity>="+humidityEnd;
        }
        String orderBy = " limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    /**