Browse Source

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

wangzhinan 3 years ago
parent
commit
de20cd859c

+ 42 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/InventoryDO.java

@ -0,0 +1,42 @@
package com.yihu.jw.entity.a1entity;
import java.io.Serializable;
public class InventoryDO implements Serializable {
    private String cargoId;
    private String drugId;
    private Integer qty;
    public InventoryDO() {
    }
    public String getCargoId() {
        return cargoId;
    }
    public void setCargoId(String cargoId) {
        this.cargoId = cargoId;
    }
    public String getDrugId() {
        return drugId;
    }
    public void setDrugId(String drugId) {
        this.drugId = drugId;
    }
    public Integer getQty() {
        return qty;
    }
    public void setQty(Integer qty) {
        this.qty = qty;
    }
}

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

@ -179,6 +179,7 @@ public class BaseRequestMapping {
        public static final String DOCINFO  = "/docInfo";
        public static final String CREATE  = "/create";
        public static final String setWarrayRule  = "/setWarrayRule";
        public static final String batchAddInventory  = "/batchAddInventory";
        public static final String getMedicineWarrayRuleByDeviceId  = "/getMedicineWarrayRuleByDeviceId";
        public static final String getDrugInventoryCount  = "/getDrugInventoryCount";
        public static final String CREATEADDRESS  = "/createAddress";

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -846,4 +846,20 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(deviceService.getDrugInventoryCount(content, lowerQty, upperQty, deviceId));
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.batchAddInventory)
    @ApiOperation(value = "批量补货")
    public Envelop batchAddInventory(
            @ApiParam(name = "list", value = "货道、药品、数量、json", required = true)
            @RequestParam(value = "list" ) String json,
            @ApiParam(name = "userId", value = "用户id", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        String str = deviceService.batchAddInventory(json, userId);
        JSONObject jsonObject = JSONObject.parseObject(str);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getString("response"));
    }
}

+ 54 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -4607,4 +4607,58 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        return collect;
    }
    @Transactional(rollbackFor = Exception.class)
    public String batchAddInventory(String json, String userId) throws Exception{
        JSONObject result = new JSONObject();
        JSONObject jsonObject = JSONObject.parseObject(json);
        JSONArray cargoList = jsonObject.getJSONArray("list");
        if (cargoList.size() == 0) {
            result.put("msg","list is empty");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        for (Object obj : cargoList) {
            InventoryDO inventoryDO = null;
            try {
                inventoryDO = objectMapper.readValue(obj.toString(), InventoryDO.class);
            } catch (IOException e) {
                result.put("msg", "convert org jsonObject to InventoryDO failed," + e.getCause());
                result.put("response", ConstantUtils.FAIL);
                return result.toJSONString();
            }
            //原货道信息
            MediicinecabinetInventory mediicinecabinetInventory = inventoryDao.findOne(inventoryDO.getCargoId());
            //没有药品跳过
            if (inventoryDO.getDrugId() == null || StringUtils.isEmpty(inventoryDO.getDrugId())) {
                if (mediicinecabinetInventory.getOrgCode() != null && !StringUtils.isEmpty(mediicinecabinetInventory.getOrgCode())
                        && mediicinecabinetInventory.getDrugCode() != null && !StringUtils.isEmpty(mediicinecabinetInventory.getDrugCode())) {
                    //下架商品
                    updateMediicinecabineInventoryInfoById(inventoryDO.getCargoId(), null, null, "0", userId);
                }
                continue;
            }
            if (mediicinecabinetInventory.getDrugCode() == null && mediicinecabinetInventory.getDrugCode() == null) {
                //新增药品
                updateMediicinecabineInventoryById(inventoryDO.getCargoId(), inventoryDO.getDrugId(), inventoryDO.getQty() + "", userId);
            } else {
                Mediicinedrugs mediicinedrugs = mediicinedrugsDao.findOne(inventoryDO.getDrugId());
                //更换前后药品相同
                if (mediicinecabinetInventory.getDrugCode().equals(mediicinedrugs.getDrugCode()) && mediicinecabinetInventory.getOrgCode().equals(mediicinedrugs.getOrgCode())) {
                    updateMediicinecabineInventoryInfoById(inventoryDO.getCargoId(), inventoryDO.getQty() + "", null, null, userId);
                } else {
                    //更换药品
                    updateMediicinecabineInventoryById(inventoryDO.getCargoId(), inventoryDO.getDrugId(), inventoryDO.getQty() + "", userId);
                }
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg", ConstantUtils.SUCCESS);
        return result.toJSONString();
    }
}