commit
8308eb59af
@ -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; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
} |
@ -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); |
||||||
|
} |
@ -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)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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…
Reference in new issue