|
@ -95,6 +95,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
@Autowired
|
|
|
private MedicineShipmentLogDao medicineShipmentLogDao;
|
|
|
|
|
|
@Autowired
|
|
|
private MedicineWarrayRuleDao medicineWarrayRuleDao;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 设备出货服务,创建设备,创建库存内容
|
|
@ -164,6 +168,8 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventory.setCargoState("1");
|
|
|
//设备初始化库存,默认货道是正常的
|
|
|
inventory.setFaultState("0");
|
|
|
//设备库存初始化,额定库存归0
|
|
|
inventory.setRatedInventory(0);
|
|
|
inventoryDao.save(inventory);
|
|
|
}
|
|
|
}
|
|
@ -695,6 +701,8 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventory.setNum("3");
|
|
|
inventory.setLongtime(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
//额定 库存归0
|
|
|
inventory.setRatedInventory(0);
|
|
|
inventoryDao.save(inventory);
|
|
|
}
|
|
|
}
|
|
@ -2913,6 +2921,100 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 通过设备id获取设备的缺货信息
|
|
|
* @param deviceId
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getOutOfStockInfoByDeviceWithPage(String deviceId, int page, int size) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "";
|
|
|
{
|
|
|
sql = "SELECT\n" +
|
|
|
"tmd.id AS id,\n" +
|
|
|
"tmd.approval_num AS approvalNum,\n" +
|
|
|
"tmd.barcode AS barcode,\n" +
|
|
|
"tmd.brand AS brand,\n" +
|
|
|
"tmd.dos_form AS dosForm,\n" +
|
|
|
"tmd.state AS state,\n" +
|
|
|
"tmd.drug_bar_code AS drugBarCode,\n" +
|
|
|
"tmd.drug_class AS drugClass,\n" +
|
|
|
"tmd.drug_class_code AS drugClassCode,\n" +
|
|
|
"tmd.drug_code AS drugCode,\n" +
|
|
|
"tmd.drug_name AS drugName,\n" +
|
|
|
"tmd.drug_name_alies AS drugNameAlies,\n" +
|
|
|
"tmd.drug_short_code AS drugShortCode,\n" +
|
|
|
"tmd.drug_type_code AS drugTypeCode,\n" +
|
|
|
"tmd.earlywarningcate AS earlywarningcate,\n" +
|
|
|
"tmd.inventory AS inventory,\n" +
|
|
|
"tmd.manufactor AS manufactor,\n" +
|
|
|
"tmd.med_cabinet AS medCabinet,\n" +
|
|
|
"tmd.pic AS pic,\n" +
|
|
|
"tmd.price AS price,\n" +
|
|
|
"tmd.sale_volume AS saleVolume,\n" +
|
|
|
"tmd.self_code AS selfCode,\n" +
|
|
|
"tmd.specif AS specif,\n" +
|
|
|
"tmd.unit AS unit,\n" +
|
|
|
"tmd.create_time AS createTime,\n" +
|
|
|
"tmd.create_user AS createUser,\n" +
|
|
|
"tmd.create_user_name AS createUserName,\n" +
|
|
|
"tmd.update_time AS updateTime,\n" +
|
|
|
"tmd.update_user AS updateUser,\n" +
|
|
|
"tmd.update_user_name AS updateUserName,\n" +
|
|
|
"tmd.drug_sku AS drugSku,\n" +
|
|
|
"tmd.drug_num AS drugNum,\n" +
|
|
|
"tmd.use_num AS useNum,\n" +
|
|
|
"tmd.use_way AS useWay,\n" +
|
|
|
"tmd.use_rate AS useRate,\n" +
|
|
|
"tmd.use_dose AS useDose,\n" +
|
|
|
"tmd.use_way_add AS useWayAdd,\n" +
|
|
|
"tmd.org_code AS orgCode,\n" +
|
|
|
"tmd.org_name AS orgName,\n" +
|
|
|
"tmd.quantity_unit AS quantityUnit,\n" +
|
|
|
"tmd.pack_unit AS packUnit,\n" +
|
|
|
"tmd.spell_code AS spellCode,\n" +
|
|
|
"\tsum(tmi.qty) AS qty,\n" +
|
|
|
"\t(\n" +
|
|
|
"\t\ttmi.rated_inventory - CAST(tmi.qty AS UNSIGNED)\n" +
|
|
|
"\t) AS daibukucun\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory tmi LEFT JOIN t_mediicine_drugs tmd ON tmi.drug_id = tmd.id\n" +
|
|
|
"WHERE" +
|
|
|
"\ttmi.id_device = '" + deviceId + "'\n" +
|
|
|
"AND CAST(tmi.qty as UNSIGNED) < tmi.rated_inventory\n" +
|
|
|
"AND tmi.drug_code IS NOT NULL\n" +
|
|
|
"AND tmi.org_code IS NOT NULL\n" +
|
|
|
"AND (tmi.state = 1 OR tmi.state = 21)\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"\ttmi.drug_code,\n" +
|
|
|
"\ttmi.org_code";
|
|
|
}
|
|
|
List<Map<String, Object>> list = null;
|
|
|
list = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
String countSql = "SELECT\n" +
|
|
|
"COUNT(DISTINCT(id))" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory\n" +
|
|
|
"WHERE" +
|
|
|
"\tid_device = '" + deviceId + "'\n" +
|
|
|
"AND CAST(qty as UNSIGNED) < rated_inventory\n" +
|
|
|
"AND drug_code IS NOT NULL\n" +
|
|
|
"AND org_code IS NOT NULL\n" +
|
|
|
"AND (state = 1 OR state = 21)\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"\tdrug_code,\n" +
|
|
|
"\torg_code";
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
|
|
|
result.put("count", count);
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取设备库存
|
|
|
* @param belongCommunity
|
|
@ -3496,7 +3598,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
public MediicinecabinetInventory updateMediicinecabineInventoryById(String id,String drugId,String qty,String userId) throws Exception {
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(id);
|
|
|
if (inventory==null){
|
|
@ -3547,9 +3649,15 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
cargoCapacityChanged = true;
|
|
|
inventory.setCargoCapacity(qty);
|
|
|
}
|
|
|
//设置额定库存
|
|
|
inventory.setRatedInventory(Integer.parseInt(qty));
|
|
|
|
|
|
inventoryDao.save(inventory);
|
|
|
//更改设备缺货状态
|
|
|
updateDeviceState(inventory.getId());
|
|
|
//重算设备容量
|
|
|
if (cargoCapacityChanged) {
|
|
|
//重算设备容量
|
|
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tsum(t.cargo_capacity)\n" +
|
|
@ -3561,6 +3669,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
mediicinedevice.setCapacity(String.valueOf(jdbcTemplate.queryForObject(tempSql, Integer.class)));
|
|
|
deviceDao.save(mediicinedevice);
|
|
|
}
|
|
|
|
|
|
return inventory;
|
|
|
}
|
|
|
|
|
@ -3573,6 +3682,95 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
return inventoryDao.findOne(id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新设备缺货状态,cargoId,货道id
|
|
|
* @param cargoId
|
|
|
*/
|
|
|
public void updateDeviceState(String cargoId) {
|
|
|
//包含原来药品信息
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
// List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoriesByIdDeviceAndStateInAndDrugCodeNotNullAndAndOrgCodeNotNull(inventory.getIdDevice(), new String[]{"1", "21"});
|
|
|
List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeCondition(inventory.getIdDevice(), new String[]{"1", "21"});
|
|
|
// //药品变更
|
|
|
// if (drugChanged) {
|
|
|
// //变更的目标药品
|
|
|
// Mediicinedrugs mediicinedrugs = mediicinedrugsDao.findOne(drugId);
|
|
|
// Iterator<Map<String, Object>> it = collect.iterator();
|
|
|
// //剔除旧药品的数量
|
|
|
// while (it.hasNext()) {
|
|
|
// Map<String, Object> stringObjectMap = it.next();
|
|
|
// if (String.valueOf(stringObjectMap.get("drugCode")).equals(inventory.getDrugCode()) &&
|
|
|
// String.valueOf(stringObjectMap.get("orgCode")).equals(inventory.getOrgCode())) {
|
|
|
// //说明只有一个货道是该种药品
|
|
|
// if (Integer.parseInt(stringObjectMap.get("qty") + "") - Integer.parseInt(inventory.getQty()) == 0) {
|
|
|
// it.remove();
|
|
|
// } else {
|
|
|
// stringObjectMap.put("qty", String.valueOf(Integer.parseInt(stringObjectMap.get("qty") + "") - Integer.parseInt(inventory.getQty())));
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// //
|
|
|
// Map<String, Object> tempMap = new HashMap<>();
|
|
|
// tempMap.put("drugCode", mediicinedrugs.getDrugCode());
|
|
|
// tempMap.put("orgCode", mediicinedrugs.getOrgCode());
|
|
|
// tempMap.put("qty", qty);
|
|
|
// tempMap.put("ratedInventory", Integer.parseInt(qty));
|
|
|
// collect.add(tempMap);
|
|
|
// } else {
|
|
|
// //数量变更
|
|
|
// if (qtyChanged) {
|
|
|
// Iterator<Map<String, Object>> it = collect.iterator();
|
|
|
// while (it.hasNext()) {
|
|
|
// Map<String, Object> stringObjectMap = it.next();
|
|
|
// if (String.valueOf(stringObjectMap.get("drugCode")).equals(inventory.getDrugCode()) &&
|
|
|
// String.valueOf(stringObjectMap.get("orgCode")).equals(inventory.getOrgCode())) {
|
|
|
// //下架
|
|
|
// if ("0".equals(qty)) {
|
|
|
// it.remove();
|
|
|
// }
|
|
|
//
|
|
|
// if (Integer.parseInt(qty) > Integer.parseInt(inventory.getQty())) {
|
|
|
// stringObjectMap.put("qty", qty);
|
|
|
// stringObjectMap.put("ratedInventory", Integer.parseInt(qty));
|
|
|
// } else if (Integer.parseInt(qty) < Integer.parseInt(inventory.getQty())) {
|
|
|
// it.remove();
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
//该设备库存预警规则
|
|
|
List<MedicineWarrayRule> rules = medicineWarrayRuleDao.findMedicineWarrayRulesByEquNumAndDel(inventory.getEquNum(), 1);
|
|
|
//不缺货
|
|
|
mediicinedevice.setStatus("1");
|
|
|
quit:for (MedicineWarrayRule rule : rules) {
|
|
|
for (Map<String, Object> stringObjectMap : collect) {
|
|
|
Integer ratedInventory = Integer.parseInt(stringObjectMap.get("ratedInventory") + "");
|
|
|
if (ratedInventory > rule.getLower() && ratedInventory < rule.getUpper()) {
|
|
|
Integer tempQty = Integer.parseInt(stringObjectMap.get("qty") + "");
|
|
|
if ("%".equals(rule.getMatchUnit())) {
|
|
|
Integer matchValue = (int) Math.ceil((rule.getUpper() * rule.getMatchValue()) / 100.0);
|
|
|
if (tempQty <= matchValue) {
|
|
|
mediicinedevice.setStatus("0");
|
|
|
break quit;
|
|
|
}
|
|
|
}
|
|
|
if ("件".equals(rule.getMatchUnit())) {
|
|
|
if (tempQty <= rule.getMatchValue()) {
|
|
|
mediicinedevice.setStatus("0");
|
|
|
break quit;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
deviceDao.save(mediicinedevice);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 矫正库存\ 更新容量 \下架商品
|
|
@ -3611,18 +3809,24 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventory.setCargoCapacity(qty);
|
|
|
}
|
|
|
inventory.setQty(qty);
|
|
|
//设置额定库存
|
|
|
inventory.setRatedInventory(Integer.parseInt(qty));
|
|
|
}
|
|
|
//更改货道容量-start
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoCapacity)){
|
|
|
if (Integer.parseInt(cargoCapacity) > 99) {
|
|
|
throw new RuntimeException("货道容量最多99个,如超过请放置另一格");
|
|
|
throw new Exception("货道容量最多99个,如超过请放置另一格");
|
|
|
}
|
|
|
inventory.setCargoCapacity(cargoCapacity);
|
|
|
cargoCapacityChanged = true;
|
|
|
}
|
|
|
//更改货道容量-end
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
//下架时,清空库存
|
|
|
if ("0".equals(status)) {
|
|
|
inventory.setQty("0");
|
|
|
//设置额定库存
|
|
|
inventory.setRatedInventory(0);
|
|
|
}
|
|
|
inventory.setShelfStatus(status);
|
|
|
MedicineDrugInventoryRecord inventoryRecord = new MedicineDrugInventoryRecord();
|
|
@ -3642,8 +3846,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
inventory.setUpdateTime(new Date());
|
|
|
inventoryDao.save(inventory);
|
|
|
//更改设备缺货状态
|
|
|
updateDeviceState(inventory.getId());
|
|
|
//重算设备容量
|
|
|
if (cargoCapacityChanged) {
|
|
|
//重算设备容量
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tsum(t.cargo_capacity)\n" +
|
|
@ -4031,6 +4237,230 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
return deviceDao.findMediicinedeviceByEquNum(equNum);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置设备药品库存预警规则,rule1,规则1,rule2,规则2
|
|
|
* @param isAll
|
|
|
* @param equNums
|
|
|
* @param jsonRules
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String setMedicineWarrayRule(Boolean isAll,String equNums, String jsonRules, String userId){
|
|
|
JSONObject result = new JSONObject();
|
|
|
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);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
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())) {
|
|
|
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 (belongCommunitys.indexOf(stringObjectMap.get("community") + "") == -1) {
|
|
|
if (StringUtils.isEmpty(belongCommunitys)) {
|
|
|
belongCommunitys += stringObjectMap.get("community").toString();
|
|
|
} else {
|
|
|
belongCommunitys += "," + stringObjectMap.get("community").toString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//所有设备
|
|
|
if (isAll) {
|
|
|
{
|
|
|
tempSql = "SELECT\n" +
|
|
|
"\tt.id,\n" +
|
|
|
"\tt.equ_num,\n" +
|
|
|
"\tt.del,\n" +
|
|
|
"\tt.upper,\n" +
|
|
|
"\tt.lower,\n" +
|
|
|
"\tt.match_value,\n" +
|
|
|
"\tt.match_unit,\n" +
|
|
|
"\tt.create_time,\n" +
|
|
|
"\tt.create_user,\n" +
|
|
|
"\tt.create_user_name,\n" +
|
|
|
"\tt.update_time,\n" +
|
|
|
"\tt.update_user,\n" +
|
|
|
"\tt.update_user_name\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_medicine_warray_rule AS t\n" +
|
|
|
"LEFT JOIN t_mediicine_device tmd ON t.equ_num = tmd.equ_num\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.del = 1\n" +
|
|
|
"AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',tmd.belong_community,',%')\n";
|
|
|
}
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(tempSql);
|
|
|
//失效原来规则
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
MedicineWarrayRule medicineWarrayRule = medicineWarrayRuleDao.findOne(stringObjectMap.get("id")+"");
|
|
|
medicineWarrayRule.setDel(0);
|
|
|
medicineWarrayRule.setUpdateTime(new Date());
|
|
|
medicineWarrayRule.setUpdateUser(userId);
|
|
|
medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
}
|
|
|
List<Mediicinedevice> deviceList = deviceDao.findMediicinedevicesByBelongCommunityInAndDel(belongCommunitys.split(","), "1");
|
|
|
for (Mediicinedevice mediicinedevice : deviceList) {
|
|
|
for (Object obj : ruleArray) {
|
|
|
RuleDO ruleDO = null;
|
|
|
try {
|
|
|
ruleDO = objectMapper.readValue(obj.toString(), RuleDO.class);
|
|
|
} catch (IOException e) {
|
|
|
result.put("msg", "convert org jsonObject to RuleDO failed," + e.getCause());
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
MedicineWarrayRule medicineWarrayRule = new MedicineWarrayRule();
|
|
|
medicineWarrayRule.setDel(1);
|
|
|
medicineWarrayRule.setEquNum(mediicinedevice.getEquNum());
|
|
|
medicineWarrayRule.setLower(ruleDO.getLower());
|
|
|
medicineWarrayRule.setUpper(ruleDO.getUpper());
|
|
|
medicineWarrayRule.setMatchValue(ruleDO.getMatchValue());
|
|
|
medicineWarrayRule.setMatchUnit(ruleDO.getMatchUnit());
|
|
|
medicineWarrayRule.setUpdateUser(userId);
|
|
|
medicineWarrayRule.setUpdateTime(new Date());
|
|
|
medicineWarrayRule.setCreateTime(new Date());
|
|
|
medicineWarrayRule.setCreateUser(userId);
|
|
|
medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
}
|
|
|
// if (!StringUtils.isEmpty(rule1)) {
|
|
|
// MedicineWarrayRule medicineWarrayRule = new MedicineWarrayRule();
|
|
|
// medicineWarrayRule.setDel(1);
|
|
|
// medicineWarrayRule.setEquNum(mediicinedevice.getEquNum());
|
|
|
// medicineWarrayRule.setLower(Integer.parseInt(rule1.split(",")[0]));
|
|
|
// medicineWarrayRule.setUpper(Integer.parseInt(rule1.split(",")[1]));
|
|
|
// medicineWarrayRule.setMatchValue(Integer.parseInt(rule1.split(",")[2]));
|
|
|
// medicineWarrayRule.setMatchUnit(rule1.split(",")[3]);
|
|
|
// medicineWarrayRule.setUpdateUser(userId);
|
|
|
// medicineWarrayRule.setUpdateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateUser(userId);
|
|
|
// medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
// }
|
|
|
// if (!StringUtils.isEmpty(rule2)) {
|
|
|
// MedicineWarrayRule medicineWarrayRule = new MedicineWarrayRule();
|
|
|
// medicineWarrayRule.setDel(1);
|
|
|
// medicineWarrayRule.setEquNum(mediicinedevice.getEquNum());
|
|
|
// medicineWarrayRule.setLower(Integer.parseInt(rule2.split(",")[0]));
|
|
|
// medicineWarrayRule.setUpper(Integer.parseInt(rule2.split(",")[1]));
|
|
|
// medicineWarrayRule.setMatchValue(Integer.parseInt(rule2.split(",")[2]));
|
|
|
// medicineWarrayRule.setMatchUnit(rule2.split(",")[3]);
|
|
|
// medicineWarrayRule.setUpdateUser(userId);
|
|
|
// medicineWarrayRule.setUpdateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateUser(userId);
|
|
|
// medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
// }
|
|
|
}
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg", ConstantUtils.SUCCESS);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
for (Object obj : ruleArray) {
|
|
|
RuleDO ruleDO = null;
|
|
|
try {
|
|
|
ruleDO = objectMapper.readValue(obj.toString(), RuleDO.class);
|
|
|
} catch (IOException e) {
|
|
|
result.put("msg", "convert org jsonObject to RuleDO failed," + e.getCause());
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
MedicineWarrayRule medicineWarrayRule = new MedicineWarrayRule();
|
|
|
medicineWarrayRule.setDel(1);
|
|
|
medicineWarrayRule.setEquNum(equNum);
|
|
|
medicineWarrayRule.setLower(ruleDO.getLower());
|
|
|
medicineWarrayRule.setUpper(ruleDO.getUpper());
|
|
|
medicineWarrayRule.setMatchValue(ruleDO.getMatchValue());
|
|
|
medicineWarrayRule.setMatchUnit(ruleDO.getMatchUnit());
|
|
|
medicineWarrayRule.setUpdateUser(userId);
|
|
|
medicineWarrayRule.setUpdateTime(new Date());
|
|
|
medicineWarrayRule.setCreateTime(new Date());
|
|
|
medicineWarrayRule.setCreateUser(userId);
|
|
|
medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
}
|
|
|
// if (!StringUtils.isEmpty(rule1)) {
|
|
|
// medicineWarrayRule = new MedicineWarrayRule();
|
|
|
// medicineWarrayRule.setDel(1);
|
|
|
// medicineWarrayRule.setEquNum(equNum);
|
|
|
// medicineWarrayRule.setLower(Integer.parseInt(rule1.split(",")[0]));
|
|
|
// medicineWarrayRule.setUpper(Integer.parseInt(rule1.split(",")[1]));
|
|
|
// medicineWarrayRule.setMatchValue(Integer.parseInt(rule1.split(",")[2]));
|
|
|
// medicineWarrayRule.setMatchUnit(rule1.split(",")[3]);
|
|
|
// medicineWarrayRule.setUpdateUser(userId);
|
|
|
// medicineWarrayRule.setUpdateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateUser(userId);
|
|
|
// medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
// }
|
|
|
// if (!StringUtils.isEmpty(rule2)) {
|
|
|
// medicineWarrayRule = new MedicineWarrayRule();
|
|
|
// medicineWarrayRule.setDel(1);
|
|
|
// medicineWarrayRule.setEquNum(equNum);
|
|
|
// medicineWarrayRule.setLower(Integer.parseInt(rule2.split(",")[0]));
|
|
|
// medicineWarrayRule.setUpper(Integer.parseInt(rule2.split(",")[1]));
|
|
|
// medicineWarrayRule.setMatchValue(Integer.parseInt(rule2.split(",")[2]));
|
|
|
// medicineWarrayRule.setMatchUnit(rule2.split(",")[3]);
|
|
|
// medicineWarrayRule.setUpdateUser(userId);
|
|
|
// medicineWarrayRule.setUpdateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateTime(new Date());
|
|
|
// medicineWarrayRule.setCreateUser(userId);
|
|
|
// medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg", ConstantUtils.SUCCESS);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
|
|
|
|