xinyb_
2021-10-18 d601d30099461edaad443625ceba80bd4d4c6ecb
优化APP提醒项的保存和更新
1个文件已添加
1个文件已修改
74 ■■■■■ 已修改文件
src/com/yc/action/personalized/controller/DesktopPanelAction.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/action/personalized/entity/TermEntity.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/action/personalized/controller/DesktopPanelAction.java
@@ -2,6 +2,7 @@
import com.yc.action.personalized.entity.CallBackMsg;
import com.yc.action.personalized.entity.PanelDataEntity;
import com.yc.action.personalized.entity.TermEntity;
import com.yc.multiData.SpObserver;
import com.yc.service.impl.DBHelper;
import com.yc.service.oapanel.WebMenuAccessIfc;
@@ -11,6 +12,7 @@
import com.yc.service.personalized.PanelDataIfc;
import com.yc.service.personalized.PanelGridIfc;
import com.yc.utils.SessionKey;
import jodd.jtx.meta.Transaction;
import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -62,34 +64,43 @@
    @RequestMapping(value = "/setDeskTop.do", method = RequestMethod.POST)
    @ResponseBody
    public CallBackMsg setDeskTopPanel(@RequestBody PanelDataEntity data, HttpServletRequest request) {
    @Transaction
    public CallBackMsg setDeskTopPanel(@RequestBody TermEntity term, HttpServletRequest request) {
        CallBackMsg msg = new CallBackMsg();
        try {
            SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
            if (data.getFormId() == 0 || data.getFormType() == 0 || StringUtils.isBlank(data.getUserCode())) {
                msg.setFail("参数不能为空");
                return msg;
            Map<String, Object> formIdMap=null;
            List<Map<String, String>> list1 = new ArrayList<>();
            List<Map<String, String>> list2 = new ArrayList<>();
            for(PanelDataEntity data : term.getTerm()) {
                if (data.getFormId() == 0 || data.getFormType() == 0 || StringUtils.isBlank(term.getUserCode())) {
                    msg.setFail("参数不能为空");
                    return msg;
                }
                //是否存在
                formIdMap = positionIfc.getIsGroup(term.getUserCode(), data.getFormId(), data.getFormType());
                Map<String, String> map = new HashMap<>();
                if (formIdMap != null && DBHelper.getValueInt(formIdMap, "formid") != 0) {
                    //存在是更新状态
                    map.put("checked", data.getIsShow() + "");
                    map.put("fid", data.formId + "");
                    list1.add(map);
                } else {
                    //不存在是添加
                    map.put("checked", "1");
                    map.put("fid", data.formId + "");
                    map.put("formtype", data.getFormType() + "");
                    map.put("fname", data.getFormName());
                    list2.add(map);
                }
            }
            //是否存在
            Map<String, Object> formIdMap = positionIfc.getIsGroup(data.getUserCode(), data.getFormId(), data.getFormType());
            List<Map<String, String>> list = new ArrayList<>();
            Map<String, String> map = new HashMap<>();
            if (formIdMap != null && DBHelper.getValueInt(formIdMap, "formid") != 0) {
                //存在是更新状态
                map.put("checked", data.getIsShow() + "");
                map.put("fid", data.formId + "");
                list.add(map);
                positionIfc.updateGroup(list, data.getUserCode());
            } else {
                //不存在是添加
                map.put("checked", "1");
                map.put("fid", data.formId + "");
                map.put("formtype", data.getFormType() + "");
                map.put("fname", data.getFormName());
                list.add(map);
                int chgid = groupIfc.getTop1GroupId(data.getUserCode());
                int maxSort = positionIfc.getMaxSort(data.getUserCode());
                positionIfc.addPanelPosition(list, maxSort, chgid, data.getUserCode());
            if(list1!=null && list1.size()>0){//修改
                positionIfc.updateGroup(list1, term.getUserCode());
            }
            if(list2!=null && list2.size()>0){//添加
                int chgid = groupIfc.getTop1GroupId(term.getUserCode());
                int maxSort = positionIfc.getMaxSort(term.getUserCode());
                positionIfc.addPanelPosition(list2, maxSort, chgid, term.getUserCode());
            }
            msg.setOk("设置完成!");
        } catch (Exception e) {
src/com/yc/action/personalized/entity/TermEntity.java
New file
@@ -0,0 +1,15 @@
package com.yc.action.personalized.entity;
import lombok.Data;
import java.util.List;
/**
 * @USER: xinyb_
 * @DATE: 2021-10-18 09:54
 */
@Data
public class TermEntity {
    String userCode;
    List<PanelDataEntity> term;
}