Browse Source

货道故障状态更新

bing 2 years ago
parent
commit
6b6a07c56f

+ 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";

+ 14 - 0
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 = "分页查询设备列表")

+ 93 - 69
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();