Fancy
2024-08-22 4a36a12d40453f7686e5f2664f19601b9f6b9ae2
order status
5个文件已修改
61 ■■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrAssemblyPlan.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/PrOrderMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPr/PrAssemblyPlan.java
@@ -43,6 +43,9 @@
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    public Long orderId;
    @TableField(exist = false)
    public String orderName;
    /**
     * 批次实体编号
     */
pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
@@ -29,6 +29,8 @@
                     select="com.dy.pmsGlobal.daoPr.PrBatchNumberMapper.selectBatchNoById" fetchType="eager"/>
        <association property="processName" column="process_id" javaType="java.lang.Long"
                     select="com.dy.pmsGlobal.daoPr.PrProductionProcessMapper.selectProcessNameById" fetchType="eager"/>
        <association property="orderName" column="order_id" javaType="java.lang.Long"
                     select="com.dy.pmsGlobal.daoPr.PrOrderMapper.selectOrderNameById" fetchType="eager" />
        <collection property="process" ofType="com.dy.pmsGlobal.pojoPr.PrProductionProcess"
                    select="com.dy.pmsGlobal.daoPr.PrProductionProcessMapper.selectByPrimaryKey" fetchType="eager"
                    column="process_id"/>
pms-parent/pms-global/src/main/resources/mapper/PrOrderMapper.xml
@@ -33,7 +33,9 @@
        from pr_order
        where  id = #{id,jdbcType=BIGINT} 
    </select>
    <select id="selectOrderNameById" parameterType="java.lang.Long" resultType="String">
        select name from pr_order where id=#{orderId,jdbcType=BIGINT}
    </select>
    <select id="exists" resultType="java.lang.Boolean">
        select count(1) from pr_order where name = #{name}
        <if test="id != null">
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java
@@ -24,10 +24,12 @@
@RequestMapping(path="order")
public class OrderCtrl {
    private OrderSv sv;
    @Autowired
    public void setAssemblySv(OrderSv orderSv) {
        this.sv = orderSv;
    }
    @PostMapping(path="save")
    @SsoPowerAop(power = "10200001")
    @Log("保存订单信息")
@@ -42,6 +44,7 @@
    /**
     * 更新
     *
     * @param order
     * @return
     */
@@ -59,6 +62,7 @@
    /**
     * 删除订单信息
     *
     * @param id
     * @return
     */
@@ -76,6 +80,7 @@
    /**
     * 根据ID查询
     *
     * @return
     */
    @GetMapping(path="one")
@@ -88,6 +93,7 @@
    /**
     * 分页查询
     *
     * @param vo
     * @return
     */
@@ -101,6 +107,7 @@
    /**
     * 查询所有订单
     *
     * @return
     */
    @GetMapping(path="all")
@@ -113,8 +120,8 @@
    @PostMapping(path="updateStatus")
    @SsoPowerAop(power = "10200001")
    @Log("更新任务计划状态")
    public BaseResponse<Boolean> updateStatus(@RequestBody PrAssemblyPlan plan){
    @Log("更新订单状态")
    public BaseResponse<Boolean> updateStatus(@RequestBody PrOrder order) {
        int count = 0;//sv.updateStatus(plan);
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java
@@ -6,6 +6,7 @@
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoPr.*;
import com.dy.pmsGlobal.util.UserUtil;
import com.dy.pmsProduct.taskPlan.PlanStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +15,8 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@@ -151,4 +154,42 @@
        }
        return orderList;
    }
    /**
     * 只更新状态,不更新其他字段
     * @param plan
     * 更新状态  如果有在执行中的任务,不让暂停
     * @return
     */
  /*  @Transactional
    public int updateStatus(PrOrder plan) {
        if(plan.status == PlanStatusEnum.NORMAL.getCode()){
            PrAssemblyPlan assemblyPlan = assemblyDao.selectByPrimaryKey(plan.id);
            assemblyPlan.status = plan.status;
            extractedCheck(assemblyPlan);
        }
        PrAssemblyPlan param = new PrAssemblyPlan();
        param.id =plan.id;
        param.status = plan.status;
        return assemblyDao.updateByPrimaryKeySelective(param);
    }
    private void extractedCheck(PrAssemblyPlan plan) {
        PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId);
        if(process == null || !process.proId.equals(plan.proId)){
            throw new RuntimeException("产品与生产流程不匹配");
        }
        //开始日期要小于结束日期
        if(plan.startDate.compareTo(plan.endDate) > 0){
            throw new RuntimeException("开始日期不能大于结束日期");
        }
        //Fancy add 2024/07/09   如果状态为执行 ,则结束日期必须大于等于当前日期
        if(plan.status == PlanStatusEnum.NORMAL.getCode()){
            String endDateStr = plan.getEndDate();
            LocalDate endDate = LocalDate.parse(endDateStr, DateTimeFormatter.ISO_LOCAL_DATE);
            LocalDate nextDay = endDate.plusDays(1);
            LocalDate today = LocalDate.now(); // 获取当前日期
            if (nextDay.isBefore(today)) {
                throw new RuntimeException("执行状态结束日期必须大于等于当前日期,请修改结束日期");
            }
        }
    }*/
}