|
@@ -32,6 +32,7 @@ import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
@@ -39,9 +40,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -121,6 +121,42 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<ProductionOrderVo> getSchedulingList(ProduceOrderSelectDto dto) {
|
|
|
+ //没传默认当前月
|
|
|
+ if (ObjectUtil.isEmpty(dto.getBeginDate())) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ dto.setBeginDate(sdf.format(new Date()));
|
|
|
+ }
|
|
|
+
|
|
|
+ IWrapper<ProductionOrder> wrapper = getWrapper();
|
|
|
+ //排程时间过滤
|
|
|
+ wrapper.and(q -> q
|
|
|
+ .eq("DATE_FORMAT( po.create_time, '%Y-%m' )", dto.getBeginDate())
|
|
|
+ .or().eq("DATE_FORMAT( po.delivery_period, '%Y-%m' )", dto.getBeginDate())
|
|
|
+ .or(q1 -> q1
|
|
|
+ .le("DATE_FORMAT( po.create_time, '%Y-%m' )", dto.getBeginDate())
|
|
|
+ .ge("DATE_FORMAT( po.delivery_period, '%Y-%m' )", dto.getBeginDate())
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ //过滤未开始的订单
|
|
|
+ wrapper.eq("po", ProductionOrder::getProduceStatus, 0);
|
|
|
+
|
|
|
+ //权限过滤:生产排程-子公司看自己,总公司看全部
|
|
|
+ Long companyId = SecurityUtils.getCompanyId();
|
|
|
+ if (!Objects.equals(companyId, 100L)) {
|
|
|
+ wrapper.eq(ProductInfo::getCompanyId, companyId);
|
|
|
+ } else {
|
|
|
+ wrapper.eq(ProductInfo::getCompanyId, dto.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ wrapper.groupBy("po.id");
|
|
|
+ wrapper.orderByDesc("po", ProductionOrder::getId);
|
|
|
+ List<ProductionOrderVo> schedulingList = baseMapper.getSchedulingList(wrapper);
|
|
|
+ return schedulingList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@DSTransactional
|
|
|
public void createOrder(ProductionOrderDto produceOrderDto) {
|
|
|
Long contractId = produceOrderDto.getContractId();
|