修改进度逻辑

main
刘胜超 1 week ago
parent 0714a2f1bb
commit ff90a75fbd
  1. 94
      src/main/java/com/zilber/boot/intelligencesite/controller/IProgressNewController.java
  2. 40
      src/main/java/com/zilber/boot/intelligencesite/controller/Test.java
  3. 10
      src/main/java/com/zilber/boot/intelligencesite/entity/IProductionPlan.java
  4. 63
      src/main/java/com/zilber/boot/intelligencesite/entity/IProgressNew.java
  5. 4
      src/main/java/com/zilber/boot/intelligencesite/mapper/IProductionPlanMapper.java
  6. 5
      src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressMapper.java
  7. 24
      src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressNewMapper.java
  8. 3
      src/main/java/com/zilber/boot/intelligencesite/service/IIProductionPlanService.java
  9. 22
      src/main/java/com/zilber/boot/intelligencesite/service/IIProgressNewService.java
  10. 20
      src/main/java/com/zilber/boot/intelligencesite/service/impl/IProductionPlanServiceImpl.java
  11. 60
      src/main/java/com/zilber/boot/intelligencesite/service/impl/IProgressNewServiceImpl.java
  12. 43
      src/main/resources/mappers/IProductionPlanMapper.xml
  13. 10
      src/main/resources/mappers/IProgressMapper.xml
  14. 38
      src/main/resources/mappers/IProgressNewMapper.xml

@ -0,0 +1,94 @@
package com.zilber.boot.intelligencesite.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zilber.boot.annotation.Anonymous;
import com.zilber.boot.commoncontroller.BaseController;
import com.zilber.boot.intelligencesite.entity.IProductionPlan;
import com.zilber.boot.intelligencesite.entity.IProgress;
import com.zilber.boot.intelligencesite.entity.IProgressNew;
import com.zilber.boot.intelligencesite.service.IIProductionPlanService;
import com.zilber.boot.intelligencesite.service.IIProgressNewService;
import com.zilber.boot.intelligencesite.service.IIProgressService;
import com.zilber.boot.utils.AjaxResult;
import com.zilber.boot.utils.TreeBuild;
import com.zilber.boot.utils.TreeBuild1;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* <p>
* 进度跟踪表 前端控制器
* </p>
*
* @author lsc
* @since 2025-05-06
*/
@RestController
@RequestMapping("/iprogressNew")
@Api(tags = "进度跟踪新")
public class IProgressNewController extends BaseController {
@Resource
private IIProgressNewService iiProgressNewService;
@Resource
private IIProductionPlanService iiProductionPlanService;
@GetMapping("/list")
@ApiOperation(value="分页查询",notes="分页查询")
@ResponseBody
@Anonymous
public AjaxResult queryList(IProductionPlan iProductionPlan,Date date, @RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
List<IProductionPlan> iProductionPlans = iiProductionPlanService.queryListNew(iProductionPlan,date);
TreeBuild treeBuild = new TreeBuild(iProductionPlans);
// 原查询结果转换树形结构
List<IProductionPlan> list = treeBuild.buildTree();
PageHelper.startPage(pageNo, pageSize);
PageInfo<IProductionPlan> page = new PageInfo<>(list);
return AjaxResult.success(page);
}
/***
* 查询单个
*/
@GetMapping("/getById")
@ApiOperation("查询单个")
public AjaxResult getById(Integer id) {
return AjaxResult.success(iiProgressNewService.getById(id));
}
@PostMapping("/add")
@ApiOperation("增加")
@Anonymous
public AjaxResult add(@RequestBody IProgressNew iProgressNew) {
iProgressNew.setCreateTime(new Date());
iProgressNew.setCreator(getUsername());
return iiProgressNewService.add(iProgressNew);
}
@PutMapping("/update")
@ApiOperation("修改")
public AjaxResult update(@RequestBody @Validated IProgressNew iProgressNew) {
iiProgressNewService.updateById(iProgressNew);
return AjaxResult.success();
}
@DeleteMapping("/delete")
@ApiOperation("删除")
public AjaxResult delete(Integer id) {
return AjaxResult.success(iiProgressNewService.removeById(id));
}
}

@ -0,0 +1,40 @@
package com.zilber.boot.intelligencesite.controller;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) {
int[] nums={2,3,9,7};
int target = 9;
twoSum(nums, target);
}
public static int[] twoSum(int[] nums, int target) {
Map<Integer,Integer> map=new HashMap<>();
int res[]=new int[2];
for (int i = 0; i < nums.length; i++) {
if (map.containsKey(target-nums[i])){//如果存在满足条件的的key,加入到数组中
res[0]=i;
res[1]=map.get(target - nums[i]);
break;
}
else{
map.put(nums[i],i);//存键值对key-value
//3,0
//2,1
//3,2
}
}
for(int i=0;i<res.length;i++){
System.out.println(res[i]);
}
return res;
}
}

@ -86,6 +86,16 @@ public class IProductionPlan implements Serializable {
@TableField(exist = false)
private Integer accumulativeProgress;
@ApiModelProperty(value = "当日完成进度")
@TableField(exist = false)
private Integer dayProgress;
@ApiModelProperty(value = "填写进度日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(exist = false)
private Date processDate;

@ -0,0 +1,63 @@
package com.zilber.boot.intelligencesite.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
* 进度跟踪表
* </p>
*
* @author lsc
* @since 2025-05-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("i_progress_new")
@ApiModel(value="IProgress对象", description="进度跟踪表")
public class IProgressNew implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "计划id")
private Long planId;
@ApiModelProperty(value = "当日完成进度")
private Integer dayProgress;
@ApiModelProperty(value = "累计完成进度")
private Integer accumulativeProgress;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date createTime;
@ApiModelProperty(value = "创建人")
private String creator;
@ApiModelProperty(value = "填写进度日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date processDate;
}

@ -4,6 +4,7 @@ import com.zilber.boot.intelligencesite.entity.IProductionPlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
@ -29,4 +30,7 @@ public interface IProductionPlanMapper extends BaseMapper<IProductionPlan> {
List<IProductionPlan> statistics();
IProductionPlan statisticsByDateAndName(@Param("id") Long id, @Param("date") String date);
List<IProductionPlan> queryListNew(IProductionPlan iProductionPlan);
}

@ -1,10 +1,12 @@
package com.zilber.boot.intelligencesite.mapper;
import com.zilber.boot.intelligencesite.entity.IProductionPlan;
import com.zilber.boot.intelligencesite.entity.IProgress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
/**
@ -24,4 +26,7 @@ public interface IProgressMapper extends BaseMapper<IProgress> {
List<IProgress> queryYsg();
List<IProgress> queryProcessSj(@Param("planId") Long planId, @Param("date") String date);
IProgress queryByIdAndDate(@Param("id") Long id, @Param("processDate") Date processDate);
List<IProgress> queryById(Long id);
}

@ -0,0 +1,24 @@
package com.zilber.boot.intelligencesite.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zilber.boot.intelligencesite.entity.IProgress;
import com.zilber.boot.intelligencesite.entity.IProgressNew;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* <p>
* 进度跟踪表 Mapper 接口
* </p>
*
* @author lsc
* @since 2025-05-06
*/
public interface IProgressNewMapper extends BaseMapper<IProgressNew> {
IProgressNew queryByDate(@Param("planId") Long planId, Date processDate);
List<IProgressNew> queryList(IProgress setPlanId);
}

@ -3,6 +3,7 @@ package com.zilber.boot.intelligencesite.service;
import com.zilber.boot.intelligencesite.entity.IProductionPlan;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -25,4 +26,6 @@ public interface IIProductionPlanService extends IService<IProductionPlan> {
Map<String, Object> dataOverview();
List<IProductionPlan> bigscreenProgress();
List<IProductionPlan> queryListNew(IProductionPlan iProductionPlan, Date date);
}

@ -0,0 +1,22 @@
package com.zilber.boot.intelligencesite.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zilber.boot.intelligencesite.entity.IProgress;
import com.zilber.boot.intelligencesite.entity.IProgressNew;
import com.zilber.boot.utils.AjaxResult;
import java.util.List;
/**
* <p>
* 进度跟踪表 服务类
* </p>
*
* @author lsc
* @since 2025-05-06
*/
public interface IIProgressNewService extends IService<IProgressNew> {
AjaxResult add(IProgressNew iProgressNew);
}

@ -153,6 +153,8 @@ public class IProductionPlanServiceImpl extends ServiceImpl<IProductionPlanMappe
return iProductionPlanMapper.bigscreenProgress();
}
//获取最近一周时间
public static List<String> getRecentWeekDates() {
List<String> dates = new ArrayList<>();
@ -167,4 +169,22 @@ public class IProductionPlanServiceImpl extends ServiceImpl<IProductionPlanMappe
return dates;
}
@Override
public List<IProductionPlan> queryListNew(IProductionPlan iProductionPlan,Date date) {
List<IProductionPlan> iProductionPlans = iProductionPlanMapper.queryList(iProductionPlan);
for(int i=0;i<iProductionPlans.size();i++){
IProgress ip=iProgressMapper.queryByIdAndDate(iProductionPlans.get(i).getId(),date) ;
if(!ObjectUtils.isEmpty(ip)){
iProductionPlans.get(i).setDayProgress(ip.getDayProgress());
}
List<IProgress> ips=iProgressMapper.queryById(iProductionPlans.get(i).getId()) ;
if(!ObjectUtils.isEmpty(ips)){
long total = ips.stream().mapToLong(IProgress::getDayProgress).sum();
iProductionPlans.get(i).setAccumulativeProgress(Integer.valueOf(String.valueOf(total)));
}
}
return iProductionPlans;
}
}

@ -0,0 +1,60 @@
package com.zilber.boot.intelligencesite.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sun.org.apache.regexp.internal.RE;
import com.zilber.boot.intelligencesite.entity.IProgress;
import com.zilber.boot.intelligencesite.entity.IProgressNew;
import com.zilber.boot.intelligencesite.mapper.IProgressMapper;
import com.zilber.boot.intelligencesite.mapper.IProgressNewMapper;
import com.zilber.boot.intelligencesite.service.IIProgressNewService;
import com.zilber.boot.intelligencesite.service.IIProgressService;
import com.zilber.boot.utils.AjaxResult;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* <p>
* 进度跟踪表 服务实现类
* </p>
*
* @author lsc
* @since 2025-05-06
*/
@Service
public class IProgressNewServiceImpl extends ServiceImpl<IProgressNewMapper, IProgressNew> implements IIProgressNewService {
@Resource
private IProgressNewMapper iProgressNewMapper;
@Override
public AjaxResult add(IProgressNew iProgressNew) {
//查询填报日期下的当日进度
IProgressNew ip=iProgressNewMapper.queryByDate(iProgressNew.getPlanId(),iProgressNew.getProcessDate());
if(ObjectUtils.isEmpty(ip)){
List<IProgressNew> list=iProgressNewMapper.queryList(new IProgress().setPlanId(iProgressNew.getPlanId()));
long total = list.stream().mapToLong(IProgressNew::getDayProgress).sum();
if(iProgressNew.getDayProgress()+total>100){
return AjaxResult.error("已超出最大值,最大值应为"+ (100 - total));
}
IProgressNew iProgressNew1=new IProgressNew();
iProgressNew1.setPlanId(iProgressNew.getPlanId());
iProgressNew1.setDayProgress(iProgressNew.getDayProgress());
iProgressNew1.setCreateTime(new Date());
iProgressNew1.setProcessDate(iProgressNew.getProcessDate());
return AjaxResult.success(iProgressNewMapper.insert(iProgressNew1)) ;
}else{
List<IProgressNew> list=iProgressNewMapper.queryList(new IProgress().setPlanId(iProgressNew.getPlanId()));
long total = list.stream().mapToLong(IProgressNew::getDayProgress).sum();
if(iProgressNew.getDayProgress()+total>100){
return AjaxResult.error("已超出最大值,最大值应为"+ (100 - total));
}
ip.setDayProgress(ip.getDayProgress()+iProgressNew.getDayProgress());
return AjaxResult.success(iProgressNewMapper.updateById(ip));
}
}
}

@ -18,6 +18,8 @@
<result property="principal" column="principal" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="INTEGER"/>
<result property="accumulativeProgress" column="accumulative_progress" jdbcType="INTEGER"/>
<result property="dayProgress" column="day_progress" jdbcType="INTEGER"/>
<result property="processDate" column="process_date" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="selectIProductionPlanVo">
@ -95,5 +97,46 @@ FROM
</select>
<select id="queryListNew" parameterType="com.zilber.boot.intelligencesite.entity.IProductionPlan" resultMap="IProductionPlanResult">
SELECT
ipn.id,
ipn.plan_name,
ipn.project_stage,
ipn.description,
ipn.start_time,
ipn.end_time,
ipn.create_time,
ipn.creator,
ipn.duration,
ipn.keystage_time,
ipn.principal,
ipn.parent_id,
ip.day_progress,
ip.process_date,
sum( ip.day_progress ) AS accumulative_progress
FROM
i_production_plan ipn
LEFT JOIN i_progress_new ip ON ipn.id = ip.plan_id
<where>
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
<if test="projectStage != null and projectStage != ''"> and project_stage like concat('%', #{projectStage}, '%')</if>
<if test="description != null and description != ''"> and description like concat('%', #{description}, '%')</if>
<if test="startTime != null"> and start_time=#{startTime}</if>
<if test="endTime != null"> and end_time=#{endTime}</if>
<if test="createTime != null"> and create_time=#{createTime}</if>
<if test="creator != null and creator != ''"> and creator=#{creator}</if>
<if test="duration != null"> and duration like concat('%', #{duration}, '%')</if>
<if test="keystageTime != null"> and keystage_time =#{keystageTime}</if>
<if test="principal != null and principal != ''"> and principal like concat('%', #{principal}, '%')</if>
<if test="processDate != null">and date_format(ip.process_date,'%y%m%d') = date_format(#{processDate},'%y%m%d')</if>
</where>
GROUP BY
ipn.id,
ipn.plan_name
order by create_time desc
</select>
</mapper>

@ -68,5 +68,15 @@ FROM
<select id="queryProcessSj" resultMap="IProgressResult">
select * from i_progress where plan_id=#{planId} and date_format(process_date,'%y%m%d') = date_format(#{date},'%y%m%d')
</select>
<select id="queryByIdAndDate" resultType="com.zilber.boot.intelligencesite.entity.IProgress">
select * from i_progress_new
where
plan_id =#{id}
and date_format(process_date,'%y%m%d') = date_format(#{processDate},'%y%m%d')
</select>
<select id="queryById" resultMap="IProgressResult">
select * from i_progress_new where plan_id =#{id}
</select>
</mapper>

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zilber.boot.intelligencesite.mapper.IProgressNewMapper">
<resultMap id="IProgressResult" type="com.zilber.boot.intelligencesite.entity.IProgressNew">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="planId" column="plan_id" jdbcType="INTEGER"/>
<result property="dayProgress" column="day_progress" jdbcType="INTEGER"/>
<result property="accumulativeProgress" column="accumulative_progress" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="creator" column="creator" jdbcType="VARCHAR"/>
<result property="processDate" column="process_date" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="selectIProgressVo">
select
id, plan_id, day_progress, accumulative_progress, create_time, creator,process_date from i_progress_new
</sql>
<select id="queryByDate" resultType="com.zilber.boot.intelligencesite.entity.IProgressNew">
select * from i_progress_new where plan_id=#{planId} and date_format(process_date,'%y%m%d') = date_format(#{processDate},'%y%m%d')
</select>
<select id="queryList" parameterType="com.zilber.boot.intelligencesite.entity.IProgressNew" resultMap="IProgressResult">
<include refid="selectIProgressVo"/>
<where>
<if test="planId != null"> and plan_id=#{planId}</if>
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
<if test="dayProgress != null"> and day_progress like concat('%', #{dayProgress}, '%')</if>
<if test="accumulativeProgress != null"> and accumulative_progress like concat('%', #{accumulativeProgress}, '%')</if>
<if test="createTime != null"> and create_time=#{createTime}</if>
<if test="creator != null and creator != ''"> and creator=#{creator}</if>
<if test="processDate != null"> and date_format(login_time,'%y%m%d')=date_format(#{processDate},'%y%m%d')</if>
</where>
order by create_time desc
</select>
</mapper>
Loading…
Cancel
Save