中扬CRM客户关系管理系统
LSH
2023-07-27 08db83852d3f00d1be9703e6adb4373395fe1466
#售前规划申请单需求多选
2个文件已添加
3个文件已修改
278 ■■■■■ 已修改文件
src/main/java/com/zy/crm/common/entity/RouteCollectCountType.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/common/utils/SetOfUtils.java 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/controller/PlanController.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/entity/Plan.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/plan/plan.js 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/common/entity/RouteCollectCountType.java
New file
@@ -0,0 +1,42 @@
package com.zy.crm.common.entity;
public enum RouteCollectCountType {
    INTERSECTION(0, "交集"),   // 交集
    DIFFERENCESET(1, "差集"),   // 差集
    UNION(2, "并集"),  //并集
    DEDUPLICATIONUNION(3, "去重并集"),  //去重并集
    ;
    public Integer id;
    public String desc;
    RouteCollectCountType(Integer id, String desc) {
        this.id = id;
        this.desc = desc;
    }
    public static RouteCollectCountType get(Short id) {
        if (null == id) {
            return null;
        }
        for (RouteCollectCountType type : RouteCollectCountType.values()) {
            if (type.id.equals(id.intValue())) {
                return type;
            }
        }
        return null;
    }
    public static RouteCollectCountType get(RouteCollectCountType type) {
        if (null == type) {
            return null;
        }
        for (RouteCollectCountType crnLiftPosType : RouteCollectCountType.values()) {
            if (crnLiftPosType == type) {
                return crnLiftPosType;
            }
        }
        return null;
    }
}
src/main/java/com/zy/crm/common/utils/SetOfUtils.java
New file
@@ -0,0 +1,154 @@
package com.zy.crm.common.utils;
import com.zy.crm.common.entity.RouteCollectCountType;
import java.util.ArrayList;
import java.util.List;
import static java.util.stream.Collectors.toList;
/**
 * Created by Monkey D. Luffy on 2023/7/18
 */
public class SetOfUtils {
//    正序
    public static final List<Integer> TRACK_POSITION_POSITIVE_SEQUENCE = new ArrayList<Integer>() {{
        add(1);add(2);add(3);add(4);add(5);add(6);add(7);add(8);add(9);add(10);add(11);add(12);
    }};
//    反序
    public static final List<Integer> TRACK_POSITION_REVERSE_SEQUENCE = new ArrayList<Integer>() {{
        add(12);add(11);add(10);add(9);add(8);add(7);add(6);add(5);add(4);add(3);add(2);add(1);
    }};
    public static String zerofill(String msg, Integer count){
        if (msg.length() == count){
            return msg;
        } else if (msg.length() > count){
            return msg.substring(0, 16);
        } else {
            StringBuilder msgBuilder = new StringBuilder(msg);
            for (int i = 0; i<count-msg.length(); i++){
                msgBuilder.insert(0,"0");
            }
            return msgBuilder.toString();
        }
    }
    // 获取当前小车未行走的路线集合
    public static List<Integer> getRoute(Integer groupStart,Integer groupEnd){
        boolean sign = groupStart < groupEnd;
        List<Integer> result = new ArrayList<>();
        List<Integer> groupRoute = null;
        if (sign){
            groupRoute = TRACK_POSITION_POSITIVE_SEQUENCE;
        }else {
            groupRoute = TRACK_POSITION_REVERSE_SEQUENCE;
        }
        if (groupRoute.contains(groupStart) && groupRoute.contains(groupEnd)) {
            sign = false;
            for (Integer route : groupRoute) {
                if (route.equals(groupStart)){
                    sign=true;
                }
                if (route.equals(groupEnd)){
                    result.add(route);
                    break;
                }
                if (sign){
                    result.add(route);
                }
            }
        }else {
            return null;
        }
        return result;
    }
    //是否有交集
    public static boolean getRouteBoolean(List<Integer> groupCurrent,List<Integer> groupOther){
        for (Integer positionCurrent : groupCurrent){
            for (Integer positionOther : groupOther){
                if (positionCurrent.equals(positionOther)){
                    return true;
                }
            }
        }
        return false;
    }
    //集合运算
    public static List<Integer> getRouteIntersection(List<Integer> groupCurrent, List<Integer> groupOther, RouteCollectCountType routeCollectCountType){
        switch (routeCollectCountType){
            case INTERSECTION:
                //交集
                return groupCurrent.stream().filter(item -> groupOther.contains(item)).collect(toList());
            case DIFFERENCESET:
                //差集
                return groupCurrent.stream().filter(item -> !groupOther.contains(item)).collect(toList());
            case UNION:
                //并集
                groupCurrent.addAll(groupOther);
                return groupCurrent;
            case DEDUPLICATIONUNION:
                //去重并集
                groupCurrent.addAll(groupOther);
                return groupCurrent.stream().distinct().collect(toList());
            default:
                return null;
        }
    }
    //集合运算
    public static List<String> getRouteIntersectionString(List<String> groupCurrent, List<String> groupOther, RouteCollectCountType routeCollectCountType){
        switch (routeCollectCountType){
            case INTERSECTION:
                //交集
                List<String> intersection = groupCurrent.stream().filter(item -> groupOther.contains(item)).collect(toList());
                return intersection;
            case DIFFERENCESET:
                //差集
                List<String> reduce1 = groupCurrent.stream().filter(item -> !groupOther.contains(item)).collect(toList());
                return reduce1;
            case UNION:
                //并集
                List<String> listAll = groupCurrent.parallelStream().collect(toList());
                List<String> listAll2 = groupOther.parallelStream().collect(toList());
                listAll.addAll(listAll2);
                return listAll;
            case DEDUPLICATIONUNION:
                //去重并集
                List<String> listAll1 = groupCurrent.parallelStream().collect(toList());
                List<String> listAll21 = groupOther.parallelStream().collect(toList());
                listAll1.addAll(listAll21);
                List<String> listAllDistinct = listAll1.stream().distinct().collect(toList());
                return listAllDistinct;
            default:
                return null;
        }
    }
    public static void main(String[] arge){
        List<Integer> routeCurrent = getRoute(2, 9);  //获取当前小车路径
        List<Integer> routeOther = getRoute(12, 5);  //获取其它小车路径
        System.out.println("当前小车路径:\t"+routeCurrent);
        System.out.println("其它小车路径:\t"+routeOther);
        boolean routeBoolean = getRouteBoolean(routeCurrent, routeOther);  //是否有交集
        System.out.println("是否有交集:\t"+routeBoolean);
        List<Integer> routeIntersection = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.INTERSECTION);//交集
        System.out.println("路径交集:\t"+routeIntersection);
        List<Integer> routeIntersection1 = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.DIFFERENCESET);//差集
        System.out.println("路径差集:\t"+routeIntersection1);
        List<Integer> routeIntersection2 = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.UNION);//并集
        System.out.println("路径并集:\t"+routeIntersection2);
        List<Integer> routeIntersection3 = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.DEDUPLICATIONUNION);//去重并集
        System.out.println("路径去重并集:\t"+routeIntersection3);
    }
}
src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -12,7 +12,9 @@
import com.core.common.R;
import com.core.domain.KeyValueVo;
import com.core.exception.CoolException;
import com.zy.crm.common.entity.RouteCollectCountType;
import com.zy.crm.common.model.SettleDto;
import com.zy.crm.common.utils.SetOfUtils;
import com.zy.crm.common.web.BaseController;
import com.zy.crm.manager.controller.result.FollowerTableVo;
import com.zy.crm.manager.entity.Plan;
@@ -38,6 +40,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import static java.util.stream.Collectors.toList;
@RestController
public class PlanController extends BaseController {
@@ -145,11 +149,43 @@
    @RequestMapping(value = "/plan/update/auth")
    @ManagerAuth
    public R update(@RequestParam Map<String, Object> param){
        String planNeed = null;
        Integer id = null;
        for (Map.Entry<String, Object> entry : param.entrySet()){
            String val = String.valueOf(entry.getValue());
            if (Cools.isEmpty(val)){
                continue;
            }
            if (entry.getKey().equals("planNeed")){
                planNeed = val;
            }
            if (entry.getKey().equals("id")){
                try{
                    id = Integer.parseInt(val);
                }catch (Exception e){
                    return R.error();
                }
            }
        }
        if (Cools.isEmpty(param) || Cools.isEmpty(param.get("id"))){
            return R.error();
        }
        List<String> planNeedbs = new ArrayList<>(Arrays.asList(planNeed.split("-")));
        if (planNeedbs.get(0).equals("[object Object]")){
            planNeedbs.remove(0);
            Plan plan1 = planService.selectById(id);
            List<String> planNeedas = Arrays.asList(plan1.getPlanNeed().split("-"));
            List<String> routeIntersectionString = SetOfUtils.getRouteIntersectionString(planNeedas, planNeedbs, RouteCollectCountType.DEDUPLICATIONUNION);
            planNeed="";
            for (String planNeedss:routeIntersectionString){
                planNeed=planNeed==""? planNeedss:planNeed + "-" + planNeedss;
            }
        }
        // pre
        Plan plan = JSON.parseObject(JSON.toJSONString(param), Plan.class);
        plan.setPlanNeed(planNeed);
        param.entrySet().removeIf(next -> this.fields.contains(next.getKey()));
        plan.setUpdateBy(getUserId());
        plan.setUpdateTime(new Date());
src/main/java/com/zy/crm/manager/entity/Plan.java
@@ -104,7 +104,7 @@
     */
    @ApiModelProperty(value= "方案所需")
    @TableField("plan_need")
    private Long planNeed;
    private String planNeed;
    /**
     * 立项 1: 是  0: 否
@@ -299,11 +299,16 @@
    public String getPlanNeed$(){
        PlanNeedService service = SpringUtils.getBean(PlanNeedService.class);
        PlanNeed planNeed = service.selectById(this.planNeed);
        if (!Cools.isEmpty(planNeed)){
            return String.valueOf(planNeed.getName());
        String[] planNeeds = this.planNeed.split("-");
        String name="";
        for (String planNeeda : planNeeds){
            PlanNeed planNeed = service.selectById(Integer.parseInt(planNeeda));
            if (!Cools.isEmpty(planNeed)){
//                return String.valueOf(planNeed.getName());
                name = name+planNeed.getName()+";";
            }
        }
        return null;
        return name;
    }
    public String getBeItem$(){
src/main/webapp/static/js/plan/plan.js
@@ -257,7 +257,12 @@
                                                        data.field.orderId = orderSel.getValue()[0] ? orderSel.getValue()[0].value : null;
                                                        data.field.cstmrId = cstmrSel.getValue()[0] ? cstmrSel.getValue()[0].value : null;
                                                        data.field.userId = userSel.getValue()[0] ? userSel.getValue()[0].value : null;
                                                        data.field.planNeed = planNeedSel.getValue()[0] ? planNeedSel.getValue()[0].value : null;
                                                        // data.field.planNeed = planNeedSel.getValue()[0] ? planNeedSel.getValue()[0].value : null;
                                                        var planNeedValue= planNeedSel.getValue()[0] ? planNeedSel.getValue()[0].value : null;
                                                        for (var i=1;i<planNeedSel.getValue().length;i++){
                                                            planNeedValue =planNeedSel.getValue()[i] ? planNeedValue+"-"+planNeedSel.getValue()[i].value : planNeedValue;
                                                        }
                                                        data.field.planNeed = planNeedValue;
                                                        delete data.field.select;delete data.field.planTypeName;
@@ -511,7 +516,20 @@
                            if (plan.orderId) { orderSel.setValue([{name: plan.orderId$, value: plan.orderId}]); }
                            if (plan.cstmrId) { cstmrSel.setValue([{name: plan.cstmrId$, value: plan.cstmrId}]); }
                            if (plan.userId) { userSel.setValue([{name: plan.userId$, value: plan.userId}]); }
                            if (plan.planNeed) { planNeedSel.setValue([{name: plan.planNeed$, value: plan.planNeed}]); }
                            // console.log(plan);
                            // console.log(plan.planNeed);
                            // console.log(plan.planNeed.split("-"));
                            // console.log(plan.planNeed.split("-").length);
                            let split = plan.planNeed.split("-");
                            // console.log(split);
                            // console.log(split.length);
                            if (plan.planNeed) {
                                var planNeedValue1=split[0];
                                for (var i=1;i<split.length;i++){
                                    planNeedValue1 = planNeedSel+"-" +split[i];
                                }
                                planNeedSel.setValue([{name: plan.planNeed$, value: planNeedValue1}]);
                            }
                            layDateRender(plan);
                            plan['planTypeName'] = plan.planType$;
                            form.val('detail', plan);
@@ -519,8 +537,12 @@
                                data.field.orderId = orderSel.getValue()[0] ? orderSel.getValue()[0].value : null;
                                data.field.cstmrId = cstmrSel.getValue()[0] ? cstmrSel.getValue()[0].value : null;
                                data.field.userId = userSel.getValue()[0] ? userSel.getValue()[0].value : null;
                                data.field.planNeed = planNeedSel.getValue()[0] ? planNeedSel.getValue()[0].value : null;
                                // data.field.planNeed = planNeedSel.getValue()[0] ? planNeedSel.getValue()[0].value : null;
                                var planNeedValue= planNeedSel.getValue()[0] ? planNeedSel.getValue()[0].value : null;
                                for (var i=1;i<planNeedSel.getValue().length;i++){
                                    planNeedValue =planNeedSel.getValue()[i] ? planNeedValue+"-"+planNeedSel.getValue()[i].value : planNeedValue;
                                }
                                data.field.planNeed = planNeedValue;
                                delete data.field.select;delete data.field.planTypeName;
                                if (!data.field.orderId) {
@@ -725,7 +747,6 @@
            autoRow: true,
            filterable: true,
            remoteSearch: true,
            radio: true,
            remoteMethod: function (val, cb, show) {
                $.ajax({
                    url: baseUrl + "/planNeed/all/get/kv",