|
|
@@ -1,22 +1,5 @@
|
|
|
package cn.vbdsm.manage.service.impl;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import javax.core.common.Page;
|
|
|
-import javax.core.common.ResultMsg;
|
|
|
-import javax.core.common.jdbc.QueryRule;
|
|
|
-import javax.core.common.utils.DataUtils;
|
|
|
-import javax.core.common.utils.StringUtils;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import cn.vbdsm.common.config.I18nConfig;
|
|
|
import cn.vbdsm.common.constants.SystemConstant;
|
|
|
import cn.vbdsm.manage.dao.OrgDao;
|
|
|
@@ -27,21 +10,41 @@ import cn.vbdsm.manage.mvc.vo.PowerUserVo;
|
|
|
import cn.vbdsm.manage.service.IPowerUserService;
|
|
|
import cn.vbdsm.model.Org;
|
|
|
import cn.vbdsm.model.PowerUser;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import javax.core.common.Page;
|
|
|
+import javax.core.common.ResultMsg;
|
|
|
+import javax.core.common.jdbc.QueryRule;
|
|
|
+import javax.core.common.utils.DataUtils;
|
|
|
+import javax.core.common.utils.StringUtils;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service("powerUserService")
|
|
|
public class PowerUserService implements IPowerUserService {
|
|
|
- @Autowired PowerUserDao powerUserDao;
|
|
|
- @Autowired ProxyCompanyDao proxyCompanyDao;
|
|
|
- @Autowired ProxyCompanyService proxyCompanyService;
|
|
|
- @Autowired OrgDao orgDao;
|
|
|
- @Autowired OrgSiteDao orgSiteDao;
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取全部
|
|
|
- */
|
|
|
- public ResultMsg<?> getAll(String local) {
|
|
|
- Page<PowerUserVo> page = null;
|
|
|
- try{
|
|
|
+ @Autowired
|
|
|
+ PowerUserDao powerUserDao;
|
|
|
+ @Autowired
|
|
|
+ ProxyCompanyDao proxyCompanyDao;
|
|
|
+ @Autowired
|
|
|
+ ProxyCompanyService proxyCompanyService;
|
|
|
+ @Autowired
|
|
|
+ OrgDao orgDao;
|
|
|
+ @Autowired
|
|
|
+ OrgSiteDao orgSiteDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取全部
|
|
|
+ */
|
|
|
+ public ResultMsg<?> getAll(String local) {
|
|
|
+ Page<PowerUserVo> page = null;
|
|
|
+ try {
|
|
|
/*List<PowerUser> list = powerUserDao.selectAll();
|
|
|
if(CollectionUtils.isEmpty(list) || list.size() < 1){
|
|
|
page = new Page<PowerUserVo>();
|
|
|
@@ -62,30 +65,30 @@ public class PowerUserService implements IPowerUserService {
|
|
|
puvList.add(vo);
|
|
|
}
|
|
|
page = new Page<PowerUserVo>(0, puvList.size(), puvList.size(), puvList);*/
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","get_success"),page);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据id获取信息
|
|
|
- */
|
|
|
- public ResultMsg<?> getOne(String local, Long id) {
|
|
|
- if(null == id){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
- }
|
|
|
- PowerUserVo vo = new PowerUserVo();
|
|
|
- try{
|
|
|
- //Map<String,Object> obj = powerUserDao.selectByOrgId(orgId);
|
|
|
- PowerUser powerUser = powerUserDao.get(id);
|
|
|
- DataUtils.copySimpleObject(powerUser, vo);
|
|
|
- Org org = orgDao.get(powerUser.getOrgId());
|
|
|
- DataUtils.copySimpleObject(org, vo);
|
|
|
- //vo.setOrgId(org.getId());
|
|
|
- vo.setId(powerUser.getId());
|
|
|
- //站点
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "get_success"), page);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id获取信息
|
|
|
+ */
|
|
|
+ public ResultMsg<?> getOne(String local, Long id) {
|
|
|
+ if (null == id) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
+ }
|
|
|
+ PowerUserVo vo = new PowerUserVo();
|
|
|
+ try {
|
|
|
+ //Map<String,Object> obj = powerUserDao.selectByOrgId(orgId);
|
|
|
+ PowerUser powerUser = powerUserDao.get(id);
|
|
|
+ DataUtils.copySimpleObject(powerUser, vo);
|
|
|
+ Org org = orgDao.get(powerUser.getOrgId());
|
|
|
+ DataUtils.copySimpleObject(org, vo);
|
|
|
+ //vo.setOrgId(org.getId());
|
|
|
+ vo.setId(powerUser.getId());
|
|
|
+ //站点
|
|
|
/*List<Map<String, Object>> sList = orgDao.selectOrgSiteByOrgId(org.getId());
|
|
|
Long [] siteId = new Long[sList.size()];
|
|
|
int i = 0;
|
|
|
@@ -94,334 +97,334 @@ public class PowerUserService implements IPowerUserService {
|
|
|
i++;
|
|
|
}
|
|
|
vo.setSiteId(siteId);*/
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","get_success"),vo);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "get_success"), vo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 分页查询
|
|
|
- */
|
|
|
- public ResultMsg<?> getForPage(String local, String name, Long serviceId,
|
|
|
- Integer province,Integer city,Integer district,Integer isRoot,Long fromSite, int pageNo, int pageSize) {
|
|
|
- Page<PowerUserVo> _page = new Page<PowerUserVo>();
|
|
|
- try{
|
|
|
- //查找t_org表
|
|
|
- Page<Map<String,Object>> page = powerUserDao.selectAllForPage(pageNo, pageSize, name,serviceId,province,city,district,isRoot,fromSite);
|
|
|
- if(CollectionUtils.isEmpty(page.getRows())){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","get_success"),_page);
|
|
|
- }
|
|
|
- List<PowerUserVo> list = new ArrayList<PowerUserVo>();
|
|
|
- //获取服务公司
|
|
|
- ResultMsg<?> result = proxyCompanyService.getComboxData(local, isRoot.intValue(), isRoot.intValue() !=1 ?fromSite.intValue():0);
|
|
|
- List<Map<String, Object>> mList = (List<Map<String, Object>>)result.getData();
|
|
|
- for(Map<String,Object> map : page.getRows()){
|
|
|
- PowerUserVo vo = new PowerUserVo();
|
|
|
- vo.setId(DataUtils.getLong(map.get("id")));
|
|
|
- vo.setOrgId(DataUtils.getLong(map.get("orgId")));
|
|
|
- vo.setName(DataUtils.getString(map.get("name")));
|
|
|
- vo.setState(DataUtils.getInteger(map.get("state")));
|
|
|
- vo.setExpiredDate(DataUtils.getString(map.get("expiredDate")));
|
|
|
- vo.setLoginTimes(DataUtils.getLong(map.get("loginTimes")));
|
|
|
- vo.setServiceId(DataUtils.getLong(map.get("serviceId")));
|
|
|
- vo.setAddress(DataUtils.getString(map.get("address")));
|
|
|
- for(Map<String, Object> m : mList){
|
|
|
- if(vo.getServiceId().longValue() == DataUtils.getLong(m.get("id")).longValue()){
|
|
|
- vo.setTitle(DataUtils.getString(m.get("title")));
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- list.add(vo);
|
|
|
- }
|
|
|
- _page.setRows(list);
|
|
|
- _page.setTotal(page.getTotal());
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","get_success"),_page);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ */
|
|
|
+ public ResultMsg<?> getForPage(String local, String name, Long serviceId,
|
|
|
+ Integer province, Integer city, Integer district, Integer isRoot, Long fromSite, int pageNo, int pageSize) {
|
|
|
+ Page<PowerUserVo> _page = new Page<PowerUserVo>();
|
|
|
+ try {
|
|
|
+ //查找t_org表
|
|
|
+ Page<Map<String, Object>> page = powerUserDao.selectAllForPage(pageNo, pageSize, name, serviceId, province, city, district, isRoot, fromSite);
|
|
|
+ if (CollectionUtils.isEmpty(page.getRows())) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "get_success"), _page);
|
|
|
+ }
|
|
|
+ List<PowerUserVo> list = new ArrayList<PowerUserVo>();
|
|
|
+ //获取服务公司
|
|
|
+ ResultMsg<?> result = proxyCompanyService.getComboxData(local, isRoot.intValue(), isRoot.intValue() != 1 ? fromSite.intValue() : 0);
|
|
|
+ List<Map<String, Object>> mList = (List<Map<String, Object>>) result.getData();
|
|
|
+ for (Map<String, Object> map : page.getRows()) {
|
|
|
+ PowerUserVo vo = new PowerUserVo();
|
|
|
+ vo.setId(DataUtils.getLong(map.get("id")));
|
|
|
+ vo.setOrgId(DataUtils.getLong(map.get("orgId")));
|
|
|
+ vo.setName(DataUtils.getString(map.get("name")));
|
|
|
+ vo.setState(DataUtils.getInteger(map.get("state")));
|
|
|
+ vo.setExpiredDate(DataUtils.getString(map.get("expiredDate")));
|
|
|
+ vo.setLoginTimes(DataUtils.getLong(map.get("loginTimes")));
|
|
|
+ vo.setServiceId(DataUtils.getLong(map.get("serviceId")));
|
|
|
+ vo.setAddress(DataUtils.getString(map.get("address")));
|
|
|
+ for (Map<String, Object> m : mList) {
|
|
|
+ if (vo.getServiceId().longValue() == DataUtils.getLong(m.get("id")).longValue()) {
|
|
|
+ vo.setTitle(DataUtils.getString(m.get("title")));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ _page.setRows(list);
|
|
|
+ _page.setTotal(page.getTotal());
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "get_success"), _page);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 伪删(支持批量)
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- public ResultMsg<?> remove(String local, String id) {
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }
|
|
|
- try{
|
|
|
- String [] ids = null;
|
|
|
- if(id.indexOf(",") > 0){
|
|
|
- ids = id.split(",");
|
|
|
- }else{
|
|
|
- ids = new String[]{id};
|
|
|
- }
|
|
|
- int result = orgDao.removeBatch(ids, SystemConstant.ENABLE);
|
|
|
- if(result > 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","remove_success"));
|
|
|
- }
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 伪删(支持批量)
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public ResultMsg<?> remove(String local, String id) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String[] ids = null;
|
|
|
+ if (id.indexOf(",") > 0) {
|
|
|
+ ids = id.split(",");
|
|
|
+ } else {
|
|
|
+ ids = new String[]{id};
|
|
|
+ }
|
|
|
+ int result = orgDao.removeBatch(ids, SystemConstant.ENABLE);
|
|
|
+ if (result > 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "remove_success"));
|
|
|
+ }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 删除
|
|
|
- */
|
|
|
- public ResultMsg<?> realDel(String local, Long id) {
|
|
|
- try{
|
|
|
- if(null == id){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }
|
|
|
- boolean result = powerUserDao.delete(id);
|
|
|
- if(result){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","remove_success"));
|
|
|
- }
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ public ResultMsg<?> realDel(String local, Long id) {
|
|
|
+ try {
|
|
|
+ if (null == id) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ }
|
|
|
+ boolean result = powerUserDao.delete(id);
|
|
|
+ if (result) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "remove_success"));
|
|
|
+ }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- */
|
|
|
- public ResultMsg<?> modify(String local, PowerUserVo vo) {
|
|
|
- if(StringUtils.isEmpty(vo.getName()) || StringUtils.isEmpty(vo.getAddress()) || StringUtils.isEmpty(vo.getCoordinate())){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
-
|
|
|
- try{
|
|
|
- PowerUser powerUser = new PowerUser();
|
|
|
- DataUtils.copySimpleObject(vo, powerUser);
|
|
|
- if(null == powerUser.getNormalLoad()){
|
|
|
- powerUser.setNormalLoad(new BigDecimal(0));
|
|
|
- }
|
|
|
- if(null == powerUser.getHalfLoadStart()){
|
|
|
- powerUser.setHalfLoadStart(new BigDecimal(0));
|
|
|
- }
|
|
|
- if(null == powerUser.getHalfLoadEnd()){
|
|
|
- powerUser.setHalfLoadEnd(new BigDecimal(0));
|
|
|
- }
|
|
|
- if(null == powerUser.getStopLoad()){
|
|
|
- powerUser.setStopLoad(new BigDecimal(0));
|
|
|
- }
|
|
|
- int result = powerUserDao.update(powerUser);
|
|
|
- if(result == 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
- Org org = new Org();
|
|
|
- DataUtils.copySimpleObject(vo, org);
|
|
|
- org.setId(vo.getOrgId());
|
|
|
- org.setOrgType(1);
|
|
|
- StringBuffer appNo = new StringBuffer();
|
|
|
- //app授权
|
|
|
- if(null != vo.getAppNo() && vo.getAppNo().length > 0){
|
|
|
- for(int i=0;i<vo.getAppNo().length;i++){
|
|
|
- if(i < vo.getAppNo().length - 1){
|
|
|
- appNo.append(vo.getAppNo()[i]).append(",");
|
|
|
- }else{
|
|
|
- appNo.append(vo.getAppNo()[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- org.setAppNo(appNo.toString());
|
|
|
- result = orgDao.update(org);
|
|
|
- if(result == 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
- if(null == vo.getSiteId() || vo.getSiteId().length == 0){
|
|
|
- //删除
|
|
|
- result = orgSiteDao.deleteOrgSite(org.getId());
|
|
|
- }else{
|
|
|
- //修改
|
|
|
- result = orgSiteDao.updateOrgSite(org.getId(), vo.getSiteId());
|
|
|
- }
|
|
|
- if(result == 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","modify_success"),vo);
|
|
|
-
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ public ResultMsg<?> modify(String local, PowerUserVo vo) {
|
|
|
+ if (StringUtils.isEmpty(vo.getName()) || StringUtils.isEmpty(vo.getAddress()) || StringUtils.isEmpty(vo.getCoordinate())) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 修改状态(支持批量)
|
|
|
- */
|
|
|
- public ResultMsg<?> modifySate(String local, String id, Integer state) {
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
- try{
|
|
|
- String [] ids = null;
|
|
|
- if(id.indexOf(",") > 0){
|
|
|
- ids = id.split(",");
|
|
|
- }else{
|
|
|
- ids = new String[]{id};
|
|
|
- }
|
|
|
- int result = powerUserDao.modifyStateBatch(ids, state);
|
|
|
- if(result > 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","modify_success"));
|
|
|
- }
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ try {
|
|
|
+ PowerUser powerUser = new PowerUser();
|
|
|
+ DataUtils.copySimpleObject(vo, powerUser);
|
|
|
+ if (null == powerUser.getNormalLoad()) {
|
|
|
+ powerUser.setNormalLoad(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ if (null == powerUser.getHalfLoadStart()) {
|
|
|
+ powerUser.setHalfLoadStart(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ if (null == powerUser.getHalfLoadEnd()) {
|
|
|
+ powerUser.setHalfLoadEnd(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ if (null == powerUser.getStopLoad()) {
|
|
|
+ powerUser.setStopLoad(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ int result = powerUserDao.update(powerUser);
|
|
|
+ if (result == 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
+ Org org = new Org();
|
|
|
+ DataUtils.copySimpleObject(vo, org);
|
|
|
+ org.setId(vo.getOrgId());
|
|
|
+ org.setOrgType(1);
|
|
|
+ StringBuffer appNo = new StringBuffer();
|
|
|
+ //app授权
|
|
|
+ if (null != vo.getAppNo() && vo.getAppNo().length > 0) {
|
|
|
+ for (int i = 0; i < vo.getAppNo().length; i++) {
|
|
|
+ if (i < vo.getAppNo().length - 1) {
|
|
|
+ appNo.append(vo.getAppNo()[i]).append(",");
|
|
|
+ } else {
|
|
|
+ appNo.append(vo.getAppNo()[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ org.setAppNo(appNo.toString());
|
|
|
+ result = orgDao.update(org);
|
|
|
+ if (result == 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
+ if (null == vo.getSiteId() || vo.getSiteId().length == 0) {
|
|
|
+ //删除
|
|
|
+ result = orgSiteDao.deleteOrgSite(org.getId());
|
|
|
+ } else {
|
|
|
+ //修改
|
|
|
+ result = orgSiteDao.updateOrgSite(org.getId(), vo.getSiteId());
|
|
|
+ }
|
|
|
+ if (result == 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "modify_success"), vo);
|
|
|
|
|
|
- public ResultMsg<?> getList(String local, String cityId) {
|
|
|
- try {
|
|
|
- QueryRule queryRule = QueryRule.getInstance();
|
|
|
- if(!StringUtils.isEmpty(cityId)){
|
|
|
- queryRule.andLike("city", cityId);
|
|
|
- }
|
|
|
- List<PowerUser> list = powerUserDao.find(queryRule);
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","get_success"),list);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public ResultMsg<?> add(String local, PowerUserVo vo, JSONObject userinfo) {
|
|
|
- try{
|
|
|
- if(StringUtils.isEmpty(vo.getName()) || StringUtils.isEmpty(vo.getAddress()) || StringUtils.isEmpty(vo.getCoordinate())){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
- if(null == vo.getFgpFlag()){
|
|
|
- vo.setFgpFlag(SystemConstant.DISABLE);
|
|
|
- }
|
|
|
- if(null == vo.getPowerSupply()){
|
|
|
- vo.setPowerSupply(SystemConstant.ENABLE);
|
|
|
- }
|
|
|
- if(null == vo.getJffs()){
|
|
|
- vo.setJffs(SystemConstant.DISABLE);
|
|
|
- }
|
|
|
- //入库t_org表
|
|
|
- Org org = new Org();
|
|
|
- DataUtils.copySimpleObject(vo, org);
|
|
|
- org.setOrgType(1);
|
|
|
- org.setCreateTime(System.currentTimeMillis());
|
|
|
- org.setCreatorId(userinfo.getJSONObject("user").getLong("id"));
|
|
|
- org.setDel(SystemConstant.DISABLE);
|
|
|
- StringBuffer appNo = new StringBuffer();
|
|
|
- //app授权
|
|
|
- if(null != vo.getAppNo() && vo.getAppNo().length > 0){
|
|
|
- for(int i=0;i<vo.getAppNo().length;i++){
|
|
|
- if(i < vo.getAppNo().length - 1){
|
|
|
- appNo.append(vo.getAppNo()[i]).append(",");
|
|
|
- }else{
|
|
|
- appNo.append(vo.getAppNo()[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- org.setAppNo(appNo.toString());
|
|
|
- Long orgId = orgDao.saveAndReturnId(org);
|
|
|
- if(orgId == 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
- //入库t_poweruser表
|
|
|
- PowerUser powerUser = new PowerUser();
|
|
|
- DataUtils.copySimpleObject(vo, powerUser);
|
|
|
- powerUser.setOrgId(orgId);
|
|
|
- powerUser.setState(SystemConstant.DISABLE);
|
|
|
- Long id = powerUserDao.insertAndReturnId(powerUser);
|
|
|
- if(id == 0){
|
|
|
- //删除之前入库的数据
|
|
|
- orgDao.delete(orgId);
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
-
|
|
|
- if(null == vo.getSiteId() || vo.getSiteId().length == 0){
|
|
|
- vo.setId(id);
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "add_success"),vo);
|
|
|
- }
|
|
|
- //入库t_org_site表
|
|
|
- int result = orgSiteDao.insertOrgSite(orgId, vo.getSiteId());
|
|
|
- if(result == 0){
|
|
|
- //删除之前入库的数据
|
|
|
- orgDao.delete(orgId);
|
|
|
- powerUserDao.delete(id);
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
- vo.setId(id);
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "add_success"));
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 修改状态(支持批量)
|
|
|
+ */
|
|
|
+ public ResultMsg<?> modifySate(String local, String id, Integer state) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String[] ids = null;
|
|
|
+ if (id.indexOf(",") > 0) {
|
|
|
+ ids = id.split(",");
|
|
|
+ } else {
|
|
|
+ ids = new String[]{id};
|
|
|
+ }
|
|
|
+ int result = powerUserDao.modifyStateBatch(ids, state);
|
|
|
+ if (result > 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "modify_success"));
|
|
|
+ }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "modify_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public ResultMsg<?> getListByParkId(String local, Long parkId,Long parkFlag, int pageNo,
|
|
|
- int pageSize) {
|
|
|
- Page<Map<String,Object>> page = null;
|
|
|
- try{
|
|
|
- //根据parkId查询对应省市区
|
|
|
- Org org = orgDao.get(parkId);
|
|
|
- Integer province = org.getProvince();
|
|
|
- Integer city = org.getCity();
|
|
|
- Integer district= org.getDistrict();
|
|
|
- if(1 == parkFlag){
|
|
|
- parkId = null;
|
|
|
- }
|
|
|
- page = powerUserDao.selectListByParkId(parkId,province,city,district,pageNo,pageSize);
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","get_success"),page);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ public ResultMsg<?> getList(String local, String cityId) {
|
|
|
+ try {
|
|
|
+ QueryRule queryRule = QueryRule.getInstance();
|
|
|
+ if (!StringUtils.isEmpty(cityId)) {
|
|
|
+ queryRule.andLike("city", cityId);
|
|
|
+ }
|
|
|
+ List<PowerUser> list = powerUserDao.find(queryRule);
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "get_success"), list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public ResultMsg<?> removeParkId(String local, String id) {
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }
|
|
|
-
|
|
|
- try{
|
|
|
- String []ids = id.split(",");
|
|
|
- int result = powerUserDao.modifyParkIdBatch(ids,null);
|
|
|
- if(result > 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","remove_success"));
|
|
|
- }
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public ResultMsg<?> add(String local, PowerUserVo vo, JSONObject userinfo) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isEmpty(vo.getName()) || StringUtils.isEmpty(vo.getAddress()) || StringUtils.isEmpty(vo.getCoordinate())) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
+ if (null == vo.getFgpFlag()) {
|
|
|
+ vo.setFgpFlag(SystemConstant.DISABLE);
|
|
|
+ }
|
|
|
+ if (null == vo.getPowerSupply()) {
|
|
|
+ vo.setPowerSupply(SystemConstant.ENABLE);
|
|
|
+ }
|
|
|
+ if (null == vo.getJffs()) {
|
|
|
+ vo.setJffs(SystemConstant.DISABLE);
|
|
|
+ }
|
|
|
+ //入库t_org表
|
|
|
+ Org org = new Org();
|
|
|
+ DataUtils.copySimpleObject(vo, org);
|
|
|
+ org.setOrgType(1);
|
|
|
+ org.setCreateTime(System.currentTimeMillis());
|
|
|
+ org.setCreatorId(userinfo.getJSONObject("user").getLong("id"));
|
|
|
+ org.setDel(SystemConstant.DISABLE);
|
|
|
+ StringBuffer appNo = new StringBuffer();
|
|
|
+ //app授权
|
|
|
+ if (null != vo.getAppNo() && vo.getAppNo().length > 0) {
|
|
|
+ for (int i = 0; i < vo.getAppNo().length; i++) {
|
|
|
+ if (i < vo.getAppNo().length - 1) {
|
|
|
+ appNo.append(vo.getAppNo()[i]).append(",");
|
|
|
+ } else {
|
|
|
+ appNo.append(vo.getAppNo()[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ org.setAppNo(appNo.toString());
|
|
|
+ Long orgId = orgDao.saveAndReturnId(org);
|
|
|
+ if (orgId == 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
+ //入库t_poweruser表
|
|
|
+ PowerUser powerUser = new PowerUser();
|
|
|
+ DataUtils.copySimpleObject(vo, powerUser);
|
|
|
+ powerUser.setOrgId(orgId);
|
|
|
+ powerUser.setState(SystemConstant.DISABLE);
|
|
|
+ Long id = powerUserDao.insertAndReturnId(powerUser);
|
|
|
+ if (id == 0) {
|
|
|
+ //删除之前入库的数据
|
|
|
+ orgDao.delete(orgId);
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public ResultMsg<?> addParkId(String local, Long parkId, String id) {
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
-
|
|
|
- try{
|
|
|
- String []ids = id.split(",");
|
|
|
- int result = powerUserDao.modifyParkIdBatch(ids,parkId);
|
|
|
- if(result > 0){
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS,I18nConfig.getValue(local, "tips","add_success"));
|
|
|
- }
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
- }
|
|
|
- }
|
|
|
+ if (null == vo.getSiteId() || vo.getSiteId().length == 0) {
|
|
|
+ vo.setId(id);
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "add_success"), vo);
|
|
|
+ }
|
|
|
+ //入库t_org_site表
|
|
|
+ int result = orgSiteDao.insertOrgSite(orgId, vo.getSiteId());
|
|
|
+ if (result == 0) {
|
|
|
+ //删除之前入库的数据
|
|
|
+ orgDao.delete(orgId);
|
|
|
+ powerUserDao.delete(id);
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
+ vo.setId(id);
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "add_success"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultMsg<?> getListByParkId(String local, Long parkId, Long parkFlag, int pageNo,
|
|
|
+ int pageSize) {
|
|
|
+ Page<Map<String, Object>> page = null;
|
|
|
+ try {
|
|
|
+ //根据parkId查询对应省市区
|
|
|
+ Org org = orgDao.get(parkId);
|
|
|
+ Integer province = org.getProvince();
|
|
|
+ Integer city = org.getCity();
|
|
|
+ Integer district = org.getDistrict();
|
|
|
+ if (1 == parkFlag) {
|
|
|
+ parkId = null;
|
|
|
+ }
|
|
|
+ page = powerUserDao.selectListByParkId(parkId, province, city, district, pageNo, pageSize);
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "get_success"), page);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "get_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultMsg<?> removeParkId(String local, String id) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String[] ids = id.split(",");
|
|
|
+ int result = powerUserDao.modifyParkIdBatch(ids, null);
|
|
|
+ if (result > 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "remove_success"));
|
|
|
+ }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "remove_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultMsg<?> addParkId(String local, Long parkId, String id) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_PARAM_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String[] ids = id.split(",");
|
|
|
+ int result = powerUserDao.modifyParkIdBatch(ids, parkId);
|
|
|
+ if (result > 0) {
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_SUCCESS, I18nConfig.getValue(local, "tips", "add_success"));
|
|
|
+ }
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResultMsg<Object>(SystemConstant.RESULT_STATUS_ERROR, I18nConfig.getValue(local, "tips", "add_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|