|
@ -4828,7 +4828,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String setMedicineWarrayRule(Boolean isAll,String equNums, String jsonRules, String userId){
|
|
|
public String setMedicineWarrayRule(Boolean isAll,String equNums, String jsonRules, String userId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonRules);
|
|
|
JSONArray ruleArray = jsonObject.getJSONArray("rules");
|
|
@ -4837,9 +4837,33 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
List<RuleDO> ruleDOS = new ArrayList<>();
|
|
|
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();
|
|
|
}
|
|
|
ruleDOS.add(ruleDO);
|
|
|
}
|
|
|
ruleDOS = ruleDOS.stream().sorted(Comparator.comparingInt(RuleDO::getLower)).collect(Collectors.toList());
|
|
|
for (int i = 0; i < ruleDOS.size(); i++) {
|
|
|
if (i + 1 < ruleDOS.size()) {
|
|
|
if (ruleDOS.get(i).getUpper() > ruleDOS.get(i+1).getLower()) {
|
|
|
result.put("msg", "当前规则有重复,请删除重复规则后重试");
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
if (role==null){
|
|
|
throw new Exception("角色为空!");
|
|
|
}
|
|
|
String belongCommunitys = "";
|
|
|
String tempSql = "";
|
|
|
//获取管理员所在社区code字符串
|
|
@ -4923,15 +4947,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
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();
|
|
|
}
|
|
|
for (RuleDO ruleDO : ruleDOS) {
|
|
|
MedicineWarrayRule medicineWarrayRule = new MedicineWarrayRule();
|
|
|
medicineWarrayRule.setDel(1);
|
|
|
medicineWarrayRule.setEquNum(mediicinedevice.getEquNum());
|
|
@ -4945,28 +4961,22 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
medicineWarrayRule.setCreateUser(userId);
|
|
|
medicineWarrayRuleDao.save(medicineWarrayRule);
|
|
|
}
|
|
|
// if (!StringUtils.isEmpty(rule1)) {
|
|
|
// 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(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.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());
|