yusm 5 месяцев назад
Родитель
Сommit
3692fbe353

+ 95 - 10
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/BusinessOpportunityController.java

@@ -8,10 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.management.platform.entity.*;
-import com.management.platform.mapper.BusinessOpportunityMapper;
-import com.management.platform.mapper.ClueMapper;
-import com.management.platform.mapper.SysFormMapper;
-import com.management.platform.mapper.UserMapper;
+import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.management.platform.service.impl.ExcelExportServiceImpl;
 import com.management.platform.util.HttpRespMsg;
@@ -63,6 +60,8 @@ public class BusinessOpportunityController {
     private BusinessOpportunityMapper boMapper;
     @Resource
     private BusinessOpportunityMapper businessOpportunityMapper;
+    @Resource
+    private ActionLogMapper actionLogMapper;
 
     @RequestMapping("getAll")
     public Object getAll(HttpServletRequest request) {
@@ -246,6 +245,14 @@ public class BusinessOpportunityController {
             bo.setUserId(user.getId());
             bo.setCreateTime(new Date());
             bo.setIsDelete(0);
+            QueryWrapper<BusinessOpportunity> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("stage_id", bo.getStageId()).eq("is_delete",0).orderByDesc("seq").last("limit 1");
+            List<BusinessOpportunity> list = bOservice.list(queryWrapper);
+            if (list != null && list.size() > 0) {
+                bo.setSeq(list.get(0).getSeq()+1);
+            }else {
+                bo.setSeq(1);
+            }
             bOservice.insert(bo);
         }else {
             //修改
@@ -290,6 +297,78 @@ public class BusinessOpportunityController {
         return msg;
     }
 
+
+    @RequestMapping("/changeOrder")
+    public HttpRespMsg changeOrder(HttpServletRequest request,Integer id, Integer oldIndex, Integer newIndex, Integer oldStagesId, Integer newStagesId) {
+
+        HttpRespMsg msg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("Token"));
+        BusinessOpportunity curItem = new BusinessOpportunity();
+        curItem.setId(id);
+        if (!oldStagesId.equals(newStagesId)) {
+            //获取移动到的目标位置上一个数据的seq,计算当前任务的新seq
+            //跨stage移动,旧的stage上移除,切换stages后,旧的任务列表自动会重新排序,不需要再操作
+            curItem.setStageId(newStagesId);
+//            curItem.setStageValue(sy.getById(newStagesId).getStagesName());
+        }
+
+        QueryWrapper<BusinessOpportunity> queryWrapper = new QueryWrapper<BusinessOpportunity>();
+        int startSeq = 0;
+        if (newIndex > 0) {
+            int beforeItemIndex = 0;
+            if (oldStagesId.equals(newStagesId)) {
+                beforeItemIndex = newIndex > oldIndex?newIndex:newIndex-1;
+            } else {
+                //跨stages移动,相当于从下往上移动
+                beforeItemIndex = newIndex-1;
+            }
+            queryWrapper.eq("stage_id", newStagesId).eq("is_delete",0).orderByAsc("seq").last("limit " +beforeItemIndex+", 1");
+            List<BusinessOpportunity> list = bOservice.list(queryWrapper);
+            if (list.size() > 0) {
+                BusinessOpportunity beforeItem = list.get(0);
+                startSeq = beforeItem.getSeq() + 1;
+            } else {
+                startSeq = 1;
+            }
+        } else {
+            //移动到了第一个位置
+            startSeq = 1;
+        }
+
+        curItem.setSeq(startSeq);
+        //在新位置下面的包括原来占据新位置的,全部调整,从startSeq开始递增
+        queryWrapper = new QueryWrapper<BusinessOpportunity>();
+        queryWrapper.eq("stage_id", newStagesId).eq("is_delete",0).ge("seq", startSeq).orderByAsc("seq");
+        List<BusinessOpportunity> list = bOservice.list(queryWrapper);
+        if (list.size() > 0) {
+            List<BusinessOpportunity> batchList = new ArrayList<>();
+            for (BusinessOpportunity t:list) {
+                BusinessOpportunity item = new BusinessOpportunity();
+                item.setId(t.getId());
+                startSeq++;
+                item.setSeq(startSeq);
+                batchList.add(item);
+            }
+            bOservice.updateBatchById(batchList);
+        }
+
+        if (!newStagesId.equals(oldStagesId)){
+            curItem.setEditTime(new Date());
+            Stage stage = stageService.getOne(new QueryWrapper<Stage>().eq("id", newStagesId).eq("company_id", user.getCompanyId()));
+            ActionLog al = new ActionLog();
+            al.setCode("business");
+            al.setName("推进了阶段至" + stage.getName());
+            al.setCreatTime(new Date());
+            al.setUserId(user.getId());
+            al.setItemId(id);
+            actionLogMapper.insert(al);
+        }
+        bOservice.updateById(curItem);
+
+        return msg;
+    }
+
+
     @RequestMapping("list")
     public HttpRespMsg list(BusinessOpportunity bo, HttpServletRequest request) {
         HashMap<Object, Object> r = new HashMap<>();
@@ -333,7 +412,6 @@ public class BusinessOpportunityController {
         List<BusinessOpportunity> list = new ArrayList<>();
         boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部商机");
         boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门商机");
-        int i = 0;
         if (isAll) {
             list = bOservice.getAll(bo);
         } else if (isNotAll) {
@@ -343,14 +421,21 @@ public class BusinessOpportunityController {
         }
 
         HttpRespMsg msg = new HttpRespMsg();
-        List<Stage> stageList = stageService.list(new QueryWrapper<Stage>().eq("company_id", user.getCompanyId()));
-        HashMap<String, Object> map = new HashMap<>();
+        List<Stage> stageList = stageService.list(new QueryWrapper<Stage>().eq("company_id", user.getCompanyId()).orderByAsc("seq"));
+
+        List<HashMap<String, Object>> mapList = new ArrayList<>();
         for (Stage stage : stageList) {
             List<BusinessOpportunity> collect = list.stream().filter(l -> l.getStageId() != null && l.getStageId().equals(stage.getId())).collect(Collectors.toList());
-            HashMap<String, Object> hashMap = new HashMap<>();
-            map.put(stage.getName(),collect);
+            collect=collect.stream().sorted(Comparator.comparing(BusinessOpportunity::getSeq)).collect(Collectors.toList());
+            HashMap<String, Object> map = new HashMap<>();
+            map.put("id", stage.getId());
+            map.put("label",stage.getName());
+            map.put("length",collect.size());
+            map.put("list",collect);
+            map.put("color",stage.getColor());
+            mapList.add(map);
         }
-        msg.setData(map);
+        msg.setData(mapList);
         return msg;
 
     }

+ 6 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/BusinessOpportunity.java

@@ -22,7 +22,7 @@ import org.springframework.format.annotation.DateTimeFormat;
  * </p>
  *
  * @author Seyason
- * @since 2024-03-22
+ * @since 2024-12-03
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -192,6 +192,11 @@ public class BusinessOpportunity extends Model<BusinessOpportunity> {
     @TableField(exist = false)
     private List<UploadFile> uploadFilePList;
 
+    /**
+     * 排序
+     */
+    @TableField("seq")
+    private Integer seq;
 
 
     @Override

+ 7 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Stage.java

@@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author Seyason
- * @since 2024-03-29
+ * @since 2024-12-03
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -56,6 +56,12 @@ public class Stage extends Model<Stage> {
     @TableField("is_finish")
     private Integer isFinish;
 
+    /**
+     * 颜色
+     */
+    @TableField("color")
+    private String color;
+
 
     @Override
     protected Serializable pkVal() {

+ 10 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/BusinessOpportunityServiceImpl.java

@@ -710,7 +710,16 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
 
     @Override
     public void saveStage(BusinessOpportunity bo, User user) {
-        bOMapper.update(bo, new UpdateWrapper<BusinessOpportunity>().eq("id", bo.getId()).set("Stage_Id", bo.getStageId()).set("edit_time",new Date()));
+        QueryWrapper<BusinessOpportunity> queryWrapper = new QueryWrapper<BusinessOpportunity>().eq("stage_id", bo.getStageId()).eq("is_delete", 0).orderByDesc("seq").last("limit 1");
+        List<BusinessOpportunity> list = bOMapper.selectList(queryWrapper);
+        if (list.isEmpty()){
+            bo.setSeq(1);
+        }else {
+            bo.setSeq(list.get(0).getSeq()+1);
+        }
+        bOMapper.update(bo, new UpdateWrapper<BusinessOpportunity>().eq("id", bo.getId())
+                .set("Stage_Id", bo.getStageId()).set(bo.getSeq()!=null,"seq",bo.getSeq())
+                .set("edit_time",new Date()));
         ActionLog al = new ActionLog();
         al.setCode("business");
         al.setName("推进了阶段至" + bo.getStageValue());

+ 38 - 8
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java

@@ -597,8 +597,40 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
                 }
                 String No = row.getCell(0)==null?null:row.getCell(0).getStringCellValue();
                 String name = row.getCell(1)==null?null:row.getCell(1).getStringCellValue();
-                String startDate = row.getCell(4)==null?null:row.getCell(4).getStringCellValue();
-                String endDate = row.getCell(5)==null?null:row.getCell(5).getStringCellValue();
+                LocalDate startDate = null;
+                LocalDate endDate = null;
+                if(row.getCell(4) != null && row.getCell(4).getCellTypeEnum() != CellType.BLANK){
+                    if(!StringUtils.isEmpty(row.getCell(4).getStringCellValue())){
+                        try {
+                            int count = Integer.parseInt(row.getCell(4).getStringCellValue());
+                            // Excel中的日期序列号的基准日期是1900年1月1日
+                            LocalDate baseDate = LocalDate.of(1900, 1, 1);
+                            LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
+                            startDate = date;
+
+                        } catch (Exception e) {
+                            System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
+                            msg.setError("日期时间格式不正确,应该是yyyy/MM/dd");
+                            return msg;
+                        }
+                    }
+                }
+                if(row.getCell(5) != null && row.getCell(5).getCellTypeEnum() != CellType.BLANK){
+                    if(!StringUtils.isEmpty(row.getCell(5).getStringCellValue())){
+                        try {
+                            int count = Integer.parseInt(row.getCell(5).getStringCellValue());
+                            // Excel中的日期序列号的基准日期是1900年1月1日
+                            LocalDate baseDate = LocalDate.of(1900, 1, 1);
+                            LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
+                            endDate = date;
+
+                        } catch (Exception e) {
+                            System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
+                            msg.setError("日期时间格式不正确,应该是yyyy/MM/dd");
+                            return msg;
+                        }
+                    }
+                }
                 String amounts = row.getCell(2)==null?null:row.getCell(2).getStringCellValue();
                 String type = row.getCell(3)==null?null:row.getCell(3).getStringCellValue();
                 String remarks = row.getCell(6)==null?null:row.getCell(6).getStringCellValue();
@@ -649,13 +681,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
                 item.setStatus(1);
                 //时间转化
                 DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-M-d");
-                if (StringUtils.isNotBlank(startDate)){
-                    LocalDate start = LocalDate.parse(startDate, dtf);
-                    item.setStartDate(start);
+                if (startDate!=null){
+                    item.setStartDate(startDate);
                 }
-                if (StringUtils.isNotBlank(endDate)){
-                    LocalDate end = LocalDate.parse(endDate, dtf);
-                    item.setEndDate(end);
+                if (endDate!=null){
+                    item.setEndDate(endDate);
                 }
                 if (StringUtils.isNotBlank(amounts) && Double.parseDouble(amounts) <= 0 ){
                     //第{0}行金额不可为负数

+ 4 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/BusinessOpportunityMapper.xml

@@ -9,7 +9,6 @@
         <result column="name" property="name" />
         <result column="contacts_id" property="contactsId" />
         <result column="customer_id" property="customerId" />
-        <result column="product_id" property="productId" />
         <result column="amount_of_money" property="amountOfMoney" />
         <result column="expected_transaction_date" property="expectedTransactionDate" />
         <result column="stage_id" property="stageId" />
@@ -24,11 +23,14 @@
         <result column="plate3" property="plate3" />
         <result column="plate4" property="plate4" />
         <result column="plate5" property="plate5" />
+        <result column="clue_id" property="clueId" />
+        <result column="reason" property="reason" />
+        <result column="seq" property="seq" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, company_id, name, contacts_id, customer_id,  amount_of_money, expected_transaction_date, stage_id, create_time, edit_time, creator_id, incharger_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5
+        id, company_id, name, contacts_id, customer_id,  amount_of_money, expected_transaction_date, stage_id, create_time, edit_time, creator_id, incharger_id, remark, is_delete,seq, plate1, plate2, plate3, plate4, plate5
     </sql>
     <select id="selectAllList" resultType="com.management.platform.entity.BusinessOpportunity">
         select

+ 3 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/StageMapper.xml

@@ -9,11 +9,13 @@
         <result column="plan" property="plan" />
         <result column="seq" property="seq" />
         <result column="is_finish" property="isFinish" />
+        <result column="company_id" property="companyId" />
+        <result column="color" property="color" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, name, plan, seq, is_finish
+        id, name, plan, seq, is_finish, company_id, color
     </sql>
 
 </mapper>