Sfoglia il codice sorgente

Merge branch 'medicare' of liubing/wlyy2.0 into medicare

liubing 2 anni fa
parent
commit
a0e761f7c8

+ 18 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/team/service/WlyyAdminTeamService.java

@ -16,6 +16,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Comparator;
@ -37,20 +39,31 @@ public class WlyyAdminTeamService {
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseTownDao baseTownDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    //查询机构
    public MixEnvelop findHospitalByTown(String townCode,String name,Integer page,Integer pageSize){
        PageRequest pageRequest = new PageRequest(page-1,pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        List<DmHospitalDO> list =null;
        if (StringUtils.isNoneBlank(name)){
            list=hospitalDao.findByTownCodeAndName(townCode,name,pageRequest);
        }else {
            list = hospitalDao.findByTownCode(townCode,pageRequest);
        String sql = " select t.* from dm_hospital t inner join t_mediicine_device de on t.code = de.belong_community where t.del='1' and de.del=1  ";
        String sqlCount =  " select count(distinct t.id) from dm_hospital t inner join t_mediicine_device de on t.code = de.belong_community where t.del='1' and de.del=1 ";
        String sqlWhere =  "  ";
        if (StringUtils.isNotBlank(townCode)){
            sqlWhere += " and t.town='"+townCode+"' ";
        }
        if (StringUtils.isNotBlank(name)){
            sqlWhere += " and t.name like '%"+name+"%' ";
        }
        sql +=sqlWhere +" group by t.code order by t.code asc limit "+(page-1)*pageSize+","+pageSize;
        list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DmHospitalDO.class));
        Integer count = jdbcTemplate.queryForObject(sqlCount+sqlWhere,Integer.class);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setTotalCount(list==null?0:list.size());
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
    //查询团队

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -200,6 +200,7 @@ public class BaseRequestMapping {
        public static final String UNBINDDEVICE  = "/unbindDevice";
        public static final String mergeAndSplitCargo  = "/mergeAndSplitCargo";
        public static final String openAndCloseCargo  = "/openAndCloseCargo";
        public static final String updateDeviceCargoStateApp  = "/updateDeviceCargoStateApp";
        public static final String getDevicesByReplenishEr  = "/getDevicesByReplenishEr";
        public static final String getDeviceListByUserId  = "/getDeviceListByUserId";
        public static final String getDeviceListWithUserId  = "/getDeviceListWithUserId";

+ 24 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -319,6 +319,20 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(jsonObject.getString("response"));
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.updateDeviceCargoStateApp)
    @ApiOperation(value = "设备货道的故障状态")
    public Envelop updateDeviceCargoStateApp(
            @ApiParam(name = "cargoIds", value = "货道Id字符串", required = true)
            @RequestParam(value = "cargoIds") String cargoIds,
            @ApiParam(name = "faultState", value = "货道故障状态,1故障,0正常", required = true)
            @RequestParam(value = "faultState") String faultState) throws Exception {
        if( deviceService.updateDeviceCargoStateApp(cargoIds, faultState)){
            return success("货道修改成功");
        }else {
            return failed("货道修改失败");
        }
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDeviceListByPage)
    @ApiOperation(value = "分页查询设备列表")
@ -951,13 +965,17 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    public Envelop getShippingTypeByUserId(
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "startTime", value = "开始时间", required = false)
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = false)
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "userId", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "level", value = "1、市级、2、区级、3、社区", required = false)
            @RequestParam(value = "level",required = false) Integer level,
            @ApiParam(name = "area", value = "1、市级、2、区级、3、社区", required = false)
            @RequestParam(value = "area",required = false) String area) throws Exception {
        return success(deviceService.getShippingTypeByUserId(userId, day,level,area));
        return success(deviceService.getShippingTypeByUserId(userId, day,startTime,endTime,level,area));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getPrescriptionStaticsByUserId)
@ -965,13 +983,17 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    public Envelop getPrescriptionStaticsByUserId(
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "startTime", value = "开始时间", required = false)
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = false)
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "userId", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "level", value = "1、市级、2、区级、3、社区", required = false)
            @RequestParam(value = "level",required = false) Integer level,
            @ApiParam(name = "area", value = "1、市级、2、区级、3、社区", required = false)
            @RequestParam(value = "area",required = false) String area) throws Exception {
        return success(deviceService.getPrescriptionStaticsByUserId(userId, day,level,area));
        return success(deviceService.getPrescriptionStaticsByUserId(userId, day,startTime,endTime,level,area));
    }
    @GetMapping("/open/setDeviceAttribute")

+ 115 - 75
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -776,13 +776,12 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        String deviceID = "";
        //true,标识当前操作为合并货道操作
        MedicineDrugInventoryRecord inventoryModifyRecord = null;
        boolean modifyRecordFlag = false;
        List<String> mergeCargoS = new ArrayList<>();
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoIds)){
            modifyRecordFlag = true;
            inventoryModifyRecord = new MedicineDrugInventoryRecord();
        /**货到状态操作日志**/
        if (isMerge) {//合并
            MedicineDrugInventoryRecord  inventoryModifyRecord = new MedicineDrugInventoryRecord();
            inventoryModifyRecord.setOldDrugId(null);
            inventoryModifyRecord.setDrugId(null);
            inventoryModifyRecord.setMergeState(isMerge?"2":"1");
@ -791,10 +790,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            inventoryModifyRecord.setCreateUser(userId);
            inventoryModifyRecord.setCreateTime(new Date());
            inventoryModifyRecord.setType("5");
        }
        /**货到状态操作日志**/
        if (isMerge) {
            String[] cargoIdArray = cargoIds.split(",");
            changedCargoNumber = cargoIdArray.length - 1;
            //合并的所有货道列编号--->集合
@ -814,12 +810,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                if(!StringUtils.isEmpty(cargoId)){
                    MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
                    mergeCargoS.add(inventory.getWayerNo());
                    if (modifyRecordFlag){
                        inventoryModifyRecord.setDeviceId(inventory.getIdDevice());
                        inventoryModifyRecord.setEquNum(inventory.getEquNum());
                        inventoryModifyRecord.setLayerNo(inventory.getLayerNo());
                        inventoryModifyRecord.setWayerNo(inventory.getWayerNo());
                    }
                    inventoryModifyRecord.setDeviceId(inventory.getIdDevice());
                    inventoryModifyRecord.setEquNum(inventory.getEquNum());
                    inventoryModifyRecord.setLayerNo(inventory.getLayerNo());
                    inventoryModifyRecord.setWayerNo(inventory.getWayerNo());
                    //有药品记录下架操作
                    if (inventory.getOrgCode() != null && inventory.getDrugCode() != null) {
@ -866,62 +861,78 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    inventoryDao.save(inventory);
                }
            }
            inventoryModifyRecord.setMergeCargo(mergeCargoS.stream().map(String::valueOf).collect(Collectors.joining(",")));
            inventoryRecordDao.save(inventoryModifyRecord);
        } else {
            MediicinecabinetInventory inventory = inventoryDao.findOne(cargoIds);
            mergeCargoS.add(inventory.getWayerNo());
            if (modifyRecordFlag){
            //多个拆分
            String[] cargoIdArray = cargoIds.split(",");
            List<MedicineDrugInventoryRecord> inventoryModifyRecords = new ArrayList<>();
            for (String cargoIdTmp:cargoIdArray){
                MediicinecabinetInventory inventory = inventoryDao.findOne(cargoIdTmp);
                //所有有关分解的货道列表
                List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByIdDeviceAndLayerNoAndMerge(inventory.getIdDevice(),inventory.getLayerNo(), inventory.getMerge());
                MedicineDrugInventoryRecord inventoryModifyRecord = new MedicineDrugInventoryRecord();
                inventoryModifyRecord.setOldDrugId(null);
                inventoryModifyRecord.setDrugId(null);
                inventoryModifyRecord.setMergeState(isMerge?"2":"1");
                inventoryModifyRecord.setOldQuantity(null);
                inventoryModifyRecord.setQuantity(null);
                inventoryModifyRecord.setCreateUser(userId);
                inventoryModifyRecord.setCreateTime(new Date());
                inventoryModifyRecord.setType("5");
                inventoryModifyRecord.setDeviceId(inventory.getIdDevice());
                inventoryModifyRecord.setEquNum(inventory.getEquNum());
                inventoryModifyRecord.setLayerNo(inventory.getLayerNo());
                inventoryModifyRecord.setWayerNo(inventory.getWayerNo());
            }
            //所有有关分解的货道列表
            List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByIdDeviceAndLayerNoAndMerge(inventory.getIdDevice(),inventory.getLayerNo(), inventory.getMerge());
            changedCargoNumber = list.size() - 1;
            //主货道拆解
            inventory.setMerge(inventory.getWayerNo());
            //有药品记录下架操作
            if (inventory.getOrgCode() != null && inventory.getDrugCode() != null) {
                MedicineDrugInventoryRecord inventoryRecord = new MedicineDrugInventoryRecord();
                inventoryRecord.setDeviceId(inventory.getIdDevice());
                inventoryRecord.setEquNum(inventory.getEquNum());
                inventoryRecord.setOldDrugId(inventory.getDrugId());
                inventoryRecord.setDrugId(inventory.getDrugId());
                inventoryRecord.setLayerNo(inventory.getLayerNo());
                inventoryRecord.setWayerNo(inventory.getWayerNo());
                inventoryRecord.setMergeState(inventory.getState());
                inventoryRecord.setMergeCargo(inventory.getMerge());
                inventoryRecord.setOldQuantity(inventory.getQty());
                inventoryRecord.setQuantity("0");
                inventoryRecord.setCreateUser(userId);
                inventoryRecord.setType("4");
                inventoryRecordDao.save(inventoryRecord);
            }
            deviceID = inventory.getIdDevice();
            //清空药品
            inventory.setQty("0");
            inventory.setDrugName(null);
            inventory.setDrugCode(null);
            inventory.setOrgCode(null);
            inventory.setPrice(null);
            //bug:13630,新增
            inventory.setShelfStatus("0");
            //额定库存
            inventory.setRatedInventory(0);
            //清空药品
            inventory.setState("1");
            inventoryDao.save(inventory);
            boolean jumpFirst = false;
            for (MediicinecabinetInventory mediicinecabinetInventory : list) {
                if(jumpFirst) {
                    changedCapacity += Integer.parseInt(mediicinecabinetInventory.getCargoCapacity());
                List<String> mergeCargos = list.stream().map(MediicinecabinetInventory::getWayerNo).collect(Collectors.toList());
                inventoryModifyRecord.setMergeCargo(mergeCargos.stream().map(String::valueOf).collect(Collectors.joining("','")));
                inventoryModifyRecords.add(inventoryModifyRecord);
                changedCargoNumber += list.size() - 1;
                //主货道拆解
                inventory.setMerge(inventory.getWayerNo());
                //有药品记录下架操作
                if (inventory.getOrgCode() != null && inventory.getDrugCode() != null) {
                    MedicineDrugInventoryRecord inventoryRecord = new MedicineDrugInventoryRecord();
                    inventoryRecord.setDeviceId(inventory.getIdDevice());
                    inventoryRecord.setEquNum(inventory.getEquNum());
                    inventoryRecord.setOldDrugId(inventory.getDrugId());
                    inventoryRecord.setDrugId(inventory.getDrugId());
                    inventoryRecord.setLayerNo(inventory.getLayerNo());
                    inventoryRecord.setWayerNo(inventory.getWayerNo());
                    inventoryRecord.setMergeState(inventory.getState());
                    inventoryRecord.setMergeCargo(inventory.getMerge());
                    inventoryRecord.setOldQuantity(inventory.getQty());
                    inventoryRecord.setQuantity("0");
                    inventoryRecord.setCreateUser(userId);
                    inventoryRecord.setType("4");
                    inventoryRecordDao.save(inventoryRecord);
                }
                deviceID = inventory.getIdDevice();
                //清空药品
                inventory.setQty("0");
                inventory.setDrugName(null);
                inventory.setDrugCode(null);
                inventory.setOrgCode(null);
                inventory.setPrice(null);
                //bug:13630,新增
                inventory.setShelfStatus("0");
                //额定库存
                inventory.setRatedInventory(0);
                //清空药品
                inventory.setState("1");
                inventoryDao.save(inventory);
                boolean jumpFirst = false;
                for (MediicinecabinetInventory mediicinecabinetInventory : list) {
                    if(jumpFirst) {
                        changedCapacity += Integer.parseInt(mediicinecabinetInventory.getCargoCapacity());
                    }
                    jumpFirst = true;
                    mediicinecabinetInventory.setMerge(mediicinecabinetInventory.getWayerNo());
                    mediicinecabinetInventory.setState("1");
                    inventoryDao.save(mediicinecabinetInventory);
                }
                jumpFirst = true;
                mediicinecabinetInventory.setMerge(mediicinecabinetInventory.getWayerNo());
                mediicinecabinetInventory.setState("1");
                inventoryDao.save(mediicinecabinetInventory);
            }
        }
        //计算货道数和货道容量
@ -937,10 +948,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            }
            deviceDao.save(mediicinedevice);
        }
        if (null!=inventoryModifyRecord){
            inventoryModifyRecord.setMergeCargo(mergeCargoS.stream().map(String::valueOf).collect(Collectors.joining(",")));
            inventoryRecordDao.save(inventoryModifyRecord);
        }
        result.put("response",ConstantUtils.SUCCESS);
        return result.toJSONString();
    }
@ -1016,6 +1024,22 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        return result.toJSONString();
    }
    /**
     * 货道故障状态更改
     * @param cargoIds
     * @param faultState
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean updateDeviceCargoStateApp(String cargoIds, String faultState){
        JSONObject result = new JSONObject();
        StringBuilder cargoIdsSql = new StringBuilder("");
        cargoIdsSql.append(" and a.category_code in ('").append(cargoIds.replace(",","','")).append("')");
        String sql = " update t_mediicinecabinet_inventory set fault_state='"+faultState+"' where id in ("+cargoIdsSql+") ";
        jdbcTemplate.execute(sql);
        return true;
    }
//    public String updateDeviceInventoryNum(String cargoIds, String cargoState){
//        JSONObject result = new JSONObject();
@ -6289,11 +6313,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        jsonObject.put("maintain", maintain);
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1,level,area));
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1,null,null,level,area));
        //非设备管理员
        if (!"replenisher".equals(role.getCode())) {
            jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(userId, 1,level,area));
            jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1,level,area));
            jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1,null,null,level,area));
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
@ -6457,7 +6481,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param userId
     * @return
     */
    public JSONObject getShippingTypeByUserId(String userId,Integer day,Integer level,String area){
    public JSONObject getShippingTypeByUserId(String userId,Integer day,String startTime,String endTime,Integer level,String area){
        JSONObject object = new JSONObject();
        String condition = "";
        String areaCondition = "";
@ -6547,9 +6571,17 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            } else {
                startDate = DateUtil.getPreDays(new Date(), -day);
            }
            String endTime = DateUtil.getStringDate();
            endTime = DateUtil.getStringDate();
            timeCondition = " and o.shipping_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.shipping_time <= '" + endTime + "'  ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(startTime)){
            timeCondition = " and o.create_time >='" + startTime + "' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(endTime)){
            timeCondition += " and o.create_time <= '" + endTime + "'  ";
        }
        String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition+ areaCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;
@ -6592,7 +6624,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param day
     * @return
     */
    public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day,Integer level,String area){
    public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day,String startTime,String endTime,Integer level,String area){
        JSONObject object = new JSONObject();
        String condition = "";
        UserDO user = userDao.findOne(userId);
@ -6682,9 +6714,17 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            } else {
                startDate = DateUtil.getPreDays(new Date(), -day);
            }
            String endTime = DateUtil.getStringDate();
            endTime = DateUtil.getStringDate();
            timeCondition = " and o.create_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.create_time <= '" + endTime + "'  ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(startTime)){
            timeCondition = " and o.create_time >='" + startTime + "' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(endTime)){
            timeCondition += " and o.create_time <= '" + endTime + "'  ";
        }
        String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition+areaCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;