parent
2a11599cb3
commit
9ff188caf0
@ -0,0 +1,24 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BigDecimalUtils
|
||||
{
|
||||
public static boolean isEqualByDecimalForFilter(BigDecimal value, BigDecimal search)
|
||||
{
|
||||
if (search == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (value != null)
|
||||
{
|
||||
String valueS = value.toPlainString();
|
||||
String searchS = search.toPlainString();
|
||||
return valueS.startsWith(searchS);
|
||||
// return (value.compareTo(search) == 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.BigDecimalUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.data.MUnitEmb;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class JoinedItemFilter implements Filter<JoinedItem>
|
||||
{
|
||||
private JoinedItem condition;
|
||||
|
||||
public JoinedItemFilter(JoinedItem cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class JoinedItemMatcher extends TypeSafeMatcher<JoinedItem>
|
||||
{
|
||||
private JoinedItem condition;
|
||||
|
||||
public JoinedItemMatcher(JoinedItem cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("JoinedItem matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(JoinedItem item)
|
||||
{
|
||||
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
|
||||
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
|
||||
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
|
||||
boolean foundQuantity = BigDecimalUtils.isEqualByDecimalForFilter(item.getQuantity(), condition.getQuantity());
|
||||
boolean foundUnitPrice = BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), condition.getUnitPrice());
|
||||
boolean foundMUnit = MUnitEmb.isEqualMUnitEmbForFilter(item.getMunit(), condition.getMunit());
|
||||
boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundDescription);
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<JoinedItem> matchBuilding(JoinedItem item)
|
||||
{
|
||||
return new JoinedItemMatcher(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JoinedItemMatcher matcher()
|
||||
{
|
||||
return new JoinedItemMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package info.bukova.isspst.services.approved;
|
||||
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
public interface ApprovedService extends Service<JoinedItem>
|
||||
{
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package info.bukova.isspst.services.approved;
|
||||
|
||||
import info.bukova.isspst.dao.BaseDao;
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.data.RequirementItem;
|
||||
import info.bukova.isspst.data.RequirementState;
|
||||
import info.bukova.isspst.data.Workgroup;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PostFilter;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public class ApprovedServiceImpl extends AbstractService<JoinedItem> implements ApprovedService
|
||||
{
|
||||
@Autowired
|
||||
WorkgroupService workgroupService;
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
// V bázi je BaseDao<T>, což nelze použít, protože třída JoinedItem nemá
|
||||
// ekvivalent v databázi
|
||||
// Bylo by dobré tuto funčnost vložit do báze...
|
||||
BaseDao<?> dao4Query;
|
||||
|
||||
public BaseDao<?> getDao4Query()
|
||||
{
|
||||
return dao4Query;
|
||||
}
|
||||
|
||||
public void setDao4Query(BaseDao<?> dao4Query)
|
||||
{
|
||||
this.dao4Query = dao4Query;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_SHOW_CENTRE_REQ')")
|
||||
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
|
||||
public List<JoinedItem> getAll()
|
||||
{
|
||||
List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent());
|
||||
Query q = dao4Query.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)");
|
||||
q.setParameterList("wgList", wgList);
|
||||
q.setParameter("state", RequirementState.APPROVED);
|
||||
List<JoinedItem> items = new ArrayList<JoinedItem>();
|
||||
|
||||
for (RequirementItem it : (List<RequirementItem>)q.list()) {
|
||||
items.add(new JoinedItem(it, it.getRequirement().getWorkgroup(), it.getRequirement().getCentre(), it.getRequirement().getOwnedBy()));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
@ -1,12 +1,8 @@
|
||||
package info.bukova.isspst.services.requirement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
|
||||
public interface RequirementService extends RequirementBaseService<Requirement>
|
||||
{
|
||||
public void loadGroups(Requirement req);
|
||||
public List<JoinedItem> getItemsForOrder();
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package info.bukova.isspst.ui.main.approved;
|
||||
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.filters.JoinedItemFilter;
|
||||
import info.bukova.isspst.services.approved.ApprovedService;
|
||||
import info.bukova.isspst.ui.BigDecimalConverter;
|
||||
import info.bukova.isspst.ui.ListViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
|
||||
public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
{
|
||||
@WireVariable
|
||||
protected ApprovedService approvedService;
|
||||
|
||||
private BigDecimalConverter bigDecimalConverter;
|
||||
|
||||
@Init
|
||||
public void initApprovedList()
|
||||
{
|
||||
service = approvedService;
|
||||
dataClass = JoinedItem.class;
|
||||
// formZul = "form.zul";
|
||||
dataFilter = new JoinedItemFilter(getFilterTemplate());
|
||||
bigDecimalConverter = new BigDecimalConverter();
|
||||
}
|
||||
|
||||
public BigDecimalConverter getBigDecimalConverter()
|
||||
{
|
||||
return bigDecimalConverter;
|
||||
}
|
||||
|
||||
public List<JoinedItem> getItems()
|
||||
{
|
||||
return approvedService.getAll();
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 682 B |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1,198 @@
|
||||
<?page title="${labels.ApprovedRequirementItems}" contentType="text/html;charset=UTF-8"?>
|
||||
<zk>
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<window
|
||||
vflex="1"
|
||||
border="normal"
|
||||
apply="org.zkoss.bind.BindComposer"
|
||||
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.approved.ApprovedList')">
|
||||
<caption
|
||||
image="/img/hammer-032.png"
|
||||
zclass="form-caption"
|
||||
label="${labels.ApprovedRequirementItems}" />
|
||||
<toolbar>
|
||||
<toolbarbutton
|
||||
image="/img/funnel.png"
|
||||
tooltiptext="${labels.ToolbarRecFilter}"
|
||||
id="btnFilter"
|
||||
onClick="@command('filter')" />
|
||||
<toolbarbutton
|
||||
image="/img/print.png"
|
||||
tooltiptext="${labels.ToolbarPrint}"
|
||||
id="btnPrint"
|
||||
onClick="@command('onPrint')" />
|
||||
</toolbar>
|
||||
<listbox
|
||||
multiple="true"
|
||||
checkmark="true"
|
||||
vflex="1"
|
||||
model="@load(vm.dataList)">
|
||||
<listhead menupopup="auto">
|
||||
<listheader width="27" />
|
||||
<listheader
|
||||
hflex="7"
|
||||
sort="czech(code)"
|
||||
label="${labels.RequirementItemCode}" />
|
||||
<listheader
|
||||
hflex="15"
|
||||
sort="czech(name)"
|
||||
label="${labels.RequirementItemName}" />
|
||||
<listheader
|
||||
hflex="20"
|
||||
sort="czech(textItem)"
|
||||
label="${labels.RequirementItemText}" />
|
||||
<listheader
|
||||
hflex="5"
|
||||
sort="auto(quantity)"
|
||||
align="right"
|
||||
label="${labels.RequirementItemQuantity}" />
|
||||
<listheader
|
||||
hflex="5"
|
||||
sort="auto(munit.name)"
|
||||
label="${labels.RequirementItemMUnit}" />
|
||||
<listheader
|
||||
hflex="7"
|
||||
align="right"
|
||||
sort="auto(unitPrice)"
|
||||
label="${labels.RequirementItemUnitPrice}" />
|
||||
<listheader
|
||||
hflex="7"
|
||||
align="right"
|
||||
sort="auto(total)"
|
||||
label="${labels.RequirementItemTotal}" />
|
||||
<listheader
|
||||
hflex="20"
|
||||
sort="czech(description)"
|
||||
label="${labels.RequirementItemDescription}" />
|
||||
</listhead>
|
||||
<auxhead visible="@load(vm.filter)">
|
||||
<auxheader />
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.code)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.name)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.textItem)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<!-- div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-img-left">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.quantity)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox-right" />
|
||||
</div>
|
||||
</div-->
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<!-- div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.munit.name)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div-->
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<!-- div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-img-left">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.unitPrice)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox-right" />
|
||||
</div>
|
||||
</div-->
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<!-- div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-img-left">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.total)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox-right" />
|
||||
</div>
|
||||
</div-->
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.description)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
</auxhead>
|
||||
<template name="model">
|
||||
<listitem>
|
||||
<listcell />
|
||||
<listcell label="@load(each.code)" />
|
||||
<listcell label="@load(each.name)" />
|
||||
<listcell label="@load(each.textItem)" />
|
||||
<listcell label="@load(each.quantity) @converter(vm.bigDecimalConverter)" />
|
||||
<listcell label="@load(each.munit.name)" />
|
||||
<listcell label="@load(each.unitPrice) @converter(vm.bigDecimalConverter)" />
|
||||
<listcell label="@load(each.total) @converter(vm.bigDecimalConverter)" />
|
||||
<listcell label="@load(each.description)" />
|
||||
</listitem>
|
||||
</template>
|
||||
</listbox>
|
||||
</window>
|
||||
</zk>
|
@ -0,0 +1,10 @@
|
||||
<?page title="${labels.ApprovedRequirementItems}" contentType="text/html;charset=UTF-8"?>
|
||||
<zk>
|
||||
|
||||
<zscript>
|
||||
String gridZul = "grid.zul";
|
||||
</zscript>
|
||||
|
||||
<include src="/app/template.zhtml"/>
|
||||
|
||||
</zk>
|
Loading…
Reference in New Issue