pos机折扣参数修改
diff --git a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
index 828f338..2953097 100644
--- a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
@@ -393,6 +393,7 @@
}
Double amount = req.getAmount() / 100.0;
Double cntamount=0.0;
+ logger.info("交易号:"+tTransdtl.getBillno()+",,,交易金额:"+req.getAmount());
DiscountBean bean = deviceDiscountRuleService.getCustomerDiscount(tDevice.getId(), req.getTermtime(), cus.getCustid());
if (null != bean) {
tTransdtl.setRuleid(bean.getRuleid());
@@ -414,7 +415,7 @@
group = deviceParamService.getDevparaGroupByGroupid(bind.getGroupid());
}
TDevpara para=deviceParamService.getDevparaInfoByParaname(group.getGroupid(),"once_limit_amt");
- if(null!=para){
+ if(null!=para||StringUtil.isEmpty(para.getParaval())){
Double oncelimit=Double.parseDouble(para.getParaval())/100;
if(amount>oncelimit&&cntamount>oncelimit){
resp.setRetcode("99");
@@ -475,12 +476,14 @@
tTransdtl.setAttr1(confirmResp.getRetmsg() + "," + confirmResp.getException());
resp.setRetcode(confirmResp.getRetcode().toString());
resp.setRetmsg(confirmResp.getRetmsg());
+ return resp;
}
} else {
tTransdtl.setStatus(RestaurantConstant.STATUS_TRANSDTL_FAIL);
tTransdtl.setAttr1(response.getRetmsg() + "," + response.getException());
resp.setRetcode(response.getRetcode().toString());
resp.setRetmsg(response.getRetmsg());
+ return resp;
}
// }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
index 42cc705..5b50f30 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
@@ -106,9 +106,7 @@
@GetMapping("/loadimport")
-
@PreAuthorize("hasPermission('/customer/loadimport','')")
-
public String loadimport(Model model) {
return "restaurant/customer/import";
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
index 934e8b5..d0098f2 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
@@ -47,12 +47,10 @@
private DiscountDetailDao discountDetailDao;
@Autowired
private SystemUtilService systemUtilService;
- @Autowired
- private CustomerDao customerDao;
+
@Autowired
private DeviceDao deviceDao;
- @Autowired
- private CardDao cardDao;
+
@Autowired
private CustomerListService customerListService;
@@ -405,7 +403,7 @@
StringBuffer sql = new StringBuffer("select d.limitcnt,d.ruletype,d.amount,d.ruleid from tb_discount_rule d " +
"left join tb_discount_devbind t on t.ruleid=d.ruleid " +
"left join tb_discount_detail c on t.ruleid=c.ruleid " +
- "where c.status='normal' and t.deviceid=:deviceid " +
+ "where d.status='normal' and t.deviceid=:deviceid " +
"and d.starttime<:termtime and d.endtime>:termtime " +
"and c.userid=:custid");
Query query = entityManager.createNativeQuery(sql.toString());
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceParamServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceParamServiceImpl.java
index bc470fc..0ad7897 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceParamServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceParamServiceImpl.java
@@ -30,283 +30,284 @@
@Service
public class DeviceParamServiceImpl implements DeviceParamService {
- @Autowired
- private DevparaGroupDao devparaGroupDao;
- @Autowired
- private DevparaBindDao devparaBindDao;
- @Autowired
- private DevparaDao devparaDao;
- @Autowired
- private DeviceDao deviceDao;
- @Autowired
- private DeviceGroupDao deviceGroupDao;
+ @Autowired
+ private DevparaGroupDao devparaGroupDao;
+ @Autowired
+ private DevparaBindDao devparaBindDao;
+ @Autowired
+ private DevparaDao devparaDao;
+ @Autowired
+ private DeviceDao deviceDao;
+ @Autowired
+ private DeviceGroupDao deviceGroupDao;
- @Autowired
- private SystemUtilService systemUtilService;
+ @Autowired
+ private SystemUtilService systemUtilService;
- @PersistenceContext
- private EntityManager entityManager;
+ @PersistenceContext
+ private EntityManager entityManager;
- @Override
- public PageResult<TDevparaGroup> getDevparaGroupPage(String groupname, int pageNo, int pageSize) {
- Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("groupid"));
- if (StringUtil.isEmpty(groupname)) {
- return new PageResult<>(devparaGroupDao.findAll(pageable));
- }
- return new PageResult<>(devparaGroupDao.findAllByGroupnameIsContaining(groupname.trim(), pageable));
- }
-
- @Override
- public TDevparaGroup getDevparaGroupByGroupid(int groupid) {
- Optional<TDevparaGroup> opt= devparaGroupDao.findById(groupid);
- if(opt.isPresent()){
- return opt.get();
- }
- return null;
- }
-
- @Override
- public TDevparaGroup getDefaultDevparaGroup() {
- return devparaGroupDao.findGlobalParaGroup();
- }
-
- @Override
- public boolean deleteDevparaGroup(TDevparaGroup group) throws WebCheckException {
- if (null != group) {
- if (group.getGlobalflag()) {
- throw new WebCheckException("默认参数组不能删除");
- }
- if (devparaBindDao.getDevparaBindRecordcnt(group.getGroupid()) > 0) {
- throw new WebCheckException("该参数组下绑定了设备,请先解绑。");
- }
-
- devparaDao.deleteAllByGroupid(group.getGroupid());
- devparaGroupDao.delete(group);
- return true;
- }
- return false;
- }
-
- @Override
- public List<TDevpara> getDevparaInfo(Integer groupid) {
- List<TDevpara> result;
- if (null != groupid && groupid > 0) {
- result = devparaDao.findAllByGroupid(groupid);
- } else {
- result = devparaDao.findSystemDefaultDevpara(); //默认
- }
- if (!StringUtil.isEmpty(result)) {
- return result;
- } else {
- return new ArrayList<>(0);
- }
- }
-
- @Override
- public TDevpara getDevparaInfoByParaname(Integer groupid,String paraname) {
- TDevpara result;
- if (null != groupid && groupid > 0) {
- result = devparaDao.findByGroupidAndParaname(groupid,paraname).get(0);
- } else {
- result = devparaDao.findSystemDefaultDevparaByParaname(paraname).get(0); //默认
- }
- if (null!=result) {
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public boolean saveOrUpdateDevpara(int groupid, String groupname, Map<String, String> param) throws WebCheckException {
- TDevparaGroup group;
- if (groupid == 0) {
- if (devparaGroupDao.checkGroupnameExists(groupname) > 0) {
- throw new WebCheckException("参数名称已经存在");
- }
- group = new TDevparaGroup();
- group.setGlobalflag(false);
- group.setGroupname(groupname);
- group.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
- group.setVerno(1L);
- group = devparaGroupDao.save(group);
-
- List<TDevpara> configList = devparaDao.findSystemDefaultDevpara(); //默认
- for (TDevpara devpara : configList) {
- TDevpara bean = new TDevpara();
- bean.setGroupid(group.getGroupid());
- bean.setParaname(devpara.getParaname());
- bean.setParaval(param.get(devpara.getParaname()));
- bean.setParadesc(devpara.getParadesc());
- bean.setValtype(devpara.getValtype());
- bean.setMinval(devpara.getMinval());
- bean.setMaxval(devpara.getMaxval());
- if (!bean.checkValue()) {
- throw new WebCheckException(bean.getErrmsg());
+ @Override
+ public PageResult<TDevparaGroup> getDevparaGroupPage(String groupname, int pageNo, int pageSize) {
+ Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("groupid"));
+ if (StringUtil.isEmpty(groupname)) {
+ return new PageResult<>(devparaGroupDao.findAll(pageable));
}
- devparaDao.save(bean);
- }
- } else {
- group = devparaGroupDao.findByGroupid(groupid);
- if (null == group) {
- throw new WebCheckException("原设备参数组不存在");
- }
- if (devparaGroupDao.checkGroupnameExists(groupname, groupid) > 0) {
- throw new WebCheckException("参数名称已经存在");
- }
- group.setGroupname(groupname);
- group.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
- devparaGroupDao.save(group);
+ return new PageResult<>(devparaGroupDao.findAllByGroupnameIsContaining(groupname.trim(), pageable));
+ }
- for (String key : param.keySet()) {
- TDevpara bean = devparaDao.findById(groupid, key);
- if (null == bean) {
- throw new WebCheckException("设备参数[" + key + "]在参数组【" + group.getGroupname() + "】中不存在");
+ @Override
+ public TDevparaGroup getDevparaGroupByGroupid(int groupid) {
+ Optional<TDevparaGroup> opt = devparaGroupDao.findById(groupid);
+ if (opt.isPresent()) {
+ return opt.get();
}
- bean.setParaval(param.get(key));
- if (!bean.checkValue()) {
- throw new WebCheckException(bean.getErrmsg());
+ return null;
+ }
+
+ @Override
+ public TDevparaGroup getDefaultDevparaGroup() {
+ return devparaGroupDao.findGlobalParaGroup();
+ }
+
+ @Override
+ public boolean deleteDevparaGroup(TDevparaGroup group) throws WebCheckException {
+ if (null != group) {
+ if (group.getGlobalflag()) {
+ throw new WebCheckException("默认参数组不能删除");
+ }
+ if (devparaBindDao.getDevparaBindRecordcnt(group.getGroupid()) > 0) {
+ throw new WebCheckException("该参数组下绑定了设备,请先解绑。");
+ }
+
+ devparaDao.deleteAllByGroupid(group.getGroupid());
+ devparaGroupDao.delete(group);
+ return true;
}
- devparaDao.save(bean);
- }
- }
- return true;
- }
-
- @Override
- public PageResult<DevparaBindBean> getDevparaBindInfos(String searchkey, int pageNo, int pageSize) {
- StringBuffer querySql = new StringBuffer("select t.groupid,a.groupname,t.deviceid,b.devicename,b.devphyid,t.lastsaved " +
- " from TB_DEVPARA_BIND t left join TB_DEVPARA_GROUP a on t.groupid=a.groupid " +
- " left join TB_DEVICE b on t.deviceid=b.id where 1=1 ");
- StringBuffer countSql = new StringBuffer("select count(t.deviceid) as cnt from TB_DEVPARA_BIND t left join TB_DEVPARA_GROUP a on t.groupid=a.groupid " +
- " left join TB_DEVICE b on t.deviceid=b.id where 1=1 ");
- if (!StringUtil.isEmpty(searchkey)) {
- querySql.append(" and (a.groupname like :str or b.devicename like :str or b.devphyid like :str) ");
- countSql.append(" and (a.groupname like :str or b.devicename like :str or b.devphyid like :str) ");
- }
- querySql.append(" order by t.deviceid ");
- Query query = entityManager.createNativeQuery(querySql.toString());
- Query countQuery = entityManager.createNativeQuery(countSql.toString());
- if (!StringUtil.isEmpty(searchkey)) {
- query.setParameter("str", "%" + searchkey.trim() + "%");
- countQuery.setParameter("str", "%" + searchkey.trim() + "%");
- }
- query.setFirstResult((pageNo - 1) * pageSize);
- query.setMaxResults(pageSize); //分页显示
- query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(DevparaBindBean.class));
- List<DevparaBindBean> list = query.getResultList();
- BigInteger count = (BigInteger) countQuery.getSingleResult();
- return new PageResult<>(count.longValue(), list);
- }
-
- @Override
- public TDevparaBind getDevparaBindByDeviceid(Integer deviceid) {
- if (null != deviceid) {
- return devparaBindDao.getByDeviceid(deviceid);
- }
- return null;
- }
-
- @Override
- public boolean deleteDevparaBind(TDevparaBind bind) {
- if (null != bind) {
- devparaBindDao.delete(bind);
- return true;
- }
- return false;
- }
-
- @Override
- public List<TDevparaGroup> getDevparaGroups() {
- List<TDevparaGroup> list = devparaGroupDao.findAll();
- if (!StringUtil.isEmpty(list)) {
- return list;
- }
- return new ArrayList<>(0);
- }
-
- @Override
- public PageResult<DevparaBinddevShowBean> getBindDevicesBySearch(Integer devgroupid, String searchkey) {
- List<Integer> chirdGroupids = null;
- if (null != devgroupid) {
- Query chirdGroupQuery = entityManager.createNativeQuery(" WITH RECURSIVE r AS ( " +
- " SELECT * FROM tb_devicegroup WHERE devgroupid = :gid " +
- " union ALL " +
- " SELECT a.* FROM tb_devicegroup a, r WHERE a.pid = r.devgroupid ) " +
- " SELECT devgroupid FROM r ORDER BY devgroupid ");
- chirdGroupQuery.setParameter("gid", devgroupid.intValue());
- chirdGroupids = chirdGroupQuery.getResultList(); //递归查询所有的子节点
+ return false;
}
- StringBuffer sql = new StringBuffer("select t.id as deviceid,t.devicename,t.devphyid,t.devgroupid,a.groupname as devgroupname " +
- " from TB_DEVICE t left join TB_DEVICEGROUP a on t.devgroupid=a.devgroupid " +
- " left join TB_DEVPARA_BIND b on t.id=b.deviceid where b.groupid is null and t.state=1 ");
- if (!StringUtil.isEmpty(chirdGroupids)) {
- sql.append(" and t.devgroupid in ("+StringUtils.join(chirdGroupids.toArray(),",")+") ");
- }
- if (!StringUtil.isEmpty(searchkey)) {
- sql.append(" and (t.devicename like :str or t.devphyid like :str) ");
- }
- sql.append(" order by t.id ");
- Query query = entityManager.createNativeQuery(sql.toString());
- if (!StringUtil.isEmpty(searchkey)) {
- query.setParameter("str", "%" + searchkey.trim() + "%");
- }
- query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(DevparaBinddevShowBean.class));
- List<DevparaBinddevShowBean> list = query.getResultList();
- return new PageResult<>(list);
- }
-
- @Override
- public List<TreeSelectNode> getDeviceGroupSelectTree() {
- List<TDeviceGroup> groupList = deviceGroupDao.findAll();
- if (StringUtil.isEmpty(groupList)) return new ArrayList<>(0);
- return getDevgroupTree(groupList, 0);
- }
-
- private List<TreeSelectNode> getDevgroupTree(List<TDeviceGroup> groupList, Integer pid) {
- List<TreeSelectNode> result = new ArrayList<>(0);
- for (TDeviceGroup gp : groupList) {
- if ((0 == pid && gp.getPid() == 0) || (null != pid && pid.equals(gp.getPid()))) {
- TreeSelectNode node = new TreeSelectNode();
- node.setId(String.valueOf(gp.getDevgroupid()));
- node.setName(gp.getGroupname());
- node.setOpen(true);
- node.setGrouptype(gp.getGrouptype());
- node.setChecked(false);
- List<TreeSelectNode> children = getDevgroupTree(groupList, gp.getDevgroupid().intValue());
- if (!StringUtil.isEmpty(children)) {
- node.setChildren(children);
+ @Override
+ public List<TDevpara> getDevparaInfo(Integer groupid) {
+ List<TDevpara> result;
+ if (null != groupid && groupid > 0) {
+ result = devparaDao.findAllByGroupid(groupid);
} else {
- node.setChildren(null);
+ result = devparaDao.findSystemDefaultDevpara(); //默认
}
- result.add(node);
- }
+ if (!StringUtil.isEmpty(result)) {
+ return result;
+ } else {
+ return new ArrayList<>(0);
+ }
}
- return result;
- }
- @Override
- public boolean saveBindDevpara(int groupid, List<Integer> deviceIds) throws WebCheckException {
- TDevparaGroup group = devparaGroupDao.findByGroupid(groupid);
- if (null == group) {
- throw new WebCheckException("所选设备参数组不存在");
- }
- for (Integer id : deviceIds) {
- TDevice device = deviceDao.findTDeviceById(id);
- if (null == device) {
- throw new WebCheckException("终端编号为[" + id + "]的设备不存在");
- } else if (1 != device.getState()) {
- throw new WebCheckException("终端编号为[" + id + "]的设备状态异常");
- }
+ @Override
+ public TDevpara getDevparaInfoByParaname(Integer groupid, String paraname) {
+ List<TDevpara> result;
+ if (null != groupid && groupid > 0) {
+ result=devparaDao.findByGroupidAndParaname(groupid, paraname);
- TDevparaBind bind = new TDevparaBind();
- bind.setDeviceid(device.getId());
- bind.setGroupid(group.getGroupid());
- bind.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
- devparaBindDao.save(bind);
+ } else {
+ result = devparaDao.findSystemDefaultDevparaByParaname(paraname); //默认
+ }
+ if (null != result||result.size()>0) {
+ return result.get(0);
+ } else {
+ return null;
+ }
}
- return true;
- }
+
+ @Override
+ public boolean saveOrUpdateDevpara(int groupid, String groupname, Map<String, String> param) throws WebCheckException {
+ TDevparaGroup group;
+ if (groupid == 0) {
+ if (devparaGroupDao.checkGroupnameExists(groupname) > 0) {
+ throw new WebCheckException("参数名称已经存在");
+ }
+ group = new TDevparaGroup();
+ group.setGlobalflag(false);
+ group.setGroupname(groupname);
+ group.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
+ group.setVerno(1L);
+ group = devparaGroupDao.save(group);
+
+ List<TDevpara> configList = devparaDao.findSystemDefaultDevpara(); //默认
+ for (TDevpara devpara : configList) {
+ TDevpara bean = new TDevpara();
+ bean.setGroupid(group.getGroupid());
+ bean.setParaname(devpara.getParaname());
+ bean.setParaval(param.get(devpara.getParaname()));
+ bean.setParadesc(devpara.getParadesc());
+ bean.setValtype(devpara.getValtype());
+ bean.setMinval(devpara.getMinval());
+ bean.setMaxval(devpara.getMaxval());
+ if (!bean.checkValue()) {
+ throw new WebCheckException(bean.getErrmsg());
+ }
+ devparaDao.save(bean);
+ }
+ } else {
+ group = devparaGroupDao.findByGroupid(groupid);
+ if (null == group) {
+ throw new WebCheckException("原设备参数组不存在");
+ }
+ if (devparaGroupDao.checkGroupnameExists(groupname, groupid) > 0) {
+ throw new WebCheckException("参数名称已经存在");
+ }
+ group.setGroupname(groupname);
+ group.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
+ devparaGroupDao.save(group);
+
+ for (String key : param.keySet()) {
+ TDevpara bean = devparaDao.findById(groupid, key);
+ if (null == bean) {
+ throw new WebCheckException("设备参数[" + key + "]在参数组【" + group.getGroupname() + "】中不存在");
+ }
+ bean.setParaval(param.get(key));
+ if (!bean.checkValue()) {
+ throw new WebCheckException(bean.getErrmsg());
+ }
+ devparaDao.save(bean);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public PageResult<DevparaBindBean> getDevparaBindInfos(String searchkey, int pageNo, int pageSize) {
+ StringBuffer querySql = new StringBuffer("select t.groupid,a.groupname,t.deviceid,b.devicename,b.devphyid,t.lastsaved " +
+ " from TB_DEVPARA_BIND t left join TB_DEVPARA_GROUP a on t.groupid=a.groupid " +
+ " left join TB_DEVICE b on t.deviceid=b.id where 1=1 ");
+ StringBuffer countSql = new StringBuffer("select count(t.deviceid) as cnt from TB_DEVPARA_BIND t left join TB_DEVPARA_GROUP a on t.groupid=a.groupid " +
+ " left join TB_DEVICE b on t.deviceid=b.id where 1=1 ");
+ if (!StringUtil.isEmpty(searchkey)) {
+ querySql.append(" and (a.groupname like :str or b.devicename like :str or b.devphyid like :str) ");
+ countSql.append(" and (a.groupname like :str or b.devicename like :str or b.devphyid like :str) ");
+ }
+ querySql.append(" order by t.deviceid ");
+ Query query = entityManager.createNativeQuery(querySql.toString());
+ Query countQuery = entityManager.createNativeQuery(countSql.toString());
+ if (!StringUtil.isEmpty(searchkey)) {
+ query.setParameter("str", "%" + searchkey.trim() + "%");
+ countQuery.setParameter("str", "%" + searchkey.trim() + "%");
+ }
+ query.setFirstResult((pageNo - 1) * pageSize);
+ query.setMaxResults(pageSize); //分页显示
+ query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(DevparaBindBean.class));
+ List<DevparaBindBean> list = query.getResultList();
+ BigInteger count = (BigInteger) countQuery.getSingleResult();
+ return new PageResult<>(count.longValue(), list);
+ }
+
+ @Override
+ public TDevparaBind getDevparaBindByDeviceid(Integer deviceid) {
+ if (null != deviceid) {
+ return devparaBindDao.getByDeviceid(deviceid);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean deleteDevparaBind(TDevparaBind bind) {
+ if (null != bind) {
+ devparaBindDao.delete(bind);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public List<TDevparaGroup> getDevparaGroups() {
+ List<TDevparaGroup> list = devparaGroupDao.findAll();
+ if (!StringUtil.isEmpty(list)) {
+ return list;
+ }
+ return new ArrayList<>(0);
+ }
+
+ @Override
+ public PageResult<DevparaBinddevShowBean> getBindDevicesBySearch(Integer devgroupid, String searchkey) {
+ List<Integer> chirdGroupids = null;
+ if (null != devgroupid) {
+ Query chirdGroupQuery = entityManager.createNativeQuery(" WITH RECURSIVE r AS ( " +
+ " SELECT * FROM tb_devicegroup WHERE devgroupid = :gid " +
+ " union ALL " +
+ " SELECT a.* FROM tb_devicegroup a, r WHERE a.pid = r.devgroupid ) " +
+ " SELECT devgroupid FROM r ORDER BY devgroupid ");
+ chirdGroupQuery.setParameter("gid", devgroupid.intValue());
+ chirdGroupids = chirdGroupQuery.getResultList(); //递归查询所有的子节点
+ }
+
+ StringBuffer sql = new StringBuffer("select t.id as deviceid,t.devicename,t.devphyid,t.devgroupid,a.groupname as devgroupname " +
+ " from TB_DEVICE t left join TB_DEVICEGROUP a on t.devgroupid=a.devgroupid " +
+ " left join TB_DEVPARA_BIND b on t.id=b.deviceid where b.groupid is null and t.state=1 ");
+ if (!StringUtil.isEmpty(chirdGroupids)) {
+ sql.append(" and t.devgroupid in (" + StringUtils.join(chirdGroupids.toArray(), ",") + ") ");
+ }
+ if (!StringUtil.isEmpty(searchkey)) {
+ sql.append(" and (t.devicename like :str or t.devphyid like :str) ");
+ }
+ sql.append(" order by t.id ");
+ Query query = entityManager.createNativeQuery(sql.toString());
+ if (!StringUtil.isEmpty(searchkey)) {
+ query.setParameter("str", "%" + searchkey.trim() + "%");
+ }
+ query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(DevparaBinddevShowBean.class));
+ List<DevparaBinddevShowBean> list = query.getResultList();
+ return new PageResult<>(list);
+ }
+
+ @Override
+ public List<TreeSelectNode> getDeviceGroupSelectTree() {
+ List<TDeviceGroup> groupList = deviceGroupDao.findAll();
+ if (StringUtil.isEmpty(groupList)) return new ArrayList<>(0);
+ return getDevgroupTree(groupList, 0);
+ }
+
+ private List<TreeSelectNode> getDevgroupTree(List<TDeviceGroup> groupList, Integer pid) {
+ List<TreeSelectNode> result = new ArrayList<>(0);
+ for (TDeviceGroup gp : groupList) {
+ if ((0 == pid && gp.getPid() == 0) || (null != pid && pid.equals(gp.getPid()))) {
+ TreeSelectNode node = new TreeSelectNode();
+ node.setId(String.valueOf(gp.getDevgroupid()));
+ node.setName(gp.getGroupname());
+ node.setOpen(true);
+ node.setGrouptype(gp.getGrouptype());
+ node.setChecked(false);
+ List<TreeSelectNode> children = getDevgroupTree(groupList, gp.getDevgroupid().intValue());
+ if (!StringUtil.isEmpty(children)) {
+ node.setChildren(children);
+ } else {
+ node.setChildren(null);
+ }
+ result.add(node);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean saveBindDevpara(int groupid, List<Integer> deviceIds) throws WebCheckException {
+ TDevparaGroup group = devparaGroupDao.findByGroupid(groupid);
+ if (null == group) {
+ throw new WebCheckException("所选设备参数组不存在");
+ }
+ for (Integer id : deviceIds) {
+ TDevice device = deviceDao.findTDeviceById(id);
+ if (null == device) {
+ throw new WebCheckException("终端编号为[" + id + "]的设备不存在");
+ } else if (1 != device.getState()) {
+ throw new WebCheckException("终端编号为[" + id + "]的设备状态异常");
+ }
+
+ TDevparaBind bind = new TDevparaBind();
+ bind.setDeviceid(device.getId());
+ bind.setGroupid(group.getGroupid());
+ bind.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
+ devparaBindDao.save(bind);
+ }
+ return true;
+ }
}
diff --git a/src/main/resources/templates/restaurant/devicegroup/deviceform.html b/src/main/resources/templates/restaurant/devicegroup/deviceform.html
index 4ceb6d4..69ff544 100644
--- a/src/main/resources/templates/restaurant/devicegroup/deviceform.html
+++ b/src/main/resources/templates/restaurant/devicegroup/deviceform.html
@@ -59,8 +59,6 @@
layer.msg("请选择设备", {icon: 2, time: 1500});
return;
}
- console.log(groupid);
- console.log(deviceids);
layer.load(2);
var token = $("meta[name='_csrf_token']").attr("value");
$.ajax({