Ver código fonte

实现设备换料的日志记录功能

oyq28 2 anos atrás
pai
commit
5866a92a34

+ 44 - 48
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

@@ -18,17 +18,17 @@ import com.github.zuihou.business.record.entity.EquRecord;
 import com.github.zuihou.business.record.service.EquRecordService;
 import com.github.zuihou.business.util.CommonUtil;
 import com.github.zuihou.common.util.DateUtil;
+import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.utils.DateUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.LocalTime;
 import java.util.*;
 
 /**
@@ -50,6 +50,7 @@ public class OpsAppApi {
     @Autowired
     private MaterialService materialService;
 
+
     /**
      * 设备列表接口
      *
@@ -61,7 +62,7 @@ public class OpsAppApi {
         BaseContextHandler.setTenant("0000");
         IPage<ProductionResource> page = params.buildPage();
         LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
-        ProductionResource productionResource = BeanUtil.toBean(params, ProductionResource.class);
+        ProductionResource productionResource = BeanUtil.toBean(params.getModel(), ProductionResource.class);
         queryWrap.eq(ProductionResource::getStatus,"1").orderByDesc(ProductionResource::getCreateTime);
         IPage<ProductionResource> list = productionTenantResourceService.pageList(page, queryWrap);
         return R.success(list);
@@ -115,7 +116,7 @@ public class OpsAppApi {
         BaseContextHandler.setTenant("0000");
         IPage<Order> page = params.buildPage();
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
-        Order order = BeanUtil.toBean(params, Order.class);
+        Order order = BeanUtil.toBean(params.getModel(), Order.class);
         if(params.getMap().containsKey("createTime_st")){
             LocalDateTime startTime = DateUtils.getStartTime(params.getMap().get("createTime_st").toString());
             orderQueryWrap.geHeader("create_time", startTime);
@@ -153,72 +154,51 @@ public class OpsAppApi {
         return R.success(orderList.getRecords().size()>0? orderList.getRecords().get(0) : Order.builder().build());
     }
 
-
-    /**
-     * 今日订单接口
-     *
-     * @return
-     */
-    @GetMapping("/todayOrders")
-    public R<List<Order>> todayOrders(@RequestParam("equId") Long equId) {
-        BaseContextHandler.setTenant("0000");
-        QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
-        orderQueryWrap.eq("order_equ_id", equId);
-
-        LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
-        LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
-        orderQueryWrap.between("create_time", startTime, endTime);
-        List<Order> list = orderService.list(orderQueryWrap);
-        return R.success(list);
-    }
-
-
-
-    /**
-     * 近七日订单接口
-     *
-     * @return
-     */
-    @GetMapping("/sevenDaysOrders")
-    public R<List<Order>> sevenDaysOrders(@RequestParam("equId") Long equId) {
-        BaseContextHandler.setTenant("0000");
-        QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
-        orderQueryWrap.eq("order_equ_id", equId);
-        LocalDateTime now = LocalDateTime.now();
-        LocalDateTime sevenAgo = now.minusDays(7);
-        orderQueryWrap.between("create_time", sevenAgo, now);
-        List<Order> list = orderService.list(orderQueryWrap);
-        return R.success(list);
-    }
-
     /**
      * 料筒查询接口
      *
      * @return
      */
     @GetMapping("/barrelList")
-    public R<IPage<EquBarrel>> barrelList(@RequestParam("equId") Long equId) {
+    public R<IPage<EquBarrel>> barrelList(@RequestParam("equId") Long equId, @RequestParam("barrelType") String barrelType) {
         BaseContextHandler.setTenant("0000");
         QueryWrap<EquBarrel> equBarrelQueryWrap = new QueryWrap<>();
-        equBarrelQueryWrap.eq("equ_id",equId);
+        equBarrelQueryWrap.eq("equ_id", equId);
+        if(StringUtils.isNotEmpty(barrelType)){
+            //equBarrelQueryWrap.in("barrel_type", new String[]{"4","5"});
+            equBarrelQueryWrap.gt("barrel_type", 3);
+        }else{
+            //equBarrelQueryWrap.in("barrel_type", new String[]{"1","2", "3"});
+            equBarrelQueryWrap.le("barrel_type", 3);
+        }
         Page<EquBarrel> page = new Page<>(1L,10);
-        //List<EquBarrel> list = equBarrelService.list(equBarrelQueryWrap);
         IPage<EquBarrel> list = equBarrelService.pageList(page, equBarrelQueryWrap);
         return R.success(list);
     }
 
-
+    /**
+     * 原料修正日志记录
+     *
+     * @param params
+     * @return
+     */
     @PostMapping("/recordList")
     public  R<IPage<EquRecord>> recordList(@RequestBody PageParams<EquRecord> params){
         BaseContextHandler.setTenant("0000");
         IPage<EquRecord> page = params.buildPage();
         LbqWrapper<EquRecord> recordQueryWrap = Wraps.lbQ();
-        EquRecord equRecord = BeanUtil.toBean(params, EquRecord.class);
+        EquRecord equRecord = BeanUtil.toBean(params.getModel(), EquRecord.class);
+        if(StringUtil.isNotEmpty(equRecord.getBarrelType())){
+            recordQueryWrap.gt(EquRecord::getBarrelType, "3");
+        }else{
+            recordQueryWrap.le(EquRecord::getBarrelType, "3");
+        }
         recordQueryWrap.eq(EquRecord::getEquId, equRecord.getEquId()).orderByDesc(EquRecord::getCreateTime);
         IPage<EquRecord> list = equRecordService.pageList(page, recordQueryWrap);
         return R.success(list);
     }
 
+
     @GetMapping("/equMaterialList")
     public  R<List<Material>> equMaterialList(@RequestParam("mtType") String mtType){
         BaseContextHandler.setTenant("0000");
@@ -272,7 +252,23 @@ public class OpsAppApi {
     }
 
 
-
+    /**
+     * 换料接口
+     *
+     * @return
+     */
+    @PostMapping("/cupRecordSave")
+    public R<Boolean> cupRecordSave(@RequestBody EquRecord equRecord) {
+        BaseContextHandler.setTenant("0000");
+        LambdaUpdateWrapper<EquBarrel> updateWrapper = new LambdaUpdateWrapper();
+        updateWrapper.set(EquBarrel::getMtrResidue, equRecord.getSpecs()).set(EquBarrel::getExprTime, equRecord.getDate())
+                .eq(EquBarrel::getId, equRecord.getMaterialId());
+        Boolean bool = equBarrelService.update(null, updateWrapper);
+        if(bool){
+            bool = equRecordService.save(equRecord);
+        }
+        return R.success(bool);
+    }
 
 
 

+ 13 - 2
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/barrel/EquBarrelMapper.xml

@@ -11,7 +11,6 @@
         <result column="update_user" jdbcType="BIGINT" property="updateUser"/>
         <result column="equ_id" jdbcType="BIGINT" property="equId"/>
         <result column="mtr_id" jdbcType="BIGINT" property="mtrId"/>
-        <result column="mtr_name" jdbcType="VARCHAR" property="mtrName"/>
         <result column="mtr_type" jdbcType="VARCHAR" property="mtrType"/>
         <result column="mtr_unit" jdbcType="VARCHAR" property="mtrUnit"/>
         <result column="mtr_residue" jdbcType="DECIMAL" property="mtrResidue"/>
@@ -19,13 +18,25 @@
         <result column="expr_war_days" jdbcType="DECIMAL" property="exprWarDays"/>
         <result column="expr_time" jdbcType="TIMESTAMP" property="exprTime"/>
         <result column="expr_Status" jdbcType="VARCHAR" property="exprStatus"/>
+        <result column="barrel_code" jdbcType="VARCHAR" property="barrelCode"/>
         <result column="barrel_weight" jdbcType="BIGINT" property="barrelWeight"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,create_time,create_user,update_time,update_user,
+        id,create_time,create_user,update_time,update_user,barrel_code,barrel_type,
         equ_id, mtr_id, mtr_name, mtr_type, mtr_unit, mtr_residue, residue_warn, expr_time, expr_war_days,expr_Status, barrel_weight
     </sql>
 
+    <select id="pageList" resultMap="BaseResultMap" parameterType="String">
+        select
+        <include refid="Base_Column_List"/>
+        from (
+        select b.id, b.create_time,b.create_user,b.update_time,b.update_user,b.barrel_code,b.barrel_type,b.equ_id, b.mtr_id, b.mtr_residue, b.residue_warn, b.expr_time, b.expr_war_days,b.expr_Status, b.barrel_weight, m.mt_name as mtr_name,m.mt_type as mtr_type, m.mt_unit as mtr_unit, p.org_id from bt_equ_barrel b left join bt_material m on b.mtr_id = m.id
+        left join imcs_tenant_productionresource p on b.equ_id = p.id
+
+        ) f ${ew.customSqlSegment}
+    </select>
+
+
 </mapper>

+ 19 - 7
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/order/OrderMapper.xml

@@ -121,9 +121,10 @@
         sum(num3) as errMsgNum,
         sum(num4) as todayAmount,
         sum(num5) as sevenAmount,
-        sum(num6) as sevenNum
+        sum(num6) as sevenNum,
+        sum(num7) as deviceNum
         from (
-        select count(1) as num1 ,0 as num2,0 as num3,0 as num4,0 as num5,0 as num6 from bt_order o where 1=1
+        select count(1) as num1 ,0 as num2,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7 from bt_order o where 1=1
         <if test="now != null">
             and o.create_time >= #{now, jdbcType=TIMESTAMP}
         </if>
@@ -134,11 +135,11 @@
             and o.id = #{id}
         </if>
         union
-        select 0 as num1, count(1) as num2 ,0 as num3,0 as num4,0 as num5,0 as num6 from bt_order o
+        select 0 as num1, count(1) as num2 ,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7 from bt_order o
         union
-        select 0 as num1,0 as num2,count(1) as num3,0 as num4,0 as num5,0 as num6 from bt_order o
+        select 0 as num1,0 as num2,count(1) as num3,0 as num4,0 as num5,0 as num6, 0 as num7 from bt_order o
         union
-        select 0 as num1,0 as num2,0 as num3,sum(o.order_amount) as num4,0 as num5,0 as num6 from bt_order o where 1=1
+        select 0 as num1,0 as num2,0 as num3,sum(o.order_amount) as num4,0 as num5,0 as num6, 0 as num7 from bt_order o where 1=1
         <if test="now != null">
             and o.create_time >= #{now, jdbcType=TIMESTAMP}
         </if>
@@ -149,7 +150,7 @@
             and o.id = #{id}
         </if>
         union
-        select 0,0,0,0,count(1) as num5,0 from bt_order o where 1=1
+        select 0,0,0,0,count(1) as num5,0, 0 from bt_order o where 1=1
         <if test="sevenAgo != null">
             and o.create_time >= #{sevenAgo, jdbcType=TIMESTAMP}
         </if>
@@ -160,7 +161,18 @@
             and o.id = #{id}
         </if>
         union
-        select 0,0,0,0,0,sum(o.order_amount) as num6 from bt_order o where produce_status = '1'
+        select 0,0,0,0,0,sum(o.order_amount) as num6, 0 from bt_order o where produce_status = '1'
+        <if test="sevenAgo != null">
+            and o.create_time >= #{sevenAgo, jdbcType=TIMESTAMP}
+        </if>
+        <if test="now != null">
+            and o.create_time <![CDATA[ <= ]]> #{now, jdbcType=TIMESTAMP}
+        </if>
+        <if test="id != null">
+            and o.id = #{id}
+        </if>
+        union
+        select 0,0,0,0,0,0, count(p.id) as num7 from imcs_tenant_productionresource p where p.status = '1'
         <if test="sevenAgo != null">
             and o.create_time >= #{sevenAgo, jdbcType=TIMESTAMP}
         </if>

+ 1 - 1
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/record/EquRecordMapper.xml

@@ -20,7 +20,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,create_time,create_user,update_time,update_user, mt_name, mtrName,barrel_code,
+        id,create_time,create_user,update_time,update_user, mt_name, mtrName,barrel_code,barrel_type,
         equ_id, material_id, current_material, replace_material, surplus, specs, date
     </sql>
 

+ 3 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/barrel/dto/EquBarrelPageDTO.java

@@ -99,4 +99,7 @@ public class EquBarrelPageDTO implements Serializable {
     @ApiModelProperty(value = "权重")
     private Long barrelWeight;
 
+    @ApiModelProperty(value = "料筒类型")
+    private String barrelType;
+
 }

+ 4 - 1
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/barrel/entity/EquBarrel.java

@@ -169,9 +169,11 @@ public class EquBarrel extends Entity<Long> {
     private String barrelDesc;
 
 
+
+
     @Builder
     public EquBarrel(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
-                     Long equId, Long mtrId, String mtrName, String mtrType, String mtrUnit,
+                     Long equId, Long mtrId, String mtrName, String mtrType, String mtrUnit,String barrelType,
                      BigDecimal mtrResidue, BigDecimal residueWarn, LocalDateTime exprTime, String exprStatus, Long barrelWeight) {
         this.id = id;
         this.createTime = createTime;
@@ -188,6 +190,7 @@ public class EquBarrel extends Entity<Long> {
         this.exprTime = exprTime;
         this.exprStatus = exprStatus;
         this.barrelWeight = barrelWeight;
+        this.barrelType = barrelType;
     }
 
 }

+ 4 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/record/dto/EquRecordPageDTO.java

@@ -81,4 +81,8 @@ public class EquRecordPageDTO implements Serializable {
     @Length(max = 255, message = "原料名称长度不能超过255")
     private String mtName;
 
+    @ApiModelProperty(value = "料筒类型")
+    @Length(max = 10, message = "料筒类型长度不能超过10")
+    private String barrelType;
+
 }

+ 3 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/record/dto/EquRecordSaveDTO.java

@@ -76,5 +76,8 @@ public class EquRecordSaveDTO implements Serializable {
     @Length(max = 20, message = "长度不能超过20")
     private String date;
 
+    @ApiModelProperty(value = "料筒类型")
+    @Length(max = 10, message = "料筒类型长度不能超过10")
+    private String barrelType;
 
 }

+ 4 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/record/dto/EquRecordUpdateDTO.java

@@ -81,4 +81,8 @@ public class EquRecordUpdateDTO implements Serializable {
     @Length(max = 20, message = "长度不能超过20")
     private String date;
 
+    @ApiModelProperty(value = "料筒类型")
+    @Length(max = 10, message = "料筒类型长度不能超过10")
+    private String barrelType;
+
 }

+ 10 - 3
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/record/entity/EquRecord.java

@@ -101,10 +101,10 @@ public class EquRecord extends Entity<Long> {
     @Excel(name = "原料名称")
     private String mtName;
 
-    @ApiModelProperty(value = "")
+    @ApiModelProperty(value = "到期日期")
     @Length(max = 20, message = "长度不能超过20")
     @TableField(value = "date", condition = LIKE)
-    @Excel(name = "")
+    @Excel(name = "到期日期")
     private String date;
 
 
@@ -120,11 +120,17 @@ public class EquRecord extends Entity<Long> {
     @Excel(name = "料筒编号")
     private String barrelCode;
 
+    @ApiModelProperty(value = "料筒类型")
+    @Length(max = 10, message = "料筒类型不能超过10")
+    @TableField(value = "barrel_type", condition = LIKE)
+    @Excel(name = "料筒类型")
+    private String barrelType;
+
 
     @Builder
     public EquRecord(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
                     Long equId, Long materialId, String currentMaterial, String replaceMaterial, BigDecimal surplus,
-                    BigDecimal specs, String date) {
+                    BigDecimal specs, String date, String barrelType) {
         this.id = id;
         this.createTime = createTime;
         this.createUser = createUser;
@@ -137,6 +143,7 @@ public class EquRecord extends Entity<Long> {
         this.surplus = surplus;
         this.specs = specs;
         this.date = date;
+        this.barrelType = barrelType;
     }
 
 }