diff --git a/src/main/java/com/zilber/boot/intelligencesite/controller/IProgressNewController.java b/src/main/java/com/zilber/boot/intelligencesite/controller/IProgressNewController.java new file mode 100644 index 0000000..1760f35 --- /dev/null +++ b/src/main/java/com/zilber/boot/intelligencesite/controller/IProgressNewController.java @@ -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; + +/** + *

+ * 进度跟踪表 前端控制器 + *

+ * + * @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 iProductionPlans = iiProductionPlanService.queryListNew(iProductionPlan,date); + TreeBuild treeBuild = new TreeBuild(iProductionPlans); + // 原查询结果转换树形结构 + List list = treeBuild.buildTree(); + PageHelper.startPage(pageNo, pageSize); + PageInfo 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)); + } + +} diff --git a/src/main/java/com/zilber/boot/intelligencesite/controller/Test.java b/src/main/java/com/zilber/boot/intelligencesite/controller/Test.java new file mode 100644 index 0000000..b2645ef --- /dev/null +++ b/src/main/java/com/zilber/boot/intelligencesite/controller/Test.java @@ -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 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 + * 进度跟踪表 + *

+ * + * @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; + + + +} diff --git a/src/main/java/com/zilber/boot/intelligencesite/mapper/IProductionPlanMapper.java b/src/main/java/com/zilber/boot/intelligencesite/mapper/IProductionPlanMapper.java index 7272f5d..17162fe 100644 --- a/src/main/java/com/zilber/boot/intelligencesite/mapper/IProductionPlanMapper.java +++ b/src/main/java/com/zilber/boot/intelligencesite/mapper/IProductionPlanMapper.java @@ -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 { List statistics(); IProductionPlan statisticsByDateAndName(@Param("id") Long id, @Param("date") String date); + + List queryListNew(IProductionPlan iProductionPlan); + } diff --git a/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressMapper.java b/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressMapper.java index 929f6c4..dc2070d 100644 --- a/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressMapper.java +++ b/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressMapper.java @@ -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 { List queryYsg(); List queryProcessSj(@Param("planId") Long planId, @Param("date") String date); + IProgress queryByIdAndDate(@Param("id") Long id, @Param("processDate") Date processDate); + List queryById(Long id); + } diff --git a/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressNewMapper.java b/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressNewMapper.java new file mode 100644 index 0000000..67ae1ea --- /dev/null +++ b/src/main/java/com/zilber/boot/intelligencesite/mapper/IProgressNewMapper.java @@ -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; + +/** + *

+ * 进度跟踪表 Mapper 接口 + *

+ * + * @author lsc + * @since 2025-05-06 + */ +public interface IProgressNewMapper extends BaseMapper { + + IProgressNew queryByDate(@Param("planId") Long planId, Date processDate); + + List queryList(IProgress setPlanId); +} diff --git a/src/main/java/com/zilber/boot/intelligencesite/service/IIProductionPlanService.java b/src/main/java/com/zilber/boot/intelligencesite/service/IIProductionPlanService.java index 26eb7a5..17fe6b2 100644 --- a/src/main/java/com/zilber/boot/intelligencesite/service/IIProductionPlanService.java +++ b/src/main/java/com/zilber/boot/intelligencesite/service/IIProductionPlanService.java @@ -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 { Map dataOverview(); List bigscreenProgress(); + + List queryListNew(IProductionPlan iProductionPlan, Date date); } diff --git a/src/main/java/com/zilber/boot/intelligencesite/service/IIProgressNewService.java b/src/main/java/com/zilber/boot/intelligencesite/service/IIProgressNewService.java new file mode 100644 index 0000000..8d46d1d --- /dev/null +++ b/src/main/java/com/zilber/boot/intelligencesite/service/IIProgressNewService.java @@ -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; + +/** + *

+ * 进度跟踪表 服务类 + *

+ * + * @author lsc + * @since 2025-05-06 + */ +public interface IIProgressNewService extends IService { + + + AjaxResult add(IProgressNew iProgressNew); +} diff --git a/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProductionPlanServiceImpl.java b/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProductionPlanServiceImpl.java index ed3e2ae..677373e 100644 --- a/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProductionPlanServiceImpl.java +++ b/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProductionPlanServiceImpl.java @@ -153,6 +153,8 @@ public class IProductionPlanServiceImpl extends ServiceImpl getRecentWeekDates() { List dates = new ArrayList<>(); @@ -167,4 +169,22 @@ public class IProductionPlanServiceImpl extends ServiceImpl queryListNew(IProductionPlan iProductionPlan,Date date) { + List iProductionPlans = iProductionPlanMapper.queryList(iProductionPlan); + for(int i=0;i 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; + } + } diff --git a/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProgressNewServiceImpl.java b/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProgressNewServiceImpl.java new file mode 100644 index 0000000..f2fa373 --- /dev/null +++ b/src/main/java/com/zilber/boot/intelligencesite/service/impl/IProgressNewServiceImpl.java @@ -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; + +/** + *

+ * 进度跟踪表 服务实现类 + *

+ * + * @author lsc + * @since 2025-05-06 + */ +@Service +public class IProgressNewServiceImpl extends ServiceImpl 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 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 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)); + } + } +} diff --git a/src/main/resources/mappers/IProductionPlanMapper.xml b/src/main/resources/mappers/IProductionPlanMapper.xml index 0943728..c3056ed 100644 --- a/src/main/resources/mappers/IProductionPlanMapper.xml +++ b/src/main/resources/mappers/IProductionPlanMapper.xml @@ -18,6 +18,8 @@ + + @@ -95,5 +97,46 @@ FROM + + + diff --git a/src/main/resources/mappers/IProgressMapper.xml b/src/main/resources/mappers/IProgressMapper.xml index e3fe7f5..f246e86 100644 --- a/src/main/resources/mappers/IProgressMapper.xml +++ b/src/main/resources/mappers/IProgressMapper.xml @@ -68,5 +68,15 @@ FROM + + diff --git a/src/main/resources/mappers/IProgressNewMapper.xml b/src/main/resources/mappers/IProgressNewMapper.xml new file mode 100644 index 0000000..1a21685 --- /dev/null +++ b/src/main/resources/mappers/IProgressNewMapper.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + select +id, plan_id, day_progress, accumulative_progress, create_time, creator,process_date from i_progress_new + + + + +