Sfoglia il codice sorgente

Merge branch 'dev' of chaoren1/wlyy2.0 into medicare

wangzhinan 3 anni fa
parent
commit
cda0a01ccf

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

@ -74,11 +74,13 @@ public class MedicineWarrayEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "startTime",required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = false, defaultValue = "")
            @RequestParam(value = "endTime",required = false) String endTime,
            @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 = warraytService.getTemperature(equNum, equType,networkStatus, lowT, heightT,lowH,heightH, content,startTime, endTime,page,size);
        JSONObject result = warraytService.getTemperature(equNum, equType,networkStatus, lowT, heightT,lowH,heightH, content,startTime, endTime,userId,page,size);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }
@ -124,11 +126,13 @@ public class MedicineWarrayEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "startTime",required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = false, defaultValue = "")
            @RequestParam(value = "endTime",required = false) String endTime,
            @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 = warraytService.getOffline(idDevice, equClass,networkStatus, content,startTime, endTime,page,size,wechatId);
        JSONObject result = warraytService.getOffline(idDevice, equClass,networkStatus, content,startTime, endTime,userId,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }
@ -147,11 +151,13 @@ public class MedicineWarrayEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "startTime",required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = false, defaultValue = "")
            @RequestParam(value = "endTime",required = false) String endTime,
            @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 = warraytService.getFault(idDevice, equClass,networkStatus,content,startTime, endTime,page,size,wechatId);
        JSONObject result = warraytService.getFault(idDevice, equClass,networkStatus,content,startTime, endTime,userId,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 7 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineStockUpService.java

@ -91,6 +91,13 @@ public class MedicineStockUpService extends BaseJpaService<Mediicinestockup, Med
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        for (UpDO upDO : list) {
            if (upDO != null && upDO.getDrugs().stream().filter(m -> m.getQty() <= 0).findAny().isPresent()) {
                result.put("msg", "药品申领数量为0不可生成备货单!");
                result.put("response", ConstantUtils.FAIL);
                return result;
            }
        }
        for (UpDO upDO : list) {
            Mediicinedevice mediicinedevice = deviceDao.findOne(upDO.getDeviceId());

+ 173 - 10
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineWarrayService.java

@ -7,10 +7,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.a2dao.MediicineDeviceDao;
import com.yihu.jw.base.dao.a2dao.MediicinestoreDao;
import com.yihu.jw.base.dao.a2dao.MediicinewarrayDao;
import com.yihu.jw.base.dao.role.RoleDao;
import com.yihu.jw.base.dao.user.UserDao;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.a1entity.Mediicinedevice;
import com.yihu.jw.entity.a1entity.Mediicinestore;
import com.yihu.jw.entity.a1entity.Mediicinewarray;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -41,7 +45,10 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
    @Autowired
    private MedicinedeviceService medicinedeviceService;
    @Autowired
    private UserDao userDao;
    @Autowired
    private RoleDao roleDao;
    @Autowired
    private HibenateUtils hibenateUtils;
@ -96,8 +103,60 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
    public JSONObject getTemperature(
            String equNum, String equType, String netStatus, String lowT, String heightT,String lowH,String heightH,
                String content, String startTime, String endTime, int page, int size) throws Exception {
                String content, String startTime, String endTime, String userId, int page, int size) throws Exception {
        JSONObject result = new JSONObject();
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        String belongCommunitys = "";
        String tempSql = "";
        //获取管理员所在社区code字符串
        {
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\tdh.`code` 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()) || "replenisher".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();
                    }
                }
            }
        }
        String conditionSql = "";
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
        }
        String sql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.belong_community as belongCommunity,\n" +
@ -138,9 +197,9 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
                "    t.update_user_name as updateUserName,\n" +
                "    t.remark as remark\n" +
                "FROM\n" +
                "    t_mediicine_warray AS t  where 1=1 and t.type like '%温度%' ";
                "    t_mediicine_warray AS t  where 1=1 and t.type like '%温度%'\n";
        String conditionSql = "";
//        conditionSql += " and t.type like '%温度%'";
@ -287,8 +346,60 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
    }
    public JSONObject getOffline(String equNum, String equClass, String netStatus, String content,
            String startTime, String endTime, int page, int size,String wechatId) throws Exception {
            String startTime, String endTime, String userId, int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        String belongCommunitys = "";
        String tempSql = "";
        //获取管理员所在社区code字符串
        {
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\tdh.`code` 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()) || "replenisher".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();
                    }
                }
            }
        }
        String conditionSql = "";
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
        }
        String sql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.belong_community as belongCommunity,\n" +
@ -329,9 +440,9 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
                "    t.update_user_name as updateUserName,\n" +
                "    t.remark as remark\n" +
                "FROM\n" +
                "    t_mediicine_warray AS t where 1=1";
                "    t_mediicine_warray AS t where 1=1\n";
        String conditionSql = "";
//        String conditionSql = "";
        conditionSql += " and t.type LIKE '%网络%'";
@ -373,8 +484,60 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
    public JSONObject getFault(
            String equNum, String equClass, String netStatus, String content,
            String startTime, String endTime, int page, int size,String wechatId) throws Exception {
            String startTime, String endTime, String userId, int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        String belongCommunitys = "";
        String tempSql = "";
        //获取管理员所在社区code字符串
        {
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\tdh.`code` 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()) || "replenisher".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();
                    }
                }
            }
        }
        String conditionSql = "";
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
        }
        String sql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.belong_community as belongCommunity,\n" +
@ -415,9 +578,9 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
                "    t.update_user_name as updateUserName,\n" +
                "    t.remark as remark\n" +
                "FROM\n" +
                "    t_mediicine_warray AS t where 1=1";
                "    t_mediicine_warray AS t where 1=1\n";
        String conditionSql = "";
//        String conditionSql = "";
        conditionSql += " and (t.type LIKE '%故障%' OR t.TYPE LIKE '%出货异常%')";

+ 24 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -793,6 +793,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    inventory.setDrugCode(null);
                    inventory.setOrgCode(null);
                    inventory.setPrice(null);
                    //bug:13630,新增
                    inventory.setShelfStatus("0");
                    //
                    //额定库存
                    inventory.setRatedInventory(0);
                    //清空药品
@ -836,6 +839,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            inventory.setDrugCode(null);
            inventory.setOrgCode(null);
            inventory.setPrice(null);
            //bug:13630,新增
            inventory.setShelfStatus("0");
            //
            //额定库存
            inventory.setRatedInventory(0);
            //清空药品
@ -4833,8 +4839,22 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        JSONObject jsonObject = JSONObject.parseObject(jsonRules);
        JSONArray ruleArray = jsonObject.getJSONArray("rules");
        if (ruleArray.size() == 0) {
            result.put("msg","rule is empty");
            result.put("response", ConstantUtils.FAIL);
            for (String equNum : equNums.split(",")) {
                if (!StringUtils.isEmpty(equNum)) {
                    List<MedicineWarrayRule> medicineWarrayRules = medicineWarrayRuleDao.findMedicineWarrayRulesByEquNumAndDel(equNum, 1);
                    for (MedicineWarrayRule medicineWarrayRule : medicineWarrayRules) {
                        medicineWarrayRule.setDel(0);
                        medicineWarrayRule.setUpdateTime(new Date());
                        medicineWarrayRule.setUpdateUser(userId);
                        medicineWarrayRuleDao.save(medicineWarrayRule);
                    }
                }
            }
//            result.put("msg","rule is empty");
//            result.put("response", ConstantUtils.FAIL);
//            return result.toJSONString();
            result.put("response", ConstantUtils.SUCCESS);
            result.put("msg", ConstantUtils.SUCCESS);
            return result.toJSONString();
        }
        List<RuleDO> ruleDOS = new ArrayList<>();
@ -5322,7 +5342,8 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            DecimalFormat df = new DecimalFormat("#.##");
            String rate = df.format(onlineTotal1/total1);
            Double rate1 = Double.parseDouble(rate)*100;
            onlineRate = rate1+"%";
            BigDecimal bigDecimal = new BigDecimal(rate1).setScale(2, BigDecimal.ROUND_HALF_UP);
            onlineRate = bigDecimal.toString()+"%";
        }
        Map<String, Object> overview = new HashMap<>();
        overview.put("total", total1);