소스 검색

货道合并分解,都清空药品,有药品的清空做下架操作记录

wangzhinan 3 년 전
부모
커밋
c36278d584

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

@ -291,8 +291,10 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "cargoIds", value = "货道Id字符串", required = true)
            @RequestParam(value = "cargoIds") String cargoIds,
            @ApiParam(name = "isMerge", value = "是否合并,true 合并,false分离", required = true)
            @RequestParam(value = "isMerge") Boolean isMerge) throws Exception {
        String str = deviceService.mergeAndSplitCargo(cargoIds, isMerge);
            @RequestParam(value = "isMerge") Boolean isMerge,
            @ApiParam(name = "userId", value = "用户id", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        String str = deviceService.mergeAndSplitCargo(cargoIds, isMerge, userId);
        JSONObject jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));

+ 67 - 28
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -737,7 +737,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param isMerge
     * @return
     */
    public String mergeAndSplitCargo(String cargoIds, Boolean isMerge){
    public String mergeAndSplitCargo(String cargoIds, Boolean isMerge, String userId){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(cargoIds)){
            result.put("msg","cargoIds is null");
@ -748,12 +748,13 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        String[] cargoIdsArray = cargoIds.split(",");
        String deviceID = "";
        //true,标识合并货道
        if (isMerge) {
            Boolean isFirst = true;
            //合并的所有货道集合
            String wayerNos = "";
            for (String deviceId : cargoIds.split(",")) {
                if(!StringUtils.isEmpty(deviceId)){
                    MediicinecabinetInventory inventory = inventoryDao.findOne(deviceId);
            for (String cargoId : cargoIds.split(",")) {
                if(!StringUtils.isEmpty(cargoId)){
                    MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
                    if (StringUtils.isEmpty(wayerNos)) {
                        wayerNos += inventory.getWayerNo();
                    }else {
@ -761,39 +762,50 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    }
                }
            }
            MediicinecabinetInventory copyInventory = new MediicinecabinetInventory();
            for (String deviceId : cargoIds.split(",")) {
                if(!StringUtils.isEmpty(deviceId)){
            boolean isFirst = true;
            for (String cargoId : cargoIds.split(",")) {
                if(!StringUtils.isEmpty(cargoId)){
                    MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
                    //有药品记录下架操作
                    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.setMerge(wayerNos);
                    //清空药品
                    inventory.setQty("0");
                    inventory.setDrugId(null);
                    inventory.setDrugName(null);
                    inventory.setDrugCode(null);
                    inventory.setOrgCode(null);
                    inventory.setPrice(null);
                    //额定库存
                    inventory.setRatedInventory(0);
                    //清空药品
                    if (isFirst) {
                        MediicinecabinetInventory inventory = inventoryDao.findOne(deviceId);
                        deviceID = inventory.getIdDevice();
                        copyInventory = inventory;
                        inventory.setMerge(wayerNos);
                        inventory.setState("21");
                        inventoryDao.save(inventory);
                        isFirst = false;
                    } else {
                        MediicinecabinetInventory inventory = inventoryDao.findOne(deviceId);
                        deviceID = inventory.getIdDevice();
                        inventory.setMerge(wayerNos);
//                        inventory.setCargoCapacity(copyInventory.getCargoCapacity());
//                        inventory.setState(copyInventory.getState());
//                        inventory.setNum(copyInventory.getNum());
//                        inventory.setShelfStatus(copyInventory.getShelfStatus());
                        inventory.setState("20");
                        //副货道内容操作-start-------》bug:13570
                        inventory.setQty("0");
                        inventory.setDrugName(null);
                        inventory.setDrugCode(null);
                        inventory.setOrgCode(null);
                        inventory.setPrice(null);
                        //额定库存
                        inventory.setRatedInventory(0);
                        inventory.setShelfStatus("0");
                        //内容操作end
                        inventoryDao.save(inventory);
                    }
                    inventoryDao.save(inventory);
                }
            }
        } else {
@ -801,6 +813,32 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            MediicinecabinetInventory inventory = inventoryDao.findOne(cargoIds);
            List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoriesByLayerNoAndMerge(inventory.getLayerNo(), inventory.getMerge());
            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);
            }
            //清空药品
            inventory.setQty("0");
            inventory.setDrugName(null);
            inventory.setDrugCode(null);
            inventory.setOrgCode(null);
            inventory.setPrice(null);
            //额定库存
            inventory.setRatedInventory(0);
            //清空药品
            inventory.setState("1");
            inventoryDao.save(inventory);
            for (MediicinecabinetInventory mediicinecabinetInventory : list) {
@ -818,6 +856,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
//                }
//            }
        }
        //重算货道数
        Mediicinedevice mediicinedevice = deviceDao.findOne(deviceID);
        if (mediicinedevice != null) {
            String tempSql = "SELECT\n" +