|
@@ -0,0 +1,280 @@
|
|
|
+package restcontroller.webmanage.saletool.sharematerial;
|
|
|
+
|
|
|
+import beans.attachment.Attachment;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设计实景管理
|
|
|
+ */
|
|
|
+public class DesignPic extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public DesignPic(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sat_sharematerial = "sat_sharematerial";
|
|
|
+
|
|
|
+ @API(title = "设计实景新增或编辑", apiversion = R.ID20240417104602.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+
|
|
|
+ if (content.containsKey("sys_enterpriseid") && content.getLongValue("sys_enterpriseid") > 0) {
|
|
|
+ sys_enterpriseid = content.getLongValue("sys_enterpriseid");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (sat_sharematerialid <= 0) {
|
|
|
+ sat_sharematerialid = createTableID(sat_sharematerial);
|
|
|
+ InsertSQL sqlFactory = SQLFactory.createInsertSQL(this, sat_sharematerial);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setUniqueid(sat_sharematerialid);
|
|
|
+ sqlFactory.setValue("classid", 5);
|
|
|
+ sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.setValue("title", content.getStringValue("title"));
|
|
|
+ sqlFactory.setValue("title_c", content.getStringValue("title_c"));
|
|
|
+ sqlFactory.setValue("type", content.getIntValue("type", 4));
|
|
|
+ sqlFactory.setValue("panoramaurl", content.getStringValue("panoramaurl", true));
|
|
|
+ sqlFactory.setValue("sequence", content.getLongValue("sequence"));
|
|
|
+ sqlFactory.setValue("renderingsclass", content.getJSONObject("renderingsclass"));
|
|
|
+ sqlFactory.setValue("isnationwide", content.getBooleanValue("isnationwide"));
|
|
|
+
|
|
|
+ sqlFactory.insert();
|
|
|
+ content.put("sat_sharematerialid", sat_sharematerialid);
|
|
|
+ } else {
|
|
|
+ UpdateSQL sqlFactory = SQLFactory.createUpdateSQL(this, sat_sharematerial);
|
|
|
+ sqlFactory.setUniqueid(sat_sharematerialid);
|
|
|
+ sqlFactory.setSiteid(siteid);
|
|
|
+ sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.setValue("title", content.getStringValue("title"));
|
|
|
+ sqlFactory.setValue("title_c", content.getStringValue("title_c"));
|
|
|
+ sqlFactory.setValue("type", content.getIntValue("type", 4));
|
|
|
+ sqlFactory.setValue("panoramaurl", content.getStringValue("panoramaurl", true));
|
|
|
+ sqlFactory.setValue("sequence", content.getLongValue("sequence"));
|
|
|
+ sqlFactory.setValue("renderingsclass", content.getJSONObject("renderingsclass"));
|
|
|
+ sqlFactory.setValue("isnationwide", content.getBooleanValue("isnationwide"));
|
|
|
+ sqlFactory.update();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return detail();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "设计实景详情", apiversion = R.ID20240417104702.v1.class)
|
|
|
+ public String detail() throws YosException {
|
|
|
+ Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
|
|
|
+ String ownertable = "sat_sharematerial";
|
|
|
+
|
|
|
+ QuerySQL querySQ = SQLFactory.createQuerySQL(this, "sat_sharematerial",
|
|
|
+ "sat_sharematerialid", "createby", "createdate", "changeby", "changedate", "checkby", "checkdate", "sys_enterpriseid", "title", "type", "sequence", "status"
|
|
|
+ , "title_c", "renderingsclass", "isnationwide", "collectcount", "likecount", "commentcount", "panoramaurl")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ querySQ.addJoinTable(JOINTYPE.left, "sys_datacollect", "t2", "t2.siteid=t1.siteid and t2.ownertable='sat_sharematerial' and type=1 and t2.ownerid=t1.sat_sharematerialid and t2.userid='" + userid + "'");
|
|
|
+ querySQ.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid"
|
|
|
+ , "enterprisename");
|
|
|
+
|
|
|
+ querySQ.addQueryFields("iscollect", "CASE WHEN t2.sys_datacollectid>0 THEN 1 ELSE 0 END");
|
|
|
+ querySQ.setSiteid(siteid);
|
|
|
+ querySQ.setWhere("sat_sharematerialid", sat_sharematerialid);
|
|
|
+
|
|
|
+ Rows rows = querySQ.query();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "查询经销商区域");
|
|
|
+ sqlFactory.addParameter_in("sys_enterpriseid", rows.toArray("sys_enterpriseid"));
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ RowsMap areaRows = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sys_enterpriseid");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ Rows areas = areaRows.getOrDefault(row.getString("sys_enterpriseid"), new Rows());
|
|
|
+ row.put("areaname", StringUtils.join(areas.toArray("areaname"), ","));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Row detailRow = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+
|
|
|
+
|
|
|
+ Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
|
|
|
+ detailRow.put("attinfos", attRows);
|
|
|
+ detailRow.putIfAbsent("areaname", "");
|
|
|
+ detailRow.putIfAbsent("checkdate", "");
|
|
|
+ detailRow.put("appleturl", "xxx/pages/product/ctw/share?id=" + sat_sharematerialid);
|
|
|
+ if (StringUtils.isBlank(detailRow.getString("panoramaurl"))) {
|
|
|
+ detailRow.put("ispanorama", 0);
|
|
|
+ } else {
|
|
|
+ detailRow.put("ispanorama", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL attachmentQuery = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
|
|
|
+ attachmentQuery.setSiteid(detailRow.getString("siteid"));
|
|
|
+ attachmentQuery.setWhere("ownertable", ownertable);
|
|
|
+ attachmentQuery.setWhere("ownerid", sat_sharematerialid);
|
|
|
+ attachmentQuery.setWhere("usetype", ownertable);
|
|
|
+ attachmentQuery.setOrderBy("t1.sequence");
|
|
|
+ Rows attachmentRows = attachmentQuery.query();
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<Long> ids = attachmentRows.toArrayList("attachmentid", new ArrayList<>());
|
|
|
+
|
|
|
+ RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
|
|
|
+
|
|
|
+ for (Row row : attachmentRows) {
|
|
|
+ Rows attPicRows = new Rows();
|
|
|
+ Rows tempAttRows = attRowsMap.getOrDefault(row.getString("attachmentid"), new Rows());
|
|
|
+ for (Row tempAttRow : tempAttRows) {
|
|
|
+ if (tempAttRow.getString("usetype").equals(ownertable)) {
|
|
|
+ attPicRows.add(tempAttRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ row.put("attinfos", attPicRows);
|
|
|
+ }
|
|
|
+
|
|
|
+ detailRow.put("attinfos_pic", attachmentRows);
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(detailRow).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "设计实景列表", apiversion = R.ID20240417104802.v1.class)
|
|
|
+ public String list() throws YosException {
|
|
|
+ /*
|
|
|
+ 过滤条件设置
|
|
|
+ */
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.title like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("begindate_create") && !"".equals(whereObject.getString("begindate_create"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.createdate >='").append(whereObject.getString("begindate_create")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate_create") && !"".equals(whereObject.getString("enddate_create"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.createdate <='").append(whereObject.getString("enddate_create")).append(" 23:59:59' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.checkdate >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.checkdate <='").append(whereObject.getString("enddate")).append(" 23:59:59' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("ispanorama") && !"".equals(whereObject.getString("ispanorama"))) {
|
|
|
+ if (whereObject.getString("ispanorama").equals("1")) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("LENGTH(t1.panoramaurl)>0 ");
|
|
|
+ where.append(")");
|
|
|
+ } else {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("LENGTH(t1.panoramaurl)=0 or t1.panoramaurl is null ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.type ='").append(whereObject.getString("type")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("style") && !"".equals(whereObject.getString("style"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("JSON_CONTAINS(t1.renderingsclass->'$.style', '\"" + whereObject.getString("style") + "\"')");
|
|
|
+ where.append(")");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("space") && !"".equals(whereObject.getString("space"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("JSON_CONTAINS(t1.renderingsclass->'$.space', '\"" + whereObject.getString("space") + "\"')");
|
|
|
+ where.append(")");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("spec") && !"".equals(whereObject.getString("spec"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("JSON_CONTAINS(t1.renderingsclass->'$.spec', '\"" + whereObject.getString("spec") + "\"')");
|
|
|
+ where.append(")");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, sat_sharematerial,
|
|
|
+ "sat_sharematerialid", "title", "status", "type", "commentcount", "likecount", "collectcount", "sequence", "createdate", "checkdate", "renderingsclass")
|
|
|
+ .setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid"
|
|
|
+ , "enterprisename","sys_enterpriseid");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("classid", 5);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "查询经销商区域");
|
|
|
+ sqlFactory.addParameter_in("sys_enterpriseid", rows.toArray("sys_enterpriseid"));
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ RowsMap areaRows = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sys_enterpriseid");
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sat_sharematerialid", new ArrayList<>());
|
|
|
+ // 附件
|
|
|
+ RowsMap RowsMap = getAttachmentUrl(sat_sharematerial, ids);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Rows Rows = RowsMap.getOrDefault(row.getString("sat_sharematerialid"), new Rows());
|
|
|
+ row.put("attinfos", Rows);
|
|
|
+ row.putIfAbsent("checkdate", "");
|
|
|
+ if (StringUtils.isBlank(row.getString("panoramaurl"))) {
|
|
|
+ row.put("ispanorama", 0);
|
|
|
+ } else {
|
|
|
+ row.put("ispanorama", 1);
|
|
|
+ }
|
|
|
+ row.put("appleturl", "xxx/pages/product/ctw/share?id=" + row.getString("sat_sharematerialid"));
|
|
|
+ if (row.getInteger("type") == 4) {
|
|
|
+ row.put("typestr", "设计");
|
|
|
+ }
|
|
|
+ if (row.getInteger("type") == 5) {
|
|
|
+ row.put("typestr", "实景");
|
|
|
+ }
|
|
|
+ Rows areas = areaRows.getOrDefault(row.getString("sys_enterpriseid"), new Rows());
|
|
|
+ String areaname=StringUtils.join(areas.toArray("areaname"), ",");
|
|
|
+ row.put("areaname",areaname);
|
|
|
+ if(StringUtils.isBlank(areaname)){
|
|
|
+ row.put("enterprisename_area",row.getString("enterprisename"));
|
|
|
+ }else {
|
|
|
+ row.put("enterprisename_area",row.getString("enterprisename")+"("+row.getString("areaname")+")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|