diff --git a/src/main/java/com/dsic/gj_erp/bean/jhgk/dto/RjhDto.java b/src/main/java/com/dsic/gj_erp/bean/jhgk/dto/RjhDto.java new file mode 100644 index 0000000..f42b37b --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/bean/jhgk/dto/RjhDto.java @@ -0,0 +1,20 @@ +package com.dsic.gj_erp.bean.jhgk.dto; + +import lombok.Data; + +@Data +public class RjhDto { + + + private Double pwnum; + private Double sk1num; + private Double lm1num; + private Double sk2num; + private Double lm2num; + private Double sk3num; + private Double lm3num; + private Double sk4num; + private Double xcnum; + + +} \ No newline at end of file diff --git a/src/main/java/com/dsic/gj_erp/controller/jhgk/RjhgzController.java b/src/main/java/com/dsic/gj_erp/controller/jhgk/RjhgzController.java new file mode 100644 index 0000000..6d54c03 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/controller/jhgk/RjhgzController.java @@ -0,0 +1,188 @@ +package com.dsic.gj_erp.controller.jhgk; + + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateRange; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.dsic.gj_erp.annotation.AuthFunction; +import com.dsic.gj_erp.bean.ResultBean; +import com.dsic.gj_erp.bean.jcsj.EmGcrl; +import com.dsic.gj_erp.bean.jhgk.DmYdjh; +import com.dsic.gj_erp.bean.jhgk.dto.RjhDto; +import com.dsic.gj_erp.exception.CustomException; +import com.dsic.gj_erp.mapper.jhgk.DmYdjhMapper; +import com.dsic.gj_erp.service.jcsj.DmCzplpNewService; +import com.dsic.gj_erp.service.jcsj.EmGcrlService; +import com.dsic.gj_erp.service.jhgk.DmYdjhService; +import com.dsic.gj_erp.service.kc.ImCkwpkwpService; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + *

+ * 前端控制器 + *

+ * + * @author xn + * @since 2023-11-09 + */ +@RestController +@RequestMapping("/rjhgz") +public class RjhgzController { + + @Autowired + private DmYdjhMapper dmYdjhMapper; + @Autowired + private EmGcrlService gcrlService; + + /** + * + * @param yf yyyy/MM + * @return + */ + @PostMapping("getRjhList") + public ResultBean getRjhList(@RequestParam String yf){ + //当前月份日期 查询月份 默认当前月 + //维修时间 + //当前日期 + DateTime date= new DateTime(); + DateTime lastMonth=DateUtil.lastMonth(); + int days=Integer.parseInt(date.toString("dd")); + //如果是本月 那就是今天 + //如果是其他月 就全月天数 + if (StrUtil.isNotEmpty(yf)){ + date= DateUtil.parseDate(yf); + lastMonth=DateUtil.offsetMonth(date,-1); + } + //上月天数 + int lastMonthDays=Integer.parseInt(DateUtil.endOfMonth(lastMonth).toString("dd")); + //本月日期list + List dateTimes=DateUtil.rangeToList(DateUtil.beginOfMonth(date) + , DateUtil.endOfMonth(date) + , DateField.DAY_OF_YEAR); + //工厂日历,取休息日 + List dateList=gcrlService.list(new QueryWrapper() + .eq("substring(gl,0,8)",date.toString("yyyy/MM")) + .eq("xxr","0")); + + //字段灵活 map<> list 跨位 计算列1 计算列2 计算列3 1日 2日 3日 + String[] gw={"抛丸", "数控1", "龙门1", "数控2", "龙门2", "数控3", "龙门3", "数控4", "七跨型材"}; + List> list=new ArrayList<>(); + for (String s : gw) { + Map map=new HashMap<>(); + map.put("gw",s); + list.add(map); + } + for (DateTime dateTime : dateTimes) { + if (!dateTime.isAfter(new Date())){ + RjhDto dtos=dmYdjhMapper.getRjh(dateTime.toString("yyyy/MM/dd")); + list.forEach(l->{ + if (ObjectUtil.isEmpty(dtos)){ + l.put("field_"+dateTime.toString("dd"),0); + }else { + if (l.get("gw").equals("抛丸")){ + l.put("field_"+dateTime.toString("dd"), ObjectUtil.isEmpty(dtos.getPwnum())?0:dtos.getPwnum()); + } + if (l.get("gw").equals("数控1")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getSk1num())?0:dtos.getSk1num()); + } + if (l.get("gw").equals("龙门1")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getLm1num())?0:dtos.getLm1num()); + } + if (l.get("gw").equals("数控2")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getSk2num())?0:dtos.getSk2num()); + } + if (l.get("gw").equals("龙门2")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getLm2num())?0:dtos.getLm2num()); + } + if (l.get("gw").equals("数控3")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getSk3num())?0:dtos.getSk3num()); + } + if (l.get("gw").equals("龙门3")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getLm3num())?0:dtos.getLm3num()); + } + if (l.get("gw").equals("数控4")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getSk4num())?0:dtos.getSk4num()); + } + if (l.get("gw").equals("七跨型材")){ + l.put("field_"+dateTime.toString("dd"),ObjectUtil.isEmpty(dtos.getXcnum())?0:dtos.getXcnum()); + } + } + }); + } + } + //上月日均完成 + RjhDto syRwc= dmYdjhMapper.getSyRwc(lastMonth.toString("yyyy/MM"),lastMonthDays); + //本月日均计划 + RjhDto byRjh= dmYdjhMapper.getByRjh(date.toString("yyyy/MM"),days); + //本月日均完成 + RjhDto byRwc= dmYdjhMapper.getSyRwc(date.toString("yyyy/MM"),days); + + list.forEach(l->{ + if (l.get("gw").equals("抛丸")){ + l.put("rjwc_sy",syRwc.getPwnum()); + l.put("rjjh_by",byRjh.getPwnum()); + l.put("rjwc_by",byRwc.getPwnum()); + } + if (l.get("gw").equals("数控1")){ + l.put("rjwc_sy",syRwc.getSk1num()); + l.put("rjjh_by",byRjh.getSk1num()); + l.put("rjwc_by",byRwc.getSk1num()); + } + if (l.get("gw").equals("龙门1")){ + l.put("rjwc_sy",syRwc.getLm1num()); + l.put("rjjh_by",byRjh.getLm1num()); + l.put("rjwc_by",byRwc.getLm1num()); + } + if (l.get("gw").equals("数控2")){ + l.put("rjwc_sy",syRwc.getSk2num()); + l.put("rjjh_by",byRjh.getSk2num()); + l.put("rjwc_by",byRwc.getSk2num()); + } + if (l.get("gw").equals("龙门2")){ + l.put("rjwc_sy",syRwc.getLm2num()); + l.put("rjjh_by",byRjh.getLm2num()); + l.put("rjwc_by",byRwc.getLm2num()); + } + if (l.get("gw").equals("数控3")){ + l.put("rjwc_sy",syRwc.getSk3num()); + l.put("rjjh_by",byRjh.getSk3num()); + l.put("rjwc_by",byRwc.getSk3num()); + } + if (l.get("gw").equals("龙门3")){ + l.put("rjwc_sy",syRwc.getLm3num()); + l.put("rjjh_by",byRjh.getLm3num()); + l.put("rjwc_by",byRwc.getLm3num()); + } + if (l.get("gw").equals("数控4")){ + l.put("rjwc_sy",syRwc.getSk4num()); + l.put("rjjh_by",byRjh.getSk4num()); + l.put("rjwc_by",byRwc.getSk4num()); + } + if (l.get("gw").equals("七跨型材")){ + l.put("rjwc_sy",syRwc.getXcnum()); + l.put("rjjh_by",byRjh.getXcnum()); + l.put("rjwc_by",byRwc.getXcnum()); + } + }); + return new ResultBean<>(list); + } +} diff --git a/src/main/java/com/dsic/gj_erp/mapper/jhgk/DmYdjhMapper.java b/src/main/java/com/dsic/gj_erp/mapper/jhgk/DmYdjhMapper.java index 1aadcf0..cb5a89e 100644 --- a/src/main/java/com/dsic/gj_erp/mapper/jhgk/DmYdjhMapper.java +++ b/src/main/java/com/dsic/gj_erp/mapper/jhgk/DmYdjhMapper.java @@ -6,6 +6,7 @@ import com.dsic.gj_erp.bean.jcsj.Ydjhzz; import com.dsic.gj_erp.bean.jhgk.DmSygdMx; import com.dsic.gj_erp.bean.jhgk.DmYdjh; import com.dsic.gj_erp.bean.jhgk.DmYdjhLj; +import com.dsic.gj_erp.bean.jhgk.dto.RjhDto; import com.dsic.gj_erp.bean.pgd.*; import com.dsic.gj_erp.controller.zyjh.dto.SljhSearch; import org.apache.ibatis.annotations.MapKey; @@ -87,4 +88,7 @@ public interface DmYdjhMapper extends BaseMapper { Map getMPSYCLJLJBP(String dcCh,String tzbh); List getYdjhzz(String ch); + RjhDto getRjh(String date); + RjhDto getSyRwc(String yf,int num); + RjhDto getByRjh(String yf,int num); } diff --git a/src/main/resources/mappers/jhgk/DmYdjhMapper.xml b/src/main/resources/mappers/jhgk/DmYdjhMapper.xml index d1e4758..bf1ea69 100644 --- a/src/main/resources/mappers/jhgk/DmYdjhMapper.xml +++ b/src/main/resources/mappers/jhgk/DmYdjhMapper.xml @@ -1580,4 +1580,49 @@ where dm_ydjh.DC_CH=#{dcch} and dm_ydjh.dc_pl=#{dcpl} WHERE zt='62' and dm_ydjh.dc_ch=#{ch} GROUP BY dc_ch,dc_pl ORDER BY dc_pl + + +