|
@@ -1,6 +1,8 @@
|
|
|
package com.jeesite.modules.mes.web;
|
|
package com.jeesite.modules.mes.web;
|
|
|
|
|
|
|
|
import com.jeesite.common.config.Global;
|
|
import com.jeesite.common.config.Global;
|
|
|
|
|
+import com.jeesite.common.collect.ListUtils;
|
|
|
|
|
+import com.jeesite.common.collect.MapUtils;
|
|
|
import com.jeesite.common.entity.Page;
|
|
import com.jeesite.common.entity.Page;
|
|
|
import com.jeesite.common.lang.StringUtils;
|
|
import com.jeesite.common.lang.StringUtils;
|
|
|
import com.jeesite.common.web.BaseController;
|
|
import com.jeesite.common.web.BaseController;
|
|
@@ -10,6 +12,7 @@ import com.jeesite.modules.mes.service.MesLineProcessService;
|
|
|
import com.jeesite.modules.mes.service.MesLineProcessUserService;
|
|
import com.jeesite.modules.mes.service.MesLineProcessUserService;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -21,6 +24,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.LinkedHashSet;
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -37,6 +42,9 @@ public class MesLineProcessUserController extends BaseController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MesLineProcessService mesLineProcessService;
|
|
private MesLineProcessService mesLineProcessService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取数据
|
|
* 获取数据
|
|
@@ -85,6 +93,50 @@ public class MesLineProcessUserController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 生产工位人员选择树:查询全部正常用户,不按当前登录人的创建人/数据权限过滤。
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesLineProcess:view")
|
|
|
|
|
+ @RequestMapping(value = "userTreeData")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public List<Map<String, Object>> userTreeData() {
|
|
|
|
|
+ List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
|
|
|
|
+ List<Map<String, Object>> officeList = jdbcTemplate.queryForList(
|
|
|
|
|
+ "select office_code, parent_code, office_name " +
|
|
|
|
|
+ "from js_sys_office where status = '0' order by tree_sorts, tree_sort");
|
|
|
|
|
+ for (Map<String, Object> office : officeList) {
|
|
|
|
|
+ Map<String, Object> map = MapUtils.newHashMap();
|
|
|
|
|
+ map.put("id", valueToString(office.get("office_code")));
|
|
|
|
|
+ map.put("pId", StringUtils.defaultIfBlank(valueToString(office.get("parent_code")), "0"));
|
|
|
|
|
+ map.put("name", office.get("office_name"));
|
|
|
|
|
+ map.put("isParent", true);
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> userList = jdbcTemplate.queryForList(
|
|
|
|
|
+ "select u.user_code, u.login_code, u.user_name, u.ref_name, e.emp_name, e.office_code " +
|
|
|
|
|
+ "from js_sys_user u " +
|
|
|
|
|
+ "left join js_sys_employee e on e.emp_code = u.ref_code and e.status = '0' " +
|
|
|
|
|
+ "where u.status = '0' and u.user_type = 'employee' " +
|
|
|
|
|
+ "order by e.office_code, u.user_weight desc, u.user_name, u.login_code");
|
|
|
|
|
+ for (Map<String, Object> user : userList) {
|
|
|
|
|
+ Map<String, Object> map = MapUtils.newHashMap();
|
|
|
|
|
+ String userCode = valueToString(user.get("user_code"));
|
|
|
|
|
+ String userName = firstNotBlank(
|
|
|
|
|
+ valueToString(user.get("user_name")),
|
|
|
|
|
+ valueToString(user.get("ref_name")),
|
|
|
|
|
+ valueToString(user.get("emp_name")),
|
|
|
|
|
+ valueToString(user.get("login_code")),
|
|
|
|
|
+ userCode);
|
|
|
|
|
+ map.put("id", userCode);
|
|
|
|
|
+ map.put("pId", StringUtils.defaultIfBlank(valueToString(user.get("office_code")), "0"));
|
|
|
|
|
+ map.put("name", userName);
|
|
|
|
|
+ map.put("isParent", false);
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ return mapList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 保存数据
|
|
* 保存数据
|
|
|
*/
|
|
*/
|
|
|
@RequiresPermissions("mes:mesLineProcess:edit")
|
|
@RequiresPermissions("mes:mesLineProcess:edit")
|
|
@@ -143,4 +195,20 @@ public class MesLineProcessUserController extends BaseController {
|
|
|
return renderResult(Global.TRUE, text("删除成功!"));
|
|
return renderResult(Global.TRUE, text("删除成功!"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String firstNotBlank(String... values) {
|
|
|
|
|
+ if (values == null) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String value : values) {
|
|
|
|
|
+ if (StringUtils.isNotBlank(value)) {
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String valueToString(Object value) {
|
|
|
|
|
+ return value == null ? "" : String.valueOf(value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|