· 6 years ago · Apr 30, 2020, 03:40 AM
1package org.jleaf.erp.sls.bo.customer;
2
3import java.util.List;
4
5import javax.persistence.Query;
6
7import org.jleaf.common.entity.User;
8import org.jleaf.core.AbstractBusinessFunction;
9import org.jleaf.core.BusinessFunction;
10import org.jleaf.core.Dto;
11import org.jleaf.core.GeneralConstants;
12import org.jleaf.core.annotation.Info;
13import org.jleaf.core.annotation.InfoIn;
14import org.jleaf.core.annotation.InfoOut;
15import org.jleaf.core.dao.CriteriaHelper;
16import org.jleaf.core.dao.QueryBuilder;
17import org.jleaf.erp.master.dao.PartnerDao;
18import org.jleaf.erp.master.entity.Partner;
19import org.jleaf.erp.master.entity.PartnerAddress;
20import org.jleaf.erp.master.entity.PartnerCp;
21import org.jleaf.erp.master.entity.PartnerType;
22import org.jleaf.erp.sls.SalesConstants;
23import org.jleaf.erp.sls.dao.OrderDao;
24import org.jleaf.erp.sls.entity.PolicyCustomerGroupBrand;
25import org.jleaf.erp.sls.entity.UserPartner;
26import org.jleaf.util.DtoUtil;
27import org.jleaf.util.ValidationUtil;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30import org.springframework.beans.factory.annotation.Autowired;
31import org.springframework.stereotype.Service;
32
33/**
34 *
35 * @author Ephraim Jehudah, April 09, 2020
36 *
37 **/
38
39//@formatter:off
40@Service
41@InfoIn(value = {
42 @Info(name = "apiKey", description = "api Key", type = String.class),
43 @Info(name = "salesmanId", description = "salesmanId", type = Long.class),
44 @Info(name = "datetime", description = "datetime", type = String.class),
45 @Info(name = "userLoginId", description = "user Login Id", type = Long.class),
46 @Info(name = "tenantLoginId", description = "tenant Login Id", type = Long.class),
47 @Info(name = "roleLoginId", description = "roleLoginId", type = Long.class),
48})
49@InfoOut(value = {
50 @Info(name = "customerWithSaldoPiutangList", description = "customerWithSaldoPiutangList (customerId, customerName, totalSaldoPiutang, totalSaldoPiutangDueDate, totalSaldoPiutangNotDueDate)", type = List.class)
51})
52//@formatter:on
53public class GetCustomerListWithSaldoPiutangBySalesmanId extends AbstractBusinessFunction implements BusinessFunction {
54 private static final Logger log = LoggerFactory.getLogger(GetCustomerListWithSaldoPiutangBySalesmanId.class);
55
56 @Autowired
57 OrderDao orderDao;
58
59 @Override
60 public String getDescription() {
61 return "Get Customer List With Saldo Piutang By Salesman";
62 }
63
64 @SuppressWarnings("unchecked")
65 @Override
66 public Dto execute(Dto inputDto) throws Exception {
67 log.info("Input BF {} -. {} ", inputDto);
68
69 ValidationUtil.valDtoContainsKey(inputDto, "apiKey");
70 ValidationUtil.valDtoContainsKey(inputDto, "salesmanId");
71 ValidationUtil.valDtoContainsKey(inputDto, "datetime");
72 ValidationUtil.valDtoContainsKey(inputDto, "userLoginId");
73 ValidationUtil.valDtoContainsKey(inputDto, "tenantLoginId");
74 ValidationUtil.valDtoContainsKey(inputDto, "roleLoginId");
75
76 Long salesmanId = inputDto.getLong("salesmanId");
77 Long userLoginId = inputDto.getLong("userLoginId");
78 Long tenantLoginId = inputDto.getLong("tenantLoginId");
79 Long roleLoginId = inputDto.getLong("roleLoginId");
80 String datetime = inputDto.getString("datetime");
81
82 Dto outputDto = new Dto();
83 List<Object[]> result = null;
84
85
86 // jumlah key pada list harus sama dengan jumlah kolom yang diselect
87 outputDto = new Dto();
88// outputDto.putList("customerWithSaldoPiutangList",DtoUtil.createDtoListFromArray(result, "customerId", "customerName",
89// "totalSaldoPiutang", "totalSaldoPiutangDueDate", "totalSaldoPiutangNotDueDate"));
90
91 log.debug("Output BF {} -. {} ", this.getClass(), outputDto);
92
93 return outputDto;
94 }
95
96}