diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/OrderMapper.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ExampleOrderMapper.java similarity index 69% rename from jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/OrderMapper.java rename to jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ExampleOrderMapper.java index fbb927e..8abdd9f 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/OrderMapper.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ExampleOrderMapper.java @@ -1,7 +1,7 @@ package jnpf.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import jnpf.entity.OrderEntity; +import jnpf.entity.ExampleOrderEntity; /** * 业务订单 Mapper @@ -11,6 +11,6 @@ import jnpf.entity.OrderEntity; * @作者: JNPF开发平台组 * @日期: 2024-02-04 */ -public interface OrderMapper extends BaseMapper { +public interface ExampleOrderMapper extends BaseMapper { } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ShiftConfigMapper.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ShiftConfigMapper.java new file mode 100644 index 0000000..97967d8 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ShiftConfigMapper.java @@ -0,0 +1,16 @@ +package jnpf.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import jnpf.entity.ShiftConfigEntity; + +/** + * 班次配置 Mapper + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +public interface ShiftConfigMapper extends BaseMapper { + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ShiftResultMapper.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ShiftResultMapper.java new file mode 100644 index 0000000..c0e99c1 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/mapper/ShiftResultMapper.java @@ -0,0 +1,16 @@ +package jnpf.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import jnpf.entity.ShiftResultEntity; + +/** + * 排班结果 Mapper + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +public interface ShiftResultMapper extends BaseMapper { + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ExampleOrderService.java similarity index 54% rename from jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderService.java rename to jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ExampleOrderService.java index eab6171..6480222 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ExampleOrderService.java @@ -1,32 +1,31 @@ package jnpf.service; import com.baomidou.mybatisplus.extension.service.IService; -import jnpf.base.service.SuperService; -import jnpf.entity.OrderEntity; +import jnpf.entity.ExampleOrderEntity; import jnpf.model.order.OrderForm; import jnpf.model.order.OrderPagination; import java.util.List; /** - * 业务订单 Service + * 示例业务订单 Service * * @版本: V3.5 * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) * @作者: JNPF开发平台组 * @日期: 2024-02-04 */ -public interface OrderService extends IService { +public interface ExampleOrderService extends IService { - List getList(OrderPagination orderPagination); - OrderEntity getInfo(String id); + List getList(OrderPagination orderPagination); + ExampleOrderEntity getInfo(String id); - void delete(OrderEntity entity); + void delete(ExampleOrderEntity entity); - void create(OrderEntity entity); + void create(ExampleOrderEntity entity); - boolean update(String id, OrderEntity entity); + boolean update(String id, ExampleOrderEntity entity); String checkForm(OrderForm form, int i); void saveOrUpdate(OrderForm orderForm,String id, boolean isSave) throws Exception; diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderDetailService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderDetailService.java index deaa5f0..8149c69 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderDetailService.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/OrderDetailService.java @@ -1,7 +1,6 @@ package jnpf.service; import com.baomidou.mybatisplus.extension.service.IService; -import jnpf.base.service.SuperService; import jnpf.entity.OrderDetailEntity; import jnpf.model.orderdetail.OrderDetailPagination; @@ -31,6 +30,6 @@ public interface OrderDetailService extends IService { * @param saleOrdId 销售订单ID * @return 订单明细列表 */ - List getListByOrderId(Integer saleOrdId); + List getListByOrderId(String saleOrdId); } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ShiftConfigService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ShiftConfigService.java new file mode 100644 index 0000000..0b2e75f --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ShiftConfigService.java @@ -0,0 +1,29 @@ +package jnpf.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import jnpf.entity.ShiftConfigEntity; +import jnpf.model.shift.ShiftConfigForm; +import jnpf.model.shift.ShiftConfigPagination; + +import java.util.List; + +/** + * 班次配置 Service + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +public interface ShiftConfigService extends IService { + + List getList(ShiftConfigPagination shiftConfigPagination); + ShiftConfigEntity getInfo(String id); + void delete(ShiftConfigEntity entity); + void create(ShiftConfigEntity entity); + boolean update(String id, ShiftConfigEntity entity); + String checkForm(ShiftConfigForm form, int i); + void saveOrUpdate(ShiftConfigForm shiftConfigForm, String id, boolean isSave) throws Exception; + + void deleteByChgClassType(String chgClassType); +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ShiftResultService.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ShiftResultService.java new file mode 100644 index 0000000..1baedb5 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/ShiftResultService.java @@ -0,0 +1,28 @@ +package jnpf.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import jnpf.entity.ShiftResultEntity; +import jnpf.model.shiftresult.ShiftResultForm; +import jnpf.model.shiftresult.ShiftResultPagination; + +import java.util.List; + +/** + * 排班结果 Service + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +public interface ShiftResultService extends IService { + + List getList(ShiftResultPagination shiftResultPagination); + ShiftResultEntity getInfo(String id); + void delete(ShiftResultEntity entity); + void create(ShiftResultEntity entity); + boolean update(String id, ShiftResultEntity entity); + String checkForm(ShiftResultForm form, int i); + void saveOrUpdate(ShiftResultForm shiftResultForm, String id, boolean isSave) throws Exception; + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ExampleOrderServiceImpl.java similarity index 70% rename from jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderServiceImpl.java rename to jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ExampleOrderServiceImpl.java index 3e2dc32..381e59f 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ExampleOrderServiceImpl.java @@ -7,18 +7,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jnpf.base.UserInfo; -import jnpf.base.service.SuperServiceImpl; import jnpf.entity.OrderDetailEntity; -import jnpf.entity.OrderEntity; -import jnpf.mapper.OrderMapper; +import jnpf.entity.ExampleOrderEntity; +import jnpf.mapper.ExampleOrderMapper; import jnpf.model.order.OrderForm; import jnpf.model.order.OrderPagination; import jnpf.permission.entity.UserEntity; import jnpf.permission.service.UserService; +import jnpf.service.ExampleOrderService; import jnpf.service.OrderDetailService; -import jnpf.service.OrderService; import jnpf.util.*; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,15 +26,15 @@ import java.util.List; import java.util.stream.Collectors; /** - * 业务订单 ServiceImpl + * 示例业务订单 ServiceImpl * * @版本: V3.5 * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) * @作者: JNPF开发平台组 * @日期: 2024-02-04 */ -@Service -public class OrderServiceImpl extends ServiceImpl implements OrderService { +@Service("exampleOrderService") +public class ExampleOrderServiceImpl extends ServiceImpl implements ExampleOrderService { @Resource private UserService userService; @Resource @@ -47,60 +45,60 @@ public class OrderServiceImpl extends ServiceImpl impl @Resource private OrderDetailService orderDetailService; @Override - public List getList(OrderPagination orderPagination) { - LambdaQueryWrapper OrderWrapper=new LambdaQueryWrapper<>(); + public List getList(OrderPagination orderPagination) { + LambdaQueryWrapper OrderWrapper=new LambdaQueryWrapper<>(); if(ObjectUtil.isNotEmpty(orderPagination.getOrdDate())){ List inParkTimeList = JsonUtil.getJsonToList(orderPagination.getOrdDate(),String.class); Long fir = Long.valueOf(String.valueOf(inParkTimeList.get(0))); Long sec = Long.valueOf(String.valueOf(inParkTimeList.get(1))); - OrderWrapper.ge(OrderEntity::getOrdDate, new Date(fir)) - .le(OrderEntity::getOrdDate, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59")); + OrderWrapper.ge(ExampleOrderEntity::getOrdDate, new Date(fir)) + .le(ExampleOrderEntity::getOrdDate, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59")); } if(ObjectUtil.isNotEmpty(orderPagination.getSaleOrdNo())){ - OrderWrapper.like(OrderEntity::getSaleOrdNo,orderPagination.getSaleOrdNo()); + OrderWrapper.like(ExampleOrderEntity::getSaleOrdNo,orderPagination.getSaleOrdNo()); } if(ObjectUtil.isNotEmpty(orderPagination.getProjectName())){ - OrderWrapper.like(OrderEntity::getProjectName,orderPagination.getProjectName()); + OrderWrapper.like(ExampleOrderEntity::getProjectName,orderPagination.getProjectName()); } if(ObjectUtil.isNotEmpty(orderPagination.getIsUrgent())){ - OrderWrapper.eq(OrderEntity::getIsUrgent,orderPagination.getIsUrgent()); + OrderWrapper.eq(ExampleOrderEntity::getIsUrgent,orderPagination.getIsUrgent()); } if(ObjectUtil.isNotEmpty(orderPagination.getOrdStatus())){ - OrderWrapper.eq(OrderEntity::getOrdStatus,orderPagination.getOrdStatus()); + OrderWrapper.eq(ExampleOrderEntity::getOrdStatus,orderPagination.getOrdStatus()); } if(ObjectUtil.isNotEmpty(orderPagination.getSaleManName())){ List userList = userService.getUserByName(orderPagination.getSaleManName()); List ids = userList.stream().map(UserEntity::getId).collect(Collectors.toList()); if (ObjectUtil.isNotEmpty(ids)){ - OrderWrapper.in(OrderEntity::getSaleMan,ids); + OrderWrapper.in(ExampleOrderEntity::getSaleMan,ids); } } - OrderWrapper.isNull(OrderEntity::getDeleteMark); - OrderWrapper.orderByDesc(OrderEntity::getCreatorTime); + OrderWrapper.isNull(ExampleOrderEntity::getDeleteMark); + OrderWrapper.orderByDesc(ExampleOrderEntity::getCreatorTime); if("0".equals(orderPagination.getDataType())){ - Page page=new Page<>(orderPagination.getCurrentPage(), orderPagination.getPageSize()); - IPage userIPage=this.page(page, OrderWrapper); + Page page=new Page<>(orderPagination.getCurrentPage(), orderPagination.getPageSize()); + IPage userIPage=this.page(page, OrderWrapper); return orderPagination.setData(userIPage.getRecords(),userIPage.getTotal()); }else { return this.list(OrderWrapper); } } @Override - public OrderEntity getInfo(String id){ - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(OrderEntity::getId,id); + public ExampleOrderEntity getInfo(String id){ + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.lambda().eq(ExampleOrderEntity::getId,id); return this.getOne(queryWrapper); } @Override - public void create(OrderEntity entity){ + public void create(ExampleOrderEntity entity){ this.save(entity); } @Override - public boolean update(String id, OrderEntity entity){ + public boolean update(String id, ExampleOrderEntity entity){ return this.updateById(entity); } @Override - public void delete(OrderEntity entity){ + public void delete(ExampleOrderEntity entity){ if(entity!=null){ this.removeById(entity.getId()); } @@ -129,7 +127,7 @@ public class OrderServiceImpl extends ServiceImpl impl public void saveOrUpdate(OrderForm OrderForm, String id, boolean isSave) throws Exception{ UserInfo userInfo=userProvider.get(); UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId()); - OrderEntity entity = JsonUtil.getJsonToBean(OrderForm, OrderEntity.class); + ExampleOrderEntity entity = JsonUtil.getJsonToBean(OrderForm, ExampleOrderEntity.class); if(isSave){ String mainId = RandomUtil.uuId() ; diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderDetailServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderDetailServiceImpl.java index 23d1bef..a47e30c 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderDetailServiceImpl.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/OrderDetailServiceImpl.java @@ -2,12 +2,10 @@ package jnpf.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jnpf.base.service.SuperServiceImpl; import jnpf.entity.OrderDetailEntity; import jnpf.mapper.OrderDetailMapper; import jnpf.model.orderdetail.OrderDetailPagination; import jnpf.service.OrderDetailService; -import jnpf.util.StringUtil; import org.springframework.stereotype.Service; import java.util.List; @@ -29,11 +27,13 @@ public class OrderDetailServiceImpl extends ServiceImpl getListByOrderId(Integer saleOrdId) { + public List getListByOrderId(String saleOrdId) { QueryWrapper query = new QueryWrapper<>(); query.lambda().eq(OrderDetailEntity::getSaleOrdId, saleOrdId); - query.lambda().orderByAsc(OrderDetailEntity::getId); + query.lambda().orderByDesc(OrderDetailEntity::getCreatorTime); return this.list(query); } + + } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ShiftConfigServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ShiftConfigServiceImpl.java new file mode 100644 index 0000000..5d93e1b --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ShiftConfigServiceImpl.java @@ -0,0 +1,128 @@ +package jnpf.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jnpf.base.UserInfo; +import jnpf.entity.ShiftConfigEntity; +import jnpf.mapper.ShiftConfigMapper; +import jnpf.model.shift.ShiftConfigForm; +import jnpf.model.shift.ShiftConfigPagination; +import jnpf.permission.entity.UserEntity; +import jnpf.permission.service.UserService; +import jnpf.service.ShiftConfigService; +import jnpf.util.*; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * 班次配置 ServiceImpl + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Service("shiftConfigService") +public class ShiftConfigServiceImpl extends ServiceImpl implements ShiftConfigService { + @Resource + private UserService userService; + @Resource + private GeneraterSwapUtil generaterSwapUtil; + @Resource + private UserProvider userProvider; + + @Override + public List getList(ShiftConfigPagination shiftConfigPagination) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (ObjectUtil.isNotEmpty(shiftConfigPagination.getChgClassType())) { + wrapper.eq(ShiftConfigEntity::getChgClassType, shiftConfigPagination.getChgClassType()); + } + wrapper.eq(ShiftConfigEntity::getDeleteMark,"0"); + wrapper.orderByDesc(ShiftConfigEntity::getCreatorTime); + if ("0".equals(shiftConfigPagination.getDataType())) { + Page page = new Page<>(shiftConfigPagination.getCurrentPage(), shiftConfigPagination.getPageSize()); + IPage userIPage = this.page(page, wrapper); + return shiftConfigPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { + return this.list(wrapper); + } + } + + @Override + public ShiftConfigEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(ShiftConfigEntity::getId, id); + return this.getOne(queryWrapper); + } + + @Override + public void create(ShiftConfigEntity entity) { + this.save(entity); + } + + @Override + public boolean update(String id, ShiftConfigEntity entity) { + return this.updateById(entity); + } + + @Override + public void delete(ShiftConfigEntity entity) { + if (entity != null) { + this.removeById(entity.getId()); + } + } + + @Override + public String checkForm(ShiftConfigForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; + String countRecover = ""; + if (isUp) { + id = form.getId(); + } + String chgClassType = form.getChgClassType(); + if (StringUtil.isEmpty(chgClassType)) { + return "班次类型不能为空"; + } + + return countRecover; + } + + @Override + @Transactional + public void saveOrUpdate(ShiftConfigForm shiftConfigForm, String id, boolean isSave) throws Exception { + List entityList = shiftConfigForm.getShiftConfigEntityList(); + + if (ObjectUtil.isEmpty(entityList)) { + return; + } + + + // 批量删除旧数据 + LambdaUpdateWrapper deleteWrapper = new LambdaUpdateWrapper<>(); + deleteWrapper.eq(ShiftConfigEntity::getChgClassType,shiftConfigForm.getChgClassType()); + this.remove(deleteWrapper); + + // 批量设置属性并保存新数据 + entityList.forEach(entity -> { + entity.setChgClassType(shiftConfigForm.getChgClassType()); + }); + this.saveOrUpdateBatch(entityList); + } + + @Override + public void deleteByChgClassType(String chgClassType) { + LambdaUpdateWrapper deleteWrapper = new LambdaUpdateWrapper<>(); + deleteWrapper.eq(ShiftConfigEntity::getChgClassType,chgClassType); + this.remove(deleteWrapper); + } +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ShiftResultServiceImpl.java b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ShiftResultServiceImpl.java new file mode 100644 index 0000000..905e1a1 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-biz/src/main/java/jnpf/service/impl/ShiftResultServiceImpl.java @@ -0,0 +1,275 @@ +package jnpf.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jnpf.base.UserInfo; +import jnpf.entity.ShiftConfigEntity; +import jnpf.entity.ShiftResultEntity; +import jnpf.mapper.ShiftConfigMapper; +import jnpf.mapper.ShiftResultMapper; +import jnpf.model.shiftresult.ShiftResultForm; +import jnpf.model.shiftresult.ShiftResultPagination; +import jnpf.permission.entity.UserEntity; +import jnpf.permission.service.UserService; +import jnpf.service.ShiftResultService; +import jnpf.util.*; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 排班结果 ServiceImpl + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Service("shiftResultService") +public class ShiftResultServiceImpl extends ServiceImpl implements ShiftResultService { + @Resource + private UserService userService; + @Resource + private GeneraterSwapUtil generaterSwapUtil; + @Resource + private UserProvider userProvider; + @Resource + private ShiftConfigMapper shiftConfigMapper; + + @Override + public List getList(ShiftResultPagination shiftResultPagination) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (ObjectUtil.isNotEmpty(shiftResultPagination.getYears())) { + long firstDayOfMonthTimestamp = Long.parseLong(shiftResultPagination.getYears().toString()); + Date firstDayOfMonth = new Date(firstDayOfMonthTimestamp); + wrapper.eq(ShiftResultEntity::getMonth, firstDayOfMonth); + } + + wrapper.eq(ShiftResultEntity::getDeleteMark,"0"); + wrapper.orderByDesc(ShiftResultEntity::getCreatorTime); + if ("0".equals(shiftResultPagination.getDataType())) { + Page page = new Page<>(shiftResultPagination.getCurrentPage(), shiftResultPagination.getPageSize()); + IPage userIPage = this.page(page, wrapper); + return shiftResultPagination.setData(userIPage.getRecords(), userIPage.getTotal()); + } else { + return this.list(wrapper); + } + } + + @Override + public ShiftResultEntity getInfo(String id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(ShiftResultEntity::getId, id); + return this.getOne(queryWrapper); + } + + @Override + public void create(ShiftResultEntity entity) { + this.save(entity); + } + + @Override + public boolean update(String id, ShiftResultEntity entity) { + return this.updateById(entity); + } + + @Override + public void delete(ShiftResultEntity entity) { + if (entity != null) { + this.removeById(entity.getId()); + } + } + + @Override + public String checkForm(ShiftResultForm form, int i) { + boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0"); + String id = ""; + String countRecover = ""; + if (isUp) { + id = form.getId(); + } + if (ObjectUtil.isEmpty(form.getChgClassType())){ + return "倒班类型不能为空"; + } + if (ObjectUtil.isEmpty(form.getBgnDtime())){ + return "排班开始日期不能为空"; + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShiftConfigEntity::getChgClassType, form.getChgClassType()); + + if (shiftConfigMapper.selectCount(queryWrapper)==0){ + + return "该倒班类型"+("1".equals(form.getChgClassType())?"四班三倒":"三班两到")+"未配置班次信息"; + } + return countRecover; + } + + @Override + @Transactional + public void saveOrUpdate(ShiftResultForm shiftResultForm, String id, boolean isSave) throws Exception { + // 查询班次配置 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShiftConfigEntity::getChgClassType, shiftResultForm.getChgClassType()); + queryWrapper.orderByAsc(ShiftConfigEntity::getSeqNo); + List shiftConfigEntityList = shiftConfigMapper.selectList(queryWrapper); + + if (ObjectUtil.isEmpty(shiftConfigEntityList)) { + throw new Exception("班次配置不存在"); + } + + // 确定每天的班次数量 + int shiftsPerDay; + String chgClassType = shiftResultForm.getChgClassType(); + if ("1".equals(chgClassType)) { + shiftsPerDay = 3; // 四班三倒:每天3个班次 + } else if ("2".equals(chgClassType)) { + shiftsPerDay = 2; // 三班两倒:每天2个班次 + } else { + throw new Exception("不支持的班次类型"); + } + + // 删除全表数据 - 先检查是否有数据,避免不必要的删除操作 + Long count = this.count(); + if (count > 0) { + this.remove(new LambdaQueryWrapper<>()); + } + + // 预分配列表容量(365天 × 每天班次),避免扩容 + int estimatedSize = 365 * shiftsPerDay; + List shiftResultList = new ArrayList<>(estimatedSize); + + // 从开始日期开始循环一年 + Date startDate = shiftResultForm.getBgnDtime(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startDate); + + int totalDays = 365; + int configListSize = shiftConfigEntityList.size(); + + // 缓存月份的第一天,避免重复计算同月的天数 + Date currentMonth = null; + Date month = null; + + for (int day = 0; day < totalDays; day++) { + // 当前日期 + Date currentDate = calendar.getTime(); + + // 只在月份变化时计算月份的第一天 + currentMonth = currentDate; + if (month == null || !month.equals(getFirstDayOfMonth(currentDate))) { + month = getFirstDayOfMonth(currentDate); + } + + // 循环每天的班次 + for (int shiftIndex = 0; shiftIndex < shiftsPerDay; shiftIndex++) { + // 按周期循环使用班次配置 + // 例如:8天周期,四班三倒(24条配置),则: + // - 第0天:使用索引 0,1,2 + // - 第1天:使用索引 3,4,5 + // - ... + // - 第7天:使用索引 21,22,23 + // - 第8天:回到索引 0,1,2(循环) + int configIndex = (day * shiftsPerDay + shiftIndex) % configListSize; + ShiftConfigEntity config = shiftConfigEntityList.get(configIndex); + + // 创建排班结果实体 + ShiftResultEntity resultEntity = new ShiftResultEntity(); + resultEntity.setClassGroup(config.getClassGroup()); + resultEntity.setClassRate(config.getClassRate()); + + // 解析时间并组合成完整日期时间 + Date bgnDtime = combineDateAndTime(currentDate, config.getBgnDtime(), false); + Date endDtime = combineDateAndTime(currentDate, config.getEndDtime(), true); + + resultEntity.setBgnDtime(bgnDtime); + resultEntity.setEndDtime(endDtime); + resultEntity.setMonth(month); + + // 计算工作小时数 + int shiftHour = calculateHours(config.getBgnDtime(), config.getEndDtime()); + resultEntity.setShiftHour(shiftHour); + + shiftResultList.add(resultEntity); + } + + // 下一天 + calendar.add(Calendar.DAY_OF_MONTH, 1); + } + + // 批量保存,设置批次大小为500,平衡内存和性能 + if (ObjectUtil.isNotEmpty(shiftResultList)) { + this.saveBatch(shiftResultList, 500); + } + } + + /** + * 获取月份的第一天 + */ + private Date getFirstDayOfMonth(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + return calendar.getTime(); + } + + /** + * 组合日期和时间 + * @param date 日期 + * @param timeStr 时间字符串 + * @param isEndTime 是否为结束时间(只有结束时间是0点时才加一天) + */ + private Date combineDateAndTime(Date date, String timeStr, boolean isEndTime) { + String[] timeParts = timeStr.split(":"); + int hour = Integer.parseInt(timeParts[0]); + int minute = timeParts.length > 1 ? Integer.parseInt(timeParts[1]) : 0; + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.HOUR_OF_DAY, hour); + calendar.set(Calendar.MINUTE, minute); + calendar.set(Calendar.SECOND, 0); + + // 只有结束时间是 0 点时,日期才自动加一天 + if (isEndTime && hour == 0 && minute == 0) { + calendar.add(Calendar.DAY_OF_MONTH, 1); + } + + return calendar.getTime(); + } + + /** + * 计算小时数 + */ + private int calculateHours(String startTime, String endTime) { + String[] startParts = startTime.split(":"); + String[] endParts = endTime.split(":"); + + int startHour = Integer.parseInt(startParts[0]); + int startMinute = startParts.length > 1 ? Integer.parseInt(startParts[1]) : 0; + int endHour = Integer.parseInt(endParts[0]); + int endMinute = endParts.length > 1 ? Integer.parseInt(endParts[1]) : 0; + + int totalMinutes = (endHour * 60 + endMinute) - (startHour * 60 + startMinute); + + // 如果结果为负数,说明跨天,加上 24 小时 + if (totalMinutes < 0) { + totalMinutes += 24 * 60; + } + + return totalMinutes / 60; + } + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ExampleOrderController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ExampleOrderController.java index d8304dd..2ff36fd 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ExampleOrderController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ExampleOrderController.java @@ -1,25 +1,34 @@ package jnpf.controller; +import cn.hutool.core.util.ObjectUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jnpf.base.ActionResult; +import jnpf.base.entity.DictionaryDataEntity; +import jnpf.base.service.DictionaryDataService; import jnpf.base.vo.PageListVO; import jnpf.base.vo.PaginationVO; -import jnpf.entity.OrderEntity; +import jnpf.entity.ExampleOrderEntity; +import jnpf.entity.OrderDetailEntity; import jnpf.model.order.OrderForm; import jnpf.model.order.OrderPagination; -import jnpf.service.OrderService; +import jnpf.permission.entity.UserEntity; +import jnpf.permission.service.UserService; +import jnpf.service.ExampleOrderService; +import jnpf.service.OrderDetailService; import jnpf.util.JsonUtil; import jnpf.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.validation.Valid; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -33,9 +42,13 @@ import java.util.stream.Collectors; @RequestMapping("/api/example/exampleOrder") public class ExampleOrderController { - @Autowired - private OrderService orderService; + @Resource + private ExampleOrderService orderService; + @Resource + private UserService userService; + @Resource + private OrderDetailService orderDetailService; /** * 列表 * @param orderPagination 分页查询对象 @@ -43,12 +56,22 @@ public class ExampleOrderController { */ @Operation(summary = "获取订单列表") @PostMapping("/getList") - public ActionResult getList(OrderPagination orderPagination) { - List list= orderService.getList(orderPagination); - List> realList = list.stream() - .map(JsonUtil::entityToMap) - .collect(Collectors.toList()); + public ActionResult getList(@RequestBody OrderPagination orderPagination) { + List list= orderService.getList(orderPagination); + List> realList =new ArrayList<>(); + for (ExampleOrderEntity entity : list) { + Map ExampleOrderMap=JsonUtil.entityToMap(entity); + ExampleOrderMap.put("id", ExampleOrderMap.get("id")); + //子表数据 + if (ObjectUtil.isNotEmpty(entity.getSaleMan())){ + UserEntity byId = userService.getById(entity.getSaleMan()); + if (ObjectUtil.isNotEmpty(byId)){ + ExampleOrderMap.put("saleManName", byId.getRealName()); + } + } + realList.add(ExampleOrderMap); + } //返回对象 PageListVO vo = new PageListVO(); vo.setList(realList); @@ -74,7 +97,7 @@ public class ExampleOrderController { return ActionResult.fail(b ); } } - OrderEntity entity= orderService.getInfo(id); + ExampleOrderEntity entity= orderService.getInfo(id); if(entity!=null){ try{ orderService.saveOrUpdate(orderForm,id,false); @@ -95,7 +118,7 @@ public class ExampleOrderController { @DeleteMapping("/{id}") @Transactional public ActionResult delete(@PathVariable("id") String id){ - OrderEntity entity = orderService.getInfo(id); + ExampleOrderEntity entity = orderService.getInfo(id); if (entity != null) { //假删除 entity.setDeleteMark(1); @@ -104,5 +127,48 @@ public class ExampleOrderController { return ActionResult.success("删除成功"); } + /** + * 表单信息(详情页) + * 详情页面使用-转换数据 + * @param id + * @return + */ + @Operation(summary = "表单信息(详情页)") + @GetMapping("/detail/{id}") + public ActionResult detailInfo(@PathVariable("id") String id){ + ExampleOrderEntity entity= orderService.getInfo(id); + if(entity==null){ + return ActionResult.fail("表单数据不存在!"); + } + Map ExampleOrderMap=JsonUtil.entityToMap(entity); + ExampleOrderMap.put("id", ExampleOrderMap.get("id")); + List orderDetailList = orderDetailService.getListByOrderId(entity.getId()); + ExampleOrderMap.put("orderDetailList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(orderDetailList))); + //副表数据 + //子表数据 + return ActionResult.success(ExampleOrderMap); + } + /** + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * @param id + * @return + */ + @Operation(summary = "信息") + @GetMapping("/{id}") + public ActionResult info(@PathVariable("id") String id){ + ExampleOrderEntity entity= orderService.getInfo(id); + if(entity==null){ + return ActionResult.fail("表单数据不存在!"); + } + Map ExampleOrderMap=JsonUtil.entityToMap(entity); + ExampleOrderMap.put("id", ExampleOrderMap.get("id")); + List orderDetailList = orderDetailService.getListByOrderId(entity.getId()); + ExampleOrderMap.put("orderDetailList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(orderDetailList))); + + //副表数据 + //子表数据 + return ActionResult.success(ExampleOrderMap); + } } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/OrderDetailController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/OrderDetailController.java index 97baf87..201e2ab 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/OrderDetailController.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/OrderDetailController.java @@ -60,7 +60,7 @@ public class OrderDetailController { @Operation(summary = "根据订单ID获取明细列表") @Parameter(name = "saleOrdId", description = "销售订单ID", required = true) @GetMapping("/byOrder/{saleOrdId}") - public ActionResult> getListByOrderId(@PathVariable Integer saleOrdId) { + public ActionResult> getListByOrderId(@PathVariable String saleOrdId) { List entityList = orderDetailService.getListByOrderId(saleOrdId); List voList = JsonUtil.getJsonToList(entityList, OrderDetailVO.class); return ActionResult.success(new ListVO<>(voList)); diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ShiftConfigController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ShiftConfigController.java new file mode 100644 index 0000000..6c64670 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ShiftConfigController.java @@ -0,0 +1,166 @@ +package jnpf.controller; + +import cn.hutool.core.util.ObjectUtil; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jnpf.base.ActionResult; +import jnpf.base.vo.PageListVO; +import jnpf.base.vo.PaginationVO; +import jnpf.entity.ShiftConfigEntity; +import jnpf.model.machine.MachineForm; +import jnpf.model.shift.ShiftConfigForm; +import jnpf.model.shift.ShiftConfigPagination; +import jnpf.service.ShiftConfigService; +import jnpf.util.JsonUtil; +import jnpf.util.StringUtil; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 班次配置 控制类 + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Tag(name = "班次配置", description = "shiftConfig") +@RestController +@RequestMapping("/api/example/shiftConfig") +public class ShiftConfigController { + + @Resource + private ShiftConfigService shiftConfigService; + + /** + * 列表 + * @param shiftConfigPagination 分页查询对象 + * @return 列表结果集 + */ + @Operation(summary = "获取班次配置列表") + @PostMapping("/getList") + public ActionResult getList(@RequestBody ShiftConfigPagination shiftConfigPagination) { + List list = shiftConfigService.getList(shiftConfigPagination); + List> realList = new ArrayList<>(); + for (ShiftConfigEntity entity : list) { + Map shiftConfigMap = JsonUtil.entityToMap(entity); + shiftConfigMap.put("id", shiftConfigMap.get("id")); + realList.add(shiftConfigMap); + } + PageListVO vo = new PageListVO(); + vo.setList(realList); + PaginationVO page = JsonUtil.getJsonToBean(shiftConfigPagination, PaginationVO.class); + vo.setPagination(page); + return ActionResult.success(vo); + } + + + + /** + * 创建 + * + * @param shiftConfigForm + * @return + */ + @PostMapping() + @Operation(summary = "创建") + public ActionResult create( @RequestBody @Valid ShiftConfigForm shiftConfigForm) { + String b = shiftConfigService.checkForm(shiftConfigForm,0); + if (StringUtil.isNotEmpty(b)){ + return ActionResult.fail(b ); + } + try{ + shiftConfigService.saveOrUpdate(shiftConfigForm,null ,true); + }catch(Exception e){ + e.printStackTrace(); + return ActionResult.fail("新增数据失败"); + } + return ActionResult.success("创建成功"); + } + + + /** + * 编辑 + * @param id + * @param shiftConfigForm + * @return + */ + @PutMapping("/{id}") + @Operation(summary = "更新") + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ShiftConfigForm shiftConfigForm, + @RequestParam(value = "isImport", required = false) boolean isImport) { + shiftConfigForm.setId(id); + if (!isImport) { + String b = shiftConfigService.checkForm(shiftConfigForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); + } + } + ShiftConfigEntity entity = shiftConfigService.getInfo(id); + if (entity != null) { + try { + shiftConfigService.saveOrUpdate(shiftConfigForm, id, false); + } catch (Exception e) { + return ActionResult.fail("修改数据失败"); + } + return ActionResult.success("更新成功"); + } else { + return ActionResult.fail("更新失败,数据不存在"); + } + } + + /** + * 删除 + * @param chgClassType + * @return + */ + @Operation(summary = "删除") + @DeleteMapping("/{chgClassType}") + public ActionResult delete(@PathVariable("chgClassType") String chgClassType) { + if (ObjectUtil.isNotEmpty(chgClassType)) { + shiftConfigService.deleteByChgClassType(chgClassType); + } + return ActionResult.success("删除成功"); + } + + /** + * 表单信息(详情页) + * 详情页面使用-转换数据 + * @param id + * @return + */ + @Operation(summary = "表单信息(详情页)") + @GetMapping("/detail/{id}") + public ActionResult detailInfo(@PathVariable("id") String id) { + ShiftConfigEntity entity = shiftConfigService.getInfo(id); + if (entity == null) { + return ActionResult.fail("表单数据不存在!"); + } + Map shiftConfigMap = JsonUtil.entityToMap(entity); + shiftConfigMap.put("id", shiftConfigMap.get("id")); + return ActionResult.success(shiftConfigMap); + } + + /** + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * @param id + * @return + */ + @Operation(summary = "信息") + @GetMapping("/{id}") + public ActionResult info(@PathVariable("id") String id) { + ShiftConfigEntity entity = shiftConfigService.getInfo(id); + if (entity == null) { + return ActionResult.fail("表单数据不存在!"); + } + Map shiftConfigMap = JsonUtil.entityToMap(entity); + shiftConfigMap.put("id", shiftConfigMap.get("id")); + return ActionResult.success(shiftConfigMap); + } +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ShiftResultController.java b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ShiftResultController.java new file mode 100644 index 0000000..ff715ae --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-controller/src/main/java/jnpf/controller/ShiftResultController.java @@ -0,0 +1,164 @@ +package jnpf.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jnpf.base.ActionResult; +import jnpf.base.vo.PageListVO; +import jnpf.base.vo.PaginationVO; +import jnpf.entity.ShiftResultEntity; +import jnpf.model.shift.ShiftConfigForm; +import jnpf.model.shiftresult.ShiftResultForm; +import jnpf.model.shiftresult.ShiftResultPagination; +import jnpf.service.ShiftResultService; +import jnpf.util.JsonUtil; +import jnpf.util.StringUtil; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 排班结果 控制类 + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Tag(name = "排班结果", description = "shiftResult") +@RestController +@RequestMapping("/api/example/shiftResult") +public class ShiftResultController { + + @Resource + private ShiftResultService shiftResultService; + + /** + * 列表 + * @param shiftResultPagination 分页查询对象 + * @return 列表结果集 + */ + @Operation(summary = "获取排班结果列表") + @PostMapping("/getList") + public ActionResult getList(@RequestBody ShiftResultPagination shiftResultPagination) { + List list = shiftResultService.getList(shiftResultPagination); + List> realList = new ArrayList<>(); + for (ShiftResultEntity entity : list) { + Map shiftResultMap = JsonUtil.entityToMap(entity); + shiftResultMap.put("id", shiftResultMap.get("id")); + realList.add(shiftResultMap); + } + PageListVO vo = new PageListVO(); + vo.setList(realList); + PaginationVO page = JsonUtil.getJsonToBean(shiftResultPagination, PaginationVO.class); + vo.setPagination(page); + return ActionResult.success(vo); + } + + /** + * 创建 + * + * @param shiftResultForm + * @return + */ + @PostMapping() + @Operation(summary = "创建") + public ActionResult create( @RequestBody @Valid ShiftResultForm shiftResultForm) { + String b = shiftResultService.checkForm(shiftResultForm,0); + if (StringUtil.isNotEmpty(b)){ + return ActionResult.fail(b ); + } + try{ + shiftResultService.saveOrUpdate(shiftResultForm,null ,true); + }catch(Exception e){ + e.printStackTrace(); + return ActionResult.fail("新增数据失败"); + } + return ActionResult.success("创建成功"); + } + + + /** + * 编辑 + * @param id + * @param shiftResultForm + * @return + */ + @PutMapping("/{id}") + @Operation(summary = "更新") + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ShiftResultForm shiftResultForm, + @RequestParam(value = "isImport", required = false) boolean isImport) { + shiftResultForm.setId(id); + if (!isImport) { + String b = shiftResultService.checkForm(shiftResultForm, 1); + if (StringUtil.isNotEmpty(b)) { + return ActionResult.fail(b); + } + } + ShiftResultEntity entity = shiftResultService.getInfo(id); + if (entity != null) { + try { + shiftResultService.saveOrUpdate(shiftResultForm, id, false); + } catch (Exception e) { + return ActionResult.fail("修改数据失败"); + } + return ActionResult.success("更新成功"); + } else { + return ActionResult.fail("更新失败,数据不存在"); + } + } + + /** + * 删除 + * @param id + * @return + */ + @Operation(summary = "删除") + @DeleteMapping("/{id}") + public ActionResult delete(@PathVariable("id") String id) { + ShiftResultEntity entity = shiftResultService.getInfo(id); + if (entity != null) { + shiftResultService.delete(entity); + } + return ActionResult.success("删除成功"); + } + + /** + * 表单信息(详情页) + * 详情页面使用-转换数据 + * @param id + * @return + */ + @Operation(summary = "表单信息(详情页)") + @GetMapping("/detail/{id}") + public ActionResult detailInfo(@PathVariable("id") String id) { + ShiftResultEntity entity = shiftResultService.getInfo(id); + if (entity == null) { + return ActionResult.fail("表单数据不存在!"); + } + Map shiftResultMap = JsonUtil.entityToMap(entity); + shiftResultMap.put("id", shiftResultMap.get("id")); + return ActionResult.success(shiftResultMap); + } + + /** + * 获取详情(编辑页) + * 编辑页面使用-不转换数据 + * @param id + * @return + */ + @Operation(summary = "信息") + @GetMapping("/{id}") + public ActionResult info(@PathVariable("id") String id) { + ShiftResultEntity entity = shiftResultService.getInfo(id); + if (entity == null) { + return ActionResult.fail("表单数据不存在!"); + } + Map shiftResultMap = JsonUtil.entityToMap(entity); + shiftResultMap.put("id", shiftResultMap.get("id")); + return ActionResult.success(shiftResultMap); + } +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/OrderEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ExampleOrderEntity.java similarity index 98% rename from jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/OrderEntity.java rename to jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ExampleOrderEntity.java index 72bd2e1..ace0934 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/OrderEntity.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ExampleOrderEntity.java @@ -7,12 +7,12 @@ import java.math.BigDecimal; import java.util.Date; /** - * 业务订单表 + * 示例业务订单表 * */ @Data @TableName("tso_order") -public class OrderEntity { +public class ExampleOrderEntity { @TableId(value = "id", type = IdType.AUTO) private String id; @TableField(value = "f_creator_user_id", fill = FieldFill.INSERT) diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ShiftConfigEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ShiftConfigEntity.java new file mode 100644 index 0000000..b52fe02 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ShiftConfigEntity.java @@ -0,0 +1,56 @@ +package jnpf.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 班次配置表 + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Data +@TableName("tba_shift_config") +public class ShiftConfigEntity { + @TableId(value = "id", type = IdType.AUTO) + private String id; + @TableField(value = "f_creator_user_id", fill = FieldFill.INSERT) + private String creatorUserId; + @TableField(value = "f_creator_time", fill = FieldFill.INSERT) + private Date creatorTime; + @TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE) + private String lastModifyUserId; + @TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE) + private Date lastModifyTime; + @TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE) + private String deleteUserId; + @TableField(value = "f_delete_time", fill = FieldFill.UPDATE) + private Date deleteTime; + @TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED) + private Integer deleteMark; + @TableField(value = "f_flow_id") + private String flowId; + @TableField(value = "f_flow_task_id") + private String flowTaskId; + @TableField(value = "class_group", updateStrategy = FieldStrategy.IGNORED) + private String classGroup; + @TableField("class_rate") + private String classRate; + @TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED) + private Integer enabledStatus; + @TableField("remark") + private String remark; + @TableField("seq_no") + private Integer seqNo; + @TableField("bgn_dtime") + private String bgnDtime; + @TableField("end_dtime") + private String endDtime; + @TableField("chg_class_type") + private String chgClassType; + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ShiftResultEntity.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ShiftResultEntity.java new file mode 100644 index 0000000..e6842ad --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/entity/ShiftResultEntity.java @@ -0,0 +1,56 @@ +package jnpf.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + +import java.util.Date; + +/** + * 排班结果表 + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Data +@TableName("tba_shift_result") +public class ShiftResultEntity { + @TableId(value = "id", type = IdType.AUTO) + private String id; + @TableField(value = "f_creator_user_id", fill = FieldFill.INSERT) + private String creatorUserId; + @TableField(value = "f_creator_time", fill = FieldFill.INSERT) + private Date creatorTime; + @TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE) + private String lastModifyUserId; + @TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE) + private Date lastModifyTime; + @TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE) + private String deleteUserId; + @TableField(value = "f_delete_time", fill = FieldFill.UPDATE) + private Date deleteTime; + @TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED) + private Integer deleteMark; + @TableField(value = "f_flow_id") + private String flowId; + @TableField(value = "f_flow_task_id") + private String flowTaskId; + @TableField(value = "bgn_dtime", updateStrategy = FieldStrategy.IGNORED) + private Date bgnDtime; + @TableField(value = "end_dtime", updateStrategy = FieldStrategy.IGNORED) + private Date endDtime; + @TableField(value = "class_group", updateStrategy = FieldStrategy.IGNORED) + private String classGroup; + @TableField("class_rate") + private String classRate; + @TableField(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED) + private Integer enabledStatus; + @TableField("remark") + private String remark; + @TableField(value = "shift_hour", updateStrategy = FieldStrategy.IGNORED) + private Integer shiftHour; + @TableField(value = "month", updateStrategy = FieldStrategy.IGNORED) + private Date month; + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/order/OrderForm.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/order/OrderForm.java index ec20221..912f4d7 100644 --- a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/order/OrderForm.java +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/order/OrderForm.java @@ -122,7 +122,7 @@ public class OrderForm { @Schema(description = "流程任务ID") private String flowTaskId; - @JsonProperty("OrderDetailList") - private List OrderDetailList; + @JsonProperty("orderDetailList") + private List orderDetailList; } diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shift/ShiftConfigForm.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shift/ShiftConfigForm.java new file mode 100644 index 0000000..0295de5 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shift/ShiftConfigForm.java @@ -0,0 +1,74 @@ +package jnpf.model.shift; + +import io.swagger.v3.oas.annotations.media.Schema; +import jnpf.entity.ShiftConfigEntity; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 班次配置 Form + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Data +public class ShiftConfigForm { + + @Schema(description = "主键") + private String id; + + @Schema(description = "班次代码") + private String classGroup; + + @Schema(description = "班次名称") + private String classRate; + + @Schema(description = "开始时间") + private String bgnDtime; + + @Schema(description = "结束时间") + private String endDtime; + + @Schema(description = "班次类型") + private String chgClassType; + + @Schema(description = "班次类型") + private String remark; + + @Schema(description = "创建时间") + private Date creatorTime; + + @Schema(description = "创建用户ID") + private String creatorUserId; + @Schema(description = "序列号") + private Integer seqNo; + @Schema(description = "最后修改时间") + private Date lastModifyTime; + + @Schema(description = "最后修改用户ID") + private String lastModifyUserId; + + @Schema(description = "删除时间") + private Date deleteTime; + + @Schema(description = "删除用户ID") + private String deleteUserId; + + @Schema(description = "删除标记") + private Integer deleteMark; + + @Schema(description = "流程ID") + private String flowId; + + @Schema(description = "流程任务ID") + private String flowTaskId; + + @Schema(description = "明细集合") + private List shiftConfigEntityList; + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shift/ShiftConfigPagination.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shift/ShiftConfigPagination.java new file mode 100644 index 0000000..b16ffb1 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shift/ShiftConfigPagination.java @@ -0,0 +1,38 @@ +package jnpf.model.shift; + +import jnpf.base.Pagination; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 班次配置分页查询 + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Data +public class ShiftConfigPagination extends Pagination { + /** 查询key */ + private String[] selectKey; + /** json */ + private String json; + /** 数据类型 0-当前页,1-全部数据 */ + private String dataType; + /** 高级查询 */ + private String superQueryJson; + /** 功能id */ + private String moduleId; + /** 菜单id */ + private String menuId; + + @Schema(description = "班次代码") + private String shiftCode; + + @Schema(description = "班次名称") + private String shiftName; + + @Schema(description = "班次类型") + private String chgClassType; +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shiftresult/ShiftResultForm.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shiftresult/ShiftResultForm.java new file mode 100644 index 0000000..37c6bb7 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shiftresult/ShiftResultForm.java @@ -0,0 +1,31 @@ +package jnpf.model.shiftresult; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 排班结果 Form + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Data +public class ShiftResultForm { + + @Schema(description = "主键") + private String id; + + @Schema(description = "排班日期") + private Date bgnDtime; + + @Schema(description = "班次代码") + private String chgClassType; + + + +} diff --git a/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shiftresult/ShiftResultPagination.java b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shiftresult/ShiftResultPagination.java new file mode 100644 index 0000000..3f06918 --- /dev/null +++ b/jnpf-java-boot/jnpf-example/jnpf-example-entity/src/main/java/jnpf/model/shiftresult/ShiftResultPagination.java @@ -0,0 +1,50 @@ +package jnpf.model.shiftresult; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jnpf.base.Pagination; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * 排班结果分页查询 + * + * @版本: V3.5 + * @版权: 引迈信息技术有限公司(https://www.jnpfsoft.com) + * @作者: JNPF开发平台组 + * @日期: 2025-04-09 + */ +@Data +public class ShiftResultPagination extends Pagination { + /** 查询key */ + private String[] selectKey; + /** json */ + private String json; + /** 数据类型 0-当前页,1-全部数据 */ + private String dataType; + /** 高级查询 */ + private String superQueryJson; + /** 功能id */ + private String moduleId; + /** 菜单id */ + private String menuId; + + @Schema(description = "排班日期") + private Object shiftDate; + + @Schema(description = "班次代码") + private String shiftCode; + + @Schema(description = "班次名称") + private String shiftName; + + @Schema(description = "用户姓名") + private String userName; + + @Schema(description = "状态") + private String status; + /** 年月 */ + @JsonProperty("years") + private Object years; +} diff --git a/jnpf-java-boot/jnpf-web/src/utils/jnpf.js b/jnpf-java-boot/jnpf-web/src/utils/jnpf.js index 2e56f7f..9999d0b 100644 --- a/jnpf-java-boot/jnpf-web/src/utils/jnpf.js +++ b/jnpf-java-boot/jnpf-web/src/utils/jnpf.js @@ -279,6 +279,16 @@ const jnpf = { if (!cellValue) return '' return dayjs(cellValue).format(format) }, + tableDateFormat3(row, column, cellValue) { + let format = 'HH:mm' + if (!cellValue) return '' + return dayjs(cellValue).format(format) + }, + tableDateFormat4(row, column, cellValue) { + let format = 'YYYY-MM' + if (!cellValue) return '' + return dayjs(cellValue).format(format) + }, storageSet(obj) { for (let i in obj) { cacheItem(i, obj[i]) diff --git a/jnpf-java-boot/jnpf-web/src/views/example/order/form.vue b/jnpf-java-boot/jnpf-web/src/views/example/order/form.vue index c634b48..25c1029 100644 --- a/jnpf-java-boot/jnpf-web/src/views/example/order/form.vue +++ b/jnpf-java-boot/jnpf-web/src/views/example/order/form.vue @@ -2,175 +2,321 @@
- +
- 保 - 存 + 保 + 存 + 取 消
- - + + + + +
+ + 基础信息 +
+
- +
- - 添加 - 删除 - - - - - - - - 确定 - 取消 - -
@@ -181,30 +327,21 @@ import request from '@/utils/request' import { mapGetters } from 'vuex' import { getDataInterfaceRes } from '@/api/systemData/dataInterface' import { getDictionaryDataSelector } from '@/api/systemData/dictionary' -import { getDefaultCurrentValueUserId } from '@/api/permission/user' -import { getDefaultCurrentValueDepartmentId } from '@/api/permission/organize' -import { getDateDay, getLaterData, getBeforeData, getBeforeTime, getLaterTime } from '@/components/Generator/utils/index.js' -import { thousandsFormat } from '@/components/Generator/utils/index' -import SelectDialog from '@/components/SelectDialog' -import { options } from 'runjs' + +import { + getDateDay, + getLaterData, + getBeforeData, + getBeforeTime, + getLaterTime +} from '@/components/Generator/utils/index.js' +import Materialslect from "@/views/example/order/materialslect.vue"; export default { - components: { SelectDialog }, + components: {Materialslect}, props: [], data() { return { - calRow: {}, - productItemList: [], - itemCenterDialog: false, - itemData: [ - { type: '产品', qxjsxd: '安全0%', qxl: '0%', qxms: '', prop: 'proSafe' }, - { type: '产品', qxjsxd: '功能1%', qxl: '0%', qxms: '', prop: 'proFun' }, - { type: '产品', qxjsxd: '外观5%', qxl: '0%', qxms: '', prop: 'proApp' }, - { type: '包装', qxjsxd: '安全0%', qxl: '0%', qxms: '', prop: 'packSafe' }, - { type: '包装', qxjsxd: '功能1%', qxl: '0%', qxms: '', prop: 'packFun' }, - { type: '包装', qxjsxd: '外观5%', qxl: '0%', qxms: '', prop: 'packApp' }, - ], - itemData1:[], dataFormSubmitType: 0, continueBtnLoading: false, index: 0, @@ -224,199 +361,202 @@ export default { addTableConf: {}, //可选范围默认值 ableAll: {}, - tableRows: { - qa_material_check_data_twList: { - avgValue: undefined, - avgValueOptions: [], - remark: '', - remarkOptions: [], - checkResultOptions: [], - enabledmark: undefined, - }, - qa_material_check_data_thList: { - actValue: undefined, - actValueOptions: [], - enabledmark: undefined, - }, - }, + tableRows: {}, Vmodel: '', currVmodel: '', dataForm: { - member: '', - materialCode: '', - checkSeq: undefined, - productNumber: undefined, - productLot: undefined, - checkUserName: undefined, - checkDate: undefined, - sampleQty: undefined, - checkResult: 1, - remark: undefined, - qa_material_check_data_twList: [], - qa_material_check_data_thList: [], - itemList: [], + contractNo: undefined, + saleDeptId: undefined, + custId: undefined, + reqDeliveryDate: undefined, + ordType: undefined, + paymentTerms: undefined, + totalAmount: undefined, + isChange: undefined, + packReq: undefined, + qualityReq: undefined, + taxRate: undefined, + saleMan: undefined, + attFile:undefined, + version: 0, + orderDetailList:[] }, tableRequiredData: {}, dataRule: { - materialCode: [ - { - required: true, - message: '请选择', - trigger: 'change', - }, + ordDate: [ + { required: true, message: '请选择下单日期', trigger: 'change' } ], + ordStatus: [ + { required: true, message: '请选择订单状态', trigger: 'change' } + ], + saleDeptId: [ + { required: true, message: '请选择业务部门', trigger: 'change' } + ], + saleMan: [ + { required: true, message: '请选择业务人员', trigger: 'change' } + ], + custId: [ + { required: true, message: '请选择客户名称', trigger: 'change' } + ], + isUrgent: [ + { required: true, message: '请选择是否急单', trigger: 'change' } + ], + projectName: [ + { required: true, message: '请输入项目名称', trigger: 'blur' } + ], + reqDeliveryDate: [ + { required: true, message: '请选择交货日期', trigger: 'change' } + ], + ordType: [ + { required: true, message: '请选择订单类型', trigger: 'change' } + ], + isChange: [ + { required: true, message: '请选择是否变更', trigger: 'change' } + ] }, - checkSeqcolumnOptions: [ - // { label: '母件编码', value: 'piece_id' }, - // { label: '母件名称', value: 'piece_name' }, - // { label: '规格型号', value: 'models' }, - // { label: '计量单位', value: 'unit' }, - // { label: '版本', value: 'version_code' }, - { label: '产品名称', value: 'materialName' }, - { label: '产品编码', value: 'materialCode' }, - { label: '规格', value: 'model' }, + ordStatusOptions: [ ], - checkResultOptions: [ - { fullName: '合格', id: 1 }, - { fullName: '不合格', id: 0 }, + ordStatusProps: { label: "fullName", value: "enCode" }, + saleDeptIdOptions: [], + saleDeptIdProps: { 'label': 'name', 'value': 'id' }, + userIdOptions: [], + userIdProps: { 'label': 'name', 'value': 'id' }, + custIdOptions: [], + custIdProps: { 'label': 'name', 'value': 'id' }, + materialIdOptions: [], + materialIdProps: { 'label': 'mat_name', 'labels':"mat_code", 'value': 'id' }, + ordTypeOptions: [ + { fullName: "常规", id: "1" }, + { fullName: "定制", id: "2" }, ], - checkResultProps: { label: 'fullName', value: 'id' }, - qa_material_check_data_twcheckResultOptions: [ - { fullName: '合格', id: 1 }, - { fullName: '不合格', id: 0 }, + ordTypeProps: { label: "fullName", value: "id" }, + paymentTermsOptions: [ + { fullName: "款到发货", id: "1" }, + { fullName: "月结", id: "2" }, + { fullName: "承兑", id: "3" }, ], - qa_material_check_data_twcheckResultProps: { label: 'fullName', value: 'id' }, + paymentTermsProps: { label: "fullName", value: "id" }, + isUrgentOptions: [ + { fullName: "是", id: "0" }, + { fullName: "否", id: "1" }, + ], + isUrgentProps: { label: "fullName", value: "id" }, + specOptions: [ + { fullName: "9cm", id: "9cm" } + ], + specProps: { label: "fullName", value: "id" }, + unitOptions: [ + { fullName: "kg", id: "kg" } + ], + unitProps: { label: "fullName", value: "id" }, + materialUseOptions: [ + { fullName: "脱硫", id: "1" }, + { fullName: "脱销", id: "2" }, + { fullName: "脱硫脱硝一体", id: "3" }, + { fullName: "净水", id: "4" } + ], + materialUseProps: { label: "fullName", value: "id" }, + childIndex: -1, isEdit: false, interfaceRes: { - supplierId: [], - materialCode: [], - productLot: [], - recieveDate: [], - checkDate: [], - recieveKg: [], - recievePiece: [], - sampleQty: [], - checkResult: [], - processResult: [], - problemReason: [], - remark: [], - creatorUserId: [], - creatorTime: [], - lastModifyUserId: [], - lastModifyTime: [], - qa_material_check_data_twavgValue: [], - qa_material_check_data_twremark: [], - qa_material_check_data_twcheckResult: [], - qa_material_check_data_thactValue: [], - }, - //掩码配置 - maskConfig: { - productLot: {}, - qa_material_check_data_twremark: {}, - }, - //定位属性 - locationScope: {}, - selectedqa_material_check_data_twRowKeys: [], - selectedqa_material_check_data_thRowKeys: [], - options: [], + code: [], + name: [], + spec: [], + photo: [], + productTypeId: [], + brandId: [], + inventoryUnitId: [], + batchNumber: [], + businessNo: [], + relevanceBusinessNo: [], + changeNumber: [], + warehouseId: [], + inventoryNumber: [], + purchasePrice: [], + retailPrice: [], + businessType: [] + } } }, computed: { - ...mapGetters(['userInfo']), - - getqa_material_check_data_twHasBatchBtn() { - let flist = [] - return flist.some(o => ['batchRemove'].includes(o.value) && o.show) - }, - getqa_material_check_data_thHasBatchBtn() { - let flist = [] - return flist.some(o => ['batchRemove'].includes(o.value) && o.show) - }, - }, - watch: { - + ...mapGetters(['userInfo']) }, + watch: {}, created() { this.dataAll() this.initDefaultData() this.dataValueAll = JSON.parse(JSON.stringify(this.dataForm)) }, mounted() { - getDictionaryDataSelector("743848488864868101").then(res => { - this.options = res.data.list.map(c => { - return { - label: c.fullName, - value: c.enCode - } - }); - if (!this.dataForm.id) { - const value = this.options.find(c => c.label == "未提交").value; - this.$set(this.dataForm, 'checkStatus', value); - } - }) }, methods: { - startCal(val) { - this.itemCenterDialog = true - this.calRow = val - if (!this.dataForm.id) { - this.productItemList = [] - for (let i = 0; i < this.dataForm.sampleQty; i++) { - this.productItemList.push({ actValue: 0 }) - } - } else { - if (val.hasOwnProperty('itemList')) { - this.productItemList = val.itemList + getOrdStatusOptions() { + getDictionaryDataSelector("811520443046428805").then(res => { + this.ordStatusOptions = res.data.list; + }); + }, + handleNumberInput(fieldName) { + let value = this.dataForm[fieldName]; + if (value === undefined || value === null || value === '') { + return; + } + // 移除非数字字符(保留小数点) + value = value.toString().replace(/[^\d.]/g, ''); + // 只允许一个小数点 + const dotIndex = value.indexOf('.'); + if (dotIndex > -1) { + const dotLastIndex = value.lastIndexOf('.'); + if (dotIndex !== dotLastIndex) { + value = value.substring(0, dotLastIndex) + value.substring(dotLastIndex + 1); } } - }, - calValue() { - //todo 校验 - if (this.productItemList.length == 0) return - let total = 0 - this.productItemList.forEach(num => { - total += num.actValue - }) - let val = Math.floor((total / this.productItemList.length) * 100) / 100 - this.calRow.avgValue = val - this.calRow.itemList = this.productItemList - // this.calRow.remark = '-' - console.log(this.calRow.lowerLimit) - console.log(this.calRow.upperLimit) - if (this.calRow.lowerLimit != null && this.calRow.upperLimit == null) { - if (val >= this.calRow.lowerLimit) { - this.calRow.checkResult = 1 - } else { - this.calRow.checkResult = 0 - } - } else if (this.calRow.lowerLimit == null && this.calRow.upperLimit != null) { - if (val <= this.calRow.upperLimit) { - this.calRow.checkResult = 1 - } else { - this.calRow.checkResult = 0 - } - } else { - if (!isNaN(parseFloat(this.calRow.lowerLimit)) && isFinite(this.calRow.upperLimit)) { - let lowerLimit = Number(this.calRow.lowerLimit) - let upperLimit = Number(this.calRow.upperLimit) - if (val >= lowerLimit && val <= upperLimit) { - this.calRow.checkResult = 1 - } else { - this.calRow.checkResult = 0 - } + // 限制小数点后两位 + if (value.includes('.')) { + const parts = value.split('.'); + if (parts[1] && parts[1].length > 2) { + value = parts[0] + '.' + parts[1].substring(0, 2); } } - this.itemCenterDialog = false + this.dataForm[fieldName] = value; }, - addDomain() { - this.productItemList.push({ actValue: 0 }) + handleTableNumberInput(scope, fieldName) { + let value = scope.row[fieldName]; + if (value === undefined || value === null || value === '') { + return; + } + // 移除非数字字符 + value = value.toString().replace(/[^\d]/g, ''); + // 不能以0开头(除非是单个0) + if (value.length > 1 && value.startsWith('0')) { + value = value.replace(/^0+/, ''); + if (value === '') value = '0'; + } + scope.row[fieldName] = value; }, - removeDomain() { - this.productItemList.pop() + delOrderDetailListList(index) { + this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { + type: 'warning' + }).then(() => { + this.dataForm.orderDetailList.splice(index, 1); + }).catch(() => { + }); + }, + addOrderDetailListList() { + const newItem = { + materialId: undefined, + spec: undefined, + unit: undefined, + ordQty: undefined, + priceTax: undefined, + materialUse: undefined, + deliveriedQty: undefined, + remark: undefined + }; + this.dataForm.orderDetailList.push(newItem); }, prev() { - this.index-- + this.index if (this.index === 0) { this.prevDis = true } @@ -443,16 +583,14 @@ export default { }, getInfo(id) { request({ - url: '/api/example/QaFinalCheckData/' + id, - method: 'get', + url: '/api/example/exampleOrder/' + id, + method: 'get' }).then(res => { - console.log('JSON.stringify(this.dataForm)' + JSON.stringify(res)) this.dataInfo(res.data) }) }, goBack() { - this.visible = false - this.$emit('refreshDataList', true) + this.$emit('refresh') }, changeData(model, index) { this.isEdit = false @@ -477,53 +615,43 @@ export default { } } }, - changeMaterialData(model, obj) { - console.log('model >>> ' + model + ' index >>> ' + obj) - this.dataForm.model = obj.model; - this.dataForm.materialCode = obj.materialCode; - this.dataForm.materialName = obj.materialName; - this.dataForm.formCode = obj.formCode; - this.dataForm.qaSchemeBaseId = obj.qaSchemeBaseId; - this.dataForm.testNum = obj.testNum; - this.$set(this.dataForm, 'isAttDet', (obj && obj.isAttDet) ? obj.isAttDet : 'N'); + + dataAll() { + this.getOrdStatusOptions() + this.getSaleDeptIdOptions() + this.getUserIdOptions() + this.getCustIdOptions() + this.getMaterialIdOptions() }, - changeDataFormData(type, data, model, index, defaultValue, edit) { - if (!edit) { - if (type == 2) { - for (let i = 0; i < this.dataForm[data].length; i++) { - if (index == -1) { - this.dataForm[data][i][model] = defaultValue - } else if (index == i) { - this.dataForm[data][i][model] = defaultValue - } - } - } else { - this.dataForm[data] = defaultValue - } - } + getSaleDeptIdOptions() { + getDataInterfaceRes('811583643129479301').then(res => { + let data = res.data + this.saleDeptIdOptions = data + }) }, - dataAll() { }, - qa_material_check_data_twExist() { - let isOk = true - for (let i = 0; i < this.dataForm.qa_material_check_data_twList.length; i++) { - const e = this.dataForm.qa_material_check_data_twList[i] - } - return isOk + getUserIdOptions() { + getDataInterfaceRes('811594014137516101').then(res => { + let data = res.data + this.userIdOptions = data + }) }, - qa_material_check_data_thExist() { - let isOk = true - for (let i = 0; i < this.dataForm.qa_material_check_data_thList.length; i++) { - const e = this.dataForm.qa_material_check_data_thList[i] - } - return isOk + getCustIdOptions() { + getDataInterfaceRes('811594631945912389').then(res => { + let data = res.data + this.custIdOptions = data + }) }, - goBack() { - this.$emit('refresh', true) + getMaterialIdOptions() { + getDataInterfaceRes('811594958946435141').then(res => { + let data = res.data + this.materialIdOptions = data + }) }, + clearData() { this.dataForm = JSON.parse(JSON.stringify(this.dataValueAll)) }, - init(id, isDetail, allList, leftTreeActiveInfo) { + init(id, isDetail, allList) { this.prevDis = false this.nextDis = false this.allList = allList || [] @@ -545,64 +673,27 @@ export default { if (this.dataForm.id) { this.loading = true request({ - url: '/api/example/QaProMaterialCheck/' + this.dataForm.id, - method: 'get', + url: '/api/scm/InventoryLog/' + this.dataForm.id, + method: 'get' }).then(res => { this.dataInfo(res.data) - this.loading = false; - if (this.dataForm.isAttDet === 'Y') { - this.itemData = [ - { type: '产品', qxjsxd: '安全0%', qxl: '0%', qxms: this.dataForm.proSafe, prop: 'proSafe' }, - { type: '产品', qxjsxd: '功能1%', qxl: '0%', qxms: this.dataForm.proFun, prop: 'proFun' }, - { type: '产品', qxjsxd: '外观5%', qxl: '0%', qxms: this.dataForm.proApp, prop: 'proApp' }, - { type: '包装', qxjsxd: '安全0%', qxl: '0%', qxms: this.dataForm.packSafe, prop: 'packSafe' }, - { type: '包装', qxjsxd: '功能1%', qxl: '0%', qxms: this.dataForm.packFun, prop: 'packFun' }, - { type: '包装', qxjsxd: '外观5%', qxl: '0%', qxms: this.dataForm.packApp, prop: 'packApp' }, - ] - } - }) - let _query = { - checkId: this.dataForm.id, - dataType: 1, - menuId: this.menuId, - checkType: 2, - } - request({ - url: `/api/example/QaMaterialCheckLog/getList`, - method: 'post', - data: _query, - }).then(res => { - var _list = [] - for (let i = 0; i < res.data.list.length; i++) { - let _data = res.data.list[i] - _list.push(_data) - } - this.itemData1 = _list.map(o => ({ - ...o, - ...this.expandObj, - })) + this.loading = false }) } else { this.clearData() this.initDefaultData() - this.dataForm = { ...this.dataForm, ...leftTreeActiveInfo }; } }) this.$store.commit('generator/UPDATE_RELATION_DATA', {}) }, //初始化默认数据 initDefaultData() { - this.dataForm.recieveDate = new Date().getTime() - this.dataForm.checkDate = new Date().getTime() + }, // 表单提交 dataFormSubmit(type) { - if(this.dataForm.qaSchemeBaseId==null|| this.dataForm.qaSchemeBaseId==''){ - this.$message.warning("成品" + this.dataForm.materialName + "缺少质检方案"); - return; - } this.dataFormSubmitType = type ? type : 0 - this.$refs['formRef'].validate(valid => { + this.$refs['formRef'].validate((valid) => { if (valid) { this.request() } @@ -617,187 +708,57 @@ export default { } if (!this.dataForm.id) { request({ - url: '/api/example/QaProMaterialCheck', + url: '/api/scm/InventoryLog', method: 'post', - data: _data, + data: _data + }).then((res) => { + this.$message({ + message: res.msg, + type: 'success', + duration: 1000, + onClose: () => { + if (this.dataFormSubmitType == 2) { + this.$nextTick(() => { + this.clearData() + this.initDefaultData() + }) + this.continueBtnLoading = false + return + } + this.visible = false + this.btnLoading = false + this.$emit('refresh', true) + } + }) + }).catch(() => { + this.btnLoading = false + this.continueBtnLoading = false }) - .then(res => { - this.$message({ - message: res.msg, - type: 'success', - duration: 1000, - onClose: () => { - if (this.dataFormSubmitType == 2) { - this.$nextTick(() => { - this.clearData() - this.initDefaultData() - }) - this.continueBtnLoading = false - return - } - this.visible = false - this.btnLoading = false - this.$emit('refresh', true) - }, - }) - }) - .catch(() => { - this.btnLoading = false - this.continueBtnLoading = false - }) } else { request({ - url: '/api/example/QaProMaterialCheck/' + this.dataForm.id, + url: '/api/scm/InventoryLog/' + this.dataForm.id, method: 'PUT', - data: _data, - }) - .then(res => { - this.$message({ - message: res.msg, - type: 'success', - duration: 1000, - onClose: () => { - if (this.dataFormSubmitType == 2) return (this.continueBtnLoading = false) - this.visible = false - this.btnLoading = false - this.$emit('refresh', true) - }, - }) + data: _data + }).then((res) => { + this.$message({ + message: res.msg, + type: 'success', + duration: 1000, + onClose: () => { + if (this.dataFormSubmitType == 2) return this.continueBtnLoading = false + this.visible = false + this.btnLoading = false + this.$emit('refresh', true) + } }) - .catch(() => { - this.btnLoading = false - this.continueBtnLoading = false - }) - } - }, - addqa_material_check_data_twRow() { - let item = { - avgValue: undefined, - remark: undefined, - checkResult: '', - } - - this.getqa_material_check_data_twList(item) - }, - removeqa_material_check_data_twRow(index, showConfirm = false) { - if (showConfirm) { - this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { - type: 'warning', - }) - .then(() => { - this.dataForm.qa_material_check_data_twList.splice(index, 1) - }) - .catch(() => { }) - } else { - this.dataForm.qa_material_check_data_twList.splice(index, 1) - } - }, - copyqa_material_check_data_twRow(index) { - let item = JSON.parse(JSON.stringify(this.dataForm.qa_material_check_data_twList[index])) - item.length && item.map(o => delete o.rowData) - this.dataForm.qa_material_check_data_twList.push(item) - }, - getqa_material_check_data_twList(value, select) { - let item = { ...this.tableRows.qa_material_check_data_twList, ...value } - this.dataForm.qa_material_check_data_twList.push(JSON.parse(JSON.stringify(item))) - if (!select) { - } - this.childIndex = this.dataForm.qa_material_check_data_twList.length - 1 - this.isEdit = true - this.isEdit = false - this.childIndex = -1 - }, - //批量删除选择 - getqa_material_check_data_twRowSelection(value) { - this.selectedqa_material_check_data_twRowKeys = value - }, - //批量删除 - batchRemoveqa_material_check_data_twRow(showConfirm = false) { - if (!this.selectedqa_material_check_data_twRowKeys.length) return this.$messages.error('请选择一条数据') - const handleRemove = () => { - this.selectedqa_material_check_data_twRowKeys.forEach(row => { - const index = this.dataForm.qa_material_check_data_twList.indexOf(row) - this.dataForm.qa_material_check_data_twList.splice(index, 1) + }).catch(() => { + this.btnLoading = false + this.continueBtnLoading = false }) } - if (showConfirm) { - this.$confirm('确定删除该数据?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - }) - .then(() => { - handleRemove() - }) - .catch(() => { }) - } else { - handleRemove() - } }, - addqa_material_check_data_thRow() { - let item = { - actValue: undefined, - } - - this.getqa_material_check_data_thList(item) - }, - removeqa_material_check_data_thRow(index, showConfirm = false) { - if (showConfirm) { - this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { - type: 'warning', - }) - .then(() => { - this.dataForm.qa_material_check_data_thList.splice(index, 1) - }) - .catch(() => { }) - } else { - this.dataForm.qa_material_check_data_thList.splice(index, 1) - } - }, - copyqa_material_check_data_thRow(index) { - let item = JSON.parse(JSON.stringify(this.dataForm.qa_material_check_data_thList[index])) - item.length && item.map(o => delete o.rowData) - this.dataForm.qa_material_check_data_thList.push(item) - }, - getqa_material_check_data_thList(value, select) { - let item = { ...this.tableRows.qa_material_check_data_thList, ...value } - this.dataForm.qa_material_check_data_thList.push(JSON.parse(JSON.stringify(item))) - if (!select) { - } - this.childIndex = this.dataForm.qa_material_check_data_thList.length - 1 - this.isEdit = true - this.isEdit = false - this.childIndex = -1 - }, - //批量删除选择 - getqa_material_check_data_thRowSelection(value) { - this.selectedqa_material_check_data_thRowKeys = value - }, - //批量删除 - batchRemoveqa_material_check_data_thRow(showConfirm = false) { - if (!this.selectedqa_material_check_data_thRowKeys.length) return this.$messages.error('请选择一条数据') - const handleRemove = () => { - this.selectedqa_material_check_data_thRowKeys.forEach(row => { - const index = this.dataForm.qa_material_check_data_thList.indexOf(row) - this.dataForm.qa_material_check_data_thList.splice(index, 1) - }) - } - if (showConfirm) { - this.$confirm('确定删除该数据?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - }) - .then(() => { - handleRemove() - }) - .catch(() => { }) - } else { - handleRemove() - } - }, - openSelectDialog(key, value) { - this.currTableConf = this.addTableConf[key + value] + openSelectDialog(key) { + this.currTableConf = this.addTableConf[key] this.currVmodel = key this.selectDialogVisible = true this.$nextTick(() => { @@ -805,17 +766,13 @@ export default { }) }, addForSelect(data) { - this.closeForSelect() for (let i = 0; i < data.length; i++) { let t = data[i] if (this['get' + this.currVmodel]) { - this['get' + this.currVmodel](t, true) + this['get' + this.currVmodel](t) } } }, - closeForSelect() { - this.selectDialogVisible = false - }, dateTime(timeRule, timeType, timeTarget, timeValueData, dataValue) { let timeDataValue = null let timeValue = Number(timeValueData) @@ -880,15 +837,7 @@ export default { return timeDataValue }, dataList() { - // this.dataForm.itemList = this.itemData - // console.log(' this.dataForm.itemList >>>>> ' + JSON.stringify(this.dataForm.itemList)) - if (this.dataForm.isAttDet == 'Y') { - this.itemData.forEach(item => { - this.dataForm[item.prop] = item.qxms - }); - } var _data = this.dataForm - console.log(' this.dataForm >>>>> ' + JSON.stringify(this.dataForm)) return _data }, dataInfo(dataAll) { @@ -896,43 +845,9 @@ export default { this.dataForm = _dataAll this.isEdit = true this.dataAll() - if (_dataAll.qa_material_check_data_twList) { - for (let i = 0; i < _dataAll.qa_material_check_data_twList.length; i++) { - this.childIndex = i - } - } - if (_dataAll.qa_material_check_data_thList) { - for (let i = 0; i < _dataAll.qa_material_check_data_thList.length; i++) { - this.childIndex = i - } - } this.childIndex = -1 - }, - objectSpanMethod({ row, column, rowIndex, columnIndex }) { - if (columnIndex === 0) { - if (rowIndex === 0) { - return [3, 1]; - } - if (rowIndex === 3) { - return [3, 1]; - } - if (rowIndex === 6) { - return [3, 1]; - } - return [0, 0]; - } } - }, -} - - + diff --git a/jnpf-java-boot/jnpf-web/src/views/example/order/index.vue b/jnpf-java-boot/jnpf-web/src/views/example/order/index.vue index 40abeff..d962a68 100644 --- a/jnpf-java-boot/jnpf-web/src/views/example/order/index.vue +++ b/jnpf-java-boot/jnpf-web/src/views/example/order/index.vue @@ -1,40 +1,40 @@