|
|
@@ -0,0 +1,137 @@
|
|
|
+package restcontroller.prsx.hospitaldep;
|
|
|
+
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import beans.datatag.DataTag;
|
|
|
+import beans.datateam.DataTeam;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 医院科室管理
|
|
|
+ */
|
|
|
+public class hospitaldep extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public hospitaldep(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "新建或编辑", apiversion = R.ID2025101409385002.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+
|
|
|
+ Long sa_hospitaldepid = content.getLongValue("sa_hospitaldepid");
|
|
|
+ Long sa_customersid = content.getLongValue("sa_customersid");
|
|
|
+ String hospitaldepname = content.getStringValue("hospitaldepname");
|
|
|
+
|
|
|
+ if (!dbConnect.runSqlQuery("select * from sa_hospitaldep WHERE siteid='" + siteid + "' and sa_customersid=" + sa_customersid + " and hospitaldepname='" + hospitaldepname + "' and sa_hospitaldepid !='" + sa_hospitaldepid + "'").isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该医院科室不可重复创建!").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sa_hospitaldepid <= 0) {
|
|
|
+ sa_hospitaldepid = createTableID("sa_hospitaldep");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_hospitaldep");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sa_hospitaldepid);
|
|
|
+ insertSQL.setValue("hospitaldepname", hospitaldepname);
|
|
|
+ insertSQL.setValue("sa_customersid", sa_customersid);
|
|
|
+ insertSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ insertSQL.setValue("remarks", content.getStringValue("remarks"));
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_hospitaldep", sa_hospitaldepid, "新建", "新建成功").getSQL());
|
|
|
+ //数据团队新增
|
|
|
+ sqlList.addAll(DataTeam.createTeamSQL(this, "sa_hospitaldep", sa_hospitaldepid, userid));
|
|
|
+ } else {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_hospitaldep");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_hospitaldepid);
|
|
|
+ updateSQL.setValue("hospitaldepname", content.getStringValue("hospitaldepname"));
|
|
|
+ updateSQL.setValue("sa_customersid", sa_customersid);
|
|
|
+ updateSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ updateSQL.setValue("remarks", content.getStringValue("remarks"));
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_hospitaldep", sa_hospitaldepid, "编辑", "编辑成功").getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ content.put("sa_hospitaldepid", sa_hospitaldepid);
|
|
|
+
|
|
|
+
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "详情", apiversion = R.ID2025101409393102.v1.class)
|
|
|
+ public String detail() throws YosException {
|
|
|
+
|
|
|
+ Long sa_hospitaldepid = content.getLongValue("sa_hospitaldepid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_hospitaldep", "*").setTableAlias("t1");
|
|
|
+
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("t1.sa_hospitaldepid", sa_hospitaldepid);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_hospitaldepid", new ArrayList<>());
|
|
|
+ RowsMap leaderRows = DataTeam.getLeader(this, "sa_hospitaldep", rows.toArrayList("sa_hospitaldepid")).toRowsMap("ownerid");
|
|
|
+ //标签
|
|
|
+ HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_hospitaldep", ids, false);
|
|
|
+ //系统标签
|
|
|
+ HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_hospitaldep", ids, true);
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_hospitaldepid");
|
|
|
+ row.put("leader", leaderRows.get(row.getString("sa_hospitaldepid")));
|
|
|
+ if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
|
|
|
+ row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
|
|
|
+ }
|
|
|
+ ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<>();
|
|
|
+ ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<>();
|
|
|
+ //非系统标签
|
|
|
+ row.put("tag", tag);
|
|
|
+ //系统标签
|
|
|
+ row.put("tag_sys", sys_tag);
|
|
|
+ //预估手术总量
|
|
|
+ row.putIfAbsent("totalop", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除", apiversion = R.ID2025101409395902.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+
|
|
|
+ Long sa_hospitaldepid = content.getLongValue("sa_hospitaldepid");
|
|
|
+ DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sa_hospitaldep");
|
|
|
+ deleteSQL.setSiteid(siteid);
|
|
|
+ deleteSQL.setUniqueid(sa_hospitaldepid);
|
|
|
+ deleteSQL.delete();
|
|
|
+ DataContrlLog.createLog(this, "sa_hospitaldep", sa_hospitaldepid, "删除", "删除成功").insert();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "列表", apiversion = R.ID2025101409402402.v1.class)
|
|
|
+ public String list() throws YosException {
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "选择医院列表", apiversion = R.ID2025101409411402.v1.class)
|
|
|
+ public String chooseHospital() throws YosException {
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|