Kaynağa Gözat

杰生 微信小程序接口迁移

home 2 yıl önce
ebeveyn
işleme
c571db8960
19 değiştirilmiş dosya ile 1278 ekleme ve 25 silme
  1. 57 0
      hx-service-api/storage-api/src/main/java/com/fjhx/entity/stock/StockInoutbill.java
  2. 0 16
      hx-service/storage/src/main/java/com/fjhx/applet/LoginConfig.java
  3. 120 0
      hx-service/storage/src/main/java/com/fjhx/applet/controller/FabricStatisticsController.java
  4. 59 0
      hx-service/storage/src/main/java/com/fjhx/applet/controller/InkStatisticsController.java
  5. 35 0
      hx-service/storage/src/main/java/com/fjhx/applet/mapper/FabricStatisticsMapper.java
  6. 156 0
      hx-service/storage/src/main/java/com/fjhx/applet/mapper/FabricStatisticsMapper.xml
  7. 20 0
      hx-service/storage/src/main/java/com/fjhx/applet/mapper/InkStatisticsMapper.java
  8. 40 0
      hx-service/storage/src/main/java/com/fjhx/applet/mapper/InkStatisticsMapper.xml
  9. 28 0
      hx-service/storage/src/main/java/com/fjhx/applet/service/FabricStatisticsService.java
  10. 16 0
      hx-service/storage/src/main/java/com/fjhx/applet/service/InkStatisticsService.java
  11. 426 0
      hx-service/storage/src/main/java/com/fjhx/applet/service/impl/FabricStatisticsServiceImpl.java
  12. 155 0
      hx-service/storage/src/main/java/com/fjhx/applet/service/impl/InkStatisticsServiceImpl.java
  13. 16 0
      hx-service/storage/src/main/java/com/fjhx/stock/mapper/StockInoutbillMapper.java
  14. 5 0
      hx-service/storage/src/main/java/com/fjhx/stock/mapper/StockInoutbillMapper.xml
  15. 16 0
      hx-service/storage/src/main/java/com/fjhx/stock/service/StockInoutbillService.java
  16. 20 0
      hx-service/storage/src/main/java/com/fjhx/stock/service/impl/StockInoutbillServiceImpl.java
  17. 12 0
      hx-service/storage/src/main/java/com/fjhx/task/controller/ScheduleTaskController.java
  18. 2 0
      hx-service/storage/src/main/java/com/fjhx/task/service/ScheduleTaskService.java
  19. 95 9
      hx-service/storage/src/main/java/com/fjhx/task/service/impl/ScheduleTaskServiceImpl.java

+ 57 - 0
hx-service-api/storage-api/src/main/java/com/fjhx/entity/stock/StockInoutbill.java

@@ -0,0 +1,57 @@
+package com.fjhx.entity.stock;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * <p>
+ * 出/入库单
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-04-12
+ */
+@Data
+@TableName("t_stock_inoutbill")
+public class StockInoutbill implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键id
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private String id;
+
+    /**
+     * 排班物料名称
+     */
+    private String schedulingMaterial;
+
+    /**
+     * 应领料数量
+     */
+    private BigDecimal quantity;
+
+    /**
+     * 工号
+     */
+    private Long jobNo;
+
+    /**
+     * 排班时间
+     */
+    private Date deviationTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+}

+ 0 - 16
hx-service/storage/src/main/java/com/fjhx/applet/LoginConfig.java

@@ -1,16 +0,0 @@
-package com.fjhx.applet;
-
-import org.springblade.core.tool.api.R;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequestMapping("/stockAttachment")
-public class LoginConfig {
-
-    public R login() {
-
-        return R.success();
-    }
-
-}

+ 120 - 0
hx-service/storage/src/main/java/com/fjhx/applet/controller/FabricStatisticsController.java

@@ -0,0 +1,120 @@
+package com.fjhx.applet.controller;
+
+import com.fjhx.applet.service.FabricStatisticsService;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 面料统计
+ */
+@RestController
+@RequestMapping("/applet")
+public class FabricStatisticsController {
+
+    @Autowired
+    private FabricStatisticsService fabricStatisticsService;
+
+    /**
+     * RFID版本的面料汇总详情(汇总)
+     *
+     * @param
+     * @return
+     */
+    @PostMapping("/selectFabricStatisticsDetails")
+    public R selectFabricDetails() {
+        Map<String, Object> map = fabricStatisticsService.selectFabricDetails();
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的面料汇总详情(物料属性详情)
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricTypeDetails")
+    public R selectFabricTypeDetails(@RequestBody Map<String, Object> condition) {
+        List<Map<String, Object>> maps = fabricStatisticsService.selectFabricTypeDetails(condition);
+        return R.success(maps);
+    }
+
+    /**
+     * RFID版本的 面料入库汇总详情(汇总)
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricWDetails")
+    public R selectFabricWDetails(@RequestBody Map<String, Object> condition) {
+        Map<String, Object> map = fabricStatisticsService.selectFabricWDetails(condition);
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的面料入库汇总详情(物料属性详情)
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricWTypeDetails")
+    public R selectFabricWTypeDetails(@RequestBody Map<String, Object> condition) {
+        List<Map<String, Object>> map = fabricStatisticsService.selectFabricWTypeDetails(condition);
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的面料出库汇总详情
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricEWDetails")
+    public R selectFabricEWDetails(@RequestBody Map<String, String> condition) {
+        List<Map<String, Object>> map = fabricStatisticsService.selectFabricEWDetails(condition);
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的面料汇总
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricStatistics")
+    public R selectFabricStatistics(@RequestBody Map<String, Object> condition) {
+        Map<String, Object> map = fabricStatisticsService.selectFabricStatistics(condition);
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的面料出库汇总
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricEW")
+    public R selectFabricEW(@RequestBody Map<String, Object> condition) {
+        Map<String, Object> map = fabricStatisticsService.selectFabricEW(condition);
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的面料入库汇总
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectFabricW")
+    public R selectFabricW(@RequestBody Map<String, Object> condition) {
+        Map<String, Object> map = fabricStatisticsService.selectFabricW(condition);
+        return R.success(map);
+    }
+
+}

+ 59 - 0
hx-service/storage/src/main/java/com/fjhx/applet/controller/InkStatisticsController.java

@@ -0,0 +1,59 @@
+package com.fjhx.applet.controller;
+
+import com.fjhx.applet.service.InkStatisticsService;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 墨水统计
+ */
+@RestController
+@RequestMapping("/applet")
+public class InkStatisticsController {
+
+    @Autowired
+    private InkStatisticsService inkStatisticsService;
+
+    /**
+     * RFID版本的墨水库存汇总
+     *
+     * @param
+     * @return
+     */
+    @PostMapping("/selectInkStatistics")
+    public R selectInkStatistics() {
+        Map<String, Object> map = inkStatisticsService.selectInkStatistics();
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的墨水出入库汇总
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectInkEW")
+    public R selectInkEW(@RequestBody Map<String, Object> condition) {
+        Map<String, Object> map = inkStatisticsService.selectInkW(condition);
+        return R.success(map);
+    }
+
+    /**
+     * RFID版本的墨水出库详情
+     *
+     * @param condition
+     * @return
+     */
+    @PostMapping("/selectInkEWDetails")
+    public R selectInkEWDetails(@RequestBody Map<String, Object> condition) {
+        Map<String, Object> map = inkStatisticsService.selectInkEWDetails(condition);
+        return R.success(map);
+    }
+
+}

+ 35 - 0
hx-service/storage/src/main/java/com/fjhx/applet/mapper/FabricStatisticsMapper.java

@@ -0,0 +1,35 @@
+package com.fjhx.applet.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.base.BaseEntity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface FabricStatisticsMapper extends BaseMapper<BaseEntity> {
+
+    List<Map<String, Object>> selectFabricDetails();
+
+    List<Map<String, Object>> selectFabricTypeDetails(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectFabricWDetails(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectFabricWTypeDetails(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> getInOutBill(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> getWaterStatistics(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> getReturnMaterial(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectFabricStatistics(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectPickingQuantitySum(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectFabricEW(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectFabricW(@Param("ew") QueryWrapper<Object> wrapper);
+
+}

+ 156 - 0
hx-service/storage/src/main/java/com/fjhx/applet/mapper/FabricStatisticsMapper.xml

@@ -0,0 +1,156 @@
+<?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.fjhx.applet.mapper.FabricStatisticsMapper">
+
+    <select id="selectFabricDetails" resultType="java.util.Map">
+        SELECT sh.`Name`                               houseName,
+               count(1)                             AS count,
+               sum(sd.Quantity)                     AS quantity,
+               round(sum(sd.Quantity * m.Price), 2) AS amount
+        FROM stock_detail sd
+                 LEFT JOIN stock_house sh ON sd.StockHouseId = sh.ID
+                 LEFT JOIN material m ON sd.MaterialCode = m.`Code`
+        WHERE m.TechnologyType != '3'
+        GROUP BY sh.`Name`
+    </select>
+
+    <select id="selectFabricTypeDetails" resultType="java.util.Map">
+        SELECT IF(m.Purpose is null, "其他", m.Purpose)  rurpose,
+               count(1)                             AS count,
+               sum(sd.Quantity)                     AS quantity,
+               round(sum(sd.Quantity * m.Price), 2) AS amount
+        FROM stock_detail sd
+                 LEFT JOIN material m ON sd.MaterialCode = m.`Code`
+                 LEFT JOIN stock_house sh ON sd.StockHouseId = sh.ID
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectFabricWDetails" resultType="java.util.Map">
+        SELECT sh.`Name`                                 houseName,
+               Count(1)                               AS count,
+               sum(swd.ChangeNum)                     AS changeNum,
+               round(sum(swd.ChangeNum * m.Price), 2) AS amount
+        FROM stock_waterdetial swd
+                 LEFT JOIN stock_water sw ON swd.WaterId = sw.ID
+                 LEFT JOIN stock_house sh ON sw.StockHouseId = sh.ID
+                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectFabricWTypeDetails" resultType="java.util.Map">
+        SELECT sh.`Name`                  houseName,
+               Count(1)                   count,
+               sum(sd.Quantity)           quantity,
+               sum(sd.Quantity * m.Price) amount
+        FROM stock_detail sd
+                 LEFT JOIN material m ON sd.MaterialCode = m.`Code`
+                 LEFT JOIN stock_house sh ON sd.StockHouseId = sh.ID
+        WHERE m.TechnologyType = '3'
+        GROUP BY sh.`Name`;
+    </select>
+
+    <select id="getInOutBill" resultType="java.util.Map">
+        SELECT sum(tsi.quantity)           planArea,
+               tsi.job_no                  jobNo,
+               uu.RealName                 realName,
+               CASE
+                   m.technologyType
+                   WHEN 0 THEN
+                       '直喷'
+                   WHEN 1 THEN
+                       '热转'
+                   WHEN 2 THEN
+                       '打纸'
+                   WHEN 3 THEN
+                       '墨水'
+                   ELSE '其他'
+                   END                     'techType',
+               ifnull(m.technologyType, 4) technologyType
+        FROM t_stock_inoutbill tsi
+                 LEFT JOIN u_user uu ON tsi.job_no = uu.JobNo
+                 LEFT JOIN (
+            SELECT SUBSTRING_INDEX(`name`, '-', 1) mat_name,
+                   m.technologyType
+            FROM material m
+            WHERE m.ID IN (SELECT min(id)
+                           FROM `storage`.material
+                           WHERE IsDelete = 0
+                           GROUP BY SUBSTRING_INDEX(`name`, '-', 1))) m ON tsi.scheduling_material = m.mat_name
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="getWaterStatistics" resultType="java.util.Map">
+        SELECT uu.JobNo                                     jobNo,
+               round(sum(swd.ChangeNum), 2)                 quantity,
+               round(sum(swd.ChangeNum * swd.Price), 2)     amount,
+               round(sum(swd.ChangeNum * m.Width / 100), 2) area,
+               ifnull(count(1), 0)                          pcs,
+               ifnull(m.technologyType, 4)                  technologyType
+        FROM `storage`.stock_waterdetial swd
+                 LEFT JOIN `storage`.material m ON swd.MaterialCode = m.`Code`
+                 LEFT JOIN `storage`.u_user uu ON swd.OperUserId = uu.ID
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="getReturnMaterial" resultType="java.util.Map">
+        SELECT uu.JobNo                               jobNo,
+               round(sum(swd.ChangeNum * m.Width), 2) backQty,
+               ifnull(m.technologyType, 4)            technologyType
+        FROM `storage`.stock_waterdetial swd
+                 LEFT JOIN `storage`.material m ON swd.MaterialCode = m.`Code`
+                 LEFT JOIN `storage`.u_user uu ON swd.OperUserId = uu.ID
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectFabricStatistics" resultType="java.util.Map">
+        SELECT m.TechnologyType                     technologyType,
+               count(1)                             count,
+               round(sum(sd.Quantity), 2)           quantity,
+               round(sum(sd.Quantity * m.Price), 2) amount
+        FROM stock_detail sd
+                 LEFT JOIN material m ON sd.MaterialCode = m.`Code`
+                 LEFT JOIN stock_house sh ON sd.StockHouseId = sh.ID
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectPickingQuantitySum" resultType="java.util.Map">
+        SELECT sum(quantity)   quantity,
+               technology_type technologyType,
+               nick_name
+        FROM (
+                 SELECT si.scheduling_material AS scheduling_material,
+                        si.job_no              AS job_no,
+                        si.quantity            AS quantity,
+                        m.TechnologyType       AS technology_type,
+                        u.RealName             AS nick_name
+                 FROM t_stock_inoutbill si
+                          LEFT JOIN storage.material m ON m.`name` LIKE CONCAT(si.scheduling_material, '%')
+                          LEFT JOIN u_user u ON si.job_no = u.JobNo
+                     ${ew.customSqlSegment}
+             ) tb
+        GROUP BY technology_type
+    </select>
+
+    <select id="selectFabricEW" resultType="java.util.Map">
+        SELECT m.TechnologyType                             technologyType,
+               Count(1)                                     count,
+               round(sum(swd.ChangeNum), 2)                 changeNum,
+               round(sum(swd.ChangeNum * m.Price), 2)       amount,
+               round(sum(swd.ChangeNum * m.Width / 100), 2) square
+        FROM stock_waterdetial swd
+                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectFabricW" resultType="java.util.Map">
+        SELECT m.TechnologyType                       technologyType,
+               Count(1)                               count,
+               round(sum(swd.ChangeNum), 2)           totalQty,
+               round(sum(swd.ChangeNum * m.Price), 2) amount
+        FROM stock_waterdetial swd
+                 left join stock_water sw on swd.WaterId = sw.id
+                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>

+ 20 - 0
hx-service/storage/src/main/java/com/fjhx/applet/mapper/InkStatisticsMapper.java

@@ -0,0 +1,20 @@
+package com.fjhx.applet.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.base.BaseEntity;
+import com.fjhx.entity.stock.StockInoutbill;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface InkStatisticsMapper extends BaseMapper<BaseEntity> {
+
+    List<Map<String, Object>> selectInkStatistics();
+
+    List<Map<String, Object>> selectInkW(@Param("ew") QueryWrapper<Object> wrapper);
+
+    List<Map<String, Object>> selectInkEWDetails(@Param("ew") QueryWrapper<Object> wrapper);
+
+}

+ 40 - 0
hx-service/storage/src/main/java/com/fjhx/applet/mapper/InkStatisticsMapper.xml

@@ -0,0 +1,40 @@
+<?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.fjhx.applet.mapper.InkStatisticsMapper">
+
+    <select id="selectInkStatistics" resultType="java.util.Map">
+        SELECT sh.`Name`                  houseName,
+               Count(1)                   count,
+               sum(sd.Quantity)           quantity,
+               sum(sd.Quantity * m.Price) amount
+        FROM stock_detail sd
+                 LEFT JOIN material m ON sd.MaterialCode = m.`Code`
+                 LEFT JOIN stock_house sh ON sd.StockHouseId = sh.ID
+        WHERE m.TechnologyType = '3'
+        GROUP BY sh.`Name`
+    </select>
+
+    <select id="selectInkW" resultType="java.util.Map">
+        SELECT sh.`Name`                              houseName,
+               count(1)                               count,
+               sum(swd.ChangeNum)                     changeNum,
+               round(sum(swd.ChangeNum * m.Price), 2) amount
+        FROM stock_waterdetial swd
+                 LEFT JOIN stock_water sw ON swd.WaterId = sw.ID
+                 LEFT JOIN stock_house sh ON sw.StockHouseId = sh.ID
+                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectInkEWDetails" resultType="java.util.Map">
+        SELECT u.RealName                             nickName,
+               Count(1)                               count,
+               sum(swd.ChangeNum)                     changeNum,
+               round(sum(swd.ChangeNum * m.Price), 2) amount
+        FROM stock_waterdetial swd
+                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
+                 LEFT JOIN u_user u ON swd.OperUserId = u.ID
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>

+ 28 - 0
hx-service/storage/src/main/java/com/fjhx/applet/service/FabricStatisticsService.java

@@ -0,0 +1,28 @@
+package com.fjhx.applet.service;
+
+import com.fjhx.base.BaseEntity;
+import com.fjhx.base.BaseService;
+import com.fjhx.entity.stock.StockInoutbill;
+
+import java.util.List;
+import java.util.Map;
+
+public interface FabricStatisticsService extends BaseService<BaseEntity> {
+
+    Map<String, Object> selectFabricDetails();
+
+    List<Map<String, Object>> selectFabricTypeDetails(Map<String, Object> condition);
+
+    Map<String, Object> selectFabricWDetails(Map<String, Object> condition);
+
+    List<Map<String, Object>> selectFabricWTypeDetails(Map<String, Object> condition);
+
+    List<Map<String, Object>> selectFabricEWDetails(Map<String, String> condition);
+
+    Map<String, Object> selectFabricStatistics(Map<String, Object> condition);
+
+    Map<String, Object> selectFabricEW(Map<String, Object> condition);
+
+    Map<String, Object> selectFabricW(Map<String, Object> condition);
+
+}

+ 16 - 0
hx-service/storage/src/main/java/com/fjhx/applet/service/InkStatisticsService.java

@@ -0,0 +1,16 @@
+package com.fjhx.applet.service;
+
+import com.fjhx.base.BaseEntity;
+import com.fjhx.base.BaseService;
+
+import java.util.Map;
+
+public interface InkStatisticsService extends BaseService<BaseEntity> {
+
+    Map<String, Object> selectInkStatistics();
+
+    Map<String, Object> selectInkW(Map<String, Object> condition);
+
+    Map<String, Object> selectInkEWDetails(Map<String, Object> condition);
+
+}

+ 426 - 0
hx-service/storage/src/main/java/com/fjhx/applet/service/impl/FabricStatisticsServiceImpl.java

@@ -0,0 +1,426 @@
+package com.fjhx.applet.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.applet.mapper.FabricStatisticsMapper;
+import com.fjhx.applet.service.FabricStatisticsService;
+import com.fjhx.base.BaseEntity;
+import com.fjhx.entity.stock.StockInoutbill;
+import com.fjhx.utils.Assert;
+import org.springblade.core.log.exception.ServiceException;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class FabricStatisticsServiceImpl extends ServiceImpl<FabricStatisticsMapper, BaseEntity> implements FabricStatisticsService {
+
+    @Override
+    public Map<String, Object> selectFabricDetails() {
+        List<Map<String, Object>> maps = baseMapper.selectFabricDetails();
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("quantity").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+        }
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    @Override
+    public List<Map<String, Object>> selectFabricTypeDetails(Map<String, Object> condition) {
+        QueryWrapper<Object> wrapper = Wrappers.query();
+        wrapper.eq(ObjectUtil.isNotNull(condition.get("technologyType")), "m.TechnologyType", condition.get("technologyType"));
+        //判断选则了那个仓库  1为1号仓库  2为2号仓库  0 查询全部仓库
+        if (Integer.parseInt(condition.get("houseType").toString()) == 1) {
+            wrapper.eq("sd.StockHouseId", "c185883dba22478cb593d33f6b66cc53");
+        } else if (Integer.parseInt(condition.get("houseType").toString()) == 2) {
+            wrapper.eq("sd.StockHouseId", "0b8f584250bb4b40b72d641ce4849d15");
+        }
+        wrapper.groupBy("m.Purpose");
+        return baseMapper.selectFabricTypeDetails(wrapper);
+    }
+
+    @Override
+    public Map<String, Object> selectFabricWDetails(Map<String, Object> condition) {
+        QueryWrapper<Object> wrapper = getDateWrapper("swd.CreatedTime", condition);
+        wrapper.ne("m.TechnologyType", 3);
+        wrapper.in("swd.StockChangeType", 10, 13);
+        wrapper.groupBy("sh.id");
+        List<Map<String, Object>> maps = baseMapper.selectFabricWDetails(wrapper);
+
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("changeNum").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+        }
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    @Override
+    public List<Map<String, Object>> selectFabricWTypeDetails(Map<String, Object> condition) {
+        QueryWrapper<Object> wrapper = getDateWrapper("swd.CreatedTime", condition);
+        wrapper.in("swd.StockChangeType", 10, 13);
+        wrapper.eq("m.TechnologyType", condition.get("technologyType"));
+        //判断选则了那个仓库  1为1号仓库  2为2号仓库  0 查询全部仓库
+        if (Integer.parseInt(condition.get("houseType").toString()) == 1) {
+            wrapper.eq("sh.id", "c185883dba22478cb593d33f6b66cc53");
+        } else if (Integer.parseInt(condition.get("houseType").toString()) == 2) {
+            wrapper.eq("sh.id", "0b8f584250bb4b40b72d641ce4849d15");
+        }
+        wrapper.groupBy("m.Purpose");
+        return baseMapper.selectFabricWTypeDetails(wrapper);
+    }
+
+    @Override
+    public List<Map<String, Object>> selectFabricEWDetails(Map<String, String> condition) {
+
+        QueryWrapper<Object> inOutBillWrapper = getDateWrapper("tsi.deviation_time", condition);
+        inOutBillWrapper.groupBy("tsi.job_no", "m.technologyType");
+        inOutBillWrapper.orderByAsc("m.technologyType");
+        List<Map<String, Object>> inOutBill = baseMapper.getInOutBill(inOutBillWrapper);
+
+        QueryWrapper<Object> waterStatisticsWrapper = getDateWrapper("swd.CreatedTime", condition);
+        waterStatisticsWrapper.in("swd.StockChangeType", 20, 23);
+        waterStatisticsWrapper.in("m.TechnologyType", 0, 1, 2, 4);
+        waterStatisticsWrapper.groupBy("JobNo", "technologyType");
+        List<Map<String, Object>> waterStatistics = baseMapper.getWaterStatistics(waterStatisticsWrapper);
+
+        QueryWrapper<Object> returnMaterialWrapper = getDateWrapper("swd.CreatedTime", condition);
+        returnMaterialWrapper.eq("swd.StockChangeType", 15);
+        returnMaterialWrapper.in("m.TechnologyType", 0, 1, 2, 4);
+        returnMaterialWrapper.groupBy("JobNo", "technologyType");
+        List<Map<String, Object>> returnMaterial = baseMapper.getReturnMaterial(returnMaterialWrapper);
+
+
+        Map<String, Map<String, Object>> collect = waterStatistics.stream().collect(
+                Collectors.toMap(item -> item.get("jobNo").toString() + item.get("technologyType").toString(), item -> item));
+
+        Map<String, Map<String, Object>> collect1 = returnMaterial.stream().collect(
+                Collectors.toMap(item -> item.get("jobNo").toString() + item.get("technologyType").toString(), item -> item));
+
+        for (Map<String, Object> map : inOutBill) {
+            String key = map.get("jobNo").toString() + map.get("technologyType").toString();
+
+            if (collect.get(key) != null) {
+                map.putAll(collect.get(key));
+                map.put("area", BigDecimal.valueOf((Double) map.get("area")));
+            } else {
+                map.put("quantity", BigDecimal.ZERO);
+                map.put("amount", BigDecimal.ZERO);
+                map.put("area", BigDecimal.ZERO);
+                map.put("pcs", 0);
+            }
+
+            if (collect1.get(key) != null) {
+                map.putAll(collect1.get(key));
+            } else {
+                map.put("backQty", BigDecimal.ZERO);
+            }
+
+            BigDecimal subtract = ((BigDecimal) map.get("area")).subtract(((BigDecimal) map.get("backQty")));
+            if (subtract.compareTo(BigDecimal.ZERO) == 0) {
+                map.put("outputRatio", BigDecimal.ZERO);
+            } else {
+                map.put("outputRatio", (((BigDecimal) map.get("planArea"))
+                        .divide(subtract, 5, RoundingMode.HALF_UP)
+                        .multiply(new BigDecimal("100"))));
+            }
+        }
+
+        Map<Integer, List<Map<String, Object>>> technologyTypeMap =
+                inOutBill.stream().collect(Collectors.groupingBy(item -> Integer.valueOf(item.get("technologyType").toString())));
+
+        List<Map<String, Object>> result = new ArrayList<>();
+
+        HashMap<String, Object> totalMap = new HashMap<>();
+        totalMap.put("realName", "合计");
+        totalMap.put("type", 1);
+        totalMap.put("planArea", BigDecimal.ZERO);
+        totalMap.put("quantity", BigDecimal.ZERO);
+        totalMap.put("amount", BigDecimal.ZERO);
+        totalMap.put("area", BigDecimal.ZERO);
+        totalMap.put("backQty", BigDecimal.ZERO);
+        totalMap.put("pcs", 0);
+
+
+        for (Integer technologyType : Arrays.asList(0, 1, 2, 4)) {
+            HashMap<String, Object> map = new HashMap<>();
+            map.put("realName", technologyType == 0 ? "直喷" : technologyType == 1 ? "热转" : technologyType == 2 ? "打纸" : "其他");
+            map.put("type", 2);
+
+            List<Map<String, Object>> list = technologyTypeMap.get(technologyType);
+            if (list == null) break;
+
+            BigDecimal planArea = list.stream().map(item -> (BigDecimal) item.get("planArea")).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal quantity = list.stream().map(item -> (BigDecimal) item.get("quantity")).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal amount = list.stream().map(item -> (BigDecimal) item.get("amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal area = list.stream().map(item -> (BigDecimal) item.get("area")).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal backQty = list.stream().map(item -> (BigDecimal) item.get("backQty")).reduce(BigDecimal.ZERO, BigDecimal::add);
+            int pcs = list.stream().mapToInt(item -> Integer.parseInt(item.get("pcs").toString())).sum();
+            map.put("planArea", planArea);
+            map.put("quantity", quantity);
+            map.put("amount", amount);
+            map.put("area", area);
+            map.put("pcs", pcs);
+            map.put("backQty", backQty);
+
+            BigDecimal subtract = ((BigDecimal) map.get("area")).subtract(((BigDecimal) map.get("backQty")));
+            if (subtract.compareTo(BigDecimal.ZERO) == 0) {
+                map.put("outputRatio", BigDecimal.ZERO);
+            } else {
+                map.put("outputRatio", (((BigDecimal) map.get("planArea"))
+                        .divide(subtract, 5, RoundingMode.HALF_UP)
+                        .multiply(new BigDecimal("100"))));
+            }
+
+            result.add(map);
+            result.addAll(list);
+
+            totalMap.put("planArea", ((BigDecimal) totalMap.get("planArea")).add(planArea));
+            totalMap.put("quantity", ((BigDecimal) totalMap.get("quantity")).add(quantity));
+            totalMap.put("amount", ((BigDecimal) totalMap.get("amount")).add(amount));
+            totalMap.put("area", ((BigDecimal) totalMap.get("area")).add(area));
+            totalMap.put("backQty", ((BigDecimal) totalMap.get("backQty")).add(backQty));
+            totalMap.put("pcs", ((Integer) totalMap.get("pcs")) + pcs);
+        }
+
+
+        BigDecimal subtract = ((BigDecimal) totalMap.get("area")).subtract(((BigDecimal) totalMap.get("backQty")));
+        if (subtract.compareTo(BigDecimal.ZERO) == 0) {
+            totalMap.put("outputRatio", BigDecimal.ZERO);
+        } else {
+            totalMap.put("outputRatio", (((BigDecimal) totalMap.get("planArea"))
+                    .divide(subtract, 5, RoundingMode.HALF_UP)
+                    .multiply(new BigDecimal("100"))));
+            result.add(0, totalMap);
+        }
+
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> selectFabricStatistics(Map<String, Object> condition) {
+
+        Object type = condition.get("type");
+        Assert.notEmpty(type, "类型参数不能为null");
+
+        QueryWrapper<Object> wrapper = Wrappers.query();
+
+        //1为1号仓库 2为2号仓库
+        if (Integer.parseInt(type.toString()) == 1) {
+            wrapper.eq("sd.StockHouseId", "c185883dba22478cb593d33f6b66cc53");
+        } else if (Integer.parseInt(type.toString()) == 2) {
+            wrapper.eq("sd.StockHouseId", "0b8f584250bb4b40b72d641ce4849d15");
+        }
+
+        wrapper.ne("m.TechnologyType", 3);
+        wrapper.groupBy("m.TechnologyType");
+        //查询明细
+        List<Map<String, Object>> maps = baseMapper.selectFabricStatistics(wrapper);
+
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("quantity").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+        }
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    @Override
+    public Map<String, Object> selectFabricEW(Map<String, Object> condition) {
+        QueryWrapper<Object> wrapper = getDateWrapper("swd.CreatedTime", condition);
+        wrapper.in("swd.StockChangeType", 20, 23);
+        wrapper.ne("m.TechnologyType", 3);
+        wrapper.groupBy("m.TechnologyType");
+        Map<String, String> pickingMap = selectPicking(condition);
+
+        List<Map<String, Object>> maps = baseMapper.selectFabricEW(wrapper);
+
+        for (Map<String, Object> map : maps) {
+            String quantity = pickingMap.get(map.get("technologyType").toString());
+            if (ObjectUtil.isNotEmpty(quantity)) {
+                map.put("quantity", pickingMap.get(map.get("technologyType").toString()));
+            } else {
+                map.put("quantity", 0);
+            }
+        }
+
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0 || ObjectUtil.isNotEmpty(maps)) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("changeNum").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计的排班面积
+            BigDecimal quantity = maps.stream().map(map -> new BigDecimal(map.get("quantity").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算总的平方
+            BigDecimal square = maps.stream().map(map -> new BigDecimal(map.get("square").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+            detailsMap.put("quantity", quantity);
+            detailsMap.put("square", square);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+            // detailsMap.put("quantity", 0);
+            detailsMap.put("square", 0);
+        }
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    @Override
+    public Map<String, Object> selectFabricW(Map<String, Object> condition) {
+        QueryWrapper<Object> wrapper = getDateWrapper("swd.CreatedTime", condition);
+        //判断选则了那个仓库  1为1号仓库  2为2号仓库  0 查询全部仓库
+        if (Integer.parseInt(condition.get("houseType").toString()) == 1) {
+            wrapper.eq("sw.StockHouseId", "c185883dba22478cb593d33f6b66cc53");
+        } else if (Integer.parseInt(condition.get("houseType").toString()) == 2) {
+            wrapper.eq("sw.StockHouseId", "0b8f584250bb4b40b72d641ce4849d15");
+        }
+        wrapper.in("swd.StockChangeType", 10, 13);
+        wrapper.ne("m.TechnologyType", 3);
+        wrapper.groupBy("m.TechnologyType");
+        List<Map<String, Object>> maps = baseMapper.selectFabricW(wrapper);
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("totalQty").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+        }
+
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    /**
+     * 获取时间段查询
+     *
+     * @param field     字段名称
+     * @param condition 条件
+     * @return
+     */
+    private static QueryWrapper<Object> getDateWrapper(String field, Map<String, ?> condition) {
+        if (ObjectUtil.isAllEmpty(condition.get("type"), condition.get("beginTime"), condition.get("endTime"))) {
+            throw new ServiceException("日期不能为空");
+        }
+        int type = Integer.parseInt(condition.get("type").toString());
+        Date date = new Date();
+        Date beginDate;
+        Date endDate;
+
+        switch (type) {
+            case 0: // 本日
+                beginDate = DateUtil.beginOfDay(date);
+                endDate = DateUtil.endOfDay(date);
+                break;
+            case 1: // 昨日
+                beginDate = DateUtil.beginOfDay(DateUtil.offsetDay(date, -1));
+                endDate = DateUtil.endOfDay(DateUtil.offsetDay(date, -1));
+                break;
+            case 2: // 本周
+                beginDate = DateUtil.beginOfWeek(date);
+                endDate = DateUtil.endOfWeek(date);
+                break;
+            case 3:  // 上周
+                beginDate = DateUtil.beginOfWeek(DateUtil.offsetWeek(date, -1));
+                endDate = DateUtil.endOfWeek(DateUtil.offsetWeek(date, -1));
+                break;
+            case 4: // 本月
+                beginDate = DateUtil.beginOfMonth(date);
+                endDate = DateUtil.endOfMonth(date);
+                break;
+            case 5: // 上月
+                beginDate = DateUtil.beginOfMonth(DateUtil.offsetMonth(date, -1));
+                endDate = DateUtil.endOfMonth(DateUtil.offsetMonth(date, -1));
+                break;
+            default: // 自定义
+                beginDate = DateUtil.parse(condition.get("beginTime").toString());
+                endDate = DateUtil.parse(condition.get("endTime").toString());
+        }
+
+        return Wrappers.query().between(field, beginDate, endDate);
+    }
+
+    private Map<String, String> selectPicking(Map<String, Object> condition) {
+        Map<String, String> details = new HashMap<>();
+        QueryWrapper<Object> wrapper = getDateWrapper("si.create_time", condition);
+        wrapper.groupBy("si.scheduling_material", "si.job_no");
+        List<Map<String, Object>> maps = baseMapper.selectPickingQuantitySum(wrapper);
+        maps = maps.stream().filter(map -> ObjectUtil.isNotEmpty(map.get("technologyType"))).collect(Collectors.toList());
+        for (Map<String, Object> map : maps) {
+            details.put(map.get("technologyType").toString(), map.get("quantity").toString());
+        }
+        return details;
+    }
+
+}

+ 155 - 0
hx-service/storage/src/main/java/com/fjhx/applet/service/impl/InkStatisticsServiceImpl.java

@@ -0,0 +1,155 @@
+package com.fjhx.applet.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.applet.mapper.InkStatisticsMapper;
+import com.fjhx.applet.service.InkStatisticsService;
+import com.fjhx.base.BaseEntity;
+import com.fjhx.entity.stock.StockInoutbill;
+import com.fjhx.utils.Assert;
+import org.springblade.core.log.exception.ServiceException;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class InkStatisticsServiceImpl extends ServiceImpl<InkStatisticsMapper, BaseEntity> implements InkStatisticsService {
+
+    @Override
+    public Map<String, Object> selectInkStatistics() {
+        //查询明细
+        List<Map<String, Object>> maps = baseMapper.selectInkStatistics();
+
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("quantity").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+        }
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    @Override
+    public Map<String, Object> selectInkW(Map<String, Object> condition) {
+        Object ewType = condition.get("EWType");
+        Assert.notEmpty(ewType, "出入库参数:EWType不能为null");
+
+        QueryWrapper<Object> wrapper = getDateWrapper(condition);
+
+        if (Integer.parseInt(ewType.toString()) == 1) {
+            wrapper.in("swd.StockChangeType", 20, 23);
+        } else if (Integer.parseInt(ewType.toString()) == 2) {
+            wrapper.in("swd.StockChangeType", 10, 13);
+        } else {
+            throw new ServiceException("检查参数EWType:只能传1或者2");
+        }
+
+        wrapper.eq("m.TechnologyType", 3);
+        wrapper.groupBy("sh.`Name`");
+        List<Map<String, Object>> maps = baseMapper.selectInkW(wrapper);
+
+        return encapsulationResult(maps);
+    }
+
+    @Override
+    public Map<String, Object> selectInkEWDetails(Map<String, Object> condition) {
+        QueryWrapper<Object> wrapper = getDateWrapper(condition);
+        wrapper.eq("m.TechnologyType", 3);
+        wrapper.groupBy("u.RealName");
+        wrapper.orderByDesc("changeNum");
+        List<Map<String, Object>> maps = baseMapper.selectInkEWDetails(wrapper);
+        return encapsulationResult(maps);
+    }
+
+    private Map<String, Object> encapsulationResult(List<Map<String, Object>> maps) {
+        Map<String, Object> detailsMap = new HashMap<>();
+        if (maps.size() > 0) {
+            //计算合计件数
+            int total = maps.stream().mapToInt(map -> Integer.parseInt(map.get("count").toString())).sum();
+
+            //计算合计数量
+            BigDecimal amountQuantity = maps.stream().map(map -> new BigDecimal(map.get("changeNum").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+            //计算合计金额
+            BigDecimal amountTotal = maps.stream().map(map -> new BigDecimal(map.get("amount").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
+            detailsMap.put("total", total);
+            detailsMap.put("amountQuantity", amountQuantity);
+            detailsMap.put("amountTotal", amountTotal);
+        } else {
+            detailsMap.put("total", 0);
+            detailsMap.put("amountQuantity", 0);
+            detailsMap.put("amountTotal", 0);
+        }
+        detailsMap.put("details", maps);
+        return detailsMap;
+    }
+
+    /**
+     * 获取时间段查询
+     *
+     * @param condition 条件
+     * @return
+     */
+    private static QueryWrapper<Object> getDateWrapper(Map<String, ?> condition) {
+        if (ObjectUtil.isAllEmpty(condition.get("type"), condition.get("beginTime"), condition.get("endTime"))) {
+            throw new ServiceException("日期不能为空");
+        }
+        int type = Integer.parseInt(condition.get("type").toString());
+        Date date = new Date();
+        Date beginDate;
+        Date endDate;
+
+        switch (type) {
+            case 0: // 本日
+                beginDate = DateUtil.beginOfDay(date);
+                endDate = DateUtil.endOfDay(date);
+                break;
+            case 1: // 昨日
+                beginDate = DateUtil.beginOfDay(DateUtil.offsetDay(date, -1));
+                endDate = DateUtil.endOfDay(DateUtil.offsetDay(date, -1));
+                break;
+            case 2: // 本周
+                beginDate = DateUtil.beginOfWeek(date);
+                endDate = DateUtil.endOfWeek(date);
+                break;
+            case 3:  // 上周
+                beginDate = DateUtil.beginOfWeek(DateUtil.offsetWeek(date, -1));
+                endDate = DateUtil.endOfWeek(DateUtil.offsetWeek(date, -1));
+                break;
+            case 4: // 本月
+                beginDate = DateUtil.beginOfMonth(date);
+                endDate = DateUtil.endOfMonth(date);
+                break;
+            case 5: // 上月
+                beginDate = DateUtil.beginOfMonth(DateUtil.offsetMonth(date, -1));
+                endDate = DateUtil.endOfMonth(DateUtil.offsetMonth(date, -1));
+                break;
+            default: // 自定义
+                beginDate = DateUtil.parse(condition.get("beginTime").toString());
+                endDate = DateUtil.parse(condition.get("endTime").toString());
+        }
+
+        return Wrappers.query().between("swd.CreatedTime", beginDate, endDate);
+    }
+
+}

+ 16 - 0
hx-service/storage/src/main/java/com/fjhx/stock/mapper/StockInoutbillMapper.java

@@ -0,0 +1,16 @@
+package com.fjhx.stock.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.entity.stock.StockInoutbill;
+
+/**
+ * <p>
+ * 出/入库单 Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-04-12
+ */
+public interface StockInoutbillMapper extends BaseMapper<StockInoutbill> {
+
+}

+ 5 - 0
hx-service/storage/src/main/java/com/fjhx/stock/mapper/StockInoutbillMapper.xml

@@ -0,0 +1,5 @@
+<?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.fjhx.stock.mapper.StockInoutbillMapper">
+
+</mapper>

+ 16 - 0
hx-service/storage/src/main/java/com/fjhx/stock/service/StockInoutbillService.java

@@ -0,0 +1,16 @@
+package com.fjhx.stock.service;
+
+import com.fjhx.base.BaseService;
+import com.fjhx.entity.stock.StockInoutbill;
+
+/**
+ * <p>
+ * 出/入库单 服务类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-04-12
+ */
+public interface StockInoutbillService extends BaseService<StockInoutbill> {
+
+}

+ 20 - 0
hx-service/storage/src/main/java/com/fjhx/stock/service/impl/StockInoutbillServiceImpl.java

@@ -0,0 +1,20 @@
+package com.fjhx.stock.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.entity.stock.StockInoutbill;
+import com.fjhx.stock.mapper.StockInoutbillMapper;
+import com.fjhx.stock.service.StockInoutbillService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 出/入库单 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-04-12
+ */
+@Service
+public class StockInoutbillServiceImpl extends ServiceImpl<StockInoutbillMapper, StockInoutbill> implements StockInoutbillService {
+
+}

+ 12 - 0
hx-service/storage/src/main/java/com/fjhx/task/controller/ScheduleTaskController.java

@@ -1,6 +1,7 @@
 package com.fjhx.task.controller;
 
 import com.fjhx.task.service.ScheduleTaskService;
+import org.springblade.core.launch.BladeApplication;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
@@ -21,4 +22,15 @@ public class ScheduleTaskController {
         scheduleTaskService.stockAcceptActionTask();
     }
 
+    /**
+     * 同步领料信息
+     */
+    @Scheduled(cron = "30 0/19 * * * ?")
+    private void schedulingTask() {
+        if (BladeApplication.isLocalDev()) {
+            return;
+        }
+        scheduleTaskService.schedulingTask();
+    }
+
 }

+ 2 - 0
hx-service/storage/src/main/java/com/fjhx/task/service/ScheduleTaskService.java

@@ -4,4 +4,6 @@ public interface ScheduleTaskService {
 
     void stockAcceptActionTask();
 
+    void schedulingTask();
+
 }

+ 95 - 9
hx-service/storage/src/main/java/com/fjhx/task/service/impl/ScheduleTaskServiceImpl.java

@@ -1,7 +1,11 @@
 package com.fjhx.task.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.fjhx.entity.stock.StockInoutbill;
+import com.fjhx.stock.service.StockInoutbillService;
 import com.fjhx.task.mapper.ScheduleTaskMapper;
 import com.fjhx.task.service.ScheduleTaskService;
 import org.springblade.core.launch.BladeApplication;
@@ -11,10 +15,9 @@ import org.springframework.http.converter.StringHttpMessageConverter;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.math.BigDecimal;
 import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class ScheduleTaskServiceImpl implements ScheduleTaskService {
@@ -31,6 +34,9 @@ public class ScheduleTaskServiceImpl implements ScheduleTaskService {
     @Autowired
     private ScheduleTaskMapper scheduleTaskMapper;
 
+    @Autowired
+    private StockInoutbillService stockInoutbillService;
+
     static {
         restTemplate = new RestTemplate();
         restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
@@ -54,12 +60,7 @@ public class ScheduleTaskServiceImpl implements ScheduleTaskService {
         List<Map<String, Object>> selectPublishedList = scheduleTaskMapper.selectPublished(SELECT_PUBLISHED_SQL);
 
         // 获取token
-        ResponseEntity<String> entity = restTemplate.getForEntity(GET_ACCESS_TOKEN_ACTION_URL, String.class);
-        String body = entity.getBody();
-        if (ObjectUtil.isEmpty(body)) return;
-        JSONObject jsonObject = JSONObject.parseObject(body);
-        String token = jsonObject.getString("token");
-        if (ObjectUtil.isEmpty(token)) return;
+        String token = getToken(GET_ACCESS_TOKEN_ACTION_URL);
 
         for (Map<String, Object> stringStringMap : selectPublishedList) {
             String content = stringStringMap.get("Content").toString();
@@ -100,6 +101,91 @@ public class ScheduleTaskServiceImpl implements ScheduleTaskService {
         }
     }
 
+    @Override
+    public synchronized void schedulingTask() {
+
+        // 请求v3接口获取token
+        String token = getToken("http://mes.cfmfactory.com:8087/portal/getAccessTokenAction.do?AppId=1&AppSecret=a2b1c2d3");
+
+        // 请求v3接口获取所有人领料信息
+        Date date = new Date();
+        if (Integer.parseInt(DateUtil.format(date, "HH")) < 5) {
+            date = DateUtil.offsetDay(date, -1);
+        }
+
+        String beginDate = DateUtil.format(DateUtil.offsetDay(date, -2), "yyyy-MM-dd 00:00:00");
+        beginDate = "2022-06-01 00:00:00";
+        String endDate = DateUtil.format(date, "yyyy-MM-dd 23:59:59");
+
+        String url = "http://mes.cfmfactory.com:8087/MesWeb/planPersonOutAction.do?action=list&beginDate=" + beginDate
+                + "&endDate=" + endDate + "&access_token=" + token;
+
+        String resultStr = restTemplate.getForEntity(url, String.class).getBody();
+        JSONObject resultMap = JSONObject.parseObject(resultStr);
+        // 接收到的消息
+        List<JSONObject> items = (List<JSONObject>) resultMap.get("items");
+
+        stockInoutbillService.remove(Wrappers.<StockInoutbill>lambdaQuery().between(StockInoutbill::getDeviationTime, beginDate, endDate));
+
+        Map<String, StockInoutbill> flagMap = new HashMap<>();
+
+        Date newDate = new Date();
+
+        // 循环领料信息
+        items.forEach(item -> {
+            // 喷印人员工号
+            long distributor = Long.parseLong(item.get("distributor").toString());
+            // 打纸人员工号
+            long paperMan = Long.parseLong(item.get("paperMan").toString());
+            // 排班面积
+            BigDecimal plantotalsquare = new BigDecimal(item.get("plantotalsquare").toString());
+            // 物料名称
+            String material = item.get("material").toString();
+            // 排班时间
+            String planDate = item.get("planDate").toString();
+
+            // 喷印人员工号添加领料记录标记
+            addOrEditFlagMap(flagMap, distributor, plantotalsquare, planDate, material, newDate);
+
+            // 打纸人员工号添加领料记录标记
+            if (paperMan > 0) {
+                addOrEditFlagMap(flagMap, paperMan, plantotalsquare, planDate, "热转印纸", newDate);
+            }
+
+        });
+
+        // 更新当天的出库单
+        stockInoutbillService.saveBatch(new ArrayList<>(flagMap.values()));
+    }
+
+    private String getToken(String url) {
+        // 获取token
+        String result = restTemplate.getForEntity(url, String.class).getBody();
+        if (ObjectUtil.isEmpty(result)) return null;
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        return jsonObject.getString("token");
+    }
+
+    private void addOrEditFlagMap(Map<String, StockInoutbill> flagMap, Long jobNo, BigDecimal plantotalsquare, String planDate, String material, Date date) {
+        String key = jobNo + material + planDate;
+        StockInoutbill stockInoutbill = flagMap.get(key);
+
+        if (stockInoutbill == null) {
+            stockInoutbill = new StockInoutbill();
+            stockInoutbill.setJobNo(jobNo);
+            stockInoutbill.setSchedulingMaterial(material);
+            stockInoutbill.setDeviationTime(DateUtil.parse(planDate));
+            stockInoutbill.setQuantity(plantotalsquare);
+            stockInoutbill.setCreateTime(date);
+
+            flagMap.put(key, stockInoutbill);
+        } else {
+            BigDecimal quantity = stockInoutbill.getQuantity();
+            stockInoutbill.setQuantity(quantity.add(plantotalsquare));
+        }
+
+    }
+
 //    public static void main(String[] args) {
 //
 //        List<String> strings1 = Arrays.asList(