| | |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.UserService; |
| | | 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.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | public class OrderController extends BaseController { |
| | |
| | | private LocOwnerService locOwnerService; |
| | | @Autowired |
| | | private OrderLogService orderLogService; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @RequestMapping(value = "/order/nav/list/auth") |
| | | @ManagerAuth |
| | |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<Order> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | // 限制销售角色只能看自己创建的单子(销售角色id固定21,不能随意修改) |
| | | User user = getUser(); |
| | | if (user.getRoleId() != 2 && user.getRoleId() != 24) { |
| | | wrapper.eq("create_by", user.getId()); |
| | | } |
| | | // 订单表只存了操作人id,所以操作人姓名查询,只能从姓名先去找id, |
| | | Object userName = param.get("oper_memb"); |
| | | if (userName != null && user.getRoleId() != 21) { |
| | | List<User> users = userService.selectList(new EntityWrapper<User>().like("username", (String) param.get("oper_memb"))); |
| | | if(users.size() > 0){ |
| | | wrapper.in("create_by", users.stream().map(User::getId).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | // 上述已自定义搜索,移除操作人姓名搜索 |
| | | param.remove("oper_memb"); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { |
| | | wrapper.orderBy("settle").orderBy("create_time", false); |
| | |
| | | DateUtils.convert(now), // 单据日期 |
| | | param.getDocType(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | param.getItemName(), // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | null, // 联系方式 |
| | | param.getNumber(), // 票据号 |
| | | param.getCstmr(), // 客户编号 |
| | | param.getCstmrName(), // 客户 |
| | | param.getTel(), // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | // 修改主档 |
| | | if (!param.getDocType().equals(order.getDocType())) { |
| | | if (!param.getDocType().equals(order.getDocType()) || param.getCstmrName() != order.getCstmrName() || !Cools.eq(param.getItemName(),order.getItemName())) { |
| | | order.setDocType(param.getDocType()); |
| | | order.setUpdateBy(userId); |
| | | order.setCstmr(param.getCstmr()); |
| | | order.setCstmrName(param.getCstmrName()); |
| | | order.setTel(param.getTel()); |
| | | order.setNumber(param.getNumber()); |
| | | order.setItemName(param.getItemName()); |
| | | order.setUpdateTime(now); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("修改订单类型失败"); |
| | |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | //if (DetlDto.has(list, dto)) { |
| | | if(false){ |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderQuery/auth") |
| | | @ManagerAuth |
| | | // @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<Order> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("id", condition); |
| | | wrapper.like("order_no", condition); |
| | | wrapper.le("settle",3); |
| | | Page<Order> page = orderService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Order order : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", order.getId()); |
| | | map.put("value", order.getOrderNo()); |
| | | map.put("customer",order.getCstmrName()); |
| | | map.put("phone",order.getTel()); |
| | | map.put("addr",order.getNumber()); |
| | | map.put("allocate",order.getItemName()); |
| | | map.put("type","order"); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | |
| | | List<OrderDetlVo> orderDetlVos=new ArrayList<>(); |
| | | OrderDetlVo orderDetlVo=new OrderDetlVo(); |
| | | for (OrderDetl o: |
| | | list) { |
| | | list) { |
| | | orderDetlVo.setOrderNo(o.getOrderNo()); |
| | | orderDetlVo.setMatnr(o.getMatnr()); |
| | | orderDetlVo.setMaktx(o.getMaktx()); |